check_function_exists( dl_iterate_phdr HAVE_DL_ITERATE_PHDR )
check_function_exists( drand48 HAVE_DRAND48 )
-check_function_exists( getpagesize HAVE_GETPAGESIZE )
check_function_exists( lrand48 HAVE_LRAND48 )
check_function_exists( setenv HAVE_SETENV )
check_function_exists( setmode HAVE_SETMODE )
// Functions
#cmakedefine HAVE_DL_ITERATE_PHDR
#cmakedefine HAVE_DRAND48
-#cmakedefine HAVE_GETPAGESIZE
#cmakedefine HAVE_LRAND48
#cmakedefine HAVE_SETENV
#cmakedefine HAVE_SETMODE
# Checks for library functions
AC_CHECK_FUNCS([lrand48 drand48 srand48 setmode setenv \
- getpagesize \
ftruncate lseek64 stat64 select dl_iterate_phdr])
AC_REPLACE_FUNCS([strcasestr])
/* grain size for buffer increment */
#define SF_GRAIN 1024
-#define SF_PAGE ((ssize_t)(SF_GRAIN*sizeof(int)*2))
/* when the buffer is empty, certain io requests may be better done directly
on the given application buffers. The below condition determines when.
#include <stddef.h>
#include <sfio/sfhdr.h>
+#include <unistd.h>
-#ifdef HAVE_GETPAGESIZE
- extern int getpagesize(void);
+#ifdef _WIN32
+#include <windows.h>
+#include <sysinfoapi.h>
#endif
+
+static ssize_t get_page_size(void) {
+#ifdef _WIN32
+ SYSTEM_INFO info;
+ GetSystemInfo(&info);
+ return (ssize_t)info.dwPageSize;
+#else
+ return (ssize_t)sysconf(_SC_PAGESIZE);
+#endif
+}
+
/* Set a (new) buffer for a stream.
** If size < 0, it is assigned a suitable value depending on the
** kind of stream. The actual buffer size allocated is dependent
/* set page size, this is also the desired default buffer size */
if (_Sfpage <= 0) {
-#ifdef HAVE_GETPAGESIZE
- if ((_Sfpage = (size_t) getpagesize()) <= 0)
-#endif
- _Sfpage = SF_PAGE;
+ _Sfpage = get_page_size();
}
}