#ifndef UA_UTIL_H_ #define UA_UTIL_H_ #include "ua_config.h" /*********************/ /* Memory Management */ /*********************/ #include // malloc, free #include // memcpy #include // assert #ifdef _WIN32 # include #endif /* Visual Studio needs __restrict */ #ifdef _MSC_VER # define UA_RESTRICT __restrict #else # define UA_RESTRICT restrict #endif /* Visual Studio does not know fnct/unistd file access results */ #ifdef _MSC_VER #ifndef R_OK #define R_OK 4 /* Test for read permission. */ #endif #ifndef R_OK #define W_OK 2 /* Test for write permission. */ #endif #ifndef X_OK #define X_OK 1 /* Test for execute permission. */ #endif #ifndef F_OK #define F_OK 0 /* Test for existence. */ #endif #endif #define UA_NULL ((void *)0) // subtract from nodeids to get from the encoding to the content #define UA_ENCODINGOFFSET_XML 1 #define UA_ENCODINGOFFSET_BINARY 2 #define UA_assert(ignore) assert(ignore) /* Replace the macros with functions for custom allocators if necessary */ #ifndef UA_free # define UA_free(ptr) free(ptr) #endif #ifndef UA_malloc # define UA_malloc(size) malloc(size) #endif #ifndef UA_calloc # define UA_calloc(num, size) calloc(num, size) #endif #ifndef UA_realloc # define UA_realloc(ptr, size) realloc(ptr, size) #endif #define UA_memcpy(dst, src, size) memcpy(dst, src, size) #define UA_memset(ptr, value, size) memset(ptr, value, size) #ifndef NO_ALLOCA # ifdef __GNUC__ # define UA_alloca(size) __builtin_alloca (size) # elif defined(_WIN32) # define UA_alloca(SIZE) _alloca(SIZE) # else # include # define UA_alloca(SIZE) alloca(SIZE) # endif #endif /************************/ /* Thread Local Storage */ /************************/ #ifdef UA_MULTITHREADING # ifdef __GNUC__ # define UA_THREAD_LOCAL __thread # elif defined(_MSC_VER) # define UA_THREAD_LOCAL __declspec(thread) # else # error No thread local storage keyword defined for this compiler # endif #else # define UA_THREAD_LOCAL #endif /********************/ /* System Libraries */ /********************/ #include // va_start, va_end #include #include // printf #ifdef _WIN32 # include //needed for amalgation # include # undef SLIST_ENTRY #else # include #endif /*************************/ /* External Dependencies */ /*************************/ #include "queue.h" #ifdef UA_MULTITHREADING # define _LGPL_SOURCE # include # include # include # include #include #endif #endif /* UA_UTIL_H_ */