aboutsummaryrefslogtreecommitdiff
path: root/time
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-12-24 00:40:15 -0500
committerUlrich Drepper <drepper@gmail.com>2012-01-01 07:17:21 -0500
commit74033a2507841cf077e31221de2481ff30b43d51 (patch)
tree4197ce221b38e8576d49388f01e53036b49bb0fb /time
parent380d7e87dc80978581e73063dff0e264283c0306 (diff)
downloadglibc-74033a2507841cf077e31221de2481ff30b43d51.tar
glibc-74033a2507841cf077e31221de2481ff30b43d51.tar.gz
glibc-74033a2507841cf077e31221de2481ff30b43d51.tar.bz2
glibc-74033a2507841cf077e31221de2481ff30b43d51.zip
Implement timespec_get
Diffstat (limited to 'time')
-rw-r--r--time/Makefile5
-rw-r--r--time/Versions3
-rw-r--r--time/time.h43
-rw-r--r--time/timespec_get.c40
4 files changed, 76 insertions, 15 deletions
diff --git a/time/Makefile b/time/Makefile
index 71d919d015..badf2f984d 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+# Copyright (C) 1991-2003, 2004, 2005, 2007, 2011 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -29,7 +29,8 @@ routines := offtime asctime clock ctime ctime_r difftime \
tzfile getitimer setitimer \
stime dysize timegm ftime \
getdate strptime strptime_l \
- strftime wcsftime strftime_l wcsftime_l
+ strftime wcsftime strftime_l wcsftime_l \
+ timespec_get
aux := era alt_digit lc-time-cleanup
distribute := datemsk
diff --git a/time/Versions b/time/Versions
index 273956d5f3..a7c263008c 100644
--- a/time/Versions
+++ b/time/Versions
@@ -62,4 +62,7 @@ libc {
GLIBC_2.3.2 {
strptime_l;
}
+ GLIBC_2.16 {
+ timespec_get;
+ }
}
diff --git a/time/time.h b/time/time.h
index fee8d27052..5cb19db29d 100644
--- a/time/time.h
+++ b/time/time.h
@@ -107,10 +107,11 @@ typedef __timer_t timer_t;
#undef __need_timer_t
-#if !defined __timespec_defined && \
- ((defined _TIME_H && \
- (defined __USE_POSIX199309 || defined __USE_MISC)) || \
- defined __need_timespec)
+#if (!defined __timespec_defined \
+ && ((defined _TIME_H \
+ && (defined __USE_POSIX199309 || defined __USE_MISC \
+ || defined __USE_ISOC11)) \
+ || defined __need_timespec))
# define __timespec_defined 1
# include <bits/types.h> /* This defines __time_t for us. */
@@ -142,13 +143,13 @@ struct tm
int tm_yday; /* Days in year.[0-365] */
int tm_isdst; /* DST. [-1/0/1]*/
-#ifdef __USE_BSD
+# ifdef __USE_BSD
long int tm_gmtoff; /* Seconds east of UTC. */
__const char *tm_zone; /* Timezone abbreviation. */
-#else
+# else
long int __tm_gmtoff; /* Seconds east of UTC. */
__const char *__tm_zone; /* Timezone abbreviation. */
-#endif
+# endif
};
__END_NAMESPACE_STD
#if defined __USE_XOPEN || defined __USE_POSIX || defined __USE_MISC
@@ -156,7 +157,7 @@ __USING_NAMESPACE_STD(tm)
#endif
-#ifdef __USE_POSIX199309
+# ifdef __USE_POSIX199309
/* POSIX.1b structure for timer start values and intervals. */
struct itimerspec
{
@@ -167,14 +168,23 @@ struct itimerspec
/* We can use a simple forward declaration. */
struct sigevent;
-#endif /* POSIX.1b */
+# endif /* POSIX.1b */
-#ifdef __USE_XOPEN2K
-# ifndef __pid_t_defined
+# ifdef __USE_XOPEN2K
+# ifndef __pid_t_defined
typedef __pid_t pid_t;
-# define __pid_t_defined
+# define __pid_t_defined
+# endif
+# endif
+
+
+# ifdef __USE_ISOC11
+/* Time base values for timespec_get. */
+enum
+ {
+ TIME_UTC = 1
+ };
# endif
-#endif
__BEGIN_NAMESPACE_STD
@@ -353,6 +363,13 @@ extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __THROW;
# endif
+# ifdef __USE_ISOC11
+/* Set TS to calendar time based in time base BASE. */
+extern int timespec_get (struct timespec *__ts, int __base)
+ __THROW __nonnull ((1));
+# endif
+
+
/* Create new per-process timer using CLOCK_ID. */
extern int timer_create (clockid_t __clock_id,
struct sigevent *__restrict __evp,
diff --git a/time/timespec_get.c b/time/timespec_get.c
new file mode 100644
index 0000000000..05009ec11b
--- /dev/null
+++ b/time/timespec_get.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <time.h>
+
+
+/* Set TS to calendar time based in time base BASE. */
+int
+timespec_get (ts, base)
+ struct timespec *ts;
+ int base;
+{
+ switch (base)
+ {
+ case TIME_UTC:
+ /* Not supported. */
+ return 0;
+
+ default:
+ return 0;
+ }
+
+ return base;
+}
+stub_warning (timespec_get)