File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 13
13
14
14
#include "base_alloc.h"
15
15
#include "base_alloc_global.h"
16
+ #include "utils_concurrency.h"
17
+
18
+ static UTIL_ONCE_FLAG Page_size_is_initialized = UTIL_ONCE_FLAG_INIT ;
19
+ static size_t Page_size ;
16
20
17
21
// The highest possible priority (101) is used, because the constructor should be called
18
22
// as the first one and the destructor as the last one in order to avoid use-after-free.
@@ -33,4 +37,9 @@ void ba_os_free(void *ptr, size_t size) {
33
37
(void )ret ; // unused
34
38
}
35
39
36
- size_t ba_os_get_page_size (void ) { return sysconf (_SC_PAGE_SIZE ); }
40
+ static void _ba_os_init_page_size (void ) { Page_size = sysconf (_SC_PAGE_SIZE ); }
41
+
42
+ size_t ba_os_get_page_size (void ) {
43
+ util_init_once (& Page_size_is_initialized , _ba_os_init_page_size );
44
+ return Page_size ;
45
+ }
You can’t perform that action at this time.
0 commit comments