From c02e802d37b52f7065b85776c583f93025055ab6 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 1 Nov 2022 09:45:49 +0300 Subject: Fix missing getpagesize() definition on OS/2 for usage by valloc() (fix of commit d4c81638d) Issue #495 (bdwgc). * include/private/gcconfig.h [I386 && OS2] (GETPAGESIZE): Define to os2_getpagesize. * os_dep.c [OS2] (INCL_DOSERRORS): Reorder among INCL_x defines lexicographically. * tools/setjmp_t.c [OS2] (INCL_DOSERRORS): Likewise. * os_dep.c [OS2] (INCL_DOSFILEMGR, INCL_DOSMISC): Define (before include os2.h). * os_dep.c [!MSWIN32 && !MSWINCE && !CYGWIN32 && OS2] (os2_getpagesize): New static function (code copied mostly from getpagesize() in setjmp_t.c). * tools/setjmp_t.c [OS2]: Update comment and move close to os2_getpagesize(). * tools/setjmp_t.c [OS2] (getpagesize): Make static and rename to os2_getpagesize. --- os_dep.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'os_dep.c') diff --git a/os_dep.c b/os_dep.c index 94219b23..16e0ffd8 100644 --- a/os_dep.c +++ b/os_dep.c @@ -689,11 +689,13 @@ struct o32_obj { # endif /* __IBMC__ */ -# define INCL_DOSEXCEPTIONS -# define INCL_DOSPROCESS # define INCL_DOSERRORS -# define INCL_DOSMODULEMGR +# define INCL_DOSEXCEPTIONS +# define INCL_DOSFILEMGR # define INCL_DOSMEMMGR +# define INCL_DOSMISC +# define INCL_DOSMODULEMGR +# define INCL_DOSPROCESS # include # endif /* OS/2 */ @@ -819,6 +821,21 @@ GC_INNER size_t GC_page_size = 0; # define HAVE_GET_STACK_BASE #else /* !MSWIN32 */ + +# ifdef OS2 + static int os2_getpagesize(void) + { + ULONG result[1]; + + if (DosQuerySysInfo(QSV_PAGE_SIZE, QSV_PAGE_SIZE, + (void *)result, sizeof(ULONG)) != NO_ERROR) { + WARN("DosQuerySysInfo failed\n", 0); + result[0] = 4096; + } + return (int)result[0]; + } +# endif /* OS2 */ + GC_INNER void GC_setpagesize(void) { # ifdef ALT_PAGESIZE_USED -- cgit v1.2.1