Installed-header hygiene (BZ#20366): time.h types.

Many headers are expected to expose a subset of the type definitions
in time.h.  time.h has a whole bunch of messy logic for conditionally
defining some its types and structs, but, as best I can tell, this
has never worked 100%.  In particular, __need_timespec is ineffective
if _TIME_H has already been defined, which means that if you compile

  #include <time.h>
  #include <sched.h>

with e.g. -fsyntax-only -std=c89 -Wall -Wsystem-headers, you will get

In file included from test.c:2:0:
/usr/include/sched.h:74:57: warning: "struct timespec" declared inside
  parameter list will not be visible outside of this definition or declaration
 extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
                                                         ^~~~~~~~

And if you want to _use_ sched_rr_get_interval in a TU compiled that
way, you're hosed.

This patch replaces all of that with small bits/types/TYPE.h headers
as introduced earlier.  time.h and bits/time.h are now *much* simpler,
and a lot of other headers are slightly simpler.

	* time/time.h, bits/time.h, sysdeps/unix/sysv/linux/bits/time.h:
	Remove all logic conditional on __need macros.  Move all the
	conditionally defined types to their own headers...
	* time/bits/types/clock_t.h: Define clock_t here.
	* time/bits/types/clockid_t.h: Define clockid_t here.
	* time/bits/types/struct_itimerspec.h: Define struct itimerspec here.
	* time/bits/types/struct_timespec.h: Define struct timespec here.
	* time/bits/types/struct_timeval.h: Define struct timeval here.
	* time/bits/types/struct_tm.h: Define struct tm here.
	* time/bits/types/time_t.h: Define time_t here.
	* time/bits/types/timer_t.h: Define timer_t here.
	* time/Makefile: Install the new headers.

	* bits/resource.h, io/fcntl.h, io/sys/poll.h, io/sys/stat.h
	* io/utime.h, misc/sys/select.h, posix/sched.h, posix/sys/times.h
	* posix/sys/types.h, resolv/netdb.h, rt/aio.h, rt/mqueue.h
	* signal/signal.h, pthread/semaphore.h, sysdeps/nptl/pthread.h
	* sysdeps/unix/sysv/linux/alpha/bits/resource.h
	* sysdeps/unix/sysv/linux/alpha/sys/acct.h
	* sysdeps/unix/sysv/linux/bits/resource.h
	* sysdeps/unix/sysv/linux/bits/timex.h
	* sysdeps/unix/sysv/linux/mips/bits/resource.h
	* sysdeps/unix/sysv/linux/net/ppp_defs.h
	* sysdeps/unix/sysv/linux/sparc/bits/resource.h
	* sysdeps/unix/sysv/linux/sys/acct.h
	* sysdeps/unix/sysv/linux/sys/timerfd.h
	* sysvipc/sys/msg.h, sysvipc/sys/sem.h, sysvipc/sys/shm.h
	* time/sys/time.h, time/sys/timeb.h
	Use the new bits/types headers.

	* include/time.h: Remove __need logic.
	* include/bits/time.h
	* include/bits/types/clock_t.h, include/bits/types/clockid_t.h
	* include/bits/types/time_t.h, include/bits/types/timer_t.h
	* include/bits/types/struct_itimerspec.h
	* include/bits/types/struct_timespec.h
	* include/bits/types/struct_timeval.h
	* include/bits/types/struct_tm.h:
	New wrapper headers.
This commit is contained in:
Zack Weinberg 2016-08-24 11:54:34 -04:00
parent f2bea4da2e
commit 05b68e14b1
51 changed files with 336 additions and 344 deletions

View File

@ -1,3 +1,45 @@
2016-09-23 Zack Weinberg <zackw@panix.com>
* time/time.h, bits/time.h, sysdeps/unix/sysv/linux/bits/time.h:
Remove all logic conditional on __need macros. Move all the
conditionally defined types to their own headers...
* time/bits/types/clock_t.h: Define clock_t here.
* time/bits/types/clockid_t.h: Define clockid_t here.
* time/bits/types/struct_itimerspec.h: Define struct itimerspec here.
* time/bits/types/struct_timespec.h: Define struct timespec here.
* time/bits/types/struct_timeval.h: Define struct timeval here.
* time/bits/types/struct_tm.h: Define struct tm here.
* time/bits/types/time_t.h: Define time_t here.
* time/bits/types/timer_t.h: Define timer_t here.
* time/Makefile: Install the new headers.
* bits/resource.h, io/fcntl.h, io/sys/poll.h, io/sys/stat.h
* io/utime.h, misc/sys/select.h, posix/sched.h, posix/sys/times.h
* posix/sys/types.h, resolv/netdb.h, rt/aio.h, rt/mqueue.h
* signal/signal.h, pthread/semaphore.h, sysdeps/nptl/pthread.h
* sysdeps/unix/sysv/linux/alpha/bits/resource.h
* sysdeps/unix/sysv/linux/alpha/sys/acct.h
* sysdeps/unix/sysv/linux/bits/resource.h
* sysdeps/unix/sysv/linux/bits/timex.h
* sysdeps/unix/sysv/linux/mips/bits/resource.h
* sysdeps/unix/sysv/linux/net/ppp_defs.h
* sysdeps/unix/sysv/linux/sparc/bits/resource.h
* sysdeps/unix/sysv/linux/sys/acct.h
* sysdeps/unix/sysv/linux/sys/timerfd.h
* sysvipc/sys/msg.h, sysvipc/sys/sem.h, sysvipc/sys/shm.h
* time/sys/time.h, time/sys/timeb.h
Use the new bits/types headers.
* include/time.h: Remove __need logic.
* include/bits/time.h
* include/bits/types/clock_t.h, include/bits/types/clockid_t.h
* include/bits/types/time_t.h, include/bits/types/timer_t.h
* include/bits/types/struct_itimerspec.h
* include/bits/types/struct_timespec.h
* include/bits/types/struct_timeval.h
* include/bits/types/struct_tm.h:
New wrapper headers.
2016-09-23 Zack Weinberg <zackw@panix.com>
* sysdeps/mach/hurd/net/if_ppp.h

View File

@ -129,8 +129,7 @@ enum __rusage_who
#define RUSAGE_CHILDREN RUSAGE_CHILDREN
};
#define __need_timeval
#include <bits/time.h> /* For `struct timeval'. */
#include <bits/types/struct_timeval.h>
/* Structure which says how much of each resource has been used. */
struct rusage

