Browse Source

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

remotes/origin_old/release/v2.9
inmarket 5 years ago
parent
commit
d7b083da1e
  1. 21
      src/gos/gos.h
  2. 4
      src/gos/gos_chibios.c
  3. 7
      src/gos/gos_chibios.h
  4. 11
      src/gos/gos_ecos.c
  5. 2
      src/gos/gos_ecos.h
  6. 18
      src/gos/gos_linux.c
  7. 3
      src/gos/gos_linux.h
  8. 11
      src/gos/gos_osx.c
  9. 2
      src/gos/gos_osx.h
  10. 10
      src/gos/gos_qt.cpp
  11. 2
      src/gos/gos_qt.h
  12. 1
      src/gos/gos_rawrtos.h
  13. 2
      src/gos/gos_win32.c
  14. 2
      src/gos/gos_win32.h
  15. 4
      src/gos/gos_x_threads.h

21
src/gos/gos.h

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

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

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

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

2
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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save