[m-rev.] diff: simplify handling of MR_THREAD_SAFE

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Jan 16 04:03:22 AEDT 2012


Branches: main

Don't make the choice of whether MR_THREAD_SAFE is defined in parallel grades
in the configure script.  There's no reason to do so and handling it
differently from the other grade component macros is just confusing.

compiler/compile_target_code.m:
scripts/mgnuc.in:
 	If we are in a parallel grade then define MR_THREAD_SAFE.

configure.in:
 	Don't include -DMR_THREAD_SAFE in the value of CFLAGS_FOR_THREADS.

Julien.

Index: configure.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/configure.in,v
retrieving revision 1.609
diff -u -r1.609 configure.in
--- configure.in	9 Jan 2012 15:02:04 -0000	1.609
+++ configure.in	15 Jan 2012 15:48:21 -0000
@@ -3017,8 +3017,7 @@

  case "$host" in
      *solaris*)
-        CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE \
-            -DGC_SOLARIS_PTHREADS -D_REENTRANT"
+        CFLAGS_FOR_THREADS="-DGC_SOLARIS_PTHREADS -D_REENTRANT"
          THREAD_LIBS="-lpthread -lrt -ldl"
          ENABLE_BOEHM_THREAD_LOCAL_ALLOC="-DTHREAD_LOCAL_ALLOC"
          ;;
@@ -3027,8 +3026,7 @@
          # Note that for old versions of Linux / glibc,
          # you may also need to make sure that you don't
          # pass -ansi to gcc.
-        CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE -DLINUX_THREADS \
-            -D_THREAD_SAFE -D_REENTRANT"
+        CFLAGS_FOR_THREADS="-DLINUX_THREADS -D_THREAD_SAFE -D_REENTRANT"
          THREAD_LIBS="-lpthread -ldl"
          ENABLE_BOEHM_THREAD_LOCAL_ALLOC="-DTHREAD_LOCAL_ALLOC"
          ENABLE_BOEHM_PARALLEL_MARK="-DPARALLEL_MARK"
@@ -3046,12 +3044,12 @@
          THREAD_LIBS=""
          case "$mercury_cv_cc_type" in
              msvc)
-                CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE -DGC_WIN32_THREADS -MD"
+                CFLAGS_FOR_THREADS="-DGC_WIN32_THREADS -MD"
                  LDFLAGS_FOR_THREADS="-MD"
                  LD_LIBFLAGS_FOR_THREADS="-MD"
                  ;;
              *)
-                CFLAGS_FOR_THREADS="$WIN32_GC_THREADLIB -DMR_THREAD_SAFE" ;;
+                CFLAGS_FOR_THREADS="$WIN32_GC_THREADLIB" ;;
          esac
          ;;

@@ -3059,7 +3057,7 @@
          THREAD_LIBS=""
          case "$mercury_cv_cc_type" in
              msvc)
-                CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE -DGC_WIN32_THREADS -MD"
+                CFLAGS_FOR_THREADS="-DGC_WIN32_THREADS -MD"
                  LDFLAGS_FOR_THREADS="-MD"
                  LD_LIBFLAGS_FOR_THREADS="-MD"
                  ;;
@@ -3067,15 +3065,14 @@
                  # By default the MinGW port of GCC targets the i386
                  # architecture.  We need to tell it to target a later
                  # architecture for the GCC built-in atomic ops to be available.
-                CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE $WIN32_GC_THREADLIB \
-                    -march=i686"
+                CFLAGS_FOR_THREADS="$WIN32_GC_THREADLIB -march=i686"
                  THREAD_LIBS="-lpthread"
                  ;;
          esac
          ;;

      *apple*darwin*)
-        CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE -DGC_DARWIN_THREADS"
+        CFLAGS_FOR_THREADS="-DGC_DARWIN_THREADS"
          THREAD_LIBS=""
          ;;

@@ -3085,21 +3082,21 @@
  ### #     use an *.par.gc* grade
  ### # XXX is this fixed in the Boehm collector now?
  ### *-osf*)
-###     CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE"
+###     CFLAGS_FOR_THREADS=""
  ###     THREAD_LIBS="-lpthreads -lmach -lc_r"
  ###     ;;

  ### # The threads stuff on HPUX is not yet enabled because
  ### # we don't have an HPUX box to test it on.
  ### *hpux*)
-###     CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE" # XXX incomplete
+###     CFLAGS_FOR_THREADS="" # XXX incomplete
  ###     THREAD_LIBS="-lpthread -lrt" ;;

  ### # The threads stuff on IRIX is not yet enabled because
  ### # we don't have an IRIX box to test it on.
  ### # (XXX perhaps we should enable it anyway, so it is easier to test?)
  ### *irix*)
-###     CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE -DIRIX_THREADS"
+###     CFLAGS_FOR_THREADS="-DIRIX_THREADS"
  ###     THREAD_LIBS="-lpthread"
  ###     ;;

Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.181
diff -u -r1.181 compile_target_code.m
--- compiler/compile_target_code.m	16 Dec 2011 03:38:20 -0000	1.181
+++ compiler/compile_target_code.m	15 Jan 2012 15:51:33 -0000
@@ -494,10 +494,12 @@
      globals.lookup_bool_option(Globals, parallel, Parallel),
      (
          Parallel = yes,
+        ParallelOpt = "-DMR_THREAD_SAFE ",
          globals.lookup_string_option(Globals, cflags_for_threads,
              CFLAGS_FOR_THREADS)
      ;
          Parallel = no,
+        ParallelOpt = "",
          CFLAGS_FOR_THREADS = ""
      ),
      globals.lookup_bool_option(Globals, threadscope, Threadscope),
@@ -895,6 +897,7 @@
          NestedFunctionsOpt,
          HighLevelDataOpt,
          RegOpt, GotoOpt, AsmOpt,
+        ParallelOpt,
          CFLAGS_FOR_REGS, " ", CFLAGS_FOR_GOTOS, " ",
          CFLAGS_FOR_THREADS, " ", CFLAGS_FOR_PIC, " ",
          ThreadscopeOpt,
Index: scripts/mgnuc.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.141
diff -u -r1.141 mgnuc.in
--- scripts/mgnuc.in	11 Oct 2011 13:48:39 -0000	1.141
+++ scripts/mgnuc.in	15 Jan 2012 15:50:06 -0000
@@ -300,7 +300,7 @@
  esac

  case $thread_safe in
-    true)       THREAD_OPTS="$CFLAGS_FOR_THREADS"
+    true)       THREAD_OPTS="-DMR_THREAD_SAFE $CFLAGS_FOR_THREADS"
                  case $FULLARCH in *linux*)
                      # Don't use -ansi under Linux or we get parse errors
                      # at sigset_t in the pthreads headers. This doesn't seem

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list