Neonode zForce(TM) SDK

Public Attributes | List of all members
OsAbstractionLayer Struct Reference

Overrides for OS Functions. More...

`#include <OsAbstractionLayer.h>`

## Public Attributes
void *(* | Malloc )(size_t size)
| Allocate memory area. The memory area is not nulled. More...
void(* | Free )(void *memoryPointer)
| Free previously allocated memory area. More...
void *(* | Realloc )(void *memoryPointer, size_t size)
| Reallocate previously allocated memory area with a new size. More...
void *(* | MallocWithPattern )(size_t size, uint8_t pattern)
| Allocate memory area, setting all memory to the supplied pattern. More...
bool(* | InitializeMutex )(zForceMutex **zForceMutex)
| Initialize Mutex. More...
bool(* | LockMutex )(zForceMutex *zForceMutex)
| Lock Mutex. More...
bool(* | UnlockMutex )(zForceMutex *zForceMutex)
| Unlock Mutex. More...
bool(* | DestroyMutex )(zForceMutex *zForceMutex)
| Destroy Mutex. More...
bool(* | InitializeSemaphore )(zForceSemaphore **zForceSemaphore, uint32_t initialValue)
| Initialize Semaphore. More...
bool(* | WaitForSemaphore )(zForceSemaphore *zForceSemaphore, uint32_t timeoutMs)
| Wait for Semaphore. More...
bool(* | IncrementSemaphore )(zForceSemaphore *zForceSemaphore)
| Increment Semaphore. More...
bool(* | DestroySemaphore )(zForceSemaphore *zForceSemaphore)
| Destroy Semaphore. More...
uint64_t(* | GetTimeMilliSeconds )(void)
| Get time in MilliSeconds. More...
bool(* | CreateThread )(zForceThread **zForceThread, void(*entryPoint)(void *), void *arguments)
| Create Thread and run it. More...
bool(* | WaitForThreadExit )(zForceThread *zForceThread)
| Wait for Thread to exit. More...
void(* | Sleep )(uint32_t milliSeconds)
| Sleep for a specified amount of MilliSeconds. More...

## Detailed Description

Overrides for OS Functions.

## Member Data Documentation

## ◆ CreateThread

bool( * OsAbstractionLayer::CreateThread) (zForceThread **zForceThread, void(*entryPoint)(void *), void *arguments)

Create Thread and run it.

Create Thread and run it.
On failure, errno is set.

- ETHREADCREATEFAILED - Thread Creation Failed.
- EOUTOFMEMORY - Out of memory.
- EBADTHREAD - Bad Thread pointer.

Parameters

  [out] | zForceThread | Pointer to zForceThread pointer.
  | entryPoint | The entrypoint of the code to run.
  | arguments | Pointer to arguments passed to the thread.

Returns
  True for success, False for failure. See errno.

## ◆ DestroyMutex

bool( * OsAbstractionLayer::DestroyMutex) (zForceMutex *zForceMutex)

Destroy Mutex.

Destroy Mutex.
On failure, errno is set.

- EMUTEXDESTROYFAILED - Mutex Destroy failed.
- EBADMUTEX - Bad Mutex pointer.

Parameters

  zForceMutex | Pointer to zForceMutex instance.

Returns
  True for success, False for failure. See errno.

## ◆ DestroySemaphore

bool( * OsAbstractionLayer::DestroySemaphore) (zForceSemaphore *zForceSemaphore)

Destroy Semaphore.

Destroy Semaphore. Regardless of return code, the Semaphore should no longer be used.
On failure, errno is set.

- ESEMAPHOREDESTROYFAILED - Semaphore Destroy failed.
- EBADSEMAPHORE - Bad Semaphore pointer.

Parameters

  zForceSemaphore | Semaphore to wait for.

Returns
  True for success, False for failure. See errno.

## ◆ Free

void( * OsAbstractionLayer::Free) (void *memoryPointer)

Free previously allocated memory area.

Free previously allocated memory area.

Parameters

  memoryPointer | Pointer to memory area to free.

Returns
  No return value.

## ◆ GetTimeMilliSeconds

uint64_t( * OsAbstractionLayer::GetTimeMilliSeconds) (void)

Get time in MilliSeconds.

The only requirement on this time is that it is a time that does not change according to timezone changes or daylight time changes. There is no requirement on this being number of milliseconds since some specified time in history.

Returns
  Unsigned 64-bit value representing time in MilliSeconds.

## ◆ IncrementSemaphore

bool( * OsAbstractionLayer::IncrementSemaphore) (zForceSemaphore *zForceSemaphore)

Increment Semaphore.

Increment Semaphore by 1.
On failure, errno is set.

- ESEMAPHOREINCREMENTFAILED - Generic Semaphore Increment error.
- EVALUEOVERFLOW - Semaphore would overflow if incremented.
- EBADSEMAPHORE - Bad Semaphore pointer.

Parameters

  zForceSemaphore | Semaphore to increment.

Returns
  True for success, False for failure. See errno.

## ◆ InitializeMutex

bool( * OsAbstractionLayer::InitializeMutex) (zForceMutex **zForceMutex)

