Module Name:    src
Committed By:   christos
Date:           Wed Apr 18 02:55:06 UTC 2012

Modified Files:
        src/external/gpl3/gcc/dist/libmudflap: mf-hooks1.c mf-hooks2.c
            mf-impl.h mf-runtime.c mf-runtime.h

Log Message:
NetBSD fixes:
1. thread_self() returns a pointer, not an unsigned integer
2. Add NetBSD to Apple and FreeBSD defines
3. Add _NETBSD_SOURCE where needed
4. Add an extra define BEGIN_PROTECTV for void functions to avoid return
   free(); where free is void.
5. Avoid weak symbol hacks to determine if we are threaded or not. We
   have a threaded copy of the library, why bother?
6. change __attribute -> __attribute__ since the former is not covered by
   our cdefs.h


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
    src/external/gpl3/gcc/dist/libmudflap/mf-hooks1.c \
    src/external/gpl3/gcc/dist/libmudflap/mf-hooks2.c \
    src/external/gpl3/gcc/dist/libmudflap/mf-impl.h \
    src/external/gpl3/gcc/dist/libmudflap/mf-runtime.c \
    src/external/gpl3/gcc/dist/libmudflap/mf-runtime.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gcc/dist/libmudflap/mf-hooks1.c
diff -u src/external/gpl3/gcc/dist/libmudflap/mf-hooks1.c:1.1.1.1 src/external/gpl3/gcc/dist/libmudflap/mf-hooks1.c:1.2
--- src/external/gpl3/gcc/dist/libmudflap/mf-hooks1.c:1.1.1.1	Mon Jun 20 21:23:33 2011
+++ src/external/gpl3/gcc/dist/libmudflap/mf-hooks1.c	Tue Apr 17 22:55:05 2012
@@ -33,7 +33,7 @@ see the files COPYING3 and COPYING.RUNTI
 
 /* These attempt to coax various unix flavours to declare all our
    needed tidbits in the system headers.  */
-#if !defined(__FreeBSD__)  && !defined(__APPLE__)
+#if !defined(__FreeBSD__)  && !defined(__APPLE__) && !defined(__NetBSD__)
 #define _POSIX_SOURCE
 #endif /* Some BSDs break <sys/socket.h> if this is defined. */
 #define _GNU_SOURCE
@@ -238,7 +238,7 @@ WRAPPER(void, free, void *buf)
   static int freeq_initialized = 0;
   DECLARE(void, free, void *);
 
-  BEGIN_PROTECT (free, buf);
+  BEGIN_PROTECTV (free, buf);
 
   if (UNLIKELY(buf == NULL))
     return;
Index: src/external/gpl3/gcc/dist/libmudflap/mf-hooks2.c
diff -u src/external/gpl3/gcc/dist/libmudflap/mf-hooks2.c:1.1.1.1 src/external/gpl3/gcc/dist/libmudflap/mf-hooks2.c:1.2
--- src/external/gpl3/gcc/dist/libmudflap/mf-hooks2.c:1.1.1.1	Mon Jun 20 21:23:31 2011
+++ src/external/gpl3/gcc/dist/libmudflap/mf-hooks2.c	Tue Apr 17 22:55:05 2012
@@ -32,9 +32,10 @@ see the files COPYING3 and COPYING.RUNTI
 
 /* These attempt to coax various unix flavours to declare all our
    needed tidbits in the system headers.  */
-#if !defined(__FreeBSD__) && !defined(__APPLE__)
+#if !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(__NetBSD__)
 #define _POSIX_SOURCE
 #endif /* Some BSDs break <sys/socket.h> if this is defined. */
+#define _NETBSD_SOURCE
 #define _GNU_SOURCE
 #define _XOPEN_SOURCE
 #define _BSD_TYPES
