forked from enlightenment/efl
eina: detect page size in a portable way.
This commit is contained in:
parent
35228f32f1
commit
ecaca1d365
|
@ -825,7 +825,7 @@ EFL_CHECK_GCC_BUILTIN([bswap64], [HAVE_BSWAP64])
|
||||||
|
|
||||||
AC_CHECK_FUNCS([fchmod])
|
AC_CHECK_FUNCS([fchmod])
|
||||||
|
|
||||||
EFL_CHECK_FUNCS([EINA], [dlopen dladdr iconv shm_open splice setxattr])
|
EFL_CHECK_FUNCS([EINA], [dlopen dladdr iconv shm_open splice setxattr getpagesize])
|
||||||
|
|
||||||
enable_log="no"
|
enable_log="no"
|
||||||
if test "x${efl_func_fnmatch}" = "xyes" && test "x${want_log}" = "xyes" ; then
|
if test "x${efl_func_fnmatch}" = "xyes" && test "x${want_log}" = "xyes" ; then
|
||||||
|
|
|
@ -235,6 +235,20 @@ long ret = splice(0, 0, 1, 0, 400, 0);
|
||||||
]])
|
]])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl _EFL_CHECK_FUNC_GETPAGESIZE is for internal use
|
||||||
|
dnl _EFL_CHECK_FUNC_GETPAGESIZE(EFL, VARIABLE)
|
||||||
|
AC_DEFUN([_EFL_CHECK_FUNC_GETPAGESIZE],
|
||||||
|
[EFL_FIND_LIB_FOR_CODE([$1], [], [$2], [[
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
]],
|
||||||
|
[[
|
||||||
|
long sz;
|
||||||
|
sz = getpagesize();
|
||||||
|
]])
|
||||||
|
])
|
||||||
|
|
||||||
dnl Macro that checks function availability
|
dnl Macro that checks function availability
|
||||||
dnl
|
dnl
|
||||||
dnl EFL_CHECK_FUNC(EFL, FUNCTION)
|
dnl EFL_CHECK_FUNC(EFL, FUNCTION)
|
||||||
|
|
|
@ -46,13 +46,17 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "eina_log.h"
|
||||||
#include "eina_cpu.h"
|
#include "eina_cpu.h"
|
||||||
|
|
||||||
/*============================================================================*
|
/*============================================================================*
|
||||||
* Local *
|
* Local *
|
||||||
*============================================================================*/
|
*============================================================================*/
|
||||||
|
|
||||||
|
static void _eina_page_size(void);
|
||||||
|
|
||||||
/* FIXME this ifdefs should be replaced */
|
/* FIXME this ifdefs should be replaced */
|
||||||
#if defined(__i386__) || defined(__x86_64__)
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
/* We save ebx and restore it to be PIC compatible */
|
/* We save ebx and restore it to be PIC compatible */
|
||||||
|
@ -140,6 +144,9 @@ eina_cpu_init(void)
|
||||||
#endif
|
#endif
|
||||||
// FIXME: Handle NEON and friends
|
// FIXME: Handle NEON and friends
|
||||||
|
|
||||||
|
// Figure out the page size for this system
|
||||||
|
_eina_page_size();
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,6 +244,40 @@ _eina_cpu_count_internal(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _page_size = 0;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_eina_page_size(void)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
SYSTEM_INFO si;
|
||||||
|
|
||||||
|
GetSystemInfo(&si);
|
||||||
|
|
||||||
|
_page_size = (int)si.dwPageSize;
|
||||||
|
#elif defined _SC_PAGESIZE
|
||||||
|
_page_size = (int)sysconf(_SC_PAGESIZE);
|
||||||
|
#elif defined _SC_PAGE_SIZE
|
||||||
|
_page_size = (int)sysconf(_SC_PAGE_SIZE);
|
||||||
|
#elif defined HAVE_GETPAGESIZE
|
||||||
|
_page_size = getpagesize();
|
||||||
|
#else
|
||||||
|
# warn "Falling back to a safe default page size (4K) !"
|
||||||
|
_page_size = 4096;
|
||||||
|
#endif
|
||||||
|
if (_page_size < 1)
|
||||||
|
{
|
||||||
|
EINA_LOG_ERR("system reported weird value for PAGESIZE, assuming 4096.");
|
||||||
|
_page_size = 4096;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI int eina_cpu_page_size(void)
|
||||||
|
{
|
||||||
|
if (_page_size == 0) _eina_page_size();
|
||||||
|
return _page_size;
|
||||||
|
}
|
||||||
|
|
||||||
EAPI int eina_cpu_count(void)
|
EAPI int eina_cpu_count(void)
|
||||||
{
|
{
|
||||||
return _cpu_count;
|
return _cpu_count;
|
||||||
|
|
|
@ -40,6 +40,7 @@ EAPI extern Eina_Cpu_Features eina_cpu_features;
|
||||||
|
|
||||||
EAPI Eina_Cpu_Features eina_cpu_features_get(void);
|
EAPI Eina_Cpu_Features eina_cpu_features_get(void);
|
||||||
EAPI int eina_cpu_count(void);
|
EAPI int eina_cpu_count(void);
|
||||||
|
EAPI int eina_cpu_page_size(void);
|
||||||
|
|
||||||
static inline unsigned short eina_swap16(unsigned short x);
|
static inline unsigned short eina_swap16(unsigned short x);
|
||||||
static inline unsigned int eina_swap32(unsigned int x);
|
static inline unsigned int eina_swap32(unsigned int x);
|
||||||
|
|
Loading…
Reference in New Issue