#ifndef __TIME_LOADED #define __TIME_LOADED #ifndef __TIME_PROCESSED #define __TIME_PROCESSED /**************************************************************************** ** ** - Date and Time ** ***************************************************************************** ** ** Header introduced by the ANSI C Standard ** ** Definitions in this header file may not be available on all versions of ** OpenVMS. See the DEC C Runtime Library reference manual for specifics. ** ***************************************************************************** */ /* ************************************************************************* */ /* * * */ /* * HPE CONFIDENTIAL. This software is confidential proprietary software * */ /* * licensed by Hewlett Packard Enterprise Development, LP, and is not * */ /* * authorized to be used, duplicated or disclosed to anyone without the * */ /* * prior written permission of HPE. * */ /* * Copyright 2017 Hewlett Packard Enterprise Development, LP * */ /* * * */ /* * VMS SOFTWARE, INC. CONFIDENTIAL. This software is confidential * */ /* * proprietary software licensed by VMS Software, Inc., and is not * */ /* * authorized to be used, duplicated or disclosed to anyone without * */ /* * the prior written permission of VMS Software, Inc. * */ /* * Copyright 2017-2022 VMS Software, Inc. * */ /* * * */ /* ************************************************************************* */ #pragma __nostandard #include #ifdef __cplusplus extern "C" { #endif /* ** If the user has used /pointer_size=short or /pointer_size=long, we will ** begin in a 32-bit pointer size context. */ #if __INITIAL_POINTER_SIZE # pragma __pointer_size __save # pragma __pointer_size 32 #endif /* ** Member align structures */ #pragma __member_alignment __save #pragma __member_alignment /* ** Disable messages */ #pragma __message __save #pragma __message __disable (__MISALGNDSTRCT) #pragma __message __disable (__MISALGNDMEM) /* ** Create 'private' typedefs that are sensitive to pointer size and must ** use 32 bit pointers. */ /* ** ANSI Standard Definitions & Typedefs */ #define CLOCKS_PER_SEC 100 #ifndef NULL # define NULL __NULL #endif #ifdef __NAMESPACE_STD namespace std { #endif #ifndef __SIZE_T # define __SIZE_T 1 typedef __size_t size_t; #endif #ifndef __TIME_T # define __TIME_T typedef __time_t time_t; #endif #ifndef __CLOCK_T # define __CLOCK_T 1 # if defined(__clang__) typedef int clock_t; # else typedef long int clock_t; # endif #endif /* ** tm data structure ** ** Note conditions for BSD extensions, introduced in VMS V7.0, and ** not wanted for some standards or legacy compilations. ** These extensions make tm "long". Not having them makes tm "short". ** - C++ Standard Library requires longer tm structure. ** After C++ V6.5-042, use filler names. Either requires __utctz_. ** - Future VMS releases will get a longer tm structure possibly with ** changed/filler names, to make all objects of tm the same length, ** which may force recompilation of all modules using tm. ** - Macro _TM_SHORT will force short tm ** - Macro _TM_LONG will force long tm ** ** This decides the time format for functions, 3 possibilities: ** - localtime (before VMS V7.0, no prefixes) ** - utc time, one of: ** o __UTCTZ_ prefixes, using BSD tm extensions ** o __UTC_ prfexes, not using BSD tm extensions */ #undef __TM_USE_UTCTZ_TIME #undef __TM_USE_UTC_TIME #undef __TM_DEF_BSD_EXTENSIONS #undef __TM_DEF_BSD_FILLER_NAMES #undef __TM_CXX_NEED_BSD_NAMES #undef __TM_CXX_NEED_FILLER_NAMES #if __CRTL_VER >= 70000000 # if defined __DECCXX && !defined _VMS_V6_SOURCE # if __DECCXX_VER > 60590042 # define __TM_CXX_NEED_FILLER_NAMES # else # define __TM_CXX_NEED_BSD_NAMES # endif # endif /* UTC time functions available in CRTL */ # if (!defined _ANSI_C_SOURCE || defined __TM_CXX_NEED_BSD_NAMES) && \ !defined _DECC_V4_SOURCE && !defined _TM_SHORT /* BSD member names visible */ # define __TM_DEF_BSD_EXTENSIONS # if !defined _VMS_V6_SOURCE || defined __TM_CXX_NEED_BSD_NAMES /* Use __UTCTZ_ prefixed functions */ # define __TM_USE_UTCTZ_TIME # endif # elif !defined _VMS_V6_SOURCE /* Use __UTC_ prefixed functions */ # define __TM_USE_UTC_TIME # endif #endif /* CRTL V7.0 */ #if !defined __TM_DEF_BSD_EXTENSIONS && !defined _TM_SHORT # if __CRTL_VER >= 80300000 || defined _TM_LONG || \ defined __TM_CXX_NEED_FILLER_NAMES /* Longer tm, but non-polluting BSD member names */ # define __TM_DEF_BSD_FILLER_NAMES # if defined __DECCXX # define __TM_USE_UTCTZ_TIME # undef __TM_USE_UTC_TIME # endif # endif #endif #if defined _TM_SHORT && defined _TM_LONG # error "Both _TM_SHORT and _TM_LONG defined; only one allowed" #endif struct tm { int tm_sec; /* seconds after the minute [0, 61] */ int tm_min; /* minutes after the hour [0, 59] */ int tm_hour; /* hours since midnight [0, 23] */ int tm_mday; /* day of the month [1, 31] */ int tm_mon; /* months since January [0, 11] */ int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday [0, 6] */ int tm_yday; /* days since January 1 [0, 365] */ int tm_isdst; /* Daylight Saving Time flag */ #if defined __TM_DEF_BSD_EXTENSIONS /* BSD tm member extensions */ # if defined(__clang__) int tm_gmtoff; /* offset from UTC in seconds */ # else long tm_gmtoff; /* offset from UTC in seconds */ # endif char *tm_zone; /* timezone abbreviation */ #elif defined __TM_DEF_BSD_FILLER_NAMES /* BSD tm member extensions, non-polluting namespace */ # if defined(__clang__) int __tm_gmtoff; /* offset from UTC in seconds */ # else long __tm_gmtoff; /* offset from UTC in seconds */ # endif char *__tm_zone; /* timezone abbreviation */ #endif }; /* tm */ #ifdef __NAMESPACE_STD } /* namespace std */ #endif #ifdef __NAMESPACE_STD typedef struct std::tm * __struct_tm_ptr32; #else typedef struct tm * __struct_tm_ptr32; #endif /* ** clock_t datatype is used in this header file in declaration of function ** times() which is not in the ANSI C standard, and, consequently, is not ** inserted into the namespace std. Make clock_t datatype available in the ** global namespace when compiling with C++ in nopure_cname mode. */ #if defined(__NAMESPACE_STD) && !defined(__NAMESPACE_STD_ONLY) using std::clock_t; #endif /* ** ISO POSIX-1 Standard Definitions & Typedefs */ #if defined _POSIX_C_SOURCE || !defined _ANSI_C_SOURCE /* ** Number of clock ticks per second returned by the times () ** function. (To be Withdrawn) */ # define CLK_TCK 100 /* ** tzname is the name of the current timezone, ** it is not visible if compiling for a local ** time based compatibility mode. */ # if __CRTL_VER >= 70000000 # if !defined _VMS_V6_SOURCE # pragma __extern_model __save # pragma __extern_model __strict_refdef extern char *tzname[2]; # pragma __extern_model __restore # endif # endif #endif /* ** X/Open extension definitions and typedefs, ** these variables are not visible if compiling ** in a local time based compatibility mode. */ #if defined _XOPEN_SOURCE || !defined _ANSI_C_SOURCE # if __CRTL_VER >= 70000000 # if !defined _VMS_V6_SOURCE # pragma __extern_model __save # pragma __extern_model __strict_refdef extern int daylight; # if defined(__clang__) extern int timezone; # else extern long int timezone; # endif # pragma __extern_model __restore # endif # endif #endif /* ** DEC C extension definitions and typedefs */ #ifndef _ANSI_C_SOURCE /* ** struct timeb is defined by XPG4 V2 to be in */ # ifndef __TIMEB_STR_LOADED # define __TIMEB_STR_LOADED 1 struct timeb { __time_t time; unsigned short millitm; short timezone; short dstflag; }; # endif # ifndef __TIMEB_T # define __TIMEB_T typedef struct timeb timeb_t; # endif # if __CRTL_VER >= 70000000 && !defined _DECC_V4_SOURCE # ifndef __TMS # define __TMS struct tms { clock_t tms_utime; /* user CPU time */ clock_t tms_stime; /* system CPU time */ clock_t tms_cutime; /* user CPU of terminated child processes */ clock_t tms_cstime; /* system CPU of terminated child processes */ }; # endif # endif # ifndef __TBUFFER_T # define __TBUFFER_T 1 typedef struct tbuffer { int proc_user_time; int proc_system_time; int child_user_time; int child_system_time; } tbuffer_t; # endif #endif /* ** We are done defining things which must always be 32 bit pointers. If the ** user has used /pointer_size=32 or /pointer_size=64, we will allow 64 bit ** pointers to be used in function calls. */ #if __INITIAL_POINTER_SIZE # pragma __pointer_size 64 #endif /* ** Create 'private' typedefs that are sensitive to pointer size and must ** use long pointers. Protect identically in all header files. */ #ifdef __NAMESPACE_STD typedef struct std::tm * __struct_tm_ptr64; #else typedef struct tm * __struct_tm_ptr64; #endif #ifdef __NAMESPACE_STD namespace std { #endif /* ** ANSI Function prototypes -- full 64 bit support */ clock_t clock (void); double difftime (__time_t __time1, __time_t __time0); __char_ptr32 asctime (const struct tm *__timeptr); #ifdef __NAMESPACE_STD } /* namespace std */ #endif #if defined _POSIX_C_SOURCE || !defined _ANSI_C_SOURCE #ifdef __NAMESPACE_STD __char_ptr32 asctime_r(const struct std::tm *__tm, __char_ptr32 __buf); #else __char_ptr32 asctime_r(const struct tm *__tm, __char_ptr32 __buf); #endif #endif /* ** Beginning in OpenVMS Version 7.0 mktime, time, ctime, strftime ** have two implementations. One implementation is provided ** for compatibility and deals with time in terms of local time, ** the other __utc_* deals with time in terms of UTC. */ #if __CRTL_VER >= 70000000 # if !defined _VMS_V6_SOURCE # ifdef __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __save # pragma __extern_prefix "__utc_" # else # define mktime(__p1) __utc_mktime(__p1) # define time(__p1) __utc_time(__p1) # define ctime(__p1) __utc_ctime(__p1) # define strftime(__p1,__p2,__p3,__p4) __utc_strftime(__p1,__p2,__p3,__p4) # endif # endif #endif /* __CRTL_VER >= 70000000 */ #ifdef __NAMESPACE_STD namespace std { #endif __time_t mktime (struct tm *__timeptr); __time_t time (__time_t *__timer); __char_ptr32 ctime (const __time_t *__timer); __size_t strftime (char *__s, __size_t __maxsize, const char *__format, const struct tm *__timeptr); #ifdef __NAMESPACE_STD } /* namespace std */ #endif /* ** Disable extern_prefix if we enabled it earlier */ #if __CRTL_VER >= 70000000 # if !defined _VMS_V6_SOURCE # ifdef __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __restore # endif # endif #endif /* ** Beginning in OpenVMS Version 7.2, we have added an implementation ** of the ctime_r function. There are both local time and utc time ** implementations. */ #if __CRTL_VER >= 70000000 && \ (defined _POSIX_C_SOURCE || !defined _ANSI_C_SOURCE) # if !defined _VMS_V6_SOURCE # ifdef __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __save # pragma __extern_prefix "__utc_" # else # define ctime_r(__p1,__p2) __utc_ctime_r(__p1,__p2) # endif # endif __char_ptr32 ctime_r (const __time_t *__timer, __char_ptr32 __buf); # if !defined _VMS_V6_SOURCE # ifdef __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __restore # endif # endif #endif /* __CRTL_VER >= 70000000 && (not ANSI) */ /* ** Beginning in OpenVMS Version 7.0 gmtime and localtime have three ** implementations: ** - Older (pre-7.0) localtime implementation ** - Two UTC time implementations: ** o __utctz_* implementations provide support for the ** additional tm_gmtoff and tm_zone fields of the tm structure ** o the __utc_* implementations deal with the ANSI definition of ** the tm structure. */ #if defined __TM_USE_UTCTZ_TIME /* UTC time with BSD tm member extensions */ # ifdef __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __save # pragma __extern_prefix "__utctz_" # else # define gmtime(__p1) __utctz_gmtime(__p1) # define localtime(__p1) __utctz_localtime(__p1) # endif #elif defined __TM_USE_UTC_TIME /* UTC time without BSD tm member extensions */ # ifdef __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __save # pragma __extern_prefix "__utc_" # else # define gmtime(__p1) __utc_gmtime(__p1) # define localtime(__p1) __utc_localtime(__p1) # endif #endif #ifdef __NAMESPACE_STD namespace std { #endif __struct_tm_ptr32 localtime (const __time_t *__timer); __struct_tm_ptr32 gmtime (const __time_t *__timer); #ifdef __NAMESPACE_STD } /* namespace std */ #endif /* ** Disable extern_prefix if we enabled it earlier */ #if defined __TM_USE_UTCTZ_TIME || defined __TM_USE_UTC_TIME # ifdef __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __restore # endif #endif #if !(defined(__NAMESPACE_STD) && defined(__PURE_CNAME)) /* ** Beginning in OpenVMS Version 7.2, we have added gmtime_t and localtime_t ** implementations. The same three interfaces are supported for each as ** described above. */ #if __CRTL_VER >= 70000000 && \ (defined _POSIX_C_SOURCE || !defined _ANSI_C_SOURCE) # undef __UTC_PREFIX_DEFINED # if defined __TM_USE_UTCTZ_TIME /* UTC time with BSD tm member extensions */ # ifdef __CAN_USE_EXTERN_PREFIX # define __UTC_PREFIX_DEFINED # pragma __extern_prefix __save # pragma __extern_prefix "__utctz_" # else # define gmtime_r(__p1,__p2) __utctz_gmtime_r(__p1,__p2) # define localtime_r(__p1,__p2) __utctz_localtime_r(__p1,__p2) # endif # elif defined __TM_USE_UTC_TIME /* UTC time without BSD tm member extensions */ # ifdef __CAN_USE_EXTERN_PREFIX # define __UTC_PREFIX_DEFINED # pragma __extern_prefix __save # pragma __extern_prefix "__utc_" # else # define gmtime_r(__p1,__p2) __utc_gmtime_r(__p1,__p2) # define localtime_r(__p1,__p2) __utc_localtime_r(__p1,__p2) # endif # endif __struct_tm_ptr32 gmtime_r (const __time_t *__timer, __struct_tm_ptr32 __result); __struct_tm_ptr32 localtime_r (const __time_t *__timer, __struct_tm_ptr32 __result); # ifdef __UTC_PREFIX_DEFINED # pragma __extern_prefix __restore # undef __UTC_PREFIX_DEFINED # endif #endif /* __CRTL_VER >= 70000000 && (not ANSI) */ #endif /* !(defined(__NAMESPACE_STD) && defined(__PURE_CNAME)) */ /* ** ISO POSIX-1 Function prototypes -- full 64 bit support */ #if defined _POSIX_C_SOURCE || !defined _ANSI_C_SOURCE # if __CRTL_VER >= 70000000 && !defined _VMS_V6_SOURCE void tzset (void); # endif # endif /* ** The following functions have interfaces of XXX, _XXX32, and _XXX64 due only ** to the fact that the return argument is a pointer that is relative to one ** of the arguments. */ #if __INITIAL_POINTER_SIZE == 32 # pragma __pointer_size 32 #endif #if defined _XOPEN_SOURCE || !defined _ANSI_C_SOURCE # if __CRTL_VER >= 60200000 char *strptime (const char *__buf, __const_char_ptr64 __fmt, __struct_tm_ptr64 __tm); # endif #endif #if __INITIAL_POINTER_SIZE == 32 # pragma __pointer_size 64 #endif /* ** DEC C Extensions */ #ifndef _ANSI_C_SOURCE /* ** Beginning in OpenVMS Version 7.0 ftime has two implementations. One ** implementation is provided for compatibility and deals with time in terms ** of local time, the other __utc_ftime deals with time in terms of UTC. */ #if __CRTL_VER >= 70000000 # if !defined _VMS_V6_SOURCE # ifdef __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __save # pragma __extern_prefix "__utc_" # else # define ftime(__p1) __utc_ftime(__p1) # endif # endif #endif /* __CRTL_VER >= 70000000 */ int ftime (struct timeb *__timeptr); /* ** Disable extern_prefix if we enabled it earlier */ #if __CRTL_VER >= 70000000 # if !defined _VMS_V6_SOURCE # ifdef __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __restore # endif # endif #endif # if __CRTL_VER >= 70000000 && !defined _DECC_V4_SOURCE clock_t times(struct tms *buffer); # else void times (tbuffer_t *__buffer); /* */ # endif # if __INITIAL_POINTER_SIZE # pragma __pointer_size 32 char * _strptime32 (const char *, __const_char_ptr64, __struct_tm_ptr64); # pragma __pointer_size 64 char * _strptime64 (const char *, const char *, __struct_tm_ptr64); # endif #endif /* __CRTL_VER >= 70000000 && ifndef _ANSI_C_SOURCE */ /**************************************************************************** ** ** - time types ** ** The following is the equivalent of . It is merged into ** since DEC C on OpenVMS systems does not distinguish ** the two header files. */ #if defined _XOPEN_SOURCE_EXTENDED || (!defined _ANSI_C_SOURCE && !defined _DECC_V4_SOURCE) /* ** Values for the which argument of getitimer() and setitimer(). */ # define ITIMER_REAL 0 /* Real time */ # define ITIMER_VIRTUAL 1 /* Per-process time */ # define ITIMER_PROF 2 /* Per-process user time */ # ifndef __TIMEVAL # define __TIMEVAL 1 struct timeval { __time_t tv_sec; /* seconds since Jan. 1, 1970 */ # if defined(__clang__) int tv_usec; /* microseconds */ # else long tv_usec; /* microseconds */ # endif }; # endif struct itimerval { struct timeval it_interval; /* timer interval */ struct timeval it_value; /* current value */ }; /* ** Select () examines I/O descriptor sets which are stored as ** bit fields in arrays of integers. The following macros are ** provided for manipulating such descriptor sets. */ /* FD_SETSIZE may be defined by the user. It is normally ** equal to the maximum number of descriptors supported by ** the system. Here it is set to the minimum maximum supported ** by the system. In order to accomodate programs which use ** a larger number of open files with select, increase this size ** within a program by providing a larger definition of FD_SETSIZE ** before including or */ # if !defined __FD_SET # define __FD_SET 1 # ifndef FD_SETSIZE # define FD_SETSIZE 1024 # endif # if defined(__clang__) typedef int fd_mask; # else typedef long fd_mask; # endif # define NBBY 8 /* bits per byte */ # define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ # define FD_SET(__n, __p) ((__p)->fds_bits[(__n)/NFDBITS] |= (1 << ((__n) % NFDBITS))) # define FD_CLR(__n, __p) ((__p)->fds_bits[(__n)/NFDBITS] &= ~(1 << ((__n) % NFDBITS))) # define FD_ISSET(__n, __p) ((__p)->fds_bits[(__n)/NFDBITS] & (1 << ((__n) % NFDBITS))) # define __howmany(__x, __y) (((__x)+((__y)-1))/(__y)) typedef struct fd_set { /* descriptor set */ fd_mask fds_bits[__howmany(FD_SETSIZE, NFDBITS)]; } fd_set; # if __INITIAL_POINTER_SIZE == 32 # pragma __pointer_size 32 # endif # if defined(__clang__) void *memset(void *__s, int __c, __size_t __n); # define FD_ZERO(__p) memset((__p), 0, sizeof(*(__p))) # else void *__MEMSET(void *__s, int __c, __size_t __n); # define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p))) # endif # if __INITIAL_POINTER_SIZE == 32 # pragma __pointer_size 64 # endif # endif /* ** We are done defining things which must always be 32 bit pointers. If the ** user has used /pointer_size=32 or /pointer_size=64, we will allow 64 bit ** pointers to be used in function calls. */ # if __INITIAL_POINTER_SIZE # pragma __pointer_size 64 # endif /* ** Note that gettimeofday() is UTC based, so it is not visible if ** compiling in a local time based compatibility mode. */ #if __CRTL_VER >= 70000000 int getitimer (int __which, struct itimerval *__value); int setitimer (int __which, const struct itimerval *__value, struct itimerval *__ovalue); # if !defined _VMS_V6_SOURCE int gettimeofday (struct timeval *__tp, void *__tzp); # endif #endif int select (int __nfds, fd_set *__readfds, fd_set *__writefds, fd_set *__exceptfds, struct timeval *__timeout); #if __CRTL_VER >= 70300000 # if !defined _VMS_V6_SOURCE # ifdef __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __save # pragma __extern_prefix "__utc_" # else # define utimes(__p1,__p2) __utc_utimes(__p1,__p2) # endif # endif int utimes(const char *__path, const struct timeval __times[2]); # if !defined _VMS_V6_SOURCE # ifdef __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __restore # endif # endif #endif #if __CRTL_VER >= 70320000 # if (!defined __TIMESPEC && !defined _TIMESPEC_T_) # define __TIMESPEC struct timespec { # if defined(__clang__) unsigned int tv_sec; /* seconds */ int tv_nsec; /* nanoseconds */ # else unsigned long tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ # endif }; # endif /* * The IDs of the various system clocks (for POSIX.1b interval timers): */ # if __CRTL_VER >= 80500000 # define CLOCK_MONOTONIC 0 # define CLOCK_MONOTONIC_RAW 4 # define CLOCK_MONOTONIC_COARSE 6 # endif # define CLOCK_REALTIME 1 # ifndef __CLOCKID_T # define __CLOCKID_T typedef unsigned int clockid_t; # endif int clock_gettime(clockid_t clock_id, struct timespec *tp); int clock_settime(clockid_t clock_id, const struct timespec *tp); int clock_getres(clockid_t clock_id, struct timespec *res); # if defined(__clang__) int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); # else long nanosleep(struct timespec *rqtp, struct timespec *rmtp); # endif #endif /* if __CRTL_VER >= 70320000 */ #endif /* _XOPEN_SOURCE_EXTENDED || (! _ANSI_C_SOURCE && ! _DECC_V4_SOURCE) */ /* ** Restore the users pointer context */ #if __INITIAL_POINTER_SIZE # pragma __pointer_size __restore #endif #ifdef __cplusplus } #endif #pragma __message __restore #pragma __member_alignment __restore #pragma __standard #endif /* __TIME_PROCESSED */ #if defined(__NAMESPACE_STD) && !defined(__NAMESPACE_STD_ONLY) # ifndef __USING_TIME_NAMES # define __USING_TIME_NAMES using std::asctime; using std::clock; using std::clock_t; using std::ctime; using std::difftime; using std::gmtime; using std::localtime; using std::mktime; using std::size_t; using std::strftime; using std::time; using std::time_t; using std::tm; # endif #endif #endif /* __TIME_LOADED */