Index: src/external/gpl3/gcc/dist/libmudflap/mf-impl.h
diff -u src/external/gpl3/gcc/dist/libmudflap/mf-impl.h:1.1.1.1 src/external/gpl3/gcc/dist/libmudflap/mf-impl.h:1.2
--- src/external/gpl3/gcc/dist/libmudflap/mf-impl.h:1.1.1.1	Mon Jun 20 21:23:33 2011
+++ src/external/gpl3/gcc/dist/libmudflap/mf-impl.h	Tue Apr 17 22:55:05 2012
@@ -273,12 +273,12 @@ extern struct __mf_options __mf_opts;
 #ifdef LIBMUDFLAPTH
 #define VERBOSE_TRACE(...) \
   do { if (UNLIKELY (__mf_opts.verbose_trace)) {  \
-      fprintf (stderr, "mf(%u): ", (unsigned) pthread_self ()); \
+      fprintf (stderr, "mf(%ju): ", (intmax_t)(intptr_t) pthread_self ()); \
       fprintf (stderr, __VA_ARGS__); \
     } } while (0)
 #define TRACE(...) \
   do { if (UNLIKELY (__mf_opts.trace_mf_calls)) { \
-      fprintf (stderr, "mf(%u): ", (unsigned) pthread_self ()); \
+      fprintf (stderr, "mf(%ju): ", (intmax_t)(intptr_t) pthread_self ()); \
       fprintf (stderr, __VA_ARGS__); \
     } } while (0)
 #else
@@ -396,6 +396,29 @@ ret __mfwrap_ ## fname (__VA_ARGS__)
     TRACE ("%s\n", __PRETTY_FUNCTION__); \
   }
 
+#define BEGIN_PROTECTV(fname, ...)       \
+  if (UNLIKELY (__mf_starting_p)) \
+  {                                         \
+    CALL_BACKUP(fname, __VA_ARGS__); \
+    return;				\
+  }                                         \
+  else if (UNLIKELY (__mf_get_state () == reentrant))   \
+  {                                         \
+    extern unsigned long __mf_reentrancy;   \
+    __mf_reentrancy ++; \
+    CALL_REAL(fname, __VA_ARGS__);   \
+    return;				\
+  }                                         \
+  else if (UNLIKELY (__mf_get_state () == in_malloc))   \
+  {                                         \
+    CALL_REAL(fname, __VA_ARGS__);   \
+    return;				\
+  }                                         \
+  else                                      \
+  {                                         \
+    TRACE ("%s\n", __PRETTY_FUNCTION__); \
+  }
+
 /* There is an assumption here that these will only be called in routines
    that call BEGIN_PROTECT at the start, and hence the state must always
    be active when BEGIN_MALLOC_PROTECT is called.  */
Index: src/external/gpl3/gcc/dist/libmudflap/mf-runtime.c
diff -u src/external/gpl3/gcc/dist/libmudflap/mf-runtime.c:1.1.1.1 src/external/gpl3/gcc/dist/libmudflap/mf-runtime.c:1.2
--- src/external/gpl3/gcc/dist/libmudflap/mf-runtime.c:1.1.1.1	Mon Jun 20 21:23:33 2011
+++ src/external/gpl3/gcc/dist/libmudflap/mf-runtime.c	Tue Apr 17 22:55:05 2012
@@ -31,9 +31,10 @@ see the files COPYING3 and COPYING.RUNTI
 
 /* These attempt to coax various unix flavours to declare all our
    needed tidbits in the system headers.  */
-#if !defined(__FreeBSD__) && !defined(__APPLE__)
+#if !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(__NetBSD__)
 #define _POSIX_SOURCE
 #endif /* Some BSDs break <sys/socket.h> if this is defined. */
+#define _NETBSD_SOURCE
 #define _GNU_SOURCE
 #define _XOPEN_SOURCE
 #define _BSD_TYPES
@@ -192,12 +193,18 @@ pthread_mutex_t __mf_biglock =
 /* Use HAVE_PTHREAD_H here instead of LIBMUDFLAPTH, so that even
    the libmudflap.la (no threading support) can diagnose whether
    the application is linked with -lpthread.  See __mf_usage() below.  */
