Patchwork OpenBSD cilkrts portability patch

login
register
mail settings
Submitter John Carr
Date Nov. 9, 2013, 8:07 p.m.
Message ID <201311092007.rA9K7diR029724@outgoing.mit.edu>
Download mbox | patch
Permalink /patch/290007/
State New
Headers show

Comments

John Carr - Nov. 9, 2013, 8:07 p.m.
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.
Andi Kleen - Nov. 10, 2013, 7:54 p.m.
John Carr <jfc@MIT.EDU> writes:

> 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.

That doesn't seem to be the autoconf'esque way to do this:
better would be to have a configure check for this somewhere and then
test the results.

-Andi

Patch

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);