mirror of
https://git.code.sf.net/p/fldigi/fldigi
synced 2026-08-13 17:47:54 -04:00
Redefine nanosleep
* nanosleep in mingw developmental library breaks compatability
This commit is contained in:
parent
ca8664522b
commit
739628e31c
10 changed files with 37 additions and 10 deletions
|
|
@ -185,7 +185,7 @@ int socketpair(int family, int type, int protocol, SOCKET *sv)
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
int nanosleep(const struct timespec *req, struct timespec *rem)
|
||||
int nano_sleep(const struct timespec *req, struct timespec *rem)
|
||||
{
|
||||
if (unlikely(req->tv_nsec < 0 || req->tv_nsec < 0L || req->tv_nsec > 999999999L)) {
|
||||
errno = EINVAL;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ int mingw_rename(const char*, const char*);
|
|||
# define SHUT_RDWR SD_BOTH
|
||||
#endif
|
||||
|
||||
int nanosleep (const struct timespec *req, struct timespec *rem);
|
||||
int socketpair(int family, int type, int protocol, SOCKET *sv);
|
||||
|
||||
/* uname */
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ void KY_sleep(double secs)
|
|||
|
||||
t2 = KY_now();
|
||||
while (t2 < end1 && (++loop1 < n1)) {
|
||||
nanosleep(&tv, NULL);
|
||||
nano_sleep(&tv, NULL);
|
||||
t2 = KY_now();
|
||||
}
|
||||
t3 = t2;
|
||||
|
|
|
|||
|
|
@ -1527,7 +1527,7 @@ void cwio_bit(int bit, double msecs)
|
|||
end1 = end2 - 0.005;
|
||||
|
||||
while (t3 < end1 && (++loop1 < n1)) {
|
||||
nanosleep(&tv, NULL);
|
||||
nano_sleep(&tv, NULL);
|
||||
t3 = cwio_now();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -162,4 +162,6 @@ public:
|
|||
bool wait( double seconds );
|
||||
};
|
||||
|
||||
int nano_sleep(const struct timespec *req, struct timespec *rem);
|
||||
|
||||
#endif // !THREADS_H_
|
||||
|
|
|
|||
|
|
@ -148,5 +148,29 @@ bool syncobj::wait( double seconds )
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef __WIN_32_
|
||||
|
||||
int nano_sleep(const struct timespec *req, struct timespec *rem)
|
||||
{
|
||||
return nanosleep(req, rem);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int nano_sleep(const struct timespec *req, struct timespec *rem)
|
||||
{
|
||||
if (unlikely(req->tv_nsec < 0 || req->tv_nsec < 0L || req->tv_nsec > 999999999L)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
Sleep(req->tv_sec * 1000 + req->tv_nsec / 1000000L);
|
||||
if (unlikely(rem)) {
|
||||
rem->tv_sec = 0;
|
||||
rem->tv_nsec = 0L;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@
|
|||
|
||||
#endif
|
||||
|
||||
#include "threads.h"
|
||||
|
||||
/** ********************************************************************
|
||||
* Return the smallest power of 2 not less than n
|
||||
***********************************************************************/
|
||||
|
|
@ -477,7 +479,7 @@ const char* uint2bin(unsigned u, size_t len)
|
|||
void MilliSleep(long msecs)
|
||||
{
|
||||
struct timespec tv[2] = { {msecs / 1000L, msecs % 1000L * 1000000L} };
|
||||
nanosleep(&tv[0], &tv[1]);
|
||||
nano_sleep(&tv[0], &tv[1]);
|
||||
}
|
||||
#else
|
||||
|
||||
|
|
@ -485,7 +487,7 @@ void MilliSleep(long msecs)
|
|||
{
|
||||
struct timespec tv[2] = { {msecs / 1000L, msecs % 1000L * 1000000L} };
|
||||
timeBeginPeriod(1);
|
||||
nanosleep(&tv[0], &tv[1]);
|
||||
nano_sleep(&tv[0], &tv[1]);
|
||||
timeEndPeriod(1);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -510,7 +512,7 @@ int accu_sleep (double sleep_time)
|
|||
tv.tv_nsec = (long) ((delay - tv.tv_sec) * 1e+9);
|
||||
int rval = 0;
|
||||
while (1) {
|
||||
rval = nanosleep (&tv, &tv);
|
||||
rval = nano_sleep (&tv, &tv);
|
||||
if (rval == 0)
|
||||
break;
|
||||
else if (errno == EINTR)
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ void FSK::fskbit(int bit, double secs)
|
|||
|
||||
t3 = fsk_now();
|
||||
while (t3 < end1 && (++loop1 < n1)) {
|
||||
nanosleep(&tv, NULL);
|
||||
nano_sleep(&tv, NULL);
|
||||
t3 = fsk_now();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1133,7 +1133,7 @@ int rtty::rtty_sleep (double sleep_time)
|
|||
timeBeginPeriod(1);
|
||||
#endif
|
||||
// while (1) {
|
||||
rval = nanosleep (&tv, &tv);
|
||||
rval = nano_sleep (&tv, &tv);
|
||||
if (errno == EINTR) {
|
||||
// continue
|
||||
std::cout << "EINTR error in rtty_sleep" << std::endl;
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ int scamp::scamp_sleep (double sleep_time)
|
|||
timeBeginPeriod(1);
|
||||
#endif
|
||||
// while (1) {
|
||||
rval = nanosleep (&tv, &tv);
|
||||
rval = nano_sleep (&tv, &tv);
|
||||
if (errno == EINTR) {
|
||||
// continue
|
||||
std::cout << "EINTR error in scamp_sleep" << std::endl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue