From 127ff55fa4eb562adab8ede82e2cff0f43da774d Mon Sep 17 00:00:00 2001 From: cedric Date: Thu, 19 Apr 2012 09:25:54 +0000 Subject: [PATCH] eina: make it possible to force the number of detected CPU as way to overcome local bug. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@70328 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- ChangeLog | 4 ++++ NEWS | 1 + src/lib/eina_cpu.c | 18 +++++++++++++++++- src/lib/eina_main.c | 2 ++ src/lib/eina_private.h | 2 ++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d268b00..b1e1209 100644 --- a/ChangeLog +++ b/ChangeLog @@ -250,3 +250,7 @@ * Add missing API eina_file_map_faulted() on Windows. Does nothing for now. + +2012-04-19 Cedric Bail + + * Make it possible to force the number of detected CPU on a system. diff --git a/NEWS b/NEWS index dd89e35..530c022 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,7 @@ Fixes: * forgotten initialization of eina list count during eina_list_split_list. * leak in Eina_File. * deadlock in Eina_File. + * make it possible to force the number of detected CPU on a system. Improvements: diff --git a/src/lib/eina_cpu.c b/src/lib/eina_cpu.c index 5b190e4..d0e1b91 100644 --- a/src/lib/eina_cpu.c +++ b/src/lib/eina_cpu.c @@ -130,7 +130,10 @@ EAPI Eina_Cpu_Features eina_cpu_features_get(void) return ecf; } -EAPI int eina_cpu_count(void) +static int _cpu_count = -1; + +static int +_eina_cpu_count_internal(void) { #ifdef EFL_HAVE_THREADS @@ -205,3 +208,16 @@ EAPI int eina_cpu_count(void) return 1; #endif } + +EAPI int eina_cpu_count(void) +{ + return _cpu_count; +} + +void eina_cpu_count_internal(void) +{ + if (getenv("EINA_CPU_FAKE")) + _cpu_count = atoi(getenv("EINA_CPU_FAKE")); + else + _cpu_count = _eina_cpu_count_internal(); +} diff --git a/src/lib/eina_main.c b/src/lib/eina_main.c index f890058..5cf77e7 100644 --- a/src/lib/eina_main.c +++ b/src/lib/eina_main.c @@ -298,6 +298,8 @@ eina_init(void) } } + eina_cpu_count_internal(); + _eina_main_count = 1; return 1; } diff --git a/src/lib/eina_private.h b/src/lib/eina_private.h index 49df565..255959b 100644 --- a/src/lib/eina_private.h +++ b/src/lib/eina_private.h @@ -142,6 +142,8 @@ void eina_log_threads_init(void); void eina_log_threads_shutdown(void); #endif +void eina_cpu_count_internal(void); + void eina_file_mmap_faulty(void *addr, long page_size); #endif /* EINA_PRIVATE_H_ */ -- 2.7.4