This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH [tree-ssa, libmudflap]: support libmudflap on FreeBSD, V2


As previously reported, libmudflap fails all tests on FreeBSD[45].
This V2 patch fixes all non-threaded failures on this platform.  All
threading tests fail on i386-unknown-freebsd4.9 (due to assumptions in
MF's spec file setup).  I generalized the WRAP_gets change based on
AJ's feedback.  If MF has a way to report the size of s [in that
context], perhaps an even better fix would be available...

OK to install?

	* mf-hooks2.c: Support FreeBSD.
	(WRAP_gets): Avoid gets().
	* testsuite/libmudflap.c/pass-stratcliff.c: Do not
	test unimplemented mem/str calls on FreeBSD.
	* testsuite/libmudflap.c/pass21-frag.c: Do not include
	<alloca.h> on FreeBSD.

Index: mf-hooks2.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/mf-hooks2.c,v
retrieving revision 1.1.2.7
diff -c -r1.1.2.7 mf-hooks2.c
*** mf-hooks2.c	8 Dec 2003 22:51:15 -0000	1.1.2.7
--- mf-hooks2.c	5 Mar 2004 09:19:08 -0000
***************
*** 49,54 ****
--- 49,67 ----
  /* A bunch of independent stdlib/unistd hook functions, all
     intercepted by mf-runtime.h macros.  */
  
+ #ifdef __FreeBSD__
+ #undef WRAP_memrchr
+ #undef WRAP_memmem
+ #include <dlfcn.h>
+ static inline size_t (strnlen) (const char* str, size_t n)
+ {
+   const char *s;
+ 
+   for (s = str; n && *s; ++s, --n)
+     ;
+   return (s - str);
+ }
+ #endif
  
  /* str*,mem*,b* */
  
***************
*** 669,675 ****
  {
    TRACE ("%s\n", __PRETTY_FUNCTION__);
    MF_VALIDATE_EXTENT (s, 1, __MF_CHECK_WRITE, "gets buffer");
!   s = gets (s);
    if (NULL != s) {	/* better late than never */
      size_t n = strlen (s);
      MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_WRITE, "gets buffer");
--- 682,689 ----
  {
    TRACE ("%s\n", __PRETTY_FUNCTION__);
    MF_VALIDATE_EXTENT (s, 1, __MF_CHECK_WRITE, "gets buffer");
!   /* Avoid link-time warning... */
!   s = fgets (s, INT_MAX, stdin);
    if (NULL != s) {	/* better late than never */
      size_t n = strlen (s);
      MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_WRITE, "gets buffer");
Index: testsuite/libmudflap.c/pass-stratcliff.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/testsuite/libmudflap.c/Attic/pass-stratcliff.c,v
retrieving revision 1.1.2.1
diff -c -r1.1.2.1 pass-stratcliff.c
*** testsuite/libmudflap.c/pass-stratcliff.c	26 Feb 2003 19:00:38 -0000	1.1.2.1
--- testsuite/libmudflap.c/pass-stratcliff.c	5 Mar 2004 09:19:08 -0000
***************
*** 153,158 ****
--- 153,159 ----
  	    }
          }
  
+ #ifndef __FreeBSD__
        /* rawmemchr test */
        for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
          {
***************
*** 173,178 ****
--- 174,180 ----
  	      adr[middle] = 'T';
  	    }
          }
+ #endif
  
        /* strcpy test */
        for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
***************
*** 248,253 ****
--- 250,256 ----
  	    }
          }
  
+ #ifndef __FreeBSD__
        /* stpcpy test */
        for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
          {
***************
*** 287,292 ****
--- 290,296 ----
  	      adr[middle] = 'T';
  	    }
          }
+ #endif
  
        /* memcpy test */
        for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
***************
*** 298,303 ****
--- 302,308 ----
  	      result = 1;
  	    }
  
+ #ifndef __FreeBSD__
        /* mempcpy test */
        for (outer = size - 1; outer >= MAX (0, size - 128); --outer)
  	for (inner = 0; inner < size - outer; ++inner)
***************
*** 307,312 ****
--- 312,318 ----
  		      outer, inner);
  	      result = 1;
  	    }
+ #endif
      }
  
    return result;
Index: testsuite/libmudflap.c/pass21-frag.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/testsuite/libmudflap.c/Attic/pass21-frag.c,v
retrieving revision 1.1.2.2
diff -c -r1.1.2.2 pass21-frag.c
*** testsuite/libmudflap.c/pass21-frag.c	25 Jun 2003 20:37:39 -0000	1.1.2.2
--- testsuite/libmudflap.c/pass21-frag.c	5 Mar 2004 09:19:08 -0000
***************
*** 1,7 ****
--- 1,9 ----
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
+ #ifndef __FreeBSD__
  #include <alloca.h>
+ #endif
  int main ()
  {
  char *boo, *foo;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]