Neonode zForce(TM) SDK

OsAbstractionLayer.h
Go to the documentation of this file.
1
11 #ifndef ZFORCE_OSABSTRACTIONLAYER_H
12 #define ZFORCE_OSABSTRACTIONLAYER_H 1
13
14 #ifndef ZFORCECOMMON_H
15 #error Please include "zForceCommon.h" before this file.
16 #endif // ZFORCECOMMON_H
17
18 typedef void zForceMutex;
19 typedef void zForceSemaphore;
20 typedef void zForceThread;
21
25 typedef struct zForceThreadWrapper zForceThreadWrapper;
29 struct zForceThreadWrapper
30 {
31 zForceThread * zForceThread;
32 void ( * EntryPoint) (void *);
33 void * Arguments;
34 };
35
39 typedef struct OsAbstractionLayer OsAbstractionLayer;
43 struct OsAbstractionLayer
44 {
58 void * ( * Malloc) (size_t size);
59
69 void ( * Free) (void * memoryPointer);
70
85 void * ( * Realloc) (void * memoryPointer, size_t size);
86
101 void * ( * MallocWithPattern) (size_t size, uint8_t pattern);
102
116 bool ( * InitializeMutex) (zForceMutex ** zForceMutex);
117
131 bool ( * LockMutex) (zForceMutex * zForceMutex);
132
146 bool ( * UnlockMutex) (zForceMutex * zForceMutex);
147
161 bool ( * DestroyMutex) (zForceMutex * zForceMutex);
162
182 bool ( * InitializeSemaphore) (zForceSemaphore ** zForceSemaphore, uint32_t initialValue);
183
201 bool ( * WaitForSemaphore) (zForceSemaphore * zForceSemaphore, uint32_t timeoutMs);
202
217 bool ( * IncrementSemaphore) (zForceSemaphore * zForceSemaphore);
218
233 bool ( * DestroySemaphore) (zForceSemaphore * zForceSemaphore);
234
245 uint64_t ( * GetTimeMilliSeconds) (void);
246
263 bool ( * CreateThread) (zForceThread ** zForceThread, void ( * entryPoint)(void *), void * arguments);
264
279 bool ( * WaitForThreadExit) (zForceThread * zForceThread);
280
291 void ( * Sleep) (uint32_t milliSeconds);
292 };
293
294 #ifdef __cplusplus
295 extern "C"
296 {
297 #endif // __cplusplus
298
299 DLLINTERNAL bool OsAbstractionLayer_Initialize (OsAbstractionLayer * osAbstractionLayer,
300 OsAbstractionLayer * userSuppliedOsAbstractionLayer);
301
302 DLLINTERNAL void OsAbstractionLayer_ThreadWrapper (zForceThreadWrapper * wrapper);
303
304 #ifdef __cplusplus
305 }
306 #endif // __cplusplus
307
308 #endif // ZFORCE_OSABSTRACTIONLAYER_H
zForceThread
void zForceThread
Typecast to underlying (system) type.
Definition: OsAbstractionLayer.h:20
zForceSemaphore
void zForceSemaphore
Typecast to underlying (system) type.
Definition: OsAbstractionLayer.h:19
zForceMutex
void zForceMutex
Typecast to underlying (system) type.
Definition: OsAbstractionLayer.h:18
OsAbstractionLayer
Overrides for OS Functions.
Definition: OsAbstractionLayer.h:44
OsAbstractionLayer::Sleep
void(* Sleep)(uint32_t milliSeconds)
Sleep for a specified amount of MilliSeconds.
Definition: OsAbstractionLayer.h:291
OsAbstractionLayer::Free
void(* Free)(void *memoryPointer)
Free previously allocated memory area.
Definition: OsAbstractionLayer.h:69
OsAbstractionLayer::InitializeMutex
bool(* InitializeMutex)(zForceMutex **zForceMutex)
Initialize Mutex.
Definition: OsAbstractionLayer.h:116
OsAbstractionLayer::GetTimeMilliSeconds
uint64_t(* GetTimeMilliSeconds)(void)
Get time in MilliSeconds.
Definition: OsAbstractionLayer.h:245
OsAbstractionLayer::IncrementSemaphore
bool(* IncrementSemaphore)(zForceSemaphore *zForceSemaphore)
Increment Semaphore.
Definition: OsAbstractionLayer.h:217
OsAbstractionLayer::DestroyMutex
bool(* DestroyMutex)(zForceMutex *zForceMutex)
Destroy Mutex.
Definition: OsAbstractionLayer.h:161
OsAbstractionLayer::InitializeSemaphore
bool(* InitializeSemaphore)(zForceSemaphore **zForceSemaphore, uint32_t initialValue)
Initialize Semaphore.
Definition: OsAbstractionLayer.h:182
OsAbstractionLayer::DestroySemaphore
bool(* DestroySemaphore)(zForceSemaphore *zForceSemaphore)
Destroy Semaphore.
Definition: OsAbstractionLayer.h:233
OsAbstractionLayer::LockMutex
bool(* LockMutex)(zForceMutex *zForceMutex)
Lock Mutex.
Definition: OsAbstractionLayer.h:131
OsAbstractionLayer::CreateThread
bool(* CreateThread)(zForceThread **zForceThread, void(*entryPoint)(void *), void *arguments)
Create Thread and run it.
Definition: OsAbstractionLayer.h:263
OsAbstractionLayer::UnlockMutex
bool(* UnlockMutex)(zForceMutex *zForceMutex)
Unlock Mutex.
Definition: OsAbstractionLayer.h:146
OsAbstractionLayer::WaitForThreadExit
bool(* WaitForThreadExit)(zForceThread *zForceThread)
Wait for Thread to exit.
Definition: OsAbstractionLayer.h:279
OsAbstractionLayer::WaitForSemaphore
bool(* WaitForSemaphore)(zForceSemaphore *zForceSemaphore, uint32_t timeoutMs)
Wait for Semaphore.
Definition: OsAbstractionLayer.h:201
zForceThreadWrapper
Wrapper for threads.
Definition: OsAbstractionLayer.h:30
zForceThreadWrapper::EntryPoint
void(* EntryPoint)(void *)
Entry function for the thread.
Definition: OsAbstractionLayer.h:32
zForceThreadWrapper::zForceThread
zForceThread * zForceThread
Thread pointer.
Definition: OsAbstractionLayer.h:31
zForceThreadWrapper::Arguments
void * Arguments
Arguments for the entry function.
Definition: OsAbstractionLayer.h:33