X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=nucleus%2Flibrary%2Ftimely%2Ftimer_driver.cpp;h=b675c6189eabf5ac347e307bb649cead3f0d4cfd;hb=b43d05116706d888890418ce9f24fa540aa4ef10;hp=9be8aba0214f532a0458a36d0b370f226c6d5276;hpb=3ea085ec301ed1399dfa1e9f3a240312dc95410b;p=feisty_meow.git diff --git a/nucleus/library/timely/timer_driver.cpp b/nucleus/library/timely/timer_driver.cpp index 9be8aba0..b675c618 100644 --- a/nucleus/library/timely/timer_driver.cpp +++ b/nucleus/library/timely/timer_driver.cpp @@ -62,7 +62,7 @@ SAFE_STATIC(timer_driver, timer_driver::global_timer_driver, ) ////////////// -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) const int OUR_SIGNAL = SIGUSR2; class signalling_thread : public ethread @@ -78,7 +78,7 @@ private: }; #endif -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) void timer_driver_private_handler(int signal_seen) #elif defined(__WIN32__) void __stdcall timer_driver_private_handler(window_handle hwnd, basis::un_int msg, @@ -92,7 +92,7 @@ void __stdcall timer_driver_private_handler(window_handle hwnd, basis::un_int ms #define static_class_name() "timer_driver" FUNCDEF("timer_driver_private_handler"); #endif -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) int seen = signal_seen; if (seen != OUR_SIGNAL) { #elif defined(__WIN32__) @@ -147,11 +147,10 @@ public: timer_driver::timer_driver() : _timers(new driven_objects_list), _lock(new mutex), -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) _prompter(new signalling_thread(INITIAL_TIMER_GRANULARITY)), -#endif -#ifdef __WIN32__ - _real_timer_id(NIL), +#else + _real_timer_id(NULL_POINTER), #endif _in_timer(false) { @@ -160,7 +159,7 @@ timer_driver::timer_driver() #ifdef __UNIX__ // register for the our personal signal. signal(OUR_SIGNAL, &timer_driver_private_handler); - _prompter->start(NIL); + _prompter->start(NULL_POINTER); #endif } @@ -174,13 +173,13 @@ timer_driver::~timer_driver() struct sigaction action; action.sa_handler = SIG_DFL; - action.sa_sigaction = NIL; + action.sa_sigaction = NULL_POINTER; sigemptyset(&action.sa_mask); action.sa_flags = 0; #ifndef __APPLE__ - action.sa_restorer = NIL; + action.sa_restorer = NULL_POINTER; #endif - int ret = sigaction(OUR_SIGNAL, &action, NIL); + int ret = sigaction(OUR_SIGNAL, &action, NULL_POINTER); if (ret) { ///uhhh } @@ -215,7 +214,7 @@ timer_driver::~timer_driver() #endif } -#ifdef __WIN32__ +#ifdef _MSC_VER basis::un_int *timer_driver::real_timer_id() { return _real_timer_id; } #endif @@ -405,13 +404,13 @@ void timer_driver::hookup_OS_timer(int duration) #ifdef DEBUG_TIMER_DRIVER LOG(a_sprintf("hooking next OS timer in %d ms.", duration)); #endif -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) // just make our thread hit after the duration specified. _prompter->reschedule(duration); -#elif defined(__WIN32__) +#elif defined(_MSC_VER) int max_tries_left = 100; while (max_tries_left-- >= 0) { - _real_timer_id = (basis::un_int *)SetTimer(NIL, 0, duration, + _real_timer_id = (basis::un_int *)SetTimer(NULL_POINTER, 0, duration, timer_driver_private_handler); if (!_real_timer_id) { // failure to set the timer. @@ -429,11 +428,11 @@ void timer_driver::unhook_OS_timer() #ifdef DEBUG_TIMER_DRIVER FUNCDEF("unhook_OS_timer"); #endif -#ifdef __UNIX__ +#if defined(__UNIX__) || defined(__GNU_WINDOWS__) // postpone the thread for quite a while so we can take care of business. _prompter->reschedule(LONG_TIME); -#elif defined(__WIN32__) - if (_real_timer_id) KillTimer(NIL, (UINT_PTR)_real_timer_id); +#elif defined(_MSC_VER) + if (_real_timer_id) KillTimer(NULL_POINTER, (UINT_PTR)_real_timer_id); #endif #ifdef DEBUG_TIMER_DRIVER LOG("unhooked OS timer.");