diff options
author | Cedric BAIL <cedric@efl.so> | 2013-11-10 09:26:12 +0100 |
---|---|---|
committer | Cedric BAIL <cedric@efl.so> | 2013-11-10 09:26:12 +0100 |
commit | da559ee5d0403b145a334c26c5cf9c45cf03f40f (patch) | |
tree | f83ca3831e76cfc88eedbae2d0cc8935f450d193 /src | |
parent | ecaca1d365b998b3e339b387897c0646b2b3556f (diff) |
eina: use portable infrastructure to detect page size.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/eina/eina_file.c | 3 | ||||
-rw-r--r-- | src/lib/eina/eina_mmap.c | 9 | ||||
-rw-r--r-- | src/modules/eina/mp/chained_pool/eina_chained_mempool.c | 6 | ||||
-rw-r--r-- | src/tests/eina/eina_test_file.c | 4 |
4 files changed, 9 insertions, 13 deletions
diff --git a/src/lib/eina/eina_file.c b/src/lib/eina/eina_file.c index 7b8aaff9e6..6d7ee56f54 100644 --- a/src/lib/eina/eina_file.c +++ b/src/lib/eina/eina_file.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <fcntl.h> | 37 | #include <fcntl.h> |
38 | 38 | ||
39 | #define PATH_DELIM '/' | 39 | #define PATH_DELIM '/' |
40 | #define COPY_BLOCKSIZE (4 * 1024 * 1024) | ||
41 | 40 | ||
42 | #include "eina_config.h" | 41 | #include "eina_config.h" |
43 | #include "eina_private.h" | 42 | #include "eina_private.h" |
@@ -67,7 +66,7 @@ | |||
67 | * @cond LOCAL | 66 | * @cond LOCAL |
68 | */ | 67 | */ |
69 | 68 | ||
70 | #define EINA_SMALL_PAGE 4096 | 69 | #define EINA_SMALL_PAGE eina_cpu_page_size() |
71 | #define EINA_HUGE_PAGE 16 * 1024 * 1024 | 70 | #define EINA_HUGE_PAGE 16 * 1024 * 1024 |
72 | 71 | ||
73 | #ifdef HAVE_DIRENT_H | 72 | #ifdef HAVE_DIRENT_H |
diff --git a/src/lib/eina/eina_mmap.c b/src/lib/eina/eina_mmap.c index d8fd2e55f8..8b2853e443 100644 --- a/src/lib/eina/eina_mmap.c +++ b/src/lib/eina/eina_mmap.c | |||
@@ -147,12 +147,8 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled) | |||
147 | struct sigaction sa; | 147 | struct sigaction sa; |
148 | 148 | ||
149 | /* find out system page size the cleanest way we can */ | 149 | /* find out system page size the cleanest way we can */ |
150 | #ifdef _SC_PAGESIZE | 150 | _eina_mmap_pagesize = eina_cpu_page_size(); |
151 | _eina_mmap_pagesize = sysconf(_SC_PAGESIZE); | 151 | |
152 | if (_eina_mmap_pagesize <= 0) return EINA_FALSE; | ||
153 | #else | ||
154 | _eina_mmap_pagesize = 4096; | ||
155 | #endif | ||
156 | /* no zero page device - open it */ | 152 | /* no zero page device - open it */ |
157 | if (_eina_mmap_zero_fd < 0) | 153 | if (_eina_mmap_zero_fd < 0) |
158 | { | 154 | { |
@@ -169,7 +165,6 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled) | |||
169 | flags |= FD_CLOEXEC; | 165 | flags |= FD_CLOEXEC; |
170 | fcntl(_eina_mmap_zero_fd, F_SETFD, flags); | 166 | fcntl(_eina_mmap_zero_fd, F_SETFD, flags); |
171 | #endif | 167 | #endif |
172 | |||
173 | } | 168 | } |
174 | /* set up signal handler for SIGBUS */ | 169 | /* set up signal handler for SIGBUS */ |
175 | sa.sa_sigaction = _eina_mmap_safe_sigbus; | 170 | sa.sa_sigaction = _eina_mmap_safe_sigbus; |
diff --git a/src/modules/eina/mp/chained_pool/eina_chained_mempool.c b/src/modules/eina/mp/chained_pool/eina_chained_mempool.c index b71b79dcf4..67e2e6a7cf 100644 --- a/src/modules/eina/mp/chained_pool/eina_chained_mempool.c +++ b/src/modules/eina/mp/chained_pool/eina_chained_mempool.c | |||
@@ -65,6 +65,7 @@ static int _eina_chained_mp_log_dom = -1; | |||
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | static int aligned_chained_pool = 0; | 67 | static int aligned_chained_pool = 0; |
68 | static int page_size = 0; | ||
68 | 69 | ||
69 | typedef struct _Chained_Mempool Chained_Mempool; | 70 | typedef struct _Chained_Mempool Chained_Mempool; |
70 | struct _Chained_Mempool | 71 | struct _Chained_Mempool |
@@ -467,8 +468,8 @@ eina_chained_mempool_init(const char *context, | |||
467 | 468 | ||
468 | mp->item_alloc = eina_mempool_alignof(item_size); | 469 | mp->item_alloc = eina_mempool_alignof(item_size); |
469 | 470 | ||
470 | mp->pool_size = (((((mp->item_alloc * mp->pool_size + aligned_chained_pool) / 4096) | 471 | mp->pool_size = (((((mp->item_alloc * mp->pool_size + aligned_chained_pool) / page_size) |
471 | + 1) * 4096) | 472 | + 1) * page_size) |
472 | - aligned_chained_pool) / mp->item_alloc; | 473 | - aligned_chained_pool) / mp->item_alloc; |
473 | 474 | ||
474 | #ifdef EINA_DEBUG_MALLOC | 475 | #ifdef EINA_DEBUG_MALLOC |
@@ -558,6 +559,7 @@ Eina_Bool chained_init(void) | |||
558 | 559 | ||
559 | #endif | 560 | #endif |
560 | aligned_chained_pool = eina_mempool_alignof(sizeof(Chained_Pool)); | 561 | aligned_chained_pool = eina_mempool_alignof(sizeof(Chained_Pool)); |
562 | page_size = eina_cpu_page_size(); | ||
561 | 563 | ||
562 | return eina_mempool_register(&_eina_chained_mp_backend); | 564 | return eina_mempool_register(&_eina_chained_mp_backend); |
563 | } | 565 | } |
diff --git a/src/tests/eina/eina_test_file.c b/src/tests/eina/eina_test_file.c index bf066237da..f2f322550f 100644 --- a/src/tests/eina/eina_test_file.c +++ b/src/tests/eina/eina_test_file.c | |||
@@ -266,8 +266,8 @@ START_TEST(eina_file_map_new_test) | |||
266 | char *test_file_path, *test_file2_path; | 266 | char *test_file_path, *test_file2_path; |
267 | char *big_buffer; | 267 | char *big_buffer; |
268 | const char *template = "abcdefghijklmnopqrstuvwxyz"; | 268 | const char *template = "abcdefghijklmnopqrstuvwxyz"; |
269 | int template_size = strlen (template); | 269 | int template_size = strlen(template); |
270 | int memory_page_size = sysconf(_SC_PAGE_SIZE); | 270 | int memory_page_size = eina_cpu_page_size(); |
271 | const int big_buffer_size = memory_page_size * 1.5; | 271 | const int big_buffer_size = memory_page_size * 1.5; |
272 | const int iteration_number = big_buffer_size / template_size; | 272 | const int iteration_number = big_buffer_size / template_size; |
273 | int test_string_length = strlen(eina_map_test_string); | 273 | int test_string_length = strlen(eina_map_test_string); |