forked from enlightenment/efl
eina: use portable infrastructure to detect page size.
This commit is contained in:
parent
ecaca1d365
commit
da559ee5d0
|
@ -37,7 +37,6 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#define PATH_DELIM '/'
|
#define PATH_DELIM '/'
|
||||||
#define COPY_BLOCKSIZE (4 * 1024 * 1024)
|
|
||||||
|
|
||||||
#include "eina_config.h"
|
#include "eina_config.h"
|
||||||
#include "eina_private.h"
|
#include "eina_private.h"
|
||||||
|
@ -67,7 +66,7 @@
|
||||||
* @cond LOCAL
|
* @cond LOCAL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define EINA_SMALL_PAGE 4096
|
#define EINA_SMALL_PAGE eina_cpu_page_size()
|
||||||
#define EINA_HUGE_PAGE 16 * 1024 * 1024
|
#define EINA_HUGE_PAGE 16 * 1024 * 1024
|
||||||
|
|
||||||
#ifdef HAVE_DIRENT_H
|
#ifdef HAVE_DIRENT_H
|
||||||
|
|
|
@ -147,12 +147,8 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled)
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
||||||
/* find out system page size the cleanest way we can */
|
/* find out system page size the cleanest way we can */
|
||||||
#ifdef _SC_PAGESIZE
|
_eina_mmap_pagesize = eina_cpu_page_size();
|
||||||
_eina_mmap_pagesize = sysconf(_SC_PAGESIZE);
|
|
||||||
if (_eina_mmap_pagesize <= 0) return EINA_FALSE;
|
|
||||||
#else
|
|
||||||
_eina_mmap_pagesize = 4096;
|
|
||||||
#endif
|
|
||||||
/* no zero page device - open it */
|
/* no zero page device - open it */
|
||||||
if (_eina_mmap_zero_fd < 0)
|
if (_eina_mmap_zero_fd < 0)
|
||||||
{
|
{
|
||||||
|
@ -169,7 +165,6 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled)
|
||||||
flags |= FD_CLOEXEC;
|
flags |= FD_CLOEXEC;
|
||||||
fcntl(_eina_mmap_zero_fd, F_SETFD, flags);
|
fcntl(_eina_mmap_zero_fd, F_SETFD, flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
/* set up signal handler for SIGBUS */
|
/* set up signal handler for SIGBUS */
|
||||||
sa.sa_sigaction = _eina_mmap_safe_sigbus;
|
sa.sa_sigaction = _eina_mmap_safe_sigbus;
|
||||||
|
|
|
@ -65,6 +65,7 @@ static int _eina_chained_mp_log_dom = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int aligned_chained_pool = 0;
|
static int aligned_chained_pool = 0;
|
||||||
|
static int page_size = 0;
|
||||||
|
|
||||||
typedef struct _Chained_Mempool Chained_Mempool;
|
typedef struct _Chained_Mempool Chained_Mempool;
|
||||||
struct _Chained_Mempool
|
struct _Chained_Mempool
|
||||||
|
@ -467,8 +468,8 @@ eina_chained_mempool_init(const char *context,
|
||||||
|
|
||||||
mp->item_alloc = eina_mempool_alignof(item_size);
|
mp->item_alloc = eina_mempool_alignof(item_size);
|
||||||
|
|
||||||
mp->pool_size = (((((mp->item_alloc * mp->pool_size + aligned_chained_pool) / 4096)
|
mp->pool_size = (((((mp->item_alloc * mp->pool_size + aligned_chained_pool) / page_size)
|
||||||
+ 1) * 4096)
|
+ 1) * page_size)
|
||||||
- aligned_chained_pool) / mp->item_alloc;
|
- aligned_chained_pool) / mp->item_alloc;
|
||||||
|
|
||||||
#ifdef EINA_DEBUG_MALLOC
|
#ifdef EINA_DEBUG_MALLOC
|
||||||
|
@ -558,6 +559,7 @@ Eina_Bool chained_init(void)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
aligned_chained_pool = eina_mempool_alignof(sizeof(Chained_Pool));
|
aligned_chained_pool = eina_mempool_alignof(sizeof(Chained_Pool));
|
||||||
|
page_size = eina_cpu_page_size();
|
||||||
|
|
||||||
return eina_mempool_register(&_eina_chained_mp_backend);
|
return eina_mempool_register(&_eina_chained_mp_backend);
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,7 @@ START_TEST(eina_file_map_new_test)
|
||||||
char *big_buffer;
|
char *big_buffer;
|
||||||
const char *template = "abcdefghijklmnopqrstuvwxyz";
|
const char *template = "abcdefghijklmnopqrstuvwxyz";
|
||||||
int template_size = strlen(template);
|
int template_size = strlen(template);
|
||||||
int memory_page_size = sysconf(_SC_PAGE_SIZE);
|
int memory_page_size = eina_cpu_page_size();
|
||||||
const int big_buffer_size = memory_page_size * 1.5;
|
const int big_buffer_size = memory_page_size * 1.5;
|
||||||
const int iteration_number = big_buffer_size / template_size;
|
const int iteration_number = big_buffer_size / template_size;
|
||||||
int test_string_length = strlen(eina_map_test_string);
|
int test_string_length = strlen(eina_map_test_string);
|
||||||
|
|
Loading…
Reference in New Issue