diff --git a/ORCACDefs/time.h b/ORCACDefs/time.h index 6bfa1e9..784b92b 100644 --- a/ORCACDefs/time.h +++ b/ORCACDefs/time.h @@ -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 diff --git a/cc.notes b/cc.notes index 4c10372..857ec8c 100644 --- a/cc.notes +++ b/cc.notes @@ -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 +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 ). 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