-#if HAVE_PTHREAD_H
-#ifdef _POSIX_THREADS
-#pragma weak pthread_join
+#ifdef LIBMUDFLAPTH
+# if HAVE_PTHREAD_H
+#  ifdef _POSIX_THREADS
+#   include <pthread.h>
+#  else
+#   define pthread_join NULL
+#  endif
+# else
+#  define pthread_join NULL
+# endif
 #else
-#define pthread_join NULL
-#endif
+# define pthread_join NULL
 #endif
 
 
@@ -1762,7 +1769,7 @@ __mf_describe_object (__mf_object_t *obj
            "bounds=[%p,%p] size=%lu area=%s check=%ur/%uw liveness=%u%s\n"
            "alloc time=%lu.%06lu pc=%p"
 #ifdef LIBMUDFLAPTH
-           " thread=%u"
+           " thread=%ju"
 #endif
            "\n",
            (obj->deallocated_p ? "dead " : ""),
@@ -1781,7 +1788,7 @@ __mf_describe_object (__mf_object_t *obj
            obj->alloc_time.tv_sec, obj->alloc_time.tv_usec,
            (void *) obj->alloc_pc
 #ifdef LIBMUDFLAPTH
-           , (unsigned) obj->alloc_thread
+           , (intmax_t)(intptr_t)obj->alloc_thread
 #endif
            );
 
@@ -1798,13 +1805,13 @@ __mf_describe_object (__mf_object_t *obj
         {
           fprintf (stderr, "dealloc time=%lu.%06lu pc=%p"
 #ifdef LIBMUDFLAPTH
-                   " thread=%u"
+                   " thread=%ju"
 #endif
                    "\n",
                    obj->dealloc_time.tv_sec, obj->dealloc_time.tv_usec,
                    (void *) obj->dealloc_pc
 #ifdef LIBMUDFLAPTH
-                   , (unsigned) obj->dealloc_thread
+                   , (intmax_t)(intptr_t)obj->dealloc_thread
 #endif
                    );
 
@@ -2318,7 +2325,7 @@ __mf_sigusr1_respond ()
 #ifndef NDEBUG
 
 static void
-write_itoa (int fd, unsigned n)
+write_itoa (int fd, intmax_t n)
 {
   enum x { bufsize = sizeof(n)*4 };
   char buf [bufsize];
@@ -2347,7 +2354,7 @@ __assert_fail (const char *msg, const ch
   write2("mf");
 #ifdef LIBMUDFLAPTH
   write2("(");
-  write_itoa (2, (unsigned) pthread_self ());
+  write_itoa (2, (intmax_t)(intptr_t)pthread_self ());
   write2(")");
 #endif
   write2(": assertion failure: `");
Index: src/external/gpl3/gcc/dist/libmudflap/mf-runtime.h
diff -u src/external/gpl3/gcc/dist/libmudflap/mf-runtime.h:1.1.1.1 src/external/gpl3/gcc/dist/libmudflap/mf-runtime.h:1.2
--- src/external/gpl3/gcc/dist/libmudflap/mf-runtime.h:1.1.1.1	Mon Jun 20 21:23:33 2011
+++ src/external/gpl3/gcc/dist/libmudflap/mf-runtime.h	Tue Apr 17 22:55:05 2012
@@ -81,11 +81,11 @@ extern "C" {
 #endif
 
 extern void __mf_check (void *ptr, __mf_size_t sz, int type, const char *location)
-       __attribute((nothrow));
+       __attribute__((nothrow));
 extern void __mf_register (void *ptr, __mf_size_t sz, int type, const char *name)
-       __attribute((nothrow));
+       __attribute__((nothrow));
 extern void __mf_unregister (void *ptr, __mf_size_t sz, int type)
-       __attribute((nothrow));
+       __attribute__((nothrow));
 extern unsigned __mf_watch (void *ptr, __mf_size_t sz);
 extern unsigned __mf_unwatch (void *ptr, __mf_size_t sz);
 extern void __mf_report ();

Reply via email to