View File

@ -20,9 +20,10 @@
* Never include this file directly; use <time.h> instead.
*/
#ifndef __need_timeval
# ifndef _BITS_TIME_H
# define _BITS_TIME_H 1
#ifndef _BITS_TIME_H
#define _BITS_TIME_H 1
#include <bits/types.h>
/* ISO/IEC 9899:1999 7.23.1: Components of time
The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is
@ -30,51 +31,34 @@
/* CAE XSH, Issue 4, Version 2: <time.h>
The value of CLOCKS_PER_SEC is required to be 1 million on all
XSI-conformant systems. */
# define CLOCKS_PER_SEC ((clock_t) 1000000)
#define CLOCKS_PER_SEC ((__clock_t) 1000000)
# if !defined __STRICT_ANSI__ && !defined __USE_XOPEN2K
#if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \
&& !defined __USE_XOPEN2K
/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK
presents the real value for clock ticks per second for the system. */
# include <bits/types.h>
extern long int __sysconf (int);
# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
# endif
# ifdef __USE_POSIX199309
/* Identifier for system-wide realtime clock. */
# define CLOCK_REALTIME 0
/* Monotonic system-wide clock. */
# define CLOCK_MONOTONIC 1
/* High-resolution timer from the CPU. */
# define CLOCK_PROCESS_CPUTIME_ID 2
/* Thread-specific CPU-time clock. */
# define CLOCK_THREAD_CPUTIME_ID 3
/* Monotonic system-wide clock, not adjusted for frequency scaling. */
# define CLOCK_MONOTONIC_RAW 4
/* Identifier for system-wide realtime clock, updated only on ticks. */
# define CLOCK_REALTIME_COARSE 5
/* Monotonic system-wide clock, updated only on ticks. */
# define CLOCK_MONOTONIC_COARSE 6
/* Flag to indicate time is absolute. */
# define TIMER_ABSTIME 1
# endif
# endif /* bits/time.h */
# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
#endif
#ifdef __need_timeval
# undef __need_timeval
# ifndef _STRUCT_TIMEVAL
# define _STRUCT_TIMEVAL 1
# include <bits/types.h>
#ifdef __USE_POSIX199309
/* Identifier for system-wide realtime clock. */
# define CLOCK_REALTIME 0
/* Monotonic system-wide clock. */
# define CLOCK_MONOTONIC 1
/* High-resolution timer from the CPU. */
# define CLOCK_PROCESS_CPUTIME_ID 2
/* Thread-specific CPU-time clock. */
# define CLOCK_THREAD_CPUTIME_ID 3
/* Monotonic system-wide clock, not adjusted for frequency scaling. */
# define CLOCK_MONOTONIC_RAW 4
/* Identifier for system-wide realtime clock, updated only on ticks. */
# define CLOCK_REALTIME_COARSE 5
/* Monotonic system-wide clock, updated only on ticks. */
# define CLOCK_MONOTONIC_COARSE 6
/* A time value that is accurate to the nearest
microsecond but also has a range of years. */
struct timeval
{
__time_t tv_sec; /* Seconds. */
__suseconds_t tv_usec; /* Microseconds. */
};
# endif /* struct timeval */
#endif /* need timeval */
/* Flag to indicate time is absolute. */
# define TIMER_ABSTIME 1
#endif
#endif /* bits/time.h */

