Remove long obsoleted (and dubious) functions gfxSemCounter() and gfxSemCounterI()

This commit is contained in:
inmarket 2017-08-16 16:49:02 +10:00
parent 422e95becf
commit d7b083da1e
15 changed files with 8 additions and 92 deletions

View File

@ -402,27 +402,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

View File

@ -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);
}

View File

@ -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()

View File

@ -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;

View File

@ -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

View File

@ -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 */

View File

@ -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);

View File

@ -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 */

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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) {}

View File

@ -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;

View File

@ -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);

View File

@ -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)