/* xmtx.h internal header */ #ifndef _XMTX #define _XMTX #include #include #if defined(__ghs) #pragma ghs start_cxx_lib_header #endif /* defined(__ghs) */ _C_LIB_DECL typedef void *_Rmtx; #if _IS_WRS /* compiler test */ #ifdef __RTP__ #define _IS_WRS_RTP 1 /* * In the RTP world, the __diab_alloc_mutex function returns a pointer * to a mutex. Since the data structure is accessed through an opaque * void * pointer, we cannot pass an address of a mutex variable - say mutx * and * expect the compiler to be able to do the following structure copy: * mutx = *(__diab_alloc_mutex()) * Therefore, changing the prototype of the function for that initializes * mutexes. */ void _Mtxinit(_Rmtx **); #else /* __RTP__ */ void _Mtxinit(_Rmtx *); #endif /* __RTP__ */ void _Mtxdst(_Rmtx *); void _Mtxlock(_Rmtx *); void _Mtxunlock(_Rmtx *); #else /* _IS_WRS */ void _Mtxinit(_Rmtx *); void _Mtxdst(_Rmtx *); void _Mtxlock(_Rmtx *); void _Mtxunlock(_Rmtx *); #endif /* _IS_WRS */ #if !_MULTI_THREAD #define _Mtxinit(mtx) #define _Mtxdst(mtx) #define _Mtxlock(mtx) #define _Mtxunlock(mtx) typedef char _Once_t; #define _Once(cntrl, func) if (*(cntrl) == 0) (func)(), *(cntrl) = 2 #define _ONCE_T_INIT 0 #else /* !_MULTI_THREAD */ #if defined(_WIN32_C_LIB) && _WIN32_C_LIB typedef long _Once_t; #ifdef _M_CEE_PURE void __clrcall _Once(_Once_t *, void (__cdecl *)(void)); #else /* _M_CEE_PURE */ void _Once(_Once_t *, void (__cdecl *)(void)); #endif /* _M_CEE_PURE */ #define _ONCE_T_INIT 0 #elif _HAS_POSIX_C_LIB || (defined(__ghs) && (defined(_MC_EXEC) || _POSIX_C_LIB)) #include #include #if 0x570 <= __SUNPRO_CC && !defined(_RESTRICT_KYWD) /* compiler test */ #define _RESTRICT_KYWD restrict #endif /* 0x570 <= __SUNPRO_CC etc. */ #include typedef pthread_once_t _Once_t; #define _Once(cntrl, func) pthread_once(cntrl, func) #define _ONCE_T_INIT PTHREAD_ONCE_INIT #elif _IS_WRS_RTP #undef _IS_WRS_RTP typedef unsigned long __diab_atomic_level; typedef _Rmtx __diab_mutex; extern __diab_atomic_level __diab_atomic_enter(void); extern void __diab_atomic_restore(__diab_atomic_level); extern __diab_mutex __diab_alloc_mutex(void); extern void __diab_free_mutex(__diab_mutex); extern void __diab_lock_mutex(__diab_mutex); extern void __diab_unlock_mutex(__diab_mutex); extern void taskDelay(int); typedef int _Once_t; void _Once(_Once_t *, void (*)(void)); #define _ONCE_T_INIT 0 #define _Mtxdst(x) __diab_free_mutex(x) #define _Mtxlock(x) __diab_lock_mutex(x) #define _Mtxunlock(x) __diab_unlock_mutex(x) #elif defined(__VXWORKS) && defined(__ghs) #include #include typedef char _Once_t; #define _Once(cntrl, func) if (*(cntrl) == 0) (func)(), *(cntrl) = 2 #define _ONCE_T_INIT 0 #elif defined(SOLARIS20) && defined(__ghs) #ifndef _REENTRANT #define _REENTRANT #endif #include typedef char _Once_t; #define _Once(cntrl, func) if (*(cntrl) == 0) (func)(), *(cntrl) = 2 #define _ONCE_T_INIT 0 #elif defined(__ghs) || defined(__SC3__) /* nothing to do - don't include "ind_thrd.h" here because C++ files include this file, and "ind_thrd.h" is not C++ compilable */ typedef char _Once_t; #define _Once(cntrl, func) if (*(cntrl) == 0) (func)(), *(cntrl) = 2 #define _ONCE_T_INIT 0 #else /* library type */ #error unknown library type #endif /* library type */ #endif /* !_MULTI_THREAD */ #if defined(__GHS_PRAGMAS) #pragma ghs startdata #endif #if defined(__ghs) && defined(__ghs_max_pack_value) #pragma pack (push, __ghs_max_pack_value) #endif #if defined(__ghs) && defined(__ghs_max_pack_value) #pragma pack(pop) #endif #if defined(__GHS_PRAGMAS) #pragma ghs enddata #endif _END_C_LIB_DECL #if defined(__ghs) #pragma ghs end_cxx_lib_header #endif /* defined(__ghs) */ #endif /* _XMTX */ /* * Copyright (c) by P.J. Plauger. All rights reserved. * Consult your license regarding permissions and restrictions. V8.03b/17:0063 */