View File

@ -0,0 +1 @@
#include "../../time/bits/types/clock_t.h"

View File

@ -0,0 +1 @@
#include "../../time/bits/types/clockid_t.h"

View File

@ -0,0 +1 @@
#include "../../time/bits/types/struct_itimerspec.h"

View File

@ -0,0 +1 @@
#include "../../time/bits/types/struct_timespec.h"

View File

@ -0,0 +1 @@
#include "../../time/bits/types/struct_timeval.h"

View File

@ -0,0 +1 @@
#include "../../time/bits/types/struct_tm.h"

View File

@ -0,0 +1 @@
#include "../../time/bits/types/time_t.h"

View File

@ -0,0 +1 @@
#include "../../time/bits/types/timer_t.h"

View File

@ -1,8 +1,7 @@
#ifndef _TIME_H
#if defined __need_time_t || defined __need_clock_t || defined __need_timespec || defined _ISOMAC
# include <time/time.h>
#else
# include <time/time.h>
#include <time/time.h>
#ifndef _ISOMAC
# include <xlocale.h>
__BEGIN_DECLS

View File

@ -72,8 +72,7 @@ typedef __pid_t pid_t;
/* For XPG all symbols from <sys/stat.h> should also be available. */
#ifdef __USE_XOPEN2K8
# define __need_timespec
# include <time.h>
# include <bits/types/struct_timespec.h>
#endif
#if defined __USE_XOPEN || defined __USE_XOPEN2K8
# include <bits/stat.h>

View File

@ -27,8 +27,7 @@
/* Get the __sigset_t definition. */
# include <bits/sigset.h>
/* Get the timespec definition. */
# define __need_timespec
# include <time.h>
#include <bits/types/struct_timespec.h>
#endif

View File

@ -26,19 +26,16 @@
#include <bits/types.h> /* For __mode_t and __dev_t. */
#if defined __USE_XOPEN || defined __USE_XOPEN2K || defined __USE_ATFILE
# if defined __USE_XOPEN || defined __USE_XOPEN2K
# define __need_time_t
# endif
# ifdef __USE_ATFILE
# define __need_timespec
# endif
# include <time.h> /* For time_t resp. timespec. */
#ifdef __USE_ATFILE
# include <bits/types/struct_timespec.h>
#endif
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
available here. */
# include <bits/types/time_t.h>
# ifndef __dev_t_defined
typedef __dev_t dev_t;
# define __dev_t_defined

View File

@ -29,8 +29,7 @@ __BEGIN_DECLS
#include <bits/types.h>
#if defined __USE_XOPEN || defined __USE_XOPEN2K
# define __need_time_t
# include <time.h>
# include <bits/types/time_t.h>
#endif
/* Structure describing file times. */

View File

@ -38,13 +38,11 @@ typedef __sigset_t sigset_t;
#endif
/* Get definition of timer specification structures. */
#define __need_time_t
#include <bits/types/time_t.h>
#include <bits/types/struct_timeval.h>
#ifdef __USE_XOPEN2K
# define __need_timespec
# include <bits/types/struct_timespec.h>
#endif
#include <time.h>
#define __need_timeval
#include <bits/time.h>
#ifndef __suseconds_t_defined
typedef __suseconds_t suseconds_t;

View File

@ -25,13 +25,14 @@
#include <bits/types.h>
#define __need_size_t
#define __need_NULL
#include <stddef.h>
#ifdef __USE_XOPEN2K
# define __need_time_t
# define __need_timespec
#include <bits/types/time_t.h>
#include <bits/types/struct_timespec.h>
#ifndef __USE_XOPEN2K
# include <time.h>
#endif
#include <time.h>
#ifndef __pid_t_defined
typedef __pid_t pid_t;

View File

@ -24,9 +24,7 @@
#include <features.h>
#define __need_clock_t
#include <time.h>
#include <bits/types/clock_t.h>
__BEGIN_DECLS

View File

@ -124,12 +124,11 @@ typedef __key_t key_t;
#endif
#if defined __USE_XOPEN || defined __USE_XOPEN2K8
# define __need_clock_t
# include <bits/types/clock_t.h>
#endif
#define __need_time_t
#define __need_timer_t
#define __need_clockid_t
#include <time.h>
#include <bits/types/clockid_t.h>
#include <bits/types/time_t.h>
#include <bits/types/timer_t.h>
#ifdef __USE_XOPEN
# ifndef __useconds_t_defined

View File

@ -35,8 +35,7 @@
#ifdef __USE_GNU
# define __need_sigevent_t
# include <bits/siginfo.h>
# define __need_timespec
# include <time.h>
# include <bits/types/struct_timespec.h>
#endif
#include <bits/netdb.h>

View File

@ -26,8 +26,7 @@
#include <sys/types.h>
#define __need_sigevent_t
#include <bits/siginfo.h>
#define __need_timespec
#include <time.h>
#include <bits/types/struct_timespec.h>
__BEGIN_DECLS

