Previous 199869 Revisions Next

r39882 Tuesday 14th July, 2015 at 19:54:21 UTC by Thomas Klausner
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>
[3rdparty/portmidi/porttime]ptlinux.c

trunk/3rdparty/portmidi/porttime/ptlinux.c
r248393r248394
3838#define FALSE 0
3939
4040static int time_started_flag = FALSE;
41static struct timeb time_offset = {0, 0, 0, 0};
41static struct timeval time_offset = {0, 0};
4242static pthread_t pt_thread_pid;
4343static int pt_thread_created = FALSE;
4444
r248393r248394
7979PtError Pt_Start(int resolution, PtCallback *callback, void *userData)
8080{
8181    if (time_started_flag) return ptNoError;
82    ftime(&time_offset); /* need this set before process runs */
82    gettimeofday(&time_offset, NULL); /* need this set before process runs */
8383    if (callback) {
8484        int res;
8585        pt_callback_parameters *parms = (pt_callback_parameters *)
r248393r248394
121121PtTimestamp Pt_Time()
122122{
123123    long seconds, milliseconds;
124    struct timeb now;
125    ftime(&now);
126    seconds = now.time - time_offset.time;
127    milliseconds = now.millitm - time_offset.millitm;
124    struct timeval now;
125    gettimeofday(&now, NULL);
126    seconds = now.tv_sec - time_offset.tv_sec;
127    milliseconds = now.tv_usec - time_offset.tv_usec;
128128    return seconds * 1000 + milliseconds;
129129}
130130

Previous 199869 Revisions Next


© 1997-2024 The MAME Team