Cache PAGE_SIZE

man:sysconf(3) states:
    The values obtained from these functions are system configuration constants.
    They do not change during the lifetime of a process.
This commit is contained in:
Christian Göttsche
2020-10-15 22:37:02 +02:00
parent 0db398d4c3
commit 361877454f
11 changed files with 60 additions and 49 deletions

7
CRT.c
View File

@ -544,6 +544,9 @@ const char* CRT_termType;
int CRT_colorScheme = 0;
long CRT_pageSize = -1;
long CRT_pageSizeKB = -1;
ATTR_NORETURN
static void CRT_handleSIGTERM(int sgn) {
(void) sgn;
@ -675,6 +678,10 @@ void CRT_init(int delay, int colorScheme, bool allowUnicode) {
mousemask(BUTTON1_RELEASED, NULL);
#endif
CRT_pageSize = sysconf(_SC_PAGESIZE);
if (CRT_pageSize == -1)
CRT_fatalError("Fatal error: Can not get PAGE_SIZE by sysconf(_SC_PAGESIZE)");
CRT_pageSizeKB = CRT_pageSize / 1024;
}
void CRT_done() {