View File

@ -23,8 +23,7 @@
#include <fcntl.h>
#define __need_sigevent_t
#include <bits/siginfo.h>
#define __need_timespec
#include <time.h>
#include <bits/types/struct_timespec.h>
/* Get the definition of mqd_t and struct mq_attr. */
#include <bits/mqueue.h>

View File

@ -71,8 +71,7 @@ typedef __uid_t uid_t;
#ifdef __USE_POSIX199309
/* We need `struct timespec' later on. */
# define __need_timespec
# include <time.h>
# include <bits/types/struct_timespec.h>
#endif
#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED

View File

@ -26,6 +26,7 @@
#include <bits/pthreadtypes.h>
#include <bits/setjmp.h>
#include <bits/wordsize.h>
#include <bits/types/struct_timespec.h>
/* Detach state. */

View File

@ -21,8 +21,7 @@
#include <features.h>
#include <sys/types.h>
#ifdef __USE_XOPEN2K
# define __need_timespec
# include <time.h>
# include <bits/types/struct_timespec.h>
#endif
/* Get the definition for sem_t. */

View File

@ -175,8 +175,7 @@ enum __rusage_who
#endif
};
#define __need_timeval
#include <bits/time.h> /* For `struct timeval'. */
#include <bits/types/struct_timeval.h>
/* Structure which says how much of each resource has been used. */
struct rusage

View File

@ -20,9 +20,7 @@
#define _SYS_ACCT_H 1
#include <features.h>
#define __need_time_t
#include <time.h>
#include <bits/types/time_t.h>
__BEGIN_DECLS

View File

@ -175,8 +175,7 @@ enum __rusage_who
#endif
};
#define __need_timeval
#include <bits/time.h> /* For `struct timeval'. */
#include <bits/types/struct_timeval.h>
/* Structure which says how much of each resource has been used. */

View File

@ -20,24 +20,10 @@
* Never include this file directly; use <time.h> instead.
*/
#if defined __need_timeval || defined __USE_GNU
# ifndef _STRUCT_TIMEVAL
# define _STRUCT_TIMEVAL 1
# include <bits/types.h>
#ifndef _BITS_TIME_H
#define _BITS_TIME_H 1
/* A time value that is accurate to the nearest
microsecond but also has a range of years. */
struct timeval
{
__time_t tv_sec; /* Seconds. */
__suseconds_t tv_usec; /* Microseconds. */
};
# endif /* struct timeval */
#endif
#ifndef __need_timeval
# ifndef _BITS_TIME_H
# define _BITS_TIME_H 1
#include <bits/types.h>
/* ISO/IEC 9899:1999 7.23.1: Components of time
The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is
@ -45,47 +31,46 @@ struct timeval
/* CAE XSH, Issue 4, Version 2: <time.h>
The value of CLOCKS_PER_SEC is required to be 1 million on all
XSI-conformant systems. */
# define CLOCKS_PER_SEC ((clock_t) 1000000)
#define CLOCKS_PER_SEC ((__clock_t) 1000000)
# if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \
#if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \
&& !defined __USE_XOPEN2K
/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK
presents the real value for clock ticks per second for the system. */
# include <bits/types.h>
extern long int __sysconf (int);
# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
# endif
# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
#endif
# ifdef __USE_POSIX199309
#ifdef __USE_POSIX199309
/* Identifier for system-wide realtime clock. */
# define CLOCK_REALTIME 0
# define CLOCK_REALTIME 0
/* Monotonic system-wide clock. */
# define CLOCK_MONOTONIC 1
# define CLOCK_MONOTONIC 1
/* High-resolution timer from the CPU. */
# define CLOCK_PROCESS_CPUTIME_ID 2
# define CLOCK_PROCESS_CPUTIME_ID 2
/* Thread-specific CPU-time clock. */
# define CLOCK_THREAD_CPUTIME_ID 3
# define CLOCK_THREAD_CPUTIME_ID 3
/* Monotonic system-wide clock, not adjusted for frequency scaling. */
# define CLOCK_MONOTONIC_RAW 4
# define CLOCK_MONOTONIC_RAW 4
/* Identifier for system-wide realtime clock, updated only on ticks. */
# define CLOCK_REALTIME_COARSE 5
# define CLOCK_REALTIME_COARSE 5
/* Monotonic system-wide clock, updated only on ticks. */
# define CLOCK_MONOTONIC_COARSE 6
# define CLOCK_MONOTONIC_COARSE 6
/* Monotonic system-wide clock that includes time spent in suspension. */
# define CLOCK_BOOTTIME 7
# define CLOCK_BOOTTIME 7
/* Like CLOCK_REALTIME but also wakes suspended system. */
# define CLOCK_REALTIME_ALARM 8
# define CLOCK_REALTIME_ALARM 8
/* Like CLOCK_BOOTTIME but also wakes suspended system. */
# define CLOCK_BOOTTIME_ALARM 9
# define CLOCK_BOOTTIME_ALARM 9
/* Like CLOCK_REALTIME but in International Atomic Time. */
# define CLOCK_TAI 11
# define CLOCK_TAI 11
/* Flag to indicate time is absolute. */
# define TIMER_ABSTIME 1
# endif
# define TIMER_ABSTIME 1
#endif
# ifdef __USE_GNU
# include <bits/timex.h>
#ifdef __USE_GNU
# include <bits/timex.h>
__BEGIN_DECLS
@ -93,9 +78,6 @@ __BEGIN_DECLS
extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW;
__END_DECLS
# endif /* use GNU */
#endif /* use GNU */
# endif /* bits/time.h */
#endif
#undef __need_timeval
#endif /* bits/time.h */

