1 /* 2 * ThreadX C/C++ Library Support 3 * 4 * Copyright 1983-2019 Green Hills Software LLC. 5 * 6 * This program is the property of Green Hills Software LLC., 7 * its contents are proprietary information and no part of it 8 * is to be disclosed to anyone except employees of Green Hills 9 * Software LLC., or as agreed in writing signed by the President 10 * of Green Hills Software LLC. 11 */ 12 13 #ifndef _TX_GHS_H_ 14 #define _TX_GHS_H_ 15 16 #include <signal.h> 17 #include <stdio.h> 18 #include <time.h> 19 #include <setjmp.h> 20 21 #if defined(__ghs) && (__GHS_VERSION_NUMBER >= 500) 22 extern void *__ghs_GetThreadLocalStorageItem(int specifier); 23 24 /* Thread-local storage routines for Green Hills releases 5.x and beyond. 25 The following specifiers are used when calling 26 __ghs_GetThreadLocalStorageItem. 27 28 If __ghs_GetThreadLocalStorageItem is customized to 29 return a per-thread errno value, define the preprocessor symbol 30 USE_THREAD_LOCAL_ERRNO in ind_errn.c. 31 */ 32 33 enum __ghs_ThreadLocalStorage_specifier { 34 __ghs_TLS_asctime_buff, 35 __ghs_TLS_tmpnam_space, 36 __ghs_TLS_strtok_saved_pos, 37 __ghs_TLS_Errno, 38 __ghs_TLS_gmtime_temp, 39 __ghs_TLS___eh_globals, 40 __ghs_TLS_SignalHandlers 41 }; 42 #else 43 /* Thread-local storage routines for Green Hills releases 4.x and 3.x . */ 44 typedef void (*SignalHandler)(int); 45 46 typedef struct 47 { 48 int Errno; /* errno. */ 49 SignalHandler SignalHandlers[_SIGMAX]; /* signal() buffer. */ 50 char tmpnam_space[L_tmpnam]; /* tmpnam(NULL) buffer. */ 51 char asctime_buff[30]; /* . */ 52 char *strtok_saved_pos; /* strtok() position. */ 53 struct tm gmtime_temp; /* gmtime() and localtime() buffer. */ 54 void *__eh_globals; /* Pointer for C++ exception handling. */ 55 } ThreadLocalStorage; 56 57 ThreadLocalStorage *GetThreadLocalStorage(void); 58 #endif 59 60 61 void __ghsLock(void); 62 void __ghsUnlock(void); 63 64 int __ghs_SaveSignalContext(jmp_buf); 65 void __ghs_RestoreSignalContext(jmp_buf); 66 67 /* prototypes for FILE lock routines. */ 68 void __ghs_flock_file(void *); 69 void __ghs_funlock_file(void *); 70 int __ghs_ftrylock_file(void *); 71 void __ghs_flock_create(void **); 72 void __ghs_flock_destroy(void *); 73 74 /* prototype for GHS/ThreadX error shell checking. */ 75 void __ghs_rnerr(char *errMsg, int stackLevels, int stackTraceDisplay, void *hexVal); 76 77 #endif /* _TX_GHS_H_ */ 78