Finished time.h?

This commit is contained in:
Gitea 2020-12-13 09:13:58 -06:00
parent 25658c7690
commit 1505f8b0e5
2 changed files with 81 additions and 4 deletions

4
README
View file

@ -14,6 +14,7 @@ iso646.h
libgen.h libgen.h
limits.h? limits.h?
stdbool.h stdbool.h
stddef.h
sys/un.h sys/un.h
tar.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 are ISO-compliant, though not POSIX-compliant:
The following headers have working code, but are still in progress: The following headers have working code, but are still in progress:
ctype.h (56%, missing locale-specific functions)
math.h (3%) math.h (3%)
stdio.h (3% + most of printf and maybe perror?) stdio.h (3% + most of printf and maybe perror?)
stdlib.h (13%) stdlib.h (13%)
@ -31,7 +33,6 @@ string.h (26%)
time.h (4%) time.h (4%)
The following headers exist and have all definitions, but no code: The following headers exist and have all definitions, but no code:
ctype.h
sys/utsname.h sys/utsname.h
syslog.h syslog.h
ulimit.h ulimit.h
@ -40,7 +41,6 @@ The following headers exist and are incomplete:
float.h (45%) float.h (45%)
math.h (<33%) math.h (<33%)
netinit/in.h (37%) netinit/in.h (37%)
stddef.h (80%)
stdio.h (<20%) stdio.h (<20%)
stdlib.h (24%) stdlib.h (24%)
string.h (26%) string.h (26%)

View file

@ -1,6 +1,12 @@
#ifndef _TIME_H #ifndef _TIME_H
#define _TIME_H #define _TIME_H
#ifdef _XOPEN_SOURCE
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200908L
#endif
#endif
#ifndef NULL #ifndef NULL
#define NULL (void *) 0 #define NULL (void *) 0
#endif #endif
@ -8,12 +14,15 @@
#include <types/clock_t.h> #include <types/clock_t.h>
#include <types/size_t.h> #include <types/size_t.h>
#include <types/time_t.h> #include <types/time_t.h>
#ifdef _POSIX_C_SOURCE
#include <types/clockid_t.h> #include <types/clockid_t.h>
#include <types/timer_t.h> #include <types/timer_t.h>
#include <types/locale_t.h>
#include <types/pid_t.h> #include <types/pid_t.h>
struct sigevent;
#endif
#include <types/locale_t.h>
struct tm{ struct tm {
unsigned int tm_sec : 6; unsigned int tm_sec : 6;
unsigned int tm_min : 6; unsigned int tm_min : 6;
unsigned int tm_hour : 5; unsigned int tm_hour : 5;
@ -25,6 +34,74 @@ struct tm{
int tm_isdst : 2; 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 *); 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 */ #endif /* not _HEADER */