View File

@ -19,6 +19,7 @@
#define _BITS_TIMEX_H 1
#include <bits/types.h>
#include <bits/types/struct_timeval.h>
/* These definitions from linux/timex.h as of 3.18. */

View File

@ -183,8 +183,7 @@ enum __rusage_who
#endif
};
#define __need_timeval
#include <bits/time.h> /* For `struct timeval'. */
#include <bits/types/struct_timeval.h>
/* Structure which says how much of each resource has been used. */
struct rusage

View File

@ -1,9 +1,7 @@
#ifndef _NET_PPP_DEFS_H
#define _NET_PPP_DEFS_H 1
#define __need_time_t
#include <time.h>
#include <bits/types/time_t.h>
#include <asm/types.h>
#include <linux/ppp_defs.h>

View File

@ -191,8 +191,7 @@ enum __rusage_who
#endif
};
#define __need_timeval
#include <bits/time.h> /* For `struct timeval'. */
#include <bits/types/struct_timeval.h>
/* Structure which says how much of each resource has been used. */
struct rusage

View File

@ -21,8 +21,7 @@
#include <sys/types.h>
#include <stdint.h>
#include <endian.h>
#define __need_time_t
#include <time.h>
#include <bits/types/time_t.h>
__BEGIN_DECLS

View File

@ -19,6 +19,7 @@
#define _SYS_TIMERFD_H 1
#include <time.h>
#include <bits/types/struct_itimerspec.h>
/* Get the platform-dependent flags. */
#include <bits/timerfd.h>

View File

@ -30,8 +30,7 @@
#include <bits/msq.h>
/* Define types required by the standard. */
#define __need_time_t
#include <time.h>
#include <bits/types/time_t.h>
#ifndef __pid_t_defined
typedef __pid_t pid_t;

View File

@ -30,8 +30,7 @@
#include <bits/sem.h>
#ifdef __USE_GNU
# define __need_timespec
# include <time.h>
# include <bits/types/struct_timespec.h>
#endif
/* The following System V style IPC functions implement a semaphore

View File

@ -30,8 +30,7 @@
#include <bits/shm.h>
/* Define types required by the standard. */
#define __need_time_t
#include <time.h>
#include <bits/types/time_t.h>
#ifdef __USE_XOPEN
# ifndef __pid_t_defined

View File

@ -22,7 +22,12 @@ subdir := time
include ../Makeconfig
headers := time.h sys/time.h sys/timeb.h bits/time.h
headers := time.h sys/time.h sys/timeb.h bits/time.h \
bits/types/clockid_t.h bits/types/clock_t.h \
bits/types/struct_itimerspec.h \
bits/types/struct_timespec.h bits/types/struct_timeval.h \
bits/types/struct_tm.h bits/types/timer_t.h \
bits/types/time_t.h
routines := offtime asctime clock ctime ctime_r difftime \
gmtime localtime mktime time \

15
time/bits/types/clock_t.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef __clock_t_defined
#define __clock_t_defined 1
#include <bits/types.h>
__BEGIN_NAMESPACE_STD
/* Returned by `clock'. */
typedef __clock_t clock_t;
__END_NAMESPACE_STD
#if defined __USE_XOPEN || defined __USE_POSIX
__USING_NAMESPACE_STD(clock_t)
#endif
#endif

View File

@ -0,0 +1,9 @@
#ifndef __clockid_t_defined
#define __clockid_t_defined 1
#include <bits/types.h>
/* Clock ID used in clock and timer functions. */
typedef __clockid_t clockid_t;
#endif

View File

@ -0,0 +1,14 @@
#ifndef __itimerspec_defined
#define __itimerspec_defined 1
#include <bits/types.h>
#include <bits/types/struct_timespec.h>
/* POSIX.1b structure for timer start values and intervals. */
struct itimerspec
{
struct timespec it_interval;
struct timespec it_value;
};
#endif

View File

