This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

OpenBSD cilkrts portability patch


I am trying to build the trunk version of gcc to have Cilk on OpenBSD.

I attach three changes to libcilkrts.  Two changes treat OpenBSD like
FreeBSD.  One change is needed because OpenBSD defines PTHREAD_MUTEX_* as
enumerations rather than preprocessor constants.

Index: /data/jfc/src/GNU/trunk/libcilkrts/runtime/os-unix.c
===================================================================
--- /data/jfc/src/GNU/trunk/libcilkrts/runtime/os-unix.c	(revision 204488)
+++ /data/jfc/src/GNU/trunk/libcilkrts/runtime/os-unix.c	(working copy)
@@ -54,7 +54,7 @@
 #elif defined __APPLE__
 #   include <sys/sysctl.h>
     // Uses sysconf(_SC_NPROCESSORS_ONLN) in verbose output
-#elif defined  __FreeBSD__
+#elif defined  __FreeBSD__ || defined __OpenBSD__
 // No additional include files
 #elif defined __CYGWIN__
 // Cygwin on Windows - no additional include files
@@ -369,7 +369,7 @@
     assert((unsigned)count == count);
 
     return count;
-#elif defined  __FreeBSD__ || defined __CYGWIN__
+#elif defined  __FreeBSD__ || defined __OpenBSD__ || defined __CYGWIN__
     int ncores = sysconf(_SC_NPROCESSORS_ONLN);
 
     return ncores;
Index: /data/jfc/src/GNU/trunk/libcilkrts/runtime/os_mutex-unix.c
===================================================================
--- /data/jfc/src/GNU/trunk/libcilkrts/runtime/os_mutex-unix.c	(revision 204488)
+++ /data/jfc/src/GNU/trunk/libcilkrts/runtime/os_mutex-unix.c	(working copy)
@@ -89,7 +89,7 @@
     status = pthread_mutexattr_init(&attr);
     CILK_ASSERT (status == 0);
 #if defined DEBUG || CILK_LIB_DEBUG 
-#ifdef PTHREAD_MUTEX_ERRORCHECK
+#if defined PTHREAD_MUTEX_ERRORCHECK || defined __OpenBSD__
     status = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
 #else
     status = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]