This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH [tree-ssa, libmudflap]: support libmudflap on FreeBSD
- From: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 4 Mar 2004 00:37:03 -0600 (CST)
- Subject: PATCH [tree-ssa, libmudflap]: support libmudflap on FreeBSD
- Reply-to: rittle at labs dot mot dot com
As I previously reported, libmudflap fails all tests on FreeBSD[45].
I have a patch [below] to fix most known failures on this platform. I
started by building MF with -Werror (then took out needless changes).
pass-stratcliff.c (cores parent gdb process) and all threading tests
(assumptions in MF's spec file setup) fail on i386-unknown-freebsd4.9.
Additional tests fail on alpha-unknown-freebsd5.2 (fail17-frag.c,
pass41-frag.cxx) and on sparc64-unknown-freebsd5.2 (pass41-frag.cxx).
OK to install? If the MF maintainers want MF enabled by default after
the roll into mainline, a more general technique might be required...
I fear many ports will be missing 1-5 of these functions to be wrapped.
* mf-hooks2.c: Support FreeBSD.
* testsuite/libmudflap.c/pass-stratcliff.c: Likewise.
* testsuite/libmudflap.c/pass21-frag.c: Likewise.
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 4 Mar 2004 05:32:59 -0000
***************
*** 49,54 ****
--- 49,68 ----
/* A bunch of independent stdlib/unistd hook functions, all
intercepted by mf-runtime.h macros. */
+ #ifdef __FreeBSD__
+ #if defined (WRAP_dlopen) || defined (WRAP_dlerror) || defined (WRAP_dlclose) || defined (WRAP_dlsym)
+ #include <dlfcn.h>
+ #endif
+ #if defined (WRAP_strncpy) || defined (WRAP_strncat) || defined (WRAP_strncmp) || defined (WRAP_strncasecmp) || defined (WRAP_strndup) || defined (WRAP_strnlen)
+ static size_t strnlen (const char* s, size_t n)
+ {
+ size_t result = strlen (s);
+ if (result > n)
+ result = n;
+ return result;
+ }
+ #endif
+ #endif
/* str*,mem*,b* */
***************
*** 101,106 ****
--- 115,121 ----
}
#endif
+ #ifndef __FreeBSD__
#ifdef WRAP_memrchr
WRAPPER2(void *, memrchr, const void *s, int c, size_t n)
{
***************
*** 109,114 ****
--- 124,130 ----
return memrchr (s, c, n);
}
#endif
+ #endif
#ifdef WRAP_strcpy
WRAPPER2(char *, strcpy, char *dest, const char *src)
***************
*** 329,334 ****
--- 345,351 ----
}
#endif
+ #ifndef __FreeBSD__
#ifdef WRAP_memmem
WRAPPER2(void *, memmem,
const void *haystack, size_t haystacklen,
***************
*** 340,345 ****
--- 357,363 ----
return memmem (haystack, haystacklen, needle, needlelen);
}
#endif
+ #endif
#ifdef WRAP_strlen
WRAPPER2(size_t, strlen, const char *s)
***************
*** 669,675 ****
--- 687,698 ----
{
TRACE ("%s\n", __PRETTY_FUNCTION__);
MF_VALIDATE_EXTENT (s, 1, __MF_CHECK_WRITE, "gets buffer");
+ #ifndef __FreeBSD__
s = gets (s);
+ #else
+ // Avoid link-time warning...
+ s = fgets (s, INT_MAX, stdin);
+ #endif
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 4 Mar 2004 05:32:59 -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 4 Mar 2004 05:32:59 -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;