@ -0,0 +1,14 @@
#ifndef __timespec_defined
#define __timespec_defined 1
#include <bits/types.h>
/* POSIX.1b structure for a time value. This is like a `struct timeval' but
has nanoseconds instead of microseconds. */
struct timespec
{
__time_t tv_sec; /* Seconds. */
__syscall_slong_t tv_nsec; /* Nanoseconds. */
};
#endif

View File

@ -0,0 +1,13 @@
#ifndef __timeval_defined
#define __timeval_defined 1
#include <bits/types.h>
/* A time value that is accurate to the nearest
microsecond but also has a range of years. */
struct timeval
{
__time_t tv_sec; /* Seconds. */
__suseconds_t tv_usec; /* Microseconds. */
};
#endif

View File

@ -0,0 +1,33 @@
#ifndef __struct_tm_defined
#define __struct_tm_defined 1
#include <bits/types.h>
/* ISO C `broken-down time' structure. */
__BEGIN_NAMESPACE_STD
struct tm
{
int tm_sec; /* Seconds. [0-60] (1 leap second) */
int tm_min; /* Minutes. [0-59] */
int tm_hour; /* Hours. [0-23] */
int tm_mday; /* Day. [1-31] */
int tm_mon; /* Month. [0-11] */
int tm_year; /* Year - 1900. */
int tm_wday; /* Day of week. [0-6] */
int tm_yday; /* Days in year.[0-365] */
int tm_isdst; /* DST. [-1/0/1]*/
# ifdef __USE_MISC
long int tm_gmtoff; /* Seconds east of UTC. */
const char *tm_zone; /* Timezone abbreviation. */
# else
long int __tm_gmtoff; /* Seconds east of UTC. */
const char *__tm_zone; /* Timezone abbreviation. */
# endif
};
__END_NAMESPACE_STD
#if defined __USE_XOPEN || defined __USE_POSIX
__USING_NAMESPACE_STD(tm)
#endif
#endif

14
time/bits/types/time_t.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef __time_t_defined
#define __time_t_defined 1
#include <bits/types.h>
__BEGIN_NAMESPACE_STD
/* Returned by `time'. */
typedef __time_t time_t;
__END_NAMESPACE_STD
#ifdef __USE_POSIX
__USING_NAMESPACE_STD(time_t)
#endif
#endif

View File

@ -0,0 +1,9 @@
#ifndef __timer_t_defined
#define __timer_t_defined 1
#include <bits/types.h>
/* Timer ID returned by `timer_create'. */
typedef __timer_t timer_t;
#endif

View File

@ -21,18 +21,15 @@
#include <features.h>
#include <bits/types.h>
#define __need_time_t
#include <time.h>
#define __need_timeval
#include <bits/time.h>
#include <sys/select.h>
#include <bits/types/time_t.h>
#include <bits/types/struct_timeval.h>
#ifndef __suseconds_t_defined
typedef __suseconds_t suseconds_t;
# define __suseconds_t_defined
#endif
#include <sys/select.h>
__BEGIN_DECLS

View File

@ -20,9 +20,7 @@
#include <features.h>
#define __need_time_t
#include <time.h>
#include <bits/types/time_t.h>
__BEGIN_DECLS

View File

