parent
4161197698
commit
8752414fa8
13 changed files with 78 additions and 83 deletions
@ -0,0 +1,61 @@ |
||||
/* Extended Module Player
|
||||
* Copyright (C) 1996-2016 Claudio Matsuoka and Hipolito Carraro Jr |
||||
* |
||||
* This file is part of the Extended Module Player and is distributed |
||||
* under the terms of the GNU General Public License. See the COPYING |
||||
* file for more information. |
||||
*/ |
||||
|
||||
#if defined(_WIN32) |
||||
#include <windows.h> |
||||
|
||||
void delay_ms(int msec) { |
||||
Sleep(msec); |
||||
} |
||||
|
||||
#elif defined(__OS2__) |
||||
#define INCL_DOSPROCESS |
||||
#include <os2.h> |
||||
|
||||
void delay_ms(int msec) { |
||||
DosSleep(msec); |
||||
} |
||||
|
||||
#elif defined(_DOS) |
||||
#include <dos.h> |
||||
|
||||
void delay_ms(int msec) { |
||||
delay(msec); /* doesn't seem to use int 15h. */ |
||||
} |
||||
|
||||
#elif defined(HAVE_USLEEP) |
||||
#include <unistd.h> |
||||
|
||||
void delay_ms(int msec) { |
||||
usleep(msec * 1000); |
||||
} |
||||
|
||||
#elif defined(HAVE_SELECT) |
||||
|
||||
#ifdef HAVE_SYS_SELECT_H |
||||
# include <sys/select.h> |
||||
#else |
||||
# include <sys/time.h> |
||||
# include <sys/types.h> |
||||
# include <unistd.h> |
||||
#endif |
||||
#include <stddef.h> |
||||
|
||||
void delay_ms(int msec) { |
||||
struct timeval tv; |
||||
long usec; |
||||
|
||||
usec = msec * 1000; |
||||
tv.tv_sec = usec / 1000000; |
||||
tv.tv_usec = usec % 1000000; |
||||
select(0, NULL, NULL, NULL, &tv); |
||||
} |
||||
|
||||
#else |
||||
#error Missing implementation of delay_ms() |
||||
#endif |
||||
@ -1,14 +0,0 @@ |
||||
#ifdef __OS2__ |
||||
#define INCL_DOSPROCESS |
||||
#include <os2.h> |
||||
void usleep (unsigned long usec) { |
||||
DosSleep (usec / 1000); |
||||
} |
||||
#endif |
||||
|
||||
#ifdef _DOS |
||||
#include <dos.h> |
||||
void usleep (unsigned long usec) { |
||||
delay (usec / 1000); /* doesn't seem to use int 15h. */ |
||||
} |
||||
#endif |
||||
@ -1,48 +0,0 @@ |
||||
#ifndef HAVE_USLEEP |
||||
|
||||
#ifdef HAVE_SELECT |
||||
|
||||
#ifdef HAVE_SYS_SELECT_H |
||||
# include <sys/select.h> |
||||
#else |
||||
# include <sys/time.h> |
||||
# include <sys/types.h> |
||||
# include <unistd.h> |
||||
#endif |
||||
|
||||
void usleep(long usec) |
||||
{ |
||||
struct timeval tv; |
||||
|
||||
tv.tv_sec = usec / 1000000; |
||||
tv.tv_usec = usec % 1000000; |
||||
select(0, NULL, NULL, NULL, &tv); |
||||
} |
||||
|
||||
#elif defined(_WIN32) |
||||
|
||||
/* usleep implementation from FreeSCI */ |
||||
|
||||
#include <windows.h> |
||||
|
||||
void usleep (long usec) |
||||
{ |
||||
LARGE_INTEGER lFrequency; |
||||
LARGE_INTEGER lEndTime; |
||||
LARGE_INTEGER lCurTime; |
||||
|
||||
QueryPerformanceFrequency (&lFrequency); |
||||
if (lFrequency.QuadPart) { |
||||
QueryPerformanceCounter (&lEndTime); |
||||
lEndTime.QuadPart += (LONGLONG) usec * |
||||
lFrequency.QuadPart / 1000000; |
||||
do { |
||||
QueryPerformanceCounter (&lCurTime); |
||||
Sleep(0); |
||||
} while (lCurTime.QuadPart < lEndTime.QuadPart); |
||||
} |
||||
} |
||||
|
||||
#endif |
||||
|
||||
#endif /* !HAVE_USLEEP */ |
||||
Loading…
Reference in new issue