mirror of
https://github.com/holub/mame
synced 2025-10-04 16:34:53 +03:00
Switch from ftime() to gettimeofday().
Even the Linux man page recommends avoiding ftime(). gettimeofday is in POSIX.1-2001 and more portable. Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
This commit is contained in:
parent
910f0215e8
commit
456590ce3e
12
3rdparty/portmidi/porttime/ptlinux.c
vendored
12
3rdparty/portmidi/porttime/ptlinux.c
vendored
@ -38,7 +38,7 @@ CHANGE LOG
|
|||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
|
|
||||||
static int time_started_flag = FALSE;
|
static int time_started_flag = FALSE;
|
||||||
static struct timeb time_offset = {0, 0, 0, 0};
|
static struct timeval time_offset = {0, 0};
|
||||||
static pthread_t pt_thread_pid;
|
static pthread_t pt_thread_pid;
|
||||||
static int pt_thread_created = FALSE;
|
static int pt_thread_created = FALSE;
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ static void *Pt_CallbackProc(void *p)
|
|||||||
PtError Pt_Start(int resolution, PtCallback *callback, void *userData)
|
PtError Pt_Start(int resolution, PtCallback *callback, void *userData)
|
||||||
{
|
{
|
||||||
if (time_started_flag) return ptNoError;
|
if (time_started_flag) return ptNoError;
|
||||||
ftime(&time_offset); /* need this set before process runs */
|
gettimeofday(&time_offset, NULL); /* need this set before process runs */
|
||||||
if (callback) {
|
if (callback) {
|
||||||
int res;
|
int res;
|
||||||
pt_callback_parameters *parms = (pt_callback_parameters *)
|
pt_callback_parameters *parms = (pt_callback_parameters *)
|
||||||
@ -121,10 +121,10 @@ int Pt_Started()
|
|||||||
PtTimestamp Pt_Time()
|
PtTimestamp Pt_Time()
|
||||||
{
|
{
|
||||||
long seconds, milliseconds;
|
long seconds, milliseconds;
|
||||||
struct timeb now;
|
struct timeval now;
|
||||||
ftime(&now);
|
gettimeofday(&now, NULL);
|
||||||
seconds = now.time - time_offset.time;
|
seconds = now.tv_sec - time_offset.tv_sec;
|
||||||
milliseconds = now.millitm - time_offset.millitm;
|
milliseconds = now.tv_usec - time_offset.tv_usec;
|
||||||
return seconds * 1000 + milliseconds;
|
return seconds * 1000 + milliseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user