[libdispatch-dev] Solaris portability, online CPU count detection - PATCH [3/6] REVISED

Joakim Johansson jocke at tbricks.com
Sat Nov 7 01:16:25 PST 2009


Thanks Paolo, it makes good sense.

Attaching revised patches to configure.ac and queue.c below:

Joakim

On 6 nov 2009, at 19.57, Paolo Bonzini wrote:

> On 11/06/2009 04:01 PM, Joakim Johansson wrote:
>> +#elif defined (__SVR4) && defined (__sun)
>
> Please use #elif defined _SC_NPROCESSORS_ONLN instead so it's picked  
> up by Linux as well.
>
> Maybe, even better, add sysconf to the functions that are checked in  
> configure and use
>
> #elif defined HAVE_SYSCONF && defined _SC_NPROCESSORS_ONLN
>
> Thanks!
>
> Paolo
> _______________________________________________
> libdispatch-dev mailing list
> libdispatch-dev at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/libdispatch-dev


-----
 > svn diff configure.ac
Index: configure.ac
===================================================================
--- configure.ac	(revision 142)
+++ configure.ac	(working copy)
@@ -184,7 +198,7 @@
  AC_CHECK_DECLS([FD_COPY], [], [], [[#include <sys/select.h>]])
  AC_CHECK_DECLS([SIGEMT], [], [], [[#include <signal.h>]])
  AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK], [], [], [[#include <sys/ 
mount.h>]])
-AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np  
mach_absolute_time malloc_create_zone])
+AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np  
mach_absolute_time malloc_create_zone sysconf])

  AC_CHECK_DECLS([POSIX_SPAWN_START_SUSPENDED],
    [have_posix_spawn_start_suspended=true],
-----
 > svn diff queue.c
Index: queue.c
===================================================================
--- queue.c	(revision 142)
+++ queue.c	(working copy)
@@ -473,6 +473,13 @@
  	_dispatch_hw_config.cc_max_logical =
  	    _dispatch_hw_config.cc_max_physical =
  	    _dispatch_hw_config.cc_max_active;
+#elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
+	_dispatch_hw_config.cc_max_active = (int) sysconf 
(_SC_NPROCESSORS_ONLN);
+
+	_dispatch_hw_config.cc_max_logical =
+	_dispatch_hw_config.cc_max_physical =
+	_dispatch_hw_config.cc_max_active;
+	
  #else
  #warning "_dispatch_queue_set_width_init: no supported way to query  
CPU count"
  	_dispatch_hw_config.cc_max_logical =
-----




More information about the libdispatch-dev mailing list