mf-runtime.c (__mf_init): Support FreeBSD.
authorLoren J. Rittle <ljrittle@acm.org>
Tue, 1 Sep 2009 18:13:18 +0000 (18:13 +0000)
committerLoren J. Rittle <ljrittle@gcc.gnu.org>
Tue, 1 Sep 2009 18:13:18 +0000 (18:13 +0000)
2009-09-01  Loren J. Rittle  <ljrittle@acm.org>

* mf-runtime.c (__mf_init): Support FreeBSD.
Prime mutex which calls calloc upon first lock to avoid deadlock.
* mf-hooks1.c (__mf_0fn_mmap): Support FreeBSD.
Ignore red zone allocation request for initial thread's stack.

From-SVN: r151278

libmudflap/ChangeLog
libmudflap/mf-hooks1.c
libmudflap/mf-runtime.c

index 5a899c18551617695caf6d99c70ee272e926773b..e51c109bbac6800baec62371370229eff559a585 100644 (file)
@@ -1,3 +1,10 @@
+2009-09-01  Loren J. Rittle  <ljrittle@acm.org>
+
+       * mf-runtime.c (__mf_init): Support FreeBSD.
+       Prime mutex which calls calloc upon first lock to avoid deadlock.
+       * mf-hooks1.c (__mf_0fn_mmap): Support FreeBSD.
+       Ignore red zone allocation request for initial thread's stack.
+
 2009-09-01  Loren J. Rittle  <ljrittle@acm.org>
            Andreas Schwab  <schwab@linux-m68k.org>
 
index e74c13afcced4e1f819920607c4cad32b11e645e..1e46a650947f759c7e16ebec64c587c750afae65 100644 (file)
@@ -321,6 +321,11 @@ WRAPPER(void, free, void *buf)
 void *
 __mf_0fn_mmap (void *start, size_t l, int prot, int f, int fd, off_t off)
 {
+#if defined(__FreeBSD__)
+  if (f == 0x1000 && fd == -1 && prot == 0 && off == 0)
+    return 0;
+#endif /* Ignore red zone allocation request for initial thread's stack. */
+
   return (void *) -1;
 }
 #endif
index 46e7e2fc30e58c2fe347bf13860fcce6f85720c5..3bfaf02b6a0870b52aea48fb15606015b6255228 100644 (file)
@@ -695,6 +695,12 @@ __mf_init ()
   if (LIKELY (__mf_starting_p == 0))
     return;
 
+#if defined(__FreeBSD__) && defined(LIBMUDFLAPTH)
+  pthread_self();
+  LOCKTH ();
+  UNLOCKTH ();
+#endif /* Prime mutex which calls calloc upon first lock to avoid deadlock. */
+
   /* This initial bootstrap phase requires that __mf_starting_p = 1. */
 #ifdef PIC
   __mf_resolve_dynamics ();