File tree Expand file tree Collapse file tree 7 files changed +35
-17
lines changed Expand file tree Collapse file tree 7 files changed +35
-17
lines changed Original file line number Diff line number Diff line change 2727// Please use C89 style variable declarations in this file because VS 2010
2828//========================================================================
2929
30- #define MONOTONIC_START_MODULE
3130#include "internal.h"
3231#include "mappings.h"
3332
Original file line number Diff line number Diff line change 1+ /*
2+ * monotonic.c
3+ * Copyright (C) 2019 Kovid Goyal <kovid at kovidgoyal.net>
4+ *
5+ * Distributed under terms of the GPL3 license.
6+ */
7+
8+ #define _POSIX_C_SOURCE 200809L
9+ #define MONOTONIC_IMPLEMENTATION
10+ #include "../kitty/monotonic.h"
Original file line number Diff line number Diff line change 3131 " input.c" ,
3232 " monitor.c" ,
3333 " vulkan.c" ,
34+ " monotonic.c" ,
3435 " window.c"
3536 ]
3637 },
Original file line number Diff line number Diff line change 55 * Distributed under terms of the GPL3 license.
66 */
77
8- #define MONOTONIC_START_MODULE
98#ifdef __APPLE__
109// Needed for _CS_DARWIN_USER_CACHE_DIR
1110#define _DARWIN_C_SOURCE
Original file line number Diff line number Diff line change 1+ /*
2+ * monotonic.c
3+ * Copyright (C) 2019 Kovid Goyal <kovid at kovidgoyal.net>
4+ *
5+ * Distributed under terms of the GPL3 license.
6+ */
7+
8+ #define _POSIX_C_SOURCE 200809L
9+ #define MONOTONIC_IMPLEMENTATION
10+ #include "monotonic.h"
Original file line number Diff line number Diff line change @@ -61,14 +61,21 @@ static inline double monotonic_t_to_s_double(monotonic_t time) {
6161 return (double )time / 1000.0 / 1000.0 / 1000.0 ;
6262}
6363
64- #ifdef MONOTONIC_START_MODULE
65- monotonic_t monotonic_start_time = 0 ;
66- #else
6764extern monotonic_t monotonic_start_time ;
68- #endif
65+ extern monotonic_t monotonic_ ( void );
6966
67+ static inline monotonic_t monotonic (void ) {
68+ return monotonic_ () - monotonic_start_time ;
69+ }
7070
71- static inline monotonic_t monotonic_ (void ) {
71+ static inline void init_monotonic (void ) {
72+ monotonic_start_time = monotonic_ ();
73+ }
74+
75+ #ifdef MONOTONIC_IMPLEMENTATION
76+ monotonic_t monotonic_start_time = 0 ;
77+
78+ monotonic_t monotonic_ (void ) {
7279 struct timespec ts = {0 };
7380#ifdef CLOCK_HIGHRES
7481 clock_gettime (CLOCK_HIGHRES , & ts );
@@ -79,11 +86,4 @@ static inline monotonic_t monotonic_(void) {
7986#endif
8087 return calc_nano_time (ts );
8188}
82-
83- static inline monotonic_t monotonic (void ) {
84- return monotonic_ () - monotonic_start_time ;
85- }
86-
87- static inline void init_monotonic (void ) {
88- monotonic_start_time = monotonic_ ();
89- }
89+ #endif
Original file line number Diff line number Diff line change @@ -212,10 +212,9 @@ def init_env(
212212 cppflags = shlex .split (cppflags )
213213 for el in extra_logging :
214214 cppflags .append ('-DDEBUG_{}' .format (el .upper ().replace ('-' , '_' )))
215- # _POSIX_C_SOURCE is needed for clock_gettime() in monotonic.h
216215 cflags = os .environ .get (
217216 'OVERRIDE_CFLAGS' , (
218- '-Wextra {} -Wno-missing-field-initializers -Wall -Wstrict-prototypes -D_POSIX_C_SOURCE=200809L - std=c11'
217+ '-Wextra {} -Wno-missing-field-initializers -Wall -Wstrict-prototypes -std=c11'
219218 ' -pedantic-errors -Werror {} {} -fwrapv {} {} -pipe {} -fvisibility=hidden'
220219 ).format (
221220 float_conversion ,
You can’t perform that action at this time.
0 commit comments