diff options
author | Joel Bodenmann <joel@unormal.org> | 2014-09-29 08:08:36 +0200 |
---|---|---|
committer | Joel Bodenmann <joel@unormal.org> | 2014-09-29 08:08:36 +0200 |
commit | 32a4969b7d4d92b1d40e60fae676d798bacb780f (patch) | |
tree | 9607d00476bff7fe4fc1f5cc4c3f261ca7d5c6bf /src/gos/gos_linux.h | |
parent | 1e8a7ff6ddb5bb9accaf2918c98667427aa1b6b3 (diff) | |
parent | 611133cbc0d55f9dd570cfbccbe432ccc63a12aa (diff) | |
download | uGFX-32a4969b7d4d92b1d40e60fae676d798bacb780f.tar.gz uGFX-32a4969b7d4d92b1d40e60fae676d798bacb780f.tar.bz2 uGFX-32a4969b7d4d92b1d40e60fae676d798bacb780f.zip |
Merge branch 'newmouse' of bitbucket.org:Tectu/ugfx into newmouse
Diffstat (limited to 'src/gos/gos_linux.h')
-rw-r--r-- | src/gos/gos_linux.h | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/gos/gos_linux.h b/src/gos/gos_linux.h index bd31184e..39cfbc85 100644 --- a/src/gos/gos_linux.h +++ b/src/gos/gos_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. */ |