CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
Loading...
Searching...
No Matches
cdi_os_api.h
Go to the documentation of this file.
1// -------------------------------------------------------------------------------------------
2// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
3// This file is part of the AWS CDI-SDK, licensed under the BSD 2-Clause "Simplified" License.
4// License details at: https://github.com/aws/aws-cdi-sdk/blob/mainline/LICENSE
5// -------------------------------------------------------------------------------------------
6
16// Page for CDI OS API
36#ifndef CDI_OS_API_H__
37#define CDI_OS_API_H__
38
39//*********************************************************************************************************************
40//***************************************** START OF DEFINITIONS AND TYPES ********************************************
41//*********************************************************************************************************************
42
43#if defined _WIN32
44 // Windows specific #defs
45 #ifndef _WIN32_WINNT
46 #define _WIN32_WINNT 0x0502
47 #endif // _WIN32_WINNT 0x0502
48
49 #ifndef WIN32_LEAN_AND_MEAN
50 #define WIN32_LEAN_AND_MEAN
51 #endif // WIN32_LEAN_AND_MEAN
52
53 #include <windows.h>
54 #include <winsock2.h>
55#elif defined (_LINUX)
56 #include <netinet/in.h>
57 #include <pthread.h>
58 #include <semaphore.h>
59 #include <signal.h>
60 #include <string.h>
61 #include <strings.h>
62 #include <unistd.h>
63#else
64#error Either _WIN32 or _LINUX must be defined.
65#endif
66
67#include <stdbool.h>
68#include <stdint.h>
69#include <stdio.h>
70#include <time.h>
71
72#include "cdi_utility_api.h"
73
74struct iovec;
75
76#if defined _WIN32
77 #define CDI_STDIN GetStdHandle(STD_INPUT_HANDLE)
78 #define CDI_STDOUT GetStdHandle(STD_OUTPUT_HANDLE)
79 #define CDI_STDERR GetStdHandle(STD_ERROR_HANDLE)
80
81 #define CDI_STDIN_FILENO _fileno(stdin)
82 #define CDI_STDOUT_FILENO _fileno(stdout)
83 #define CDI_STDERR_FILENO _fileno(stderr)
84
85 // Define portable thread Function.
86 #define CdiThreadFuncName LPTHREAD_START_ROUTINE
87 #define CDI_THREAD DWORD WINAPI
88 #define CDI_THREAD_PARAM LPVOID
89
90 typedef DWORD CdiThreadData;
91
92 // Define portable semaphore. Don't use void* here, which prevents the compiler from type checking.
93 typedef struct CdiSemID_* CdiSemID;
94
95 // Define portable signal type.
96 typedef HANDLE CdiSignalType;
97
98 // Define portable critical section.
99 typedef CRITICAL_SECTION* CdiCsID;
100
101 // Define portable File ID type.
102 typedef HANDLE CdiFileID;
103
104 #define CDI_INFINITE INFINITE // Infinity used as wait arguments, i.e "wait for infinity".
105
106 // NOTE: These macros operate on 16-bit values.
107 #define CdiOsAtomicInc16(x) InterlockedIncrement16(x)
108 #define CdiOsAtomicDec16(x) InterlockedDecrement16(x)
109 #define CdiOsAtomicRead16(x) InterlockedAdd16((x), 0)
110 #define CdiOsAtomicAdd16(x, b) InterlockedAdd16((x), (b))
111
112 // NOTE: These macros operate on 32-bit values.
113 #define CdiOsAtomicInc32(x) InterlockedIncrement(x)
114 #define CdiOsAtomicDec32(x) InterlockedDecrement(x)
115 #define CdiOsAtomicRead32(x) InterlockedAdd((x), 0)
116 #define CdiOsAtomicAdd32(x, b) InterlockedAdd((x), (b))
117
118 // NOTE: These macros operate on 64-bit values.
119 #define CdiOsAtomicInc64(x) InterlockedIncrement64(x)
120 #define CdiOsAtomicDec64(x) InterlockedDecrement64(x)
121 #define CdiOsAtomicRead64(x) InterlockedAdd64((x), 0)
122 #define CdiOsAtomicAdd64(x, b) InterlockedAdd64((x), (b))
123
124 // MSVC uses volatile to add necessary compiler/memory fence barriers as needed depending on CPU architecture. For
125 // x86 platforms, recommend to use "/volatile:iso" for "C/C++"", "Command Line", "Additional Options" in MSVC
126 // project configuration properties.
127 #define CdiOsAtomicLoad16(x) *(volatile uint16_t*)(x)
128 #define CdiOsAtomicStore16(x, v) *volatile (uint16_t*)(x) = (v)
129 #define CdiOsAtomicLoad32(x) *(volatile uint32_t*)(x)
130 #define CdiOsAtomicStore32(x, v) *(volatile uint32_t*)(x) = (v)
131 #define CdiOsAtomicLoad64(x) *(volatile uint64_t*)(x)
132 #define CdiOsAtomicStore64(x, v) *(volatile uint64_t*)(x) = (v)
133 #define CdiOsAtomicLoadPointer(x) *(volatile void**)(x)
134 #define CdiOsAtomicStorePointer(x, v) *(volatile void**)(x) = (v)
135
136 #define CDI_INVALID_HANDLE_VALUE INVALID_HANDLE_VALUE
137
138 typedef struct siginfo_t siginfo_t;
139
140 struct siginfo_t {
141 long si_pid;
142 long si_uid;
143 };
144
145 struct sockaddr_in;
146
147 typedef HANDLE CdiStaticMutexType;
148 #define CDI_STATIC_MUTEX_INITIALIZER NULL
149 #define CdiOsStaticMutexLock(x) StaticMutexLockWin32(&(x))
150 // If two threads enter the if-body, then only one succeeds in initializing the lock. When the application exists,
151 // the mutex handle held in x will be freed by the windows OS.
152 static inline void StaticMutexLockWin32(volatile HANDLE* x) {
153 if (*x == NULL) {
154 HANDLE tmp = CreateMutex(NULL, FALSE, NULL);
155 if (InterlockedCompareExchangePointer((PVOID*)x, (PVOID)tmp, NULL) != NULL) {
156 CloseHandle(tmp);
157 }
158 }
159 WaitForSingleObject(*x, INFINITE);
160 }
161 #define CdiOsStaticMutexUnlock(x) (ReleaseMutex(x) == 0)
162
163 // Huge pages not implemented in windows, so just use 1 byte for size.
164 #define CDI_HUGE_PAGES_BYTE_SIZE (1)
165
166 // Windows generates a meaningful error that contains the specified message.
167 #define CDI_STATIC_ASSERT(condition, message) static_assert(condition, message)
168
169#elif defined _LINUX
170 #define CDI_STDIN stdin
171 #define CDI_STDOUT stdout
172 #define CDI_STDERR stderr
173
174 #define CDI_STDIN_FILENO STDIN_FILENO
175 #define CDI_STDOUT_FILENO STDOUT_FILENO
176 #define CDI_STDERR_FILENO STDERR_FILENO
177
178 #define CDI_THREAD_PARAM void*
179 #define CDI_THREAD int
181
183 typedef pthread_key_t CdiThreadData;
184
186 typedef sem_t* CdiSemID;
187
189 typedef struct CdiSignalType_t* CdiSignalType;
190
192 typedef pthread_mutex_t* CdiCsID;
193
195 typedef FILE* CdiFileID;
196
197 #define CDI_INFINITE 0xFFFFFFFF
198
200 #define CdiOsAtomicInc16(x) __sync_add_and_fetch((x), 1)
202 #define CdiOsAtomicDec16(x) __sync_sub_and_fetch((x), 1)
204 #define CdiOsAtomicRead16(x) __sync_add_and_fetch((x), 0)
206 #define CdiOsAtomicAdd16(x, b) __sync_add_and_fetch((x), (b))
207
209 #define CdiOsAtomicInc32(x) __sync_add_and_fetch((x), 1)
211 #define CdiOsAtomicDec32(x) __sync_sub_and_fetch((x), 1)
213 #define CdiOsAtomicRead32(x) __sync_add_and_fetch((x), 0)
215 #define CdiOsAtomicAdd32(x, b) __sync_add_and_fetch((x), (b))
216
218 #define CdiOsAtomicInc64(x) __sync_add_and_fetch((x), 1)
220 #define CdiOsAtomicDec64(x) __sync_sub_and_fetch((x), 1)
222 #define CdiOsAtomicRead64(x) __sync_add_and_fetch((x), 0)
224 #define CdiOsAtomicAdd64(x, b) __sync_add_and_fetch((x), (b))
225
227
235 #define CdiOsAtomicLoad16(x) __atomic_load_n((x), __ATOMIC_CONSUME)
237 #define CdiOsAtomicLoad32(x) __atomic_load_n((x), __ATOMIC_CONSUME)
239 #define CdiOsAtomicLoad64(x) __atomic_load_n((x), __ATOMIC_CONSUME)
241 #define CdiOsAtomicLoadPointer(x) __atomic_load_n((x), __ATOMIC_CONSUME)
242
244
251 #define CdiOsAtomicStore16(x, v) __atomic_store_n((x), (v), __ATOMIC_RELEASE)
253 #define CdiOsAtomicStore32(x, v) __atomic_store_n((x), (v), __ATOMIC_RELEASE)
255 #define CdiOsAtomicStore64(x, v) __atomic_store_n((x), (v), __ATOMIC_RELEASE)
257 #define CdiOsAtomicStorePointer(x, v) __atomic_store_n((x), (v), __ATOMIC_RELEASE)
258
260 #define CDI_INVALID_HANDLE_VALUE -1
261
263
272 typedef pthread_mutex_t CdiStaticMutexType;
274 #define CDI_STATIC_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
276 #define CdiOsStaticMutexLock(x) pthread_mutex_lock(&(x))
278 #define CdiOsStaticMutexUnlock(x) pthread_mutex_unlock(&(x))
279
283 #define CDI_HUGE_PAGES_BYTE_SIZE (2 * 1024 * 1024)
284
289#define CDI_STATIC_ASSERT(condition, message) _Static_assert(condition, message) // NOTE: ACTUAL ERROR IS BELOW.
290#endif // _LINUX
291
292#define CDI_MAX_THREAD_NAME (50)
293#define CDI_OS_SIG_TIMEOUT (0xFFFFFFFF)
294
296#define CDI_MAX_WAIT_MULTIPLE (64)
297
299#define CDI_OS_SOCKET_MAX_IOVCNT (10)
300
302typedef void (*CdiSignalHandlerFunction)(int sig, siginfo_t* siginfo, void* context);
303
309
312typedef struct CdiThreadID_t* CdiThreadID;
313
315typedef struct CdiSocket_t* CdiSocket;
316
318#define CDI_MAX_SIGNAL_HANDLERS (10)
319
321#define CDI_MAX_FORMATTED_TIMEZONE_STRING_LENGTH (128)
322
323//*********************************************************************************************************************
324//******************************************* START OF PUBLIC FUNCTIONS ***********************************************
325//*********************************************************************************************************************
326
332
333// -- Threads --
334
344
357CDI_INTERFACE bool CdiOsThreadCreatePinned(CdiThreadFuncName thread_func, CdiThreadID* thread_id_out_ptr,
358 const char* thread_name_str, void* thread_func_arg_ptr,
359 CdiSignalType start_signal, int cpu_affinity);
360
373static inline bool CdiOsThreadCreate(CdiThreadFuncName thread_func, CdiThreadID* thread_id_out_ptr,
374 const char* thread_name_str, void* thread_func_arg_ptr, CdiSignalType start_signal)
375{
376 return CdiOsThreadCreatePinned(thread_func, thread_id_out_ptr, thread_name_str, thread_func_arg_ptr, start_signal,
377 -1);
378}
379
389
399
409CDI_INTERFACE bool CdiOsThreadSetData(CdiThreadData handle, void* content_ptr);
410
419CDI_INTERFACE bool CdiOsThreadGetData(CdiThreadData handle, void** content_out_ptr);
420
428CDI_INTERFACE const char* CdiOsThreadGetName(CdiThreadID thread_id);
429
439CDI_INTERFACE bool CdiOsThreadJoin(CdiThreadID thread_id, uint32_t timeout_in_ms, bool* timed_out_ptr);
440
441// -- Semaphores --
442
451CDI_INTERFACE bool CdiOsSemaphoreCreate(CdiSemID* ret_sem_handle_ptr, int sem_count);
452
461
470
480CDI_INTERFACE bool CdiOsSemaphoreReserve(CdiSemID sem_handle, int timeout_in_ms);
481
490
491// -- Critical Sections --
492
500CDI_INTERFACE bool CdiOsCritSectionCreate(CdiCsID* cs_handle_ptr);
501
508
515
524
525// -- String Functions ---
526
527#if defined _WIN32
529#define CdiOsStrTokR strtok_s
530#else
532#define CdiOsStrTokR strtok_r
533#endif
534
535// -- Signals --
536
544CDI_INTERFACE bool CdiOsSignalCreate(CdiSignalType* signal_handle_ptr);
545
554
563
571CDI_INTERFACE bool CdiOsSignalSet(CdiSignalType signal_handle);
572
580CDI_INTERFACE bool CdiOsSignalGet(CdiSignalType signal_handle);
581
590
600CDI_INTERFACE bool CdiOsSignalWait(CdiSignalType signal_handle, uint32_t timeout_in_ms, bool* timed_out_ptr);
601
615CDI_INTERFACE bool CdiOsSignalsWait(CdiSignalType* signal_array, uint8_t num_signals, bool wait_all,
616 uint32_t timeout_in_ms, uint32_t* ret_signal_index_ptr);
617
618// -- Memory --
619
627CDI_INTERFACE void* CdiOsMemAlloc(int64_t mem_size);
628
636CDI_INTERFACE void* CdiOsMemAllocZero(int64_t mem_size);
637
643CDI_INTERFACE void CdiOsMemFree(void* mem_ptr);
644
653CDI_INTERFACE void* CdiOsMemAllocHugePage(int64_t mem_size);
654
661CDI_INTERFACE void CdiOsMemFreeHugePage(void* mem_ptr, int64_t mem_size);
662
663// -- File --
664
673CDI_INTERFACE bool CdiOsOpenForWrite(const char* file_name_str, CdiFileID* file_handle_ptr);
674
683CDI_INTERFACE bool CdiOsOpenForRead(const char* file_name_str, CdiFileID* file_handle_ptr);
684
692CDI_INTERFACE bool CdiOsClose(CdiFileID file_handle);
693
704CDI_INTERFACE bool CdiOsRead(CdiFileID file_handle, void* buffer_ptr, uint32_t byte_count, uint32_t* bytes_read_ptr);
705
715CDI_INTERFACE bool CdiOsWrite(CdiFileID file_handle, const void* data_ptr, uint32_t byte_count);
716
724CDI_INTERFACE bool CdiOsFlush(CdiFileID file_handle);
725
734CDI_INTERFACE bool CdiOsFTell(CdiFileID file_handle, uint64_t* current_position_ptr);
735
745CDI_INTERFACE bool CdiOsFSeek(CdiFileID file_handle, int64_t offset, int position);
746
760CDI_INTERFACE bool CdiOsSplitPath(const char* filepath_str, char* filename_str, int filename_buf_size,
761 char* directory_str, int directory_buf_size);
762
770CDI_INTERFACE bool CdiOsIsPathWriteable(const char* directory_str);
771
772// -- Utilities - Strings, Sleep --
773
783CDI_INTERFACE int CdiOsStrCpy(char* dest_str, uint32_t max_str_len, const char* src_str);
784
790CDI_INTERFACE void CdiOsSleep(uint32_t milliseconds);
791
797CDI_INTERFACE void CdiOsSleepMicroseconds(uint32_t microseconds);
798
799#if defined _WIN32
800#define CdiOsStrCaseCmp _stricmp
801#define CdiOsStrNCaseCmp _strnicmp
802#else
804#define CdiOsStrNCaseCmp strncasecmp
806#define CdiOsStrCaseCmp strcasecmp
807#endif
808
819#define CdiOsStrCmp strcmp
820
831#define CdiOsStrNCmp strncmp
832
839
845#define CdiOsGetMilliseconds() (CdiOsGetMicroseconds()/1000)
846
859CDI_INTERFACE void CdiOsGetUtcTime(struct timespec* ret_time_ptr);
860
866CDI_INTERFACE void CdiOsGetLocalTime(struct tm* local_time_ret_ptr);
867
876CDI_INTERFACE int CdiOsGetLocalTimeString(char* time_str, int max_string_len);
877
902CDI_INTERFACE bool CdiOsSocketOpen(const char* host_address_str, int port_number, const char* bind_address_str,
903 CdiSocket* new_socket_ptr);
904
915CDI_INTERFACE bool CdiOsSocketGetPort(CdiSocket socket_handle, int* port_number_ptr);
916
925CDI_INTERFACE bool CdiOsSocketGetSockAddrIn(CdiSocket socket_handle, struct sockaddr_in* sockaddr_in_ptr);
926
935CDI_INTERFACE bool CdiOsSocketClose(CdiSocket socket_handle);
936
953CDI_INTERFACE bool CdiOsSocketRead(CdiSocket socket_handle, void* buffer_ptr, int* byte_count_ptr);
954
973CDI_INTERFACE bool CdiOsSocketReadFrom(CdiSocket socket_handle, void* buffer_ptr, int* byte_count_ptr,
974 struct sockaddr_in* source_address_ptr);
975
990CDI_INTERFACE bool CdiOsSocketWrite(CdiSocket socket_handle, struct iovec* iov, int iovcnt, int* byte_count_ptr);
991
1008CDI_INTERFACE bool CdiOsSocketWriteTo(CdiSocket socket_handle, struct iovec* iov, int iovcnt,
1009 const struct sockaddr_in* destination_address_ptr, int* byte_count_ptr);
1010
1019CDI_INTERFACE bool CdiOsEnvironmentVariableSet(const char* name_str, const char* value_str);
1020
1024CDI_INTERFACE void CdiOsShutdown(void);
1025
1026#endif // CDI_OS_API_H__
CDI_INTERFACE bool CdiOsThreadSetData(CdiThreadData handle, void *content_ptr)
Definition os_linux.c:397
pthread_key_t CdiThreadData
Define portable thread data type.
Definition cdi_os_api.h:183
CDI_INTERFACE bool CdiOsEnvironmentVariableSet(const char *name_str, const char *value_str)
Definition os_linux.c:1456
CDI_INTERFACE void CdiOsCritSectionReserve(CdiCsID cs_handle)
Definition os_linux.c:579
CDI_INTERFACE bool CdiOsSignalWait(CdiSignalType signal_handle, uint32_t timeout_in_ms, bool *timed_out_ptr)
Definition os_linux.c:700
CDI_INTERFACE bool CdiOsSemaphoreRelease(CdiSemID sem_handle)
Definition os_linux.c:512
CDI_INTERFACE void CdiOsMemFree(void *mem_ptr)
Definition os_linux.c:937
CDI_INTERFACE bool CdiOsWrite(CdiFileID file_handle, const void *data_ptr, uint32_t byte_count)
Definition os_linux.c:1043
CDI_INTERFACE bool CdiOsSignalCreate(CdiSignalType *signal_handle_ptr)
Definition os_linux.c:600
struct CdiSignalType_t * CdiSignalType
Define portable signal type. Don't use void* here, which prevents the compiler from type checking.
Definition cdi_os_api.h:189
CDI_INTERFACE uint64_t CdiOsGetMicroseconds(void)
Timers get a microsecond timestamp from CLOCK_MONOTONIC on linux or from the performance counter on W...
Definition os_linux.c:1203
CDI_INTERFACE bool CdiOsOpenForWrite(const char *file_name_str, CdiFileID *file_handle_ptr)
Definition os_linux.c:969
CDI_INTERFACE bool CdiOsSignalHandlerSet(int signal_num, CdiSignalHandlerFunction func_ptr)
Definition os_linux.c:285
CDI_INTERFACE bool CdiOsCritSectionDelete(CdiCsID cs_handle)
Definition os_linux.c:589
CDI_INTERFACE bool CdiOsSignalClear(CdiSignalType signal_handle)
Definition os_linux.c:641
CDI_INTERFACE bool CdiOsSocketClose(CdiSocket socket_handle)
Definition os_linux.c:1369
pthread_mutex_t * CdiCsID
Define portable critical section.
Definition cdi_os_api.h:192
CDI_INTERFACE bool CdiOsSignalsWait(CdiSignalType *signal_array, uint8_t num_signals, bool wait_all, uint32_t timeout_in_ms, uint32_t *ret_signal_index_ptr)
Definition os_linux.c:756
CDI_INTERFACE int CdiOsGetLocalTimeString(char *time_str, int max_string_len)
Definition os_linux.c:1227
static bool CdiOsThreadCreate(CdiThreadFuncName thread_func, CdiThreadID *thread_id_out_ptr, const char *thread_name_str, void *thread_func_arg_ptr, CdiSignalType start_signal)
Definition cdi_os_api.h:373
CDI_INTERFACE bool CdiOsThreadFreeData(CdiThreadData handle)
Definition os_linux.c:392
CDI_INTERFACE bool CdiOsSocketOpen(const char *host_address_str, int port_number, const char *bind_address_str, CdiSocket *new_socket_ptr)
Definition os_linux.c:1270
CDI_INTERFACE void CdiOsGetLocalTime(struct tm *local_time_ret_ptr)
Definition os_linux.c:1219
CDI_INTERFACE bool CdiOsThreadJoin(CdiThreadID thread_id, uint32_t timeout_in_ms, bool *timed_out_ptr)
Definition os_linux.c:421
CDI_INTERFACE void CdiOsSleepMicroseconds(uint32_t microseconds)
Definition os_linux.c:1195
CDI_INTERFACE void CdiOsMemFreeHugePage(void *mem_ptr, int64_t mem_size)
Definition os_linux.c:961
FILE * CdiFileID
Define portable File ID type.
Definition cdi_os_api.h:195
CDI_INTERFACE bool CdiOsSemaphoreDelete(CdiSemID sem_handle)
Definition os_linux.c:491
CDI_INTERFACE bool CdiOsSocketWrite(CdiSocket socket_handle, struct iovec *iov, int iovcnt, int *byte_count_ptr)
Definition os_linux.c:1430
CDI_INTERFACE int CdiOsStrCpy(char *dest_str, uint32_t max_str_len, const char *src_str)
Definition os_linux.c:1167
void(* CdiSignalHandlerFunction)(int sig, siginfo_t *siginfo, void *context)
Type used for signal handler.
Definition cdi_os_api.h:302
CDI_INTERFACE void CdiOsUseLogger(void)
Definition os_linux.c:279
CDI_INTERFACE void * CdiOsMemAlloc(int64_t mem_size)
Definition os_linux.c:915
CDI_INTERFACE bool CdiOsFTell(CdiFileID file_handle, uint64_t *current_position_ptr)
Definition os_linux.c:1061
struct CdiSocket_t * CdiSocket
Define portable socket type.
Definition cdi_os_api.h:315
CDI_INTERFACE bool CdiOsThreadAllocData(CdiThreadData *handle_out_ptr)
Definition os_linux.c:387
CDI_INTERFACE bool CdiOsSocketReadFrom(CdiSocket socket_handle, void *buffer_ptr, int *byte_count_ptr, struct sockaddr_in *source_address_ptr)
Definition os_linux.c:1388
CDI_INTERFACE void CdiOsShutdown(void)
Definition os_linux.c:1466
CDI_INTERFACE bool CdiOsCritSectionCreate(CdiCsID *cs_handle_ptr)
Definition os_linux.c:557
CDI_INTERFACE bool CdiOsClose(CdiFileID file_handle)
Definition os_linux.c:995
#define CDI_THREAD_PARAM
Define portable thread function parameter type.
Definition cdi_os_api.h:178
CDI_INTERFACE bool CdiOsThreadCreatePinned(CdiThreadFuncName thread_func, CdiThreadID *thread_id_out_ptr, const char *thread_name_str, void *thread_func_arg_ptr, CdiSignalType start_signal, int cpu_affinity)
Definition os_linux.c:307
CDI_INTERFACE void CdiOsSleep(uint32_t milliseconds)
Definition os_linux.c:1181
CDI_INTERFACE bool CdiOsSignalDelete(CdiSignalType signal_handle)
Definition os_linux.c:624
CDI_INTERFACE void * CdiOsMemAllocZero(int64_t mem_size)
Definition os_linux.c:926
CDI_INTERFACE bool CdiOsIsPathWriteable(const char *directory_str)
Definition os_linux.c:1143
struct CdiThreadID_t * CdiThreadID
Define portable thread type. Separate name from type, otherwise the typedef that follows it will gene...
Definition cdi_os_api.h:312
CDI_INTERFACE bool CdiOsSignalReadState(CdiSignalType signal_handle)
Definition os_linux.c:695
CDI_INTERFACE bool CdiOsSignalGet(CdiSignalType signal_handle)
Definition os_linux.c:686
CDI_INTERFACE bool CdiOsSplitPath(const char *filepath_str, char *filename_str, int filename_buf_size, char *directory_str, int directory_buf_size)
Definition os_linux.c:1087
CDI_INTERFACE bool CdiOsSocketRead(CdiSocket socket_handle, void *buffer_ptr, int *byte_count_ptr)
Definition os_linux.c:1383
sem_t * CdiSemID
Define portable semaphore.
Definition cdi_os_api.h:186
CDI_INTERFACE void CdiOsCritSectionRelease(CdiCsID cs_handle)
Definition os_linux.c:584
CDI_INTERFACE bool CdiOsSemaphoreReserve(CdiSemID sem_handle, int timeout_in_ms)
Definition os_linux.c:526
CDI_INTERFACE bool CdiOsSocketWriteTo(CdiSocket socket_handle, struct iovec *iov, int iovcnt, const struct sockaddr_in *destination_address_ptr, int *byte_count_ptr)
Definition os_linux.c:1443
CDI_INTERFACE bool CdiOsRead(CdiFileID file_handle, void *buffer_ptr, uint32_t byte_count, uint32_t *bytes_read_ptr)
Definition os_linux.c:1008
pthread_mutex_t CdiStaticMutexType
Define portable static mutex type. An example implementation:
Definition cdi_os_api.h:272
CDI_INTERFACE bool CdiOsFSeek(CdiFileID file_handle, int64_t offset, int position)
Definition os_linux.c:1077
CDI_INTERFACE void CdiOsGetUtcTime(struct timespec *ret_time_ptr)
This is an OS call to get the current synced AWS network time in UTC format.
Definition os_linux.c:1214
CDI_INTERFACE bool CdiOsFlush(CdiFileID file_handle)
Definition os_linux.c:1056
CDI_INTERFACE bool CdiOsSignalSet(CdiSignalType signal_handle)
Definition os_linux.c:653
CDI_INTERFACE int CdiOsSemaphoreValueGet(CdiSemID sem_handle)
Definition os_linux.c:545
CDI_THREAD(* CdiThreadFuncName)(CDI_THREAD_PARAM)
Define portable thread function.
Definition cdi_os_api.h:180
CDI_INTERFACE bool CdiOsOpenForRead(const char *file_name_str, CdiFileID *file_handle_ptr)
Definition os_linux.c:981
CDI_INTERFACE void * CdiOsMemAllocHugePage(int64_t mem_size)
Definition os_linux.c:944
CDI_INTERFACE bool CdiOsThreadGetData(CdiThreadData handle, void **content_out_ptr)
Definition os_linux.c:406
CDI_INTERFACE bool CdiOsSocketGetPort(CdiSocket socket_handle, int *port_number_ptr)
Definition os_linux.c:1341
CDI_INTERFACE bool CdiOsSocketGetSockAddrIn(CdiSocket socket_handle, struct sockaddr_in *sockaddr_in_ptr)
Definition os_linux.c:1358
#define CDI_THREAD
Define portable thread function return type.
Definition cdi_os_api.h:179
CDI_INTERFACE bool CdiOsSemaphoreCreate(CdiSemID *ret_sem_handle_ptr, int sem_count)
Definition os_linux.c:463
CDI_INTERFACE const char * CdiOsThreadGetName(CdiThreadID thread_id)
Definition os_linux.c:415
The declarations in this header file correspond to the definitions in cdi_utility_api....
#define CDI_INTERFACE
Specify C linkage when compiling as C++ and define API interface export for Windows.
Definition cdi_utility_api.h:34
Structure used to hold signal handler data.
Definition cdi_os_api.h:305
CdiSignalHandlerFunction func_ptr
Pointer to signal handler.
Definition cdi_os_api.h:307
int signal_num
Signal number of the signal related to the handler.
Definition cdi_os_api.h:306