forked from 0ad/0ad
janwas
5299dcad86
- debug: add provision for naming threads. allows adding current thread name to log messages and displays their names in the debugger. - replaced various if(err < 0) complain() sequences with new variants of CHECK_ERR (see lib.h) - fixes to mmgr/VC debug alloc enable code - improved h_mgr error reporting (now complains when h_free fails) - US -> UK english (partial) - fix tex_load double-free bug - move win32 mouse cursor code into sysdep - error dialog is now topmost to make sure it's visible (was a problem) - handle WM_QUIT before displaying error dialog (makes sure it's shown) also as in previous 3 revisions. This was SVN commit r2588.
85 lines
1.9 KiB
C
Executable File
85 lines
1.9 KiB
C
Executable File
// Windows-specific high resolution timer
|
|
// Copyright (c) 2004 Jan Wassenberg
|
|
//
|
|
// This program is free software; you can redistribute it and/or
|
|
// modify it under the terms of the GNU General Public License as
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
// License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful, but
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
// General Public License for more details.
|
|
//
|
|
// Contact info:
|
|
// Jan.Wassenberg@stud.uni-karlsruhe.de
|
|
// http://www.stud.uni-karlsruhe.de/~urkt/
|
|
|
|
#ifndef WTIME_H__
|
|
#define WTIME_H__
|
|
|
|
// advertise support for the timer routines we emulate; used by timer.cpp.
|
|
// #undef to avoid macro redefinition warning.
|
|
#undef HAVE_CLOCK_GETTIME
|
|
#define HAVE_CLOCK_GETTIME 1
|
|
#undef HAVE_GETTIMEOFDAY
|
|
#define HAVE_GETTIMEOFDAY 1
|
|
|
|
|
|
//
|
|
// <sys/types.h>
|
|
//
|
|
|
|
typedef unsigned long useconds_t;
|
|
typedef long suseconds_t;
|
|
|
|
|
|
//
|
|
// <unistd.h>
|
|
//
|
|
|
|
extern unsigned int sleep(unsigned int sec);
|
|
extern int usleep(useconds_t us);
|
|
|
|
|
|
//
|
|
// <time.h>
|
|
//
|
|
|
|
typedef enum
|
|
{
|
|
CLOCK_REALTIME
|
|
}
|
|
clockid_t;
|
|
|
|
// BSD gettimeofday
|
|
struct timeval
|
|
{
|
|
time_t tv_sec;
|
|
suseconds_t tv_usec;
|
|
};
|
|
|
|
// POSIX realtime clock_*
|
|
struct timespec
|
|
{
|
|
time_t tv_sec;
|
|
long tv_nsec;
|
|
};
|
|
|
|
extern int gettimeofday(struct timeval* tv, void* tzp);
|
|
|
|
extern int nanosleep(const struct timespec* rqtp, struct timespec* rmtp);
|
|
extern int clock_gettime(clockid_t clock, struct timespec* ts);
|
|
extern int clock_getres(clockid_t clock, struct timespec* res);
|
|
|
|
|
|
// HACK: on Windows, the HRT makes its final implementation choice
|
|
// in the first calibrate call where cpu_freq is available.
|
|
// provide a routine that makes the choice when called,
|
|
// so app code isn't surprised by a timer change, although the HRT
|
|
// does try to keep the timer continuous.
|
|
extern void wtime_reset_impl(void);
|
|
|
|
|
|
#endif // #ifndef WTIME_H__
|