aboutsummaryrefslogtreecommitdiffstats
path: root/src/gos
diff options
context:
space:
mode:
authorinmarket <inmarket@ugfx.io>2017-08-16 16:49:02 +1000
committerinmarket <inmarket@ugfx.io>2017-08-16 16:49:02 +1000
commitd7b083da1e3fbc9355422bc29470c387e88389d7 (patch)
tree5b21b55ae61e54fb1bdad40aaf0f590385176c02 /src/gos
parent422e95becf719ab3dfc3e37d5fda1b6f37dd02fb (diff)
downloaduGFX-d7b083da1e3fbc9355422bc29470c387e88389d7.tar.gz
uGFX-d7b083da1e3fbc9355422bc29470c387e88389d7.tar.bz2
uGFX-d7b083da1e3fbc9355422bc29470c387e88389d7.zip
Remove long obsoleted (and dubious) functions gfxSemCounter() and gfxSemCounterI()
Diffstat (limited to 'src/gos')
-rw-r--r--src/gos/gos.h21
-rw-r--r--src/gos/gos_chibios.c4
-rw-r--r--src/gos/gos_chibios.h7
-rw-r--r--src/gos/gos_ecos.c11
-rw-r--r--src/gos/gos_ecos.h2
-rw-r--r--src/gos/gos_linux.c18
-rw-r--r--src/gos/gos_linux.h3
-rw-r--r--src/gos/gos_osx.c11
-rw-r--r--src/gos/gos_osx.h2
-rw-r--r--src/gos/gos_qt.cpp10
-rw-r--r--src/gos/gos_qt.h2
-rw-r--r--src/gos/gos_rawrtos.h1
-rw-r--r--src/gos/gos_win32.c2
-rw-r--r--src/gos/gos_win32.h2
-rw-r--r--src/gos/gos_x_threads.h4
15 files changed, 8 insertions, 92 deletions
diff --git a/src/gos/gos.h b/src/gos/gos.h
index ddca0d94..2db896af 100644
--- a/src/gos/gos.h
+++ b/src/gos/gos.h
@@ -403,27 +403,6 @@
void gfxSemSignalI(gfxSem *psem);
/**
- * @brief Get the current semaphore count
- * @return The current semaphore count
- *
- * @param[in] psem A pointer to the semaphore
- *
- * @api
- */
- semcount_t gfxSemCounter(gfxSem *psem);
-
- /**
- * @brief Get the current semaphore count
- * @return The current semaphore count
- *
- * @param[in] psem A pointer to the semaphore
- *
- * @iclass
- * @api
- */
- semcount_t gfxSemCounterI(gfxSem *psem);
-
- /**
* @brief Start a new thread.
* @return Returns a thread handle if the thread was started, NULL on an error
*
diff --git a/src/gos/gos_chibios.c b/src/gos/gos_chibios.c
index d02127ab..b54f32ea 100644
--- a/src/gos/gos_chibios.c
+++ b/src/gos/gos_chibios.c
@@ -149,7 +149,7 @@ void gfxSemSignal(gfxSem *psem)
{
chSysLock();
- if (gfxSemCounterI(psem) < psem->limit)
+ if (psem->sem.s_cnt < psem->limit)
chSemSignalI(&psem->sem);
chSchRescheduleS();
@@ -158,7 +158,7 @@ void gfxSemSignal(gfxSem *psem)
void gfxSemSignalI(gfxSem *psem)
{
- if (gfxSemCounterI(psem) < psem->limit)
+ if (psem->sem.s_cnt < psem->limit)
chSemSignalI(&psem->sem);
}
diff --git a/src/gos/gos_chibios.h b/src/gos/gos_chibios.h
index c3fc9d36..aedfb492 100644
--- a/src/gos/gos_chibios.h
+++ b/src/gos/gos_chibios.h
@@ -120,13 +120,6 @@ bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
bool_t gfxSemWaitI(gfxSem *psem);
void gfxSemSignal(gfxSem *psem);
void gfxSemSignalI(gfxSem *psem);
-#if (CH_KERNEL_MAJOR == 2) || (CH_KERNEL_MAJOR == 3)
-#define gfxSemCounterI(psem) ((psem)->sem.s_cnt)
-#define gfxSemCounter(psem) ((psem)->sem.s_cnt)
-#elif (CH_KERNEL_MAJOR == 4)
-#define gfxSemCounterI(psem) ((psem)->sem.cnt)
-#define gfxSemCounter(psem) ((psem)->sem.cnt)
-#endif
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
#define gfxThreadWait(thread) chThdWait(thread)
#define gfxThreadMe() chThdSelf()
diff --git a/src/gos/gos_ecos.c b/src/gos/gos_ecos.c
index f7e557ac..a55773d9 100644
--- a/src/gos/gos_ecos.c
+++ b/src/gos/gos_ecos.c
@@ -84,7 +84,7 @@ void gfxSemSignal(gfxSem *psem)
cyg_semaphore_post(&psem->sem);
else {
cyg_scheduler_lock();
- if (gfxSemCounterI(psem) < psem->limit)
+ if (cyg_semaphore_peek(&psem->sem, &cnt) < psem->limit)
cyg_semaphore_post(&psem->sem);
cyg_scheduler_unlock();
}
@@ -92,17 +92,10 @@ void gfxSemSignal(gfxSem *psem)
void gfxSemSignalI(gfxSem *psem)
{
- if (psem->limit == MAX_SEMAPHORE_COUNT || gfxSemCounterI(psem) < psem->limit)
+ if (psem->limit == MAX_SEMAPHORE_COUNT || cyg_semaphore_peek(&psem->sem, &cnt) < psem->limit)
cyg_semaphore_post(&psem->sem);
}
-semcount_t gfxSemCounterI(gfxSem *psem) {
- semcount_t cnt;
-
- cyg_semaphore_peek(&psem->sem, &cnt);
- return cnt;
-}
-
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
{
gfxThreadHandle th;
diff --git a/src/gos/gos_ecos.h b/src/gos/gos_ecos.h
index 6aa55a3a..0e438fb0 100644
--- a/src/gos/gos_ecos.h
+++ b/src/gos/gos_ecos.h
@@ -91,8 +91,6 @@ bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
bool_t gfxSemWaitI(gfxSem *psem);
void gfxSemSignal(gfxSem *psem);
void gfxSemSignalI(gfxSem *psem);
-semcount_t gfxSemCounterI(gfxSem *psem);
-#define gfxSemCounter(psem) gfxSemCounterI(psem)
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
#define gfxThreadWait(thread) NOTIMPLEMENTED_YET
diff --git a/src/gos/gos_linux.c b/src/gos/gos_linux.c
index dac3838f..43371443 100644
--- a/src/gos/gos_linux.c
+++ b/src/gos/gos_linux.c
@@ -165,15 +165,12 @@ threadreturn_t gfxThreadWait(gfxThreadHandle thread) {
}
}
void gfxSemSignal(gfxSem *pSem) {
- if (gfxSemCounter(pSem) < pSem->max)
- sem_post(&pSem->sem);
- }
- semcount_t gfxSemCounter(gfxSem *pSem) {
int res;
res = 0;
sem_getvalue(&pSem->sem, &res);
- return res;
+ if (res < pSem->max)
+ sem_post(&pSem->sem);
}
#else
void gfxSemInit(gfxSem *pSem, semcount_t val, semcount_t limit) {
@@ -239,17 +236,6 @@ threadreturn_t gfxThreadWait(gfxThreadHandle thread) {
pthread_mutex_unlock(&pSem->mtx);
}
- semcount_t gfxSemCounter(gfxSem *pSem) {
- semcount_t res;
-
- // The locking is really only required if obtaining the count is a divisible operation
- // which it might be on a 8/16 bit processor with a 32 bit semaphore count.
- pthread_mutex_lock(&pSem->mtx);
- res = pSem->cnt;
- pthread_mutex_unlock(&pSem->mtx);
-
- return res;
- }
#endif // GFX_USE_POSIX_SEMAPHORES
#endif /* GFX_USE_OS_LINUX */
diff --git a/src/gos/gos_linux.h b/src/gos/gos_linux.h
index fe406cb6..b9bfe82e 100644
--- a/src/gos/gos_linux.h
+++ b/src/gos/gos_linux.h
@@ -65,7 +65,6 @@ typedef pthread_mutex_t gfxMutex;
sem_t sem;
semcount_t max;
} gfxSem;
- #define gfxSemCounterI(psem) gfxSemCounter(psem)
#else
typedef struct gfxSem {
pthread_mutex_t mtx;
@@ -73,7 +72,6 @@ typedef pthread_mutex_t gfxMutex;
semcount_t cnt;
semcount_t max;
} gfxSem;
- #define gfxSemCounterI(psem) ((psem)->cnt)
#endif
/*===========================================================================*/
@@ -95,7 +93,6 @@ void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
void gfxSemDestroy(gfxSem *psem);
bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
void gfxSemSignal(gfxSem *psem);
-semcount_t gfxSemCounter(gfxSem *pSem);
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
threadreturn_t gfxThreadWait(gfxThreadHandle thread);
diff --git a/src/gos/gos_osx.c b/src/gos/gos_osx.c
index f06685d7..56d64d98 100644
--- a/src/gos/gos_osx.c
+++ b/src/gos/gos_osx.c
@@ -180,15 +180,4 @@ void gfxSemSignal(gfxSem *pSem) {
pthread_mutex_unlock(&pSem->mtx);
}
-semcount_t gfxSemCounter(gfxSem *pSem) {
- semcount_t res;
-
- // The locking is really only required if obtaining the count is a divisible operation
- // which it might be on a 8/16 bit processor with a 32 bit semaphore count.
- pthread_mutex_lock(&pSem->mtx);
- res = pSem->cnt;
- pthread_mutex_unlock(&pSem->mtx);
- return res;
-}
-
#endif /* GFX_USE_OS_OSX */
diff --git a/src/gos/gos_osx.h b/src/gos/gos_osx.h
index 9a8e10d9..94c67eab 100644
--- a/src/gos/gos_osx.h
+++ b/src/gos/gos_osx.h
@@ -44,7 +44,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)
@@ -78,7 +77,6 @@ void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
void gfxSemDestroy(gfxSem *psem);
bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
void gfxSemSignal(gfxSem *psem);
-semcount_t gfxSemCounter(gfxSem *pSem);
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
threadreturn_t gfxThreadWait(gfxThreadHandle thread);
diff --git a/src/gos/gos_qt.cpp b/src/gos/gos_qt.cpp
index 422f1535..e7480dd2 100644
--- a/src/gos/gos_qt.cpp
+++ b/src/gos/gos_qt.cpp
@@ -178,16 +178,6 @@ void gfxSemSignalI(gfxSem *psem)
static_cast<QSemaphore*>(*psem)->release(1);
}
-semcount_t gfxSemCounter(gfxSem *psem)
-{
- return static_cast<QSemaphore*>(*psem)->available();
-}
-
-semcount_t gfxSemCounterI(gfxSem *psem)
-{
- return static_cast<QSemaphore*>(*psem)->available();
-}
-
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
{
Q_UNUSED(stackarea)
diff --git a/src/gos/gos_qt.h b/src/gos/gos_qt.h
index 9986d7f2..45d743f5 100644
--- a/src/gos/gos_qt.h
+++ b/src/gos/gos_qt.h
@@ -63,8 +63,6 @@ bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
bool_t gfxSemWaitI(gfxSem *psem);
void gfxSemSignal(gfxSem *psem);
void gfxSemSignalI(gfxSem *psem);
-semcount_t gfxSemCounter(gfxSem *psem);
-semcount_t gfxSemCounterI(gfxSem *psem);
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
threadreturn_t gfxThreadWait(gfxThreadHandle thread);
gfxThreadHandle gfxThreadMe(void);
diff --git a/src/gos/gos_rawrtos.h b/src/gos/gos_rawrtos.h
index e7778d15..d1026c9d 100644
--- a/src/gos/gos_rawrtos.h
+++ b/src/gos/gos_rawrtos.h
@@ -47,7 +47,6 @@ typedef RAW_TASK_OBJ* gfxThreadHandle;
#define gfxSemDestroy(psem) raw_semaphore_delete(psem)
#define gfxSemSignal(psem) raw_semaphore_put((psem))
#define gfxSemSignalI(psem) raw_semaphore_put_all((psem))
-#define gfxSemCounterI(psem) ((psem)->count)
#define gfxThreadMe() {(unsigned int)raw_task_identify()}
#define gfxThreadClose(thread) {}
diff --git a/src/gos/gos_win32.c b/src/gos/gos_win32.c
index ba4bbec2..1aa13dd6 100644
--- a/src/gos/gos_win32.c
+++ b/src/gos/gos_win32.c
@@ -86,6 +86,7 @@ typedef LONG (__stdcall *_NtQuerySemaphore)(
PULONG ReturnLength OPTIONAL
);
+/* - Left here simply because of its undocumented cleverness...
semcount_t gfxSemCounter(gfxSem *pSem) {
static _NtQuerySemaphore NtQuerySemaphore;
struct _SEMAPHORE_BASIC_INFORMATION {
@@ -100,6 +101,7 @@ semcount_t gfxSemCounter(gfxSem *pSem) {
return BasicInfo.CurrentCount;
}
+*/
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION(*fn,p), void *param) {
(void) stackarea;
diff --git a/src/gos/gos_win32.h b/src/gos/gos_win32.h
index e6e45d2f..62602ad3 100644
--- a/src/gos/gos_win32.h
+++ b/src/gos/gos_win32.h
@@ -78,7 +78,6 @@ typedef HANDLE gfxThreadHandle;
#define gfxSemWaitI(psem) gfxSemWait((psem), TIME_IMMEDIATE)
#define gfxSemSignal(psem) ReleaseSemaphore(*(psem), 1, 0)
#define gfxSemSignalI(psem) ReleaseSemaphore(*(psem), 1, 0)
-#define gfxSemCounterI(psem) gfxSemCounter(psem)
#define gfxThreadMe() GetCurrentThread()
#define gfxThreadClose(thread) CloseHandle(thread)
@@ -93,7 +92,6 @@ extern "C" {
void gfxHalt(const char *msg);
void gfxSleepMicroseconds(delaytime_t ms);
bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
-semcount_t gfxSemCounter(gfxSem *pSem);
void gfxSystemLock(void);
void gfxSystemUnlock(void);
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION(*fn,p), void *param);
diff --git a/src/gos/gos_x_threads.h b/src/gos/gos_x_threads.h
index 05a08cc2..546e9e13 100644
--- a/src/gos/gos_x_threads.h
+++ b/src/gos/gos_x_threads.h
@@ -80,10 +80,6 @@ extern "C" {
void gfxSemSignal(gfxSem *psem);
void gfxSemSignalI(gfxSem *psem);
- // Deprecated Semaphore functions (they still work here)
- #define gfxSemCounter(psem) ((psem)->cnt)
- #define gfxSemCounterI(psem) ((psem)->cnt)
-
// Threads
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
#define gfxThreadClose(thread)