@ -20,168 +20,52 @@
*/
#ifndef _TIME_H
#define _TIME_H 1
#if (! defined __need_time_t && !defined __need_clock_t && \
! defined __need_timespec)
# define _TIME_H 1
# include <features.h>
#include <features.h>
__BEGIN_DECLS
#endif
#ifdef _TIME_H
/* Get size_t and NULL from <stddef.h>. */
# define __need_size_t
# define __need_NULL
# include <stddef.h>
#define __need_size_t
#define __need_NULL
#include <stddef.h>
/* This defines CLOCKS_PER_SEC, which is the number of processor clock
ticks per second. */
# include <bits/time.h>
ticks per second, and possibly a number of other constants. */
#include <bits/time.h>
/* This is the obsolete POSIX.1-1988 name for the same constant. */
# if !defined __STRICT_ANSI__ && !defined __USE_XOPEN2K
# ifndef CLK_TCK
# define CLK_TCK CLOCKS_PER_SEC
# endif
# endif
/* Many of the typedefs and structs whose official home is this header
may also need to be defined by other headers. */
#include <bits/types/clock_t.h>
#include <bits/types/time_t.h>
#include <bits/types/struct_tm.h>
#endif /* <time.h> included. */
#if !defined __clock_t_defined && (defined _TIME_H || defined __need_clock_t)
# define __clock_t_defined 1
# include <bits/types.h>
__BEGIN_NAMESPACE_STD
/* Returned by `clock'. */
typedef __clock_t clock_t;
__END_NAMESPACE_STD
#if defined __USE_XOPEN || defined __USE_POSIX
__USING_NAMESPACE_STD(clock_t)
#if defined __USE_POSIX199309 || defined __USE_ISOC11
# include <bits/types/struct_timespec.h>
#endif
#endif /* clock_t not defined and <time.h> or need clock_t. */
#undef __need_clock_t
#if !defined __time_t_defined && (defined _TIME_H || defined __need_time_t)
# define __time_t_defined 1
# include <bits/types.h>
__BEGIN_NAMESPACE_STD
/* Returned by `time'. */
typedef __time_t time_t;
__END_NAMESPACE_STD
#ifdef __USE_POSIX
__USING_NAMESPACE_STD(time_t)
#endif
#endif /* time_t not defined and <time.h> or need time_t. */
#undef __need_time_t
#if !defined __clockid_t_defined && \
((defined _TIME_H && defined __USE_POSIX199309) || defined __need_clockid_t)
# define __clockid_t_defined 1
# include <bits/types.h>
/* Clock ID used in clock and timer functions. */
typedef __clockid_t clockid_t;
#endif /* clockid_t not defined and <time.h> or need clockid_t. */
#undef __clockid_time_t
#if !defined __timer_t_defined && \
((defined _TIME_H && defined __USE_POSIX199309) || defined __need_timer_t)
# define __timer_t_defined 1
# include <bits/types.h>
/* Timer ID returned by `timer_create'. */
typedef __timer_t timer_t;
#endif /* timer_t not defined and <time.h> or need timer_t. */
#undef __need_timer_t
#if (!defined __timespec_defined \
&& ((defined _TIME_H \
&& (defined __USE_POSIX199309 \
|| defined __USE_ISOC11)) \
|| defined __need_timespec))
# define __timespec_defined 1
# include <bits/types.h> /* This defines __time_t for us. */
/* POSIX.1b structure for a time value. This is like a `struct timeval' but
has nanoseconds instead of microseconds. */
struct timespec
{
__time_t tv_sec; /* Seconds. */
__syscall_slong_t tv_nsec; /* Nanoseconds. */
};
#endif /* timespec not defined and <time.h> or need timespec. */
#undef __need_timespec
#ifdef _TIME_H
__BEGIN_NAMESPACE_STD
/* Used by other time functions. */
struct tm
{
int tm_sec; /* Seconds. [0-60] (1 leap second) */
int tm_min; /* Minutes. [0-59] */
int tm_hour; /* Hours. [0-23] */
int tm_mday; /* Day. [1-31] */
int tm_mon; /* Month. [0-11] */
int tm_year; /* Year - 1900. */
int tm_wday; /* Day of week. [0-6] */
int tm_yday; /* Days in year.[0-365] */
int tm_isdst; /* DST. [-1/0/1]*/
# ifdef __USE_MISC
long int tm_gmtoff; /* Seconds east of UTC. */
const char *tm_zone; /* Timezone abbreviation. */
# else
long int __tm_gmtoff; /* Seconds east of UTC. */
const char *__tm_zone; /* Timezone abbreviation. */
# endif
};
__END_NAMESPACE_STD
#if defined __USE_XOPEN || defined __USE_POSIX
__USING_NAMESPACE_STD(tm)
#endif
# ifdef __USE_POSIX199309
/* POSIX.1b structure for timer start values and intervals. */
struct itimerspec
{
struct timespec it_interval;
struct timespec it_value;
};
/* We can use a simple forward declaration. */
#ifdef __USE_POSIX199309
# include <bits/types/clockid_t.h>
# include <bits/types/timer_t.h>
# include <bits/types/struct_itimerspec.h>
struct sigevent;
#endif
# 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
# endif
# define __pid_t_defined
# endif
#endif
#ifdef __USE_XOPEN2K8
# include <xlocale.h>
#endif
# ifdef __USE_ISOC11
#ifdef __USE_ISOC11
/* Time base values for timespec_get. */
# define TIME_UTC 1
# endif
#endif
__BEGIN_DECLS
__BEGIN_NAMESPACE_STD
/* Time used by the program so far (user time + system time).
@ -207,30 +91,29 @@ extern size_t strftime (char *__restrict __s, size_t __maxsize,
const struct tm *__restrict __tp) __THROW;
__END_NAMESPACE_STD
# ifdef __USE_XOPEN
#ifdef __USE_XOPEN
/* Parse S according to FORMAT and store binary time information in TP.
The return value is a pointer to the first unparsed character in S. */
extern char *strptime (const char *__restrict __s,
const char *__restrict __fmt, struct tm *__tp)
__THROW;
# endif
#endif
# ifdef __USE_XOPEN2K8
#ifdef __USE_XOPEN2K8
/* Similar to the two functions above but take the information from
the provided locale and not the global locale. */
# include <xlocale.h>
extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
const char *__restrict __format,
const struct tm *__restrict __tp,
__locale_t __loc) __THROW;
# endif
#endif
# ifdef __USE_GNU
#ifdef __USE_GNU
extern char *strptime_l (const char *__restrict __s,
const char *__restrict __fmt, struct tm *__tp,
__locale_t __loc) __THROW;
# endif
#endif
__BEGIN_NAMESPACE_STD
@ -243,7 +126,7 @@ extern struct tm *gmtime (const time_t *__timer) __THROW;
extern struct tm *localtime (const time_t *__timer) __THROW;
__END_NAMESPACE_STD
# ifdef __USE_POSIX
#ifdef __USE_POSIX
/* Return the `struct tm' representation of *TIMER in UTC,
using *TP to store the result. */
extern struct tm *gmtime_r (const time_t *__restrict __timer,
@ -253,7 +136,7 @@ extern struct tm *gmtime_r (const time_t *__restrict __timer,
using *TP to store the result. */
extern struct tm *localtime_r (const time_t *__restrict __timer,
struct tm *__restrict __tp) __THROW;
# endif /* POSIX */
#endif /* POSIX */
__BEGIN_NAMESPACE_STD
/* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n"
@ -264,7 +147,7 @@ extern char *asctime (const struct tm *__tp) __THROW;
extern char *ctime (const time_t *__timer) __THROW;
__END_NAMESPACE_STD
# ifdef __USE_POSIX
#ifdef __USE_POSIX
/* Reentrant versions of the above functions. */
/* Return in BUF a string of the form "Day Mon dd hh:mm:ss yyyy\n"
@ -275,7 +158,7 @@ extern char *asctime_r (const struct tm *__restrict __tp,
/* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'. */
extern char *ctime_r (const time_t *__restrict __timer,
char *__restrict __buf) __THROW;
# endif /* POSIX */
#endif /* POSIX */
/* Defined in localtime.c. */
@ -284,34 +167,34 @@ extern int __daylight; /* If daylight-saving time is ever in use. */
extern long int __timezone; /* Seconds west of UTC. */
# ifdef __USE_POSIX
#ifdef __USE_POSIX
/* Same as above. */
extern char *tzname[2];
/* Set time conversion information from the TZ environment variable.
If TZ is not defined, a locale-dependent default is used. */
extern void tzset (void) __THROW;
# endif
#endif
# if defined __USE_MISC || defined __USE_XOPEN
#if defined __USE_MISC || defined __USE_XOPEN
extern int daylight;
extern long int timezone;
# endif
#endif
# ifdef __USE_MISC
#ifdef __USE_MISC
/* Set the system time to *WHEN.
This call is restricted to the superuser. */
extern int stime (const time_t *__when) __THROW;
# endif
#endif
/* Nonzero if YEAR is a leap year (every 4 years,
except every 100th isn't, and every 400th is). */
# define __isleap(year) \
#define __isleap(year) \
((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
# ifdef __USE_MISC
#ifdef __USE_MISC
/* Miscellaneous functions many Unices inherited from the public domain
localtime package. These are included only for compatibility. */
@ -323,10 +206,10 @@ extern time_t timelocal (struct tm *__tp) __THROW;
/* Return the number of days in YEAR. */
extern int dysize (int __year) __THROW __attribute__ ((__const__));
# endif
#endif
# ifdef __USE_POSIX199309
#ifdef __USE_POSIX199309
/* Pause execution for a number of nanoseconds.
This function is a cancellation point and therefore not marked with
@ -345,7 +228,7 @@ extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
__THROW;
# ifdef __USE_XOPEN2K
# ifdef __USE_XOPEN2K
/* High-resolution sleep with the specified clock.
This function is a cancellation point and therefore not marked with
@ -356,7 +239,7 @@ extern int clock_nanosleep (clockid_t __clock_id, int __flags,
/* Return clock ID for CPU-time clock. */
extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __THROW;
# endif
# endif
/* Create new per-process timer using CLOCK_ID. */
@ -378,17 +261,17 @@ extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
/* Get expiration overrun for timer TIMERID. */
extern int timer_getoverrun (timer_t __timerid) __THROW;
# endif
#endif
# ifdef __USE_ISOC11
#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
#endif
# ifdef __USE_XOPEN_EXTENDED
#ifdef __USE_XOPEN_EXTENDED
/* Set to one of the following values to indicate an error.
1 the DATEMSK environment variable is null or undefined,
2 the template file cannot be opened for reading,
@ -410,9 +293,9 @@ extern int getdate_err;
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern struct tm *getdate (const char *__string);
# endif
#endif
# ifdef __USE_GNU
#ifdef __USE_GNU
/* Since `getdate' is not reentrant because of the use of `getdate_err'
and the static buffer to return the result in, we provide a thread-safe
variant. The functionality is the same. The result is returned in
@ -425,10 +308,8 @@ extern struct tm *getdate (const char *__string);
therefore not marked with __THROW. */
extern int getdate_r (const char *__restrict __string,
struct tm *__restrict __resbufp);
# endif
#endif
__END_DECLS
#endif /* <time.h> included. */
#endif /* <time.h> not already included. */
#endif /* time.h. */