Make timer init part of platform API

This is part of runtime platform selection because the null backend
needs the timer implementation for the current OS.
master
Camilla Löwy ago%!(EXTRA string=4 years)
parent 6d51b39106
commit e31deedc99
  1. 2
      src/cocoa_init.m
  2. 2
      src/cocoa_platform.h
  3. 11
      src/cocoa_time.c
  4. 4
      src/init.c
  5. 1
      src/internal.h
  6. 1
      src/null_init.c
  7. 11
      src/posix_time.c
  8. 3
      src/posix_time.h
  9. 2
      src/win32_init.c
  10. 2
      src/win32_platform.h
  11. 11
      src/win32_time.c
  12. 2
      src/wl_init.c
  13. 2
      src/x11_init.c

@ -547,8 +547,6 @@ int _glfwPlatformInit(void)
if (!initializeTIS())
return GLFW_FALSE;
_glfwInitTimerNS();
_glfwPollMonitorsNS();
if (![[NSRunningApplication currentApplication] isFinishedLaunching])

@ -191,8 +191,6 @@ typedef struct _GLFWtimerNS
} _GLFWtimerNS;
void _glfwInitTimerNS(void);
void _glfwPollMonitorsNS(void);
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);

@ -32,12 +32,10 @@
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
// Initialise timer
//
void _glfwInitTimerNS(void)
void _glfwPlatformInitTimer(void)
{
mach_timebase_info_data_t info;
mach_timebase_info(&info);
@ -45,11 +43,6 @@ void _glfwInitTimerNS(void)
_glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
uint64_t _glfwPlatformGetTimerValue(void)
{
return mach_absolute_time();

@ -340,9 +340,11 @@ GLFWAPI int glfwInit(void)
_glfwInitGamepadMappings();
_glfw.initialized = GLFW_TRUE;
_glfwPlatformInitTimer();
_glfw.timer.offset = _glfwPlatformGetTimerValue();
_glfw.initialized = GLFW_TRUE;
glfwDefaultWindowHints();
return GLFW_TRUE;
}

@ -644,6 +644,7 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode);
void _glfwPlatformUpdateGamepadGUID(char* guid);
const char* _glfwPlatformGetMappingName(void);
void _glfwPlatformInitTimer(void);
uint64_t _glfwPlatformGetTimerValue(void);
uint64_t _glfwPlatformGetTimerFrequency(void);

@ -38,7 +38,6 @@
int _glfwPlatformInit(void)
{
_glfwInitTimerPOSIX();
_glfwPollMonitorsNull();
return GLFW_TRUE;

@ -34,12 +34,10 @@
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
// Initialise timer
//
void _glfwInitTimerPOSIX(void)
void _glfwPlatformInitTimer(void)
{
_glfw.timer.posix.clock = CLOCK_REALTIME;
_glfw.timer.posix.frequency = 1000000000;
@ -51,11 +49,6 @@ void _glfwInitTimerPOSIX(void)
#endif
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
uint64_t _glfwPlatformGetTimerValue(void)
{
struct timespec ts;

@ -39,6 +39,3 @@ typedef struct _GLFWtimerPOSIX
uint64_t frequency;
} _GLFWtimerPOSIX;
void _glfwInitTimerPOSIX(void);

@ -576,8 +576,6 @@ int _glfwPlatformInit(void)
if (!createHelperWindow())
return GLFW_FALSE;
_glfwInitTimerWin32();
_glfwPollMonitorsWin32();
return GLFW_TRUE;
}

@ -445,8 +445,6 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build);
void _glfwInputErrorWin32(int error, const char* description);
void _glfwUpdateKeyNamesWin32(void);
void _glfwInitTimerWin32(void);
void _glfwPollMonitorsWin32(void);
void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);

@ -31,12 +31,10 @@
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
// Initialise timer
//
void _glfwInitTimerWin32(void)
void _glfwPlatformInitTimer(void)
{
uint64_t frequency;
@ -52,11 +50,6 @@ void _glfwInitTimerWin32(void)
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
uint64_t _glfwPlatformGetTimerValue(void)
{
if (_glfw.timer.win32.hasPC)

@ -1227,8 +1227,6 @@ int _glfwPlatformInit(void)
// Sync so we got all initial output events
wl_display_roundtrip(_glfw.wl.display);
_glfwInitTimerPOSIX();
_glfw.wl.timerfd = -1;
if (_glfw.wl.seatVersion >= 4)
_glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);

@ -1381,8 +1381,6 @@ int _glfwPlatformInit(void)
NULL);
}
_glfwInitTimerPOSIX();
_glfwPollMonitorsX11();
return GLFW_TRUE;
}

Loading…
Cancel
Save