Add documentation and headers for timespec_get.

A macro is used to control whether struct timespec is declared, because GNO might want to declare it in other headers, and this would allow it to avoid duplicate declarations. (This will still require changes in the GNO headers. Currently, they declare struct timespec with different field names, although the layout is the same.)
This commit is contained in:
Stephen Heumann 2023-01-01 21:46:19 -06:00
parent 59664df9d9
commit 5476118951
2 changed files with 27 additions and 1 deletions

View File

@ -28,12 +28,22 @@ struct tm {
int tm_isdst;
};
#ifndef __struct_timespec__
#define __struct_timespec__
struct timespec {
time_t tv_sec;
long tv_nsec;
};
#endif
clock_t __clocks_per_sec(void);
#ifndef __KeepNamespacePure__
#define CLK_TCK (__clocks_per_sec())
#endif
#define CLOCKS_PER_SEC (__clocks_per_sec())
#define TIME_UTC 1
#ifndef NULL
#define NULL (void *) 0L
#endif
@ -52,5 +62,6 @@ struct tm *localtime(const time_t *);
time_t mktime(struct tm *);
size_t strftime(char *, size_t, const char *, const struct tm *);
time_t time(time_t *);
int timespec_get(struct timespec *, int);
#endif

View File

@ -1,6 +1,6 @@
ORCA/C 2.2.0 B7
Copyright 1997, Byte Works Inc.
Updated by Stephen Heumann and Kelvin Sherlock, 2017-2022
Updated by Stephen Heumann and Kelvin Sherlock, 2017-2023
-- Change List --------------------------------------------------------------
@ -1402,6 +1402,21 @@ Note that the ORCA/C run-time libraries will not start up the Time Tool Set. If
https://timetool.gwlink.net
21. (C11) The timespec_get function has been added:
#include <time.h>
struct timespec {
time_t tv_sec; /* full seconds */
long tv_nsec; /* nanoseconds */
};
int timespec_get(struct timespec *ts, int base);
This function sets the structure *ts to a representation of the current time based on a specified time base determined by the base parameter (which should be a macro value defined in <time.h>). If it completes successfully, it returns the value of base; otherwise, it returns 0.
The only time base supported by ORCA/C is TIME_UTC. This gives the time in seconds and nanoseconds since an implementation-defined time known as the epoch. In ORCA/C, the epoch is 13 Nov 1969 00:00:00. If the Time Tool Set is installed and active, timespec_get will use it to determine the time zone offset from UTC and provide a representation of the current UTC time; otherwise, it provides a representation of the current local time, assuming it is equal to UTC. For more information on using the Time Tool Set, see the discussion of gmtime() above.
Although struct timespec can represent a time with nanosecond resolution, ORCA/C currently only reports the time with a resolution of one second, so ts->tv_nsec is always set to 0.
-- Compiler changes introduced in C 2.1.0 -----------------------------------
The Default .h File