#ifndef __STDLIB_LOADED #define __STDLIB_LOADED 1 #ifndef __STDLIB_PROCESSED #define __STDLIB_PROCESSED /**************************************************************************** ** ** - General Utilities ** ***************************************************************************** ** Header introduced by the ANSI C Standard ***************************************************************************** */ /* ************************************************************************* */ /* * * */ /* * 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 2019-2023 VMS Software, Inc. * */ /* * * */ /* ************************************************************************* */ #pragma __nostandard #include #ifdef __cplusplus extern "C" { #endif /* ** X/Open specifies that WNOHANG, WUNTRACED, WEXITSTATUS, WIFEXITED, ** WIFSIGNALED, WIFSTOPPED, WSTOPSIG and WTRERMSIG are defined here, and that ** inclusion of may make visible all symbols from ** and . */ #if defined _XOPEN_SOURCE || (!defined _ANSI_C_SOURCE && !defined _DECC_V4_SOURCE) # include # include #endif #if __INITIAL_POINTER_SIZE || defined(__clang__) # pragma __required_pointer_size __save # pragma __required_pointer_size 32 #endif /* ** Member align structures */ #pragma __member_alignment __save #pragma __member_alignment /* ** Create 'public' typedefs that are sensitive to pointer size and must ** use 32 bit pointers. Create other declarations which are not sensitive ** to pointer size. */ #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 typedef struct { int quot, rem; } div_t; typedef struct { long int quot, rem; } ldiv_t; #ifdef __NAMESPACE_STD } /* namespace std */ #endif #ifndef __WCHAR_T # define __WCHAR_T typedef __wchar_t wchar_t; #endif /* ** mode_t is needed for a DEC C RTL Extension */ #ifndef _ANSI_C_SOURCE # if !defined __MODE_T && !defined _DECC_V4_SOURCE # define __MODE_T 1 typedef __mode_t mode_t; # endif #endif /* ** Define constant values */ /* ** Exit function failure definition changes corresponding to ** V7.0 "UNIX"-like exit function behavior. */ #if __CRTL_VER >= 70000000 && defined(_POSIX_EXIT) # define EXIT_FAILURE (1) #else # define EXIT_FAILURE 0x10000002 #endif #define EXIT_SUCCESS 0 #define RAND_MAX 2147483647 /* ** Beginning in OpenVMS V6.2, MB_CUR_MAX is no longer a literal value */ #if __CRTL_VER < 60200000 # define MB_CUR_MAX 1 #else # pragma __extern_model __save # pragma __extern_model __strict_refdef extern int decc$$gl___mb_cur_max; # pragma __extern_model __restore # define MB_CUR_MAX (decc$$gl___mb_cur_max) #endif /**************************************************************************** ** ** Functions which do not support 64 bit pointers ** ****************************************************************************/ #ifdef __NAMESPACE_STD namespace std { #endif /* ** ANSI functions */ int atexit(void(*__func)(void)); #ifdef __NAMESPACE_STD } /* namespace std */ #endif /* ** X/Open functions */ #if defined _XOPEN_SOURCE || !defined _ANSI_C_SOURCE # if __CRTL_VER >= 70000000 int putenv (const char *__string); # endif #endif /* ** X/Open Extended functions */ #if defined _XOPEN_SOURCE_EXTENDED || !defined _ANSI_C_SOURCE && __CRTL_VER >= 70000000 char *setstate(char *); char *initstate(unsigned int, char *, int); #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 || defined(__clang__) # pragma __required_pointer_size 64 #endif /**************************************************************************** ** ** Functions which accept either 32 bit or 64 bit pointers ** ****************************************************************************/ #ifdef __NAMESPACE_STD namespace std { #endif /* ** ANSI functions */ void abort (void); int abs (int __j); double atof (const char *__nptr); int atoi (const char *__nptr); long int atol (const char *__nptr); div_t div (int __numer, int __denom); void free (void *__ptr); long int labs (long int __j); ldiv_t ldiv (long int __numer, long int __denom); int mblen (const char *__s, __size_t __n); __size_t mbstowcs (__wchar_t *__pwcs, const char *__s, __size_t __n); int mbtowc (__wchar_t *__pwc, const char *__s, __size_t __n); int rand (void); void srand (unsigned int __seed); __size_t wcstombs (char *__s, const __wchar_t *__pwcs, __size_t __n); int wctomb (char *__s, __wchar_t __wchar); #if __CRTL_VER >= 70000000 && defined(_POSIX_EXIT) # if __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __save # pragma __extern_prefix "__posix_" # else # if defined(__clang__) # define exit __posix_exit # define system __posix_system # else # define exit(__p1) __posix_exit(__p1) # define system(__p1) __posix_system(__p1) # endif # endif #endif void exit (int __status); int system (const char *__string); #if __CRTL_VER >= 70000000 && defined(_POSIX_EXIT) # if __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __restore # endif #endif #ifdef __NAMESPACE_STD } /* namespace std */ #endif /* ** X/Open functions */ #if defined _XOPEN_SOURCE || !defined _ANSI_C_SOURCE # if __CRTL_VER >= 70000000 double drand48 (void); double erand48 (unsigned short int __xsubi[3]); long int jrand48 (unsigned short int __xsubi[3]); void lcong48 (unsigned short int __param[7]); long int lrand48 (void); long int mrand48 (void); long int nrand48 (unsigned short int __xsubi[3]); void srand48 (long int __seedval); # endif # if __CRTL_VER >= 80300000 void setkey(const char *__key); # endif #endif /* ** X/Open Extended functions */ #if defined _XOPEN_SOURCE_EXTENDED || !defined _ANSI_C_SOURCE # if __CRTL_VER >= 70000000 long int random (void); void srandom (unsigned int); # endif # if __CRTL_VER >= 70320000 int rand_r (unsigned int *__seed_ptr); __char_ptr32 l64a (long __val); long int a64l (__const_char_ptr64 __s); # if !defined _POSIX_C_SOURCE int l64a_r (long int __val, __char_ptr64 __s, int __len); # endif /* not defined while building for posix */ # endif #endif /* ** X/Open functions that were previously in X/Open Extended */ #if defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || !defined _ANSI_C_SOURCE # if __CRTL_VER >= 70000000 int mkstemp(char *__template); # endif #endif /* ** GNU extensions */ #if defined _GNU_SOURCE || !defined _ANSI_C_SOURCE # if __CRTL_VER >= 80500000 int mkostemp(char *__template, int __flags); # endif #endif /* ** DEC C extensions */ #ifndef _ANSI_C_SOURCE int nice (int __increment); /* */ __mode_t umask (__mode_t __old_mask); /* */ void cfree (void *__ptr); typedef struct { __int64 quot, rem; } __qdiv_t, __lldiv_t; typedef __lldiv_t lldiv_t; __int64 atoll (const char *__nptr); __int64 atoq (const char *__nptr); __int64 llabs (__int64 __j); __lldiv_t lldiv (__int64 __numer, __int64 __denom); __int64 qabs (__int64 __j); __lldiv_t qdiv (__int64 __numer, __int64 __denom); # if __CRTL_VER >= 70000000 int setenv (const char *__name, const char *__value, int __overwrite); int unsetenv (const char *__name); # endif # if __CRTL_VER >= 70000000 && defined(_POSIX_EXIT) # if __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __save # pragma __extern_prefix "__posix_" # else # define _exit(__p1) __posix__exit(__p1) # endif # endif void _exit (int __status); /* */ # if __CRTL_VER >= 70000000 && defined(_POSIX_EXIT) # if __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __restore # endif # endif #endif /* ifndef _ANSI_C_SOURCE */ /**************************************************************************** ** ** Functions which accept either 32 bit or 64 bit pointers, but always ** return 32 bit pointers. ** ****************************************************************************/ #ifdef __NAMESPACE_STD namespace std { #endif /* ** ANSI functions */ __char_ptr32 getenv (const char *__name); #ifdef __NAMESPACE_STD } /* namespace std */ #endif /* ** X/Open functions */ #if defined _XOPEN_SOURCE || !defined _ANSI_C_SOURCE # if __CRTL_VER >= 70000000 __unsigned_short_ptr32 seed48(unsigned short __seed16v[3]); # endif #endif /* ** X/Open Extended functions */ #if defined _XOPEN_SOURCE_EXTENDED || !defined _ANSI_C_SOURCE __char_ptr32 ecvt (double __value, int __ndigit, int *__decpt, int *__sign); __char_ptr32 fcvt (double __value, int __ndigit, int *__decpt, int *__sign); /* BSD stuff (GNU uses alloca.h) */ # ifndef alloca # define alloca(size) __ALLOCA((size)) # endif #endif /* ** DEC C extensions. */ #ifndef _ANSI_C_SOURCE __void_ptr32 brk (unsigned long int __addr); /* */ __void_ptr32 sbrk (long int __incr); /* */ #endif /**************************************************************************** ** ** Functions which have separate implementations for 32 bit and 64 bit ** pointers. The implementation defaults to that corresponding to the ** default pointer size used in the /POINTER_SIZE qualifier. The 32 bit ** interface is used with no /POINTER_SIZE qualifier is present. Later ** in this header file we will define additional function prototypes ** which allow you to call the non-default form of the implementation. ** ****************************************************************************/ #if __INITIAL_POINTER_SIZE == 32 # pragma __required_pointer_size 32 #endif #ifdef __NAMESPACE_STD namespace std { #endif /* ** ANSI functions */ void * calloc (__size_t __nmemb, __size_t __size); void * malloc (__size_t __size); void * realloc (__void_ptr64 __ptr, __size_t __size); void * bsearch (const void *, const void *, __size_t, __size_t, int (*__compar)(const void *, const void *)); void qsort (void *, __size_t, __size_t, int (*__compar)(const void *, const void *)); double strtod (const char *__nptr, char **__endptr); long int strtol (const char *__nptr, char **__endptr, int __base); #if defined (__clang__) unsigned int strtoul (const char *__nptr, char **__endptr, int __base); #else unsigned long int strtoul (const char *__nptr, char **__endptr, int __base); #endif #if (defined(__clang__) || defined(__DECC)) && (__CRTL_VER >= 80500000) && (__STDC_VERSION__ >= 199901L) /* C99 */ float strtof (const char *__nptr, char **__endptr); long double strtold (const char *__nptr, char **__endptr); # if __CRTL_VER >= 90210000 void * aligned_alloc(__size_t __alignment, __size_t __size); # endif #endif /* C99 */ #ifdef __NAMESPACE_STD } /* namespace std */ #endif /* ** X/Open Extended functions */ #if defined _XOPEN_SOURCE_EXTENDED || !defined _ANSI_C_SOURCE char * gcvt (double __value, int __ndigit, char *__buffer); char * mktemp (char *__template); # if __CRTL_VER >= 90210000 int posix_memalign(void **memptr, __size_t alignment, __size_t size); # endif #endif /* ** DEC C extensions */ #if !defined(_ANSI_C_SOURCE ) || (defined(__DECC) && (__CRTL_VER >= 80500000) && (__STDC_VERSION__ >= 199901L)) __int64 strtoll(const char *__nptr, char **__endptr, int __base); __int64 strtoq (const char *__nptr, char **__endptr, int __base); unsigned __int64 strtoull(const char *__nptr, char **__endptr, int __base); unsigned __int64 strtouq (const char *__nptr, char **__endptr, int __base); #endif /* ** GNU extended function */ #ifdef _GNU_SOURCE # if __CRTL_VER >= 80500000 void qsort_r(void *, __size_t, __size_t, int (*__compar)(const void *, const void *, void *), void *); # endif #endif /* ** realpath() ** Not in ANSI standard. ** Optional parameters not in X/Open or Posix specifications. */ #if __CRTL_VER >=80300000 # if defined _POSIX_C_SOURCE || !defined _ANSI_C_SOURCE # if defined _POSIX_C_SOURCE char * realpath (const char * __XOPEN_RESTRICT __file_name, char * __XOPEN_RESTRICT __resolved_name); # else char * realpath (const char * __XOPEN_RESTRICT __file_name, char * __XOPEN_RESTRICT __resolved_name, ...); # endif # if __INITIAL_POINTER_SIZE || defined(__clang__) # pragma __required_pointer_size 32 char * _realpath32 (const char * __XOPEN_RESTRICT __file_name, char * __XOPEN_RESTRICT __resolved_name, ...); # pragma __required_pointer_size 64 char * _realpath64 (const char * __XOPEN_RESTRICT __file_name, char * __XOPEN_RESTRICT __resolved_name, ...); # endif /* __INITIAL_POINTER_SIZE */ # endif /* defined _POSIX_C_SOURCE || !defined _ANSI_C_SOURCE */ #endif /* __CRTL_VER >=80300000 */ /**************************************************************************** ** ** In addition to the function prototypes above, two additional function ** prototypes are defined. These prototypes are prefixed with "_" and ** have a suffix of either "32" or "64" depending on whether you want to ** use the 32 bit pointer form or the 64 bit pointer form. These ** functions can be used if you have used the /POINTER_SIZE qualifier, ** and you need to explitly call either the 32 or 64 bit pointer form of ** the function. ** ****************************************************************************/ #if (__INITIAL_POINTER_SIZE || defined(__clang__)) && !defined _ANSI_C_SOURCE /************************************************************************ ** ** 32 Bit Interfaces ** ************************************************************************/ # pragma __required_pointer_size 32 /* ** ANSI functions */ void * _calloc32 (__size_t, __size_t); void * _malloc32 (__size_t); void * _realloc32 (void *, __size_t); void * _bsearch32 (const void *, const void *, __size_t, __size_t, int (*__compar)(const void *, const void *)); void _qsort32 (void *, __size_t, __size_t, int (*__compar)(const void *, const void *)); double _strtod32 (const char *, char **); long int _strtol32 (const char *, char **, int); #if defined(__clang__) unsigned int _strtoul32 (const char *, char **, int); #else unsigned long int _strtoul32 (const char *, char **, int); #endif # if __CRTL_VER >= 80500000 float _strtof32(const char *, char **); long double _strtold32(const char *, char **); # endif # if __CRTL_VER >= 90210000 void * _aligned_alloc32(__size_t, __size_t); int _posix_memalign32(void **, __size_t, __size_t); # endif /* ** X/Open Extended functions */ char * _gcvt32 (double __value, int __ndigit, char *__buffer); char * _mktemp32 (char *); /* ** DEC C extensions */ __int64 _strtoll32 (const char *, char **, int); __int64 _strtoq32 (const char *, char **, int); unsigned __int64 _strtoull32 (const char *, char **, int); unsigned __int64 _strtouq32 (const char *, char **, int); /* ** GNU extended function */ #ifdef _GNU_SOURCE # if __CRTL_VER >= 80500000 void _qsort_r32(void *, __size_t, __size_t, int (*__compar)(const void *, const void *, void *), void *); # endif #endif /************************************************************************ ** ** 64 Bit Interfaces ** ************************************************************************/ # pragma __required_pointer_size 64 /* ** ANSI functions */ void * _calloc64 (__size_t, __size_t); void * _malloc64 (__size_t); void * _realloc64 (void *, __size_t); void * _bsearch64 (const void *, const void *, __size_t, __size_t, int (*__compar)(const void *, const void *)); void _qsort64 (void *, __size_t, __size_t, int (*__compar)(const void *, const void *)); double _strtod64 (const char *, char **); long int _strtol64 (const char *, char **, int); #if defined(__clang__) unsigned int _strtoul64 (const char *, char **, int); #else unsigned long int _strtoul64 (const char *, char **, int); #endif # if __CRTL_VER >= 80500000 float _strtof64(const char *, char **); long double _strtold64(const char *, char **); # endif # if __CRTL_VER >= 90210000 void * _aligned_alloc64(__size_t, __size_t); int _posix_memalign64(void **, __size_t, __size_t); # endif /* ** X/Open Extended functions */ char * _gcvt64 (double __value, int __ndigit, char *__buffer); char * _mktemp64 (char *); /* ** DEC C extensions */ __int64 _strtoll64 (const char *, char **, int); __int64 _strtoq64 (const char *, char **, int); unsigned __int64 _strtoull64 (const char *, char **, int); unsigned __int64 _strtouq64 (const char *, char **, int); /* ** GNU extended function */ #ifdef _GNU_SOURCE # if __CRTL_VER >= 80500000 void _qsort_r64(void *, __size_t, __size_t, int (*__compar)(const void *, const void *, void *), void *); # endif #endif #endif /* ** DEC C Performance ** ** Certain DEC C functions are available as compiler builtins. Using ** the builtins offer performance improvements and are enabled here ** for all programs including this header file. */ #if defined(__DECC) int __ABS (int __j); long int __LABS (long int __j); # define abs(__x) __ABS(__x) # define labs(__x) __LABS(__x) #endif /* ** Restore the user's pointer context */ #if __INITIAL_POINTER_SIZE || defined(__clang__) # pragma __required_pointer_size __restore #endif #ifdef __cplusplus } #endif #pragma __member_alignment __restore #pragma __standard #endif /* __STDLIB_PROCESSED */ #if defined(__NAMESPACE_STD) && !defined(__NAMESPACE_STD_ONLY) # ifndef __USING_STDLIB_NAMES # define __USING_STDLIB_NAMES using std::abort; using std::abs; using std::atexit; using std::atof; using std::atoi; using std::atol; using std::bsearch; using std::calloc; using std::div; using std::div_t; using std::exit; using std::free; using std::getenv; using std::labs; using std::ldiv; using std::ldiv_t; using std::malloc; using std::mblen; using std::mbstowcs; using std::mbtowc; using std::qsort; using std::rand; using std::realloc; using std::size_t; using std::srand; using std::strtod; using std::strtol; using std::strtoul; #if defined(__clang__) using std::strtof; using std::strtold; using std::aligned_alloc; # endif using std::system; using std::wcstombs; using std::wctomb; # endif #endif #endif /* __STDLIB_LOADED */