Initialize Mutex.

Initialize Mutex.
On failure, errno is set.

- EMUTEXINITIALIZATIONFAILED - Mutex Initialization failed.
- EBADMUTEX - Pointer supplied is NULL.

Parameters

  [out] | zForceMutex | Pointer to a zForceMutex pointer.

Returns
  True for success, False for failure. See errno.

## ◆ InitializeSemaphore

bool( * OsAbstractionLayer::InitializeSemaphore) (zForceSemaphore **zForceSemaphore, uint32_t initialValue)

Initialize Semaphore.

Initialize Semaphore and set it to initialValue. The initial value is 0 for blocking and positive value for not currently blocking regardless of underlying implementation. For example for a queue, an initial value of 0 is desirable as the queue is empty initially.
On failure, errno is set.

- ESEMAPHOREINITIALIZATIONFAILED - Semaphore Initialization failed.
- EVALUEOVERFLOW - Timeout value too large.
- EBADSEMAPHORE - Bad Semaphore pointer.

Parameters

  [out] | zForceSemaphore | Pointer to zForceSemaphore pointer.
  | initialValue | Initial value to set the Semaphore to.

Returns
  True for success, False for failure. See errno.

## ◆ LockMutex

bool( * OsAbstractionLayer::LockMutex) (zForceMutex *zForceMutex)

Lock Mutex.

Lock Mutex.
On failure, errno is set.

- EMUTEXLOCKFAILED - Mutex Lock failed.
- EBADMUTEX - Bad Mutex pointer.

Parameters

  zForceMutex | Pointer to zForceMutex instance.

Returns
  True for success, False for failure. See errno.

## ◆ Malloc

void*( * OsAbstractionLayer::Malloc) (size_t size)

Allocate memory area. The memory area is not nulled.

Allocate memory area. The memory area is not nulled.
On failure, errno is set.

- EOUTOFMEMORY
- EILLEGALMEMORYSIZE

Parameters

  size | Size of the requested memory area in bytes.

Returns
  Pointer to allocated memory area or NULL for failure. See errno.

## ◆ MallocWithPattern

void*( * OsAbstractionLayer::MallocWithPattern) (size_t size, uint8_t pattern)

Allocate memory area, setting all memory to the supplied pattern.

Allocate memory area, setting all memory to the supplied pattern.
On failure, errno is set.

- EOUTOFMEMORY
- EILLEGALMEMORYSIZE

Parameters

  size | Size of the requested memory area in bytes.
  pattern | 1-byte pattern to fill the memory with.

Returns
  Pointer to allocated memory area or NULL for failure. See errno.

## ◆ Realloc

void*( * OsAbstractionLayer::Realloc) (void *memoryPointer, size_t size)

Reallocate previously allocated memory area with a new size.

Reallocate previously allocated memory area with a new size.
On failure, errno is set.

- EOUTOFMEMORY
- EILLEGALMEMORYSIZE

Parameters

  memoryPointer | Pointer to memory area or NULL to allocate a new one.
  size | Size of the new area.

Returns
  Pointer to memory area. Can point to a new location.

## ◆ Sleep

void( * OsAbstractionLayer::Sleep) (uint32_t milliSeconds)

Sleep for a specified amount of MilliSeconds.

Suspends the execution of the current thread for the specified amount of MilliSeconds.

Parameters

  milliSeconds | Amount of MilliSeconds to Sleep.

Returns
  No return value.

## ◆ UnlockMutex

bool( * OsAbstractionLayer::UnlockMutex) (zForceMutex *zForceMutex)

Unlock Mutex.

Unlock Mutex.
On failure, errno is set.

- EMUTEXUNLOCKFAILED - Mutex Unlock failed.
- EBADMUTEX - Bad Mutex pointer.

Parameters

  zForceMutex | Pointer to zForceMutex instance.

Returns
  True for success, False for failure. See errno.

## ◆ WaitForSemaphore

bool( * OsAbstractionLayer::WaitForSemaphore) (zForceSemaphore *zForceSemaphore, uint32_t timeoutMs)

Wait for Semaphore.

Wait for Semaphore. Blocks until count is incremented. No guarantee of order if multiple threads are waiting for the same Semaphore.
On failure, errno is set.

- ESEMAPHOREWAITFAILED - Semaphore Wait failed.
- EFAILEDGETTINGTIME - Failed getting time.
- EINTERRUPTED - Interrupted before timeout.
- EBADSEMAPHORE - Bad Semaphore pointer.

Parameters

  zForceSemaphore | Semaphore to wait for.

Returns
  True for success, False for failure. See errno.

## ◆ WaitForThreadExit

bool( * OsAbstractionLayer::WaitForThreadExit) (zForceThread *zForceThread)

Wait for Thread to exit.

Waits for Thread to exit. This function should normally never be called other than internally in the library. Blocks until Thread has exited, possibly forever.
On failure, errno is set.

- EBADTHREAD - Bad Thread pointer.

Parameters

  zForceThread | zForceThread to wait for.

Returns
  True for success, False for failure. See errno.

The documentation for this struct was generated from the following file:

- OsAbstractionLayer.h