eina: use portable infrastructure to detect page size.

This commit is contained in:
Cedric BAIL 2013-11-10 09:26:12 +01:00
parent ecaca1d365
commit da559ee5d0
4 changed files with 9 additions and 13 deletions

View File

@ -37,7 +37,6 @@
#include <fcntl.h>
#define PATH_DELIM '/'
#define COPY_BLOCKSIZE (4 * 1024 * 1024)
#include "eina_config.h"
#include "eina_private.h"
@ -67,7 +66,7 @@
* @cond LOCAL
*/
#define EINA_SMALL_PAGE 4096
#define EINA_SMALL_PAGE eina_cpu_page_size()
#define EINA_HUGE_PAGE 16 * 1024 * 1024
#ifdef HAVE_DIRENT_H

View File

@ -147,12 +147,8 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled)
struct sigaction sa;
/* find out system page size the cleanest way we can */
#ifdef _SC_PAGESIZE
_eina_mmap_pagesize = sysconf(_SC_PAGESIZE);
if (_eina_mmap_pagesize <= 0) return EINA_FALSE;
#else
_eina_mmap_pagesize = 4096;
#endif
_eina_mmap_pagesize = eina_cpu_page_size();
/* no zero page device - open it */
if (_eina_mmap_zero_fd < 0)
{
@ -169,7 +165,6 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled)
flags |= FD_CLOEXEC;
fcntl(_eina_mmap_zero_fd, F_SETFD, flags);
#endif
}
/* set up signal handler for SIGBUS */
sa.sa_sigaction = _eina_mmap_safe_sigbus;

View File

@ -65,6 +65,7 @@ static int _eina_chained_mp_log_dom = -1;
#endif
static int aligned_chained_pool = 0;
static int page_size = 0;
typedef struct _Chained_Mempool 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->pool_size = (((((mp->item_alloc * mp->pool_size + aligned_chained_pool) / 4096)
+ 1) * 4096)
mp->pool_size = (((((mp->item_alloc * mp->pool_size + aligned_chained_pool) / page_size)
+ 1) * page_size)
- aligned_chained_pool) / mp->item_alloc;
#ifdef EINA_DEBUG_MALLOC
@ -558,6 +559,7 @@ Eina_Bool chained_init(void)
#endif
aligned_chained_pool = eina_mempool_alignof(sizeof(Chained_Pool));
page_size = eina_cpu_page_size();
return eina_mempool_register(&_eina_chained_mp_backend);
}

View File

@ -266,8 +266,8 @@ START_TEST(eina_file_map_new_test)
char *test_file_path, *test_file2_path;
char *big_buffer;
const char *template = "abcdefghijklmnopqrstuvwxyz";
int template_size = strlen (template);
int memory_page_size = sysconf(_SC_PAGE_SIZE);
int template_size = strlen(template);
int memory_page_size = eina_cpu_page_size();
const int big_buffer_size = memory_page_size * 1.5;
const int iteration_number = big_buffer_size / template_size;
int test_string_length = strlen(eina_map_test_string);