Skip to content

Commit 38b435f

Browse files
SiegeLordExSiegeLord
authored andcommitted
Move the time routines into the system driver.
This simplifies the implementation of new drivers, and fixes the oddities with doc generation. First steps towards fixing #996.
1 parent e949a85 commit 38b435f

File tree

15 files changed

+105
-45
lines changed

15 files changed

+105
-45
lines changed

include/allegro5/internal/aintern_system.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ struct ALLEGRO_SYSTEM_INTERFACE
4848
void (*close_library)(void *handle);
4949
void (*heartbeat)(void);
5050
void (*heartbeat_init)(void);
51+
double (*get_time)(void);
52+
void (*rest)(double seconds);
53+
void (*init_timeout)(ALLEGRO_TIMEOUT *timeout, double seconds);
5154
};
5255

5356
struct ALLEGRO_SYSTEM

include/allegro5/platform/aintunix.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#ifndef __al_included_allegro5_aintunix_h
1919
#define __al_included_allegro5_aintunix_h
2020

21+
#include "allegro5/altime.h"
2122
#include "allegro5/path.h"
2223
#include "allegro5/internal/aintern_driver.h"
2324

@@ -30,7 +31,10 @@
3031
extern "C" {
3132
#endif
3233

33-
AL_FUNC(ALLEGRO_PATH *, _al_unix_get_path, (int id));
34+
ALLEGRO_PATH *_al_unix_get_path(int id);
35+
double _al_unix_get_time(void);
36+
void _al_unix_rest(double seconds);
37+
void _al_unix_init_timeout(ALLEGRO_TIMEOUT *timeout, double seconds);
3438

3539

3640
#ifdef __cplusplus
@@ -60,7 +64,7 @@ extern "C" {
6064
#endif
6165

6266
/* time */
63-
AL_FUNC(void, _al_unix_init_time, (void));
67+
void _al_unix_init_time(void);
6468

6569
/* fdwatch */
6670
void _al_unix_start_watching_fd(int fd, void (*callback)(void *), void *cb_data);

include/allegro5/platform/aintwin.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ void _al_win_touch_input_handle_cancel(int id, size_t timestamp, float x, float
289289
AL_FUNC(const char*, _al_win_error, (DWORD));
290290
AL_FUNC(const char*, _al_win_last_error, (void));
291291

292+
/* Time handling */
293+
double _al_win_get_time(void);
294+
void _al_win_rest(double seconds);
295+
void _al_win_init_timeout(ALLEGRO_TIMEOUT *timeout, double seconds);
296+
292297
#ifdef __cplusplus
293298
}
294299
#endif

include/allegro5/platform/allegro_internal_sdl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "SDL.h"
22

3+
#include "allegro5/altime.h"
34
#include "allegro5/internal/aintern_display.h"
45
#include "allegro5/internal/aintern_keyboard.h"
56
#include "allegro5/internal/aintern_mouse.h"
@@ -46,3 +47,6 @@ float _al_sdl_get_display_pixel_ratio(ALLEGRO_DISPLAY *display);
4647

4748
void _al_sdl_event_hack(void);
4849

50+
double _al_sdl_get_time(void);
51+
void _al_sdl_rest(double seconds);
52+
void _al_sdl_init_timeout(ALLEGRO_TIMEOUT *timeout, double seconds);

src/android/android_system.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,9 @@ ALLEGRO_SYSTEM_INTERFACE *_al_system_android_interface()
545545
android_vt->get_path = _al_android_get_path;
546546
android_vt->shutdown_system = android_shutdown_system;
547547
android_vt->inhibit_screensaver = android_inhibit_screensaver;
548+
android_vt->get_time = _al_unix_get_time;
549+
android_vt->rest = _al_unix_rest;
550+
android_vt->init_timeout = _al_unix_init_timeout;
548551

549552
return android_vt;
550553
}

src/gp2xwiz/wiz_system.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ ALLEGRO_SYSTEM_INTERFACE *_al_system_gp2xwiz_driver(void)
156156
gp2xwiz_vt->get_path = _al_unix_get_path;
157157
gp2xwiz_vt->inhibit_screensaver = gp2xwiz_inhibit_screensaver;
158158
gp2xwiz_vt->get_num_display_formats = gp2xwiz_get_num_display_formats;
159+
gp2xwiz_vt->get_time = _al_unix_get_time;
160+
gp2xwiz_vt->rest = _al_unix_rest;
161+
gp2xwiz_vt->init_timeout = _al_unix_init_timeout;
159162

160163
return gp2xwiz_vt;
161164
}

src/macosx/system.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,9 @@ static void osx_thread_exit(ALLEGRO_THREAD *thread)
542542
vt->inhibit_screensaver = osx_inhibit_screensaver;
543543
vt->thread_init = osx_thread_init;
544544
vt->thread_exit = osx_thread_exit;
545+
vt->get_time = _al_unix_get_time;
546+
vt->rest = _al_unix_rest;
547+
vt->init_timeout = _al_unix_init_timeout;
545548

546549
};
547550

src/raspberrypi/pisystem.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ ALLEGRO_SYSTEM_INTERFACE *_al_system_raspberrypi_driver(void)
195195
pi_vt->get_cursor_position = pi_get_cursor_position;
196196
pi_vt->get_path = _al_unix_get_path;
197197
pi_vt->inhibit_screensaver = pi_inhibit_screensaver;
198+
pi_vt->get_time = _al_unix_get_time;
199+
pi_vt->rest = _al_unix_rest;
200+
pi_vt->init_timeout = _al_unix_init_timeout;
198201

199202
return pi_vt;
200203
}

src/sdl/sdl_system.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ ALLEGRO_SYSTEM_INTERFACE *_al_sdl_system_driver(void)
342342
vt->close_library = sdl_close_library;*/
343343
vt->heartbeat = sdl_heartbeat;
344344
vt->heartbeat_init = sdl_heartbeat_init;
345+
vt->get_time = _al_sdl_get_time;
346+
vt->rest = _al_sdl_rest;
347+
vt->init_timeout = _al_sdl_init_timeout;
345348

346349
return vt;
347350
}

src/sdl/sdl_time.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020

2121
ALLEGRO_DEBUG_CHANNEL("SDL")
2222

23-
double al_get_time(void)
23+
double _al_sdl_get_time(void)
2424
{
2525
return 1.0 * SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency();
2626
}
2727

2828

2929

30-
void al_rest(double seconds)
30+
void _al_sdl_rest(double seconds)
3131
{
3232
SDL_Delay(seconds * 1000);
3333
}
3434

3535

3636

37-
void al_init_timeout(ALLEGRO_TIMEOUT *timeout, double seconds)
37+
void _al_sdl_init_timeout(ALLEGRO_TIMEOUT *timeout, double seconds)
3838
{
3939
ALLEGRO_TIMEOUT_SDL *timeout_sdl = (void *)timeout;
4040
timeout_sdl->ms = seconds * 1000;

0 commit comments

Comments
 (0)