diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-09-29 15:45:44 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-09-29 15:45:44 +1000 |
commit | e3545c55bf706984af5962221f95881d868c5407 (patch) | |
tree | bf8cf9b79a77a85ae3bc31ec1c28275ace7e6feb /src/gos/gfx_linux.h | |
parent | daf9f65b9fb9822bc3bc80d63b66a612e085802a (diff) | |
download | uGFX-e3545c55bf706984af5962221f95881d868c5407.tar.gz uGFX-e3545c55bf706984af5962221f95881d868c5407.tar.bz2 uGFX-e3545c55bf706984af5962221f95881d868c5407.zip |
Bug fixes for the linux GOS layer. Also add POSIX semaphore implementation.
Diffstat (limited to 'src/gos/gfx_linux.h')
-rw-r--r-- | src/gos/gfx_linux.h | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/gos/gfx_linux.h b/src/gos/gfx_linux.h index bd31184e..39cfbc85 100644 --- a/src/gos/gfx_linux.h +++ b/src/gos/gfx_linux.h @@ -10,11 +10,20 @@ #if GFX_USE_OS_LINUX +// We don't put this in the general sys_options.h as it is Linux specific. +#ifndef GFX_USE_POSIX_SEMAPHORES + #define GFX_USE_POSIX_SEMAPHORES TRUE +#endif + #include <sys/types.h> #include <stdlib.h> #include <stdint.h> #include <pthread.h> +#if GFX_USE_POSIX_SEMAPHORES + #include <semaphore.h> +#endif + /* Already defined int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, size_t */ typedef int8_t bool_t; @@ -42,7 +51,6 @@ typedef pthread_mutex_t gfxMutex; #define gfxMutexExit(pmtx) pthread_mutex_unlock(pmtx) #define gfxSemWaitI(psem) gfxSemWait(psem, TIME_IMMEDIATE) #define gfxSemSignalI(psem) gfxSemSignal(psem) -#define gfxSemCounterI(pSem) ((pSem)->cnt) #define TIME_IMMEDIATE 0 #define TIME_INFINITE ((delaytime_t)-1) @@ -51,12 +59,21 @@ typedef pthread_mutex_t gfxMutex; #define NORMAL_PRIORITY 0 #define HIGH_PRIORITY -10 -typedef struct gfxSem { - pthread_mutex_t mtx; - pthread_cond_t cond; - semcount_t cnt; - semcount_t max; -} gfxSem; +#if GFX_USE_POSIX_SEMAPHORES + typedef struct gfxSem { + sem_t sem; + semcount_t max; + } gfxSem; + #define gfxSemCounterI(psem) gfxSemCounter(psem) +#else + typedef struct gfxSem { + pthread_mutex_t mtx; + pthread_cond_t cond; + semcount_t cnt; + semcount_t max; + } gfxSem; + #define gfxSemCounterI(psem) ((psem)->cnt) +#endif /*===========================================================================*/ /* Function declarations. */ |