GOS updates to fix compile warnings on linux
This commit is contained in:
parent
0d35e6b6ae
commit
2776d00e82
3 changed files with 28 additions and 8 deletions
|
@ -9,10 +9,20 @@
|
|||
|
||||
#if GFX_USE_OS_LINUX
|
||||
|
||||
// Linux seems to have deprecated pthread_yield() and now says to use sched_yield()
|
||||
#define USE_SCHED_NOT_PTHREAD_YIELD TRUE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#if USE_SCHED_NOT_PTHREAD_YIELD
|
||||
#include <sched.h>
|
||||
#define linuxyield() sched_yield()
|
||||
#else
|
||||
#define linuxyield() pthread_yield()
|
||||
#endif
|
||||
|
||||
static gfxMutex SystemMutex;
|
||||
|
||||
|
@ -35,6 +45,10 @@ void gfxSystemUnlock(void) {
|
|||
gfxMutexExit(&SystemMutex);
|
||||
}
|
||||
|
||||
void gfxYield(void) {
|
||||
linuxyield();
|
||||
}
|
||||
|
||||
void gfxHalt(const char *msg) {
|
||||
if (msg)
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
|
@ -46,7 +60,7 @@ void gfxSleepMilliseconds(delaytime_t ms) {
|
|||
|
||||
switch(ms) {
|
||||
case TIME_IMMEDIATE:
|
||||
pthread_yield();
|
||||
linuxyield();
|
||||
return;
|
||||
|
||||
case TIME_INFINITE:
|
||||
|
@ -67,7 +81,7 @@ void gfxSleepMicroseconds(delaytime_t ms) {
|
|||
|
||||
switch(ms) {
|
||||
case TIME_IMMEDIATE:
|
||||
pthread_yield();
|
||||
linuxyield();
|
||||
return;
|
||||
|
||||
case TIME_INFINITE:
|
||||
|
@ -93,6 +107,9 @@ systemticks_t gfxSystemTicks(void) {
|
|||
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) {
|
||||
gfxThreadHandle th;
|
||||
(void) stackarea;
|
||||
(void) stacksz;
|
||||
(void) prio;
|
||||
|
||||
// Implementing priority with pthreads is a rats nest that is also pthreads implementation dependent.
|
||||
// Only some pthreads schedulers support it, some implementations use the operating system process priority mechanisms.
|
||||
|
@ -151,7 +168,7 @@ bool_t gfxSemWait(gfxSem *pSem, delaytime_t ms) {
|
|||
struct timeval now;
|
||||
struct timespec tm;
|
||||
|
||||
gettimeofday(&now);
|
||||
gettimeofday(&now, 0);
|
||||
tm.tv_sec = now.tv_sec + ms / 1000;
|
||||
tm.tv_nsec = (now.tv_usec + ms % 1000) * 1000;
|
||||
while (!pSem->cnt) {
|
||||
|
|
|
@ -34,7 +34,6 @@ typedef pthread_mutex_t gfxMutex;
|
|||
#define gfxRealloc(p,osz,nsz) realloc(p, nsz)
|
||||
#define gfxFree(ptr) free(ptr)
|
||||
#define gfxMillisecondsToTicks(ms) (ms)
|
||||
#define gfxYield() pthread_yield()
|
||||
#define gfxThreadMe() pthread_self()
|
||||
#define gfxThreadClose(th) (void)th
|
||||
#define gfxMutexInit(pmtx) pthread_mutex_init(pmtx, 0)
|
||||
|
@ -67,6 +66,7 @@ typedef struct gfxSem {
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void gfxYield(void);
|
||||
void gfxHalt(const char *msg);
|
||||
void gfxSleepMilliseconds(delaytime_t ms);
|
||||
void gfxSleepMicroseconds(delaytime_t ms);
|
||||
|
|
|
@ -99,6 +99,9 @@ systemticks_t gfxSystemTicks(void) {
|
|||
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) {
|
||||
gfxThreadHandle th;
|
||||
(void) stackarea;
|
||||
(void) stacksz;
|
||||
(void) prio;
|
||||
|
||||
// Implementing priority with pthreads is a rats nest that is also pthreads implementation dependent.
|
||||
// Only some pthreads schedulers support it, some implementations use the operating system process priority mechanisms.
|
||||
|
|
Loading…
Add table
Reference in a new issue