diff --git a/README b/README index 7fe7535..c91e72c 100755 --- a/README +++ b/README @@ -14,6 +14,7 @@ iso646.h libgen.h limits.h? stdbool.h +stddef.h sys/un.h tar.h @@ -24,6 +25,7 @@ The following headers are POSIX-compliant, but not XSI-compliant: The following headers are ISO-compliant, though not POSIX-compliant: The following headers have working code, but are still in progress: +ctype.h (56%, missing locale-specific functions) math.h (3%) stdio.h (3% + most of printf and maybe perror?) stdlib.h (13%) @@ -31,7 +33,6 @@ string.h (26%) time.h (4%) The following headers exist and have all definitions, but no code: -ctype.h sys/utsname.h syslog.h ulimit.h @@ -40,7 +41,6 @@ The following headers exist and are incomplete: float.h (45%) math.h (<33%) netinit/in.h (37%) -stddef.h (80%) stdio.h (<20%) stdlib.h (24%) string.h (26%) diff --git a/include/time.h b/include/time.h index f7daf4d..9323d44 100644 --- a/include/time.h +++ b/include/time.h @@ -1,6 +1,12 @@ #ifndef _TIME_H #define _TIME_H +#ifdef _XOPEN_SOURCE +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200908L +#endif +#endif + #ifndef NULL #define NULL (void *) 0 #endif @@ -8,12 +14,15 @@ #include #include #include +#ifdef _POSIX_C_SOURCE #include #include -#include #include +struct sigevent; +#endif +#include -struct tm{ +struct tm { unsigned int tm_sec : 6; unsigned int tm_min : 6; unsigned int tm_hour : 5; @@ -25,6 +34,74 @@ struct tm{ int tm_isdst : 2; }; +struct timespec { + time_t tv_sec; + long int tv_nsec; +}; + +#ifdef _POSIX_C_SOURCE +struct itimerspec { + struct timespec it_interval; + struct timespec it_value; +}; +#endif + +#define CLOCKS_PER_SEC ((clock_t) 1000000) + +#ifdef _POSIX_C_SOURCE +#define CLOCK_MONOTONIC 01 +#define CLOCK_PROCESS_CPUTIME_ID 02 +#define CLOCK_REALTIME 04 +#define CLOCK_THREAD_CPUTIME_ID 010 + +#define TIMER_ABS_TIME 1 +#endif + +#ifdef _XOPEN_SOURCE +extern int getdate_err; +extern int daylight; +extern long timezone; +#endif + +clock_t clock(void); time_t time(time_t *); +double difftime(time_t, time_t); +time_t mktime(struct tm *); +int timespec_get(struct timespec *, int); +char * asctime(const struct tm *); +char * ctime(const time_t *); +struct tm * gmtime(const time_t *); +struct tm * localtime(const time_t *); +size_t strftime(char * restrict, size_t, const char * restrict, + const struct tm * restrict); + + +#ifdef _POSIX_C_SOURCE +char * asctime_r(const struct tm * restrict, char * restrict); +int clock_getcpuclockid(pid_t, clockid_t *); +int clock_getres(clockid_t, struct timespec *); +int clock_gettime(clockid_t, struct timespec *); +int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *); +int clock_settime(clockid_t, const struct timespec *); +char * ctime_r(const time_t *, char *); +struct tm * gmtime_r(const time_t * restrict, struct tm * restrict); +struct tm * localtime_r(const time_t * restrict, struct tm * restrict); +int nanosleep(const struct timespec *, struct timespec *); +size_t strftime_l(char * restrict, size_t, const char * restrict, + const struct tm * restrict, locale_t); +int timer_create(clockid_t, struct sigevent * restrict, timer_t * restrict); +int timer_delete(timer_t); +int timer_getoverrun(timer_t); +int timer_gettime(timer_t, struct itimerspec *); +int timer_settime(timer_t, int, const struct itimerspec * restrict, + struct itimerspec * restrict); +void tzset(void); +#endif + +#ifdef _XOPEN_SOURCE +struct time * getdate(const char *); +char * strptime(const char * restrict, const char * restrict, + struct tm * restrict); +#endif #endif /* not _HEADER */