Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gcc/dist/libmudflap NetBSD fixes:



details:   https://anonhg.NetBSD.org/src/rev/ff4ba3ffe907
branches:  trunk
changeset: 778874:ff4ba3ffe907
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Apr 18 02:55:05 2012 +0000

description:
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

diffstat:

 external/gpl3/gcc/dist/libmudflap/mf-hooks1.c  |   4 +-
 external/gpl3/gcc/dist/libmudflap/mf-hooks2.c  |   3 +-
 external/gpl3/gcc/dist/libmudflap/mf-impl.h    |  27 ++++++++++++++++++++-
 external/gpl3/gcc/dist/libmudflap/mf-runtime.c |  31 +++++++++++++++----------
 external/gpl3/gcc/dist/libmudflap/mf-runtime.h |   6 ++--
 5 files changed, 51 insertions(+), 20 deletions(-)

diffs (193 lines):

diff -r 3f85b731f29f -r ff4ba3ffe907 external/gpl3/gcc/dist/libmudflap/mf-hooks1.c
--- a/external/gpl3/gcc/dist/libmudflap/mf-hooks1.c     Wed Apr 18 02:52:07 2012 +0000
+++ b/external/gpl3/gcc/dist/libmudflap/mf-hooks1.c     Wed Apr 18 02:55:05 2012 +0000
@@ -33,7 +33,7 @@
 
 /* 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 @@
   static int freeq_initialized = 0;
   DECLARE(void, free, void *);
 
-  BEGIN_PROTECT (free, buf);
+  BEGIN_PROTECTV (free, buf);
 
   if (UNLIKELY(buf == NULL))
     return;
diff -r 3f85b731f29f -r ff4ba3ffe907 external/gpl3/gcc/dist/libmudflap/mf-hooks2.c
--- a/external/gpl3/gcc/dist/libmudflap/mf-hooks2.c     Wed Apr 18 02:52:07 2012 +0000
+++ b/external/gpl3/gcc/dist/libmudflap/mf-hooks2.c     Wed Apr 18 02:55:05 2012 +0000
@@ -32,9 +32,10 @@
 
 /* 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
diff -r 3f85b731f29f -r ff4ba3ffe907 external/gpl3/gcc/dist/libmudflap/mf-impl.h
--- a/external/gpl3/gcc/dist/libmudflap/mf-impl.h       Wed Apr 18 02:52:07 2012 +0000
+++ b/external/gpl3/gcc/dist/libmudflap/mf-impl.h       Wed Apr 18 02:55:05 2012 +0000
@@ -273,12 +273,12 @@
 #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 @@
     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.  */
diff -r 3f85b731f29f -r ff4ba3ffe907 external/gpl3/gcc/dist/libmudflap/mf-runtime.c
--- a/external/gpl3/gcc/dist/libmudflap/mf-runtime.c    Wed Apr 18 02:52:07 2012 +0000
+++ b/external/gpl3/gcc/dist/libmudflap/mf-runtime.c    Wed Apr 18 02:55:05 2012 +0000
@@ -31,9 +31,10 @@
 
 /* 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 @@
 /* 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 @@
            "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 @@
            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 @@
         {
           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 @@
 #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 @@
   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: `");
diff -r 3f85b731f29f -r ff4ba3ffe907 external/gpl3/gcc/dist/libmudflap/mf-runtime.h
--- a/external/gpl3/gcc/dist/libmudflap/mf-runtime.h    Wed Apr 18 02:52:07 2012 +0000
+++ b/external/gpl3/gcc/dist/libmudflap/mf-runtime.h    Wed Apr 18 02:55:05 2012 +0000
@@ -81,11 +81,11 @@
 #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 ();



Home | Main Index | Thread Index | Old Index