summaryrefslogtreecommitdiff
path: root/libmudflap
diff options
context:
space:
mode:
authorfche <fche@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-09 19:04:56 +0000
committerfche <fche@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-09 19:04:56 +0000
commite46563d95c39e4e437ec5f5bd752983f220ef3d1 (patch)
tree45d762f48cc30af98123706913cfa76316d87f76 /libmudflap
parent4a6a3ec71ff798a4de0e0ce9c14795bb65f8389e (diff)
downloadgcc-e46563d95c39e4e437ec5f5bd752983f220ef3d1.tar.gz
2004-06-09 Frank Ch. Eigler <fche@redhat.com>
ctype support. * configure.in: Look for ctype header and glibc implementation. * mf-hooks2.c (__ctype_{b,toupper,tolower}_loc): Sample ctype array hooks for glibc 2.3. * mf-runtime.h.in: Wrap them. * mf-runtime.c (__mf_init): Leave marker regarding other ctype implementations. * testsuite/libmudflap.c/pass47-frag.c: New test. * configure, config.h.in: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82848 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libmudflap')
-rw-r--r--libmudflap/ChangeLog12
-rw-r--r--libmudflap/config.h.in12
-rwxr-xr-xlibmudflap/configure92
-rw-r--r--libmudflap/configure.in5
-rw-r--r--libmudflap/mf-hooks2.c76
-rw-r--r--libmudflap/mf-runtime.c6
-rw-r--r--libmudflap/mf-runtime.h.in3
-rw-r--r--libmudflap/testsuite/libmudflap.c/pass47-frag.c10
8 files changed, 213 insertions, 3 deletions
diff --git a/libmudflap/ChangeLog b/libmudflap/ChangeLog
index e2b034b9ed2..2bcf83d7656 100644
--- a/libmudflap/ChangeLog
+++ b/libmudflap/ChangeLog
@@ -1,3 +1,15 @@
+2004-06-09 Frank Ch. Eigler <fche@redhat.com>
+
+ ctype support.
+ * configure.in: Look for ctype header and glibc implementation.
+ * mf-hooks2.c (__ctype_{b,toupper,tolower}_loc): Sample ctype
+ array hooks for glibc 2.3.
+ * mf-runtime.h.in: Wrap them.
+ * mf-runtime.c (__mf_init): Leave marker regarding other ctype
+ implementations.
+ * testsuite/libmudflap.c/pass47-frag.c: New test.
+ * configure, config.h.in: Regenerated.
+
2004-06-04 Frank Ch. Eigler <fche@redhat.com>
Portability improvements, e.g., libmudflap/15293.
diff --git a/libmudflap/config.h.in b/libmudflap/config.h.in
index a9c7ed65dfc..bdcd239e59c 100644
--- a/libmudflap/config.h.in
+++ b/libmudflap/config.h.in
@@ -6,6 +6,9 @@
/* Define to 1 if you have the `backtrace_symbols' function. */
#undef HAVE_BACKTRACE_SYMBOLS
+/* Define to 1 if you have the <ctype.h> header file. */
+#undef HAVE_CTYPE_H
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
@@ -108,6 +111,15 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
+/* Define to 1 if you have the `__ctype_b_loc' function. */
+#undef HAVE___CTYPE_B_LOC
+
+/* Define to 1 if you have the `__ctype_tolower_loc' function. */
+#undef HAVE___CTYPE_TOLOWER_LOC
+
+/* Define to 1 if you have the `__ctype_toupper_loc' function. */
+#undef HAVE___CTYPE_TOUPPER_LOC
+
/* Name of package */
#undef PACKAGE
diff --git a/libmudflap/configure b/libmudflap/configure
index c5f6b609807..0f49ab9eee2 100755
--- a/libmudflap/configure
+++ b/libmudflap/configure
@@ -3428,8 +3428,9 @@ done
+
for ac_header in stdint.h execinfo.h signal.h dlfcn.h \
- netdb.h sys/ipc.h sys/sem.h sys/shm.h sys/wait.h sys/socket.h
+ netdb.h sys/ipc.h sys/sem.h sys/shm.h sys/wait.h sys/socket.h ctype.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
@@ -3835,6 +3836,93 @@ fi
done
+
+
+
+for ac_func in __ctype_b_loc __ctype_tolower_loc __ctype_toupper_loc
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
@@ -4672,7 +4760,7 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
case $host in
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 4675 "configure"' > conftest.$ac_ext
+ echo '#line 4763 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
diff --git a/libmudflap/configure.in b/libmudflap/configure.in
index 67bc2d4261a..6e03ed5bbbb 100644
--- a/libmudflap/configure.in
+++ b/libmudflap/configure.in
@@ -63,7 +63,7 @@ AC_TRY_COMPILE([
enable_shared=no])
AC_CHECK_HEADERS(stdint.h execinfo.h signal.h dlfcn.h \
- netdb.h sys/ipc.h sys/sem.h sys/shm.h sys/wait.h sys/socket.h)
+ netdb.h sys/ipc.h sys/sem.h sys/shm.h sys/wait.h sys/socket.h ctype.h)
AC_CHECK_FUNCS(backtrace backtrace_symbols gettimeofday signal)
dnl Check for 64-bit stdio calls related to Large File Support
@@ -72,6 +72,9 @@ AC_CHECK_FUNCS(fopen64 fseeko64 ftello64 stat64)
dnl Check for nonstandard functions
AC_CHECK_FUNCS(strnlen memrchr strncpy memmem sethostname)
+dnl Check for glibc ctype functions
+AC_CHECK_FUNCS(__ctype_b_loc __ctype_tolower_loc __ctype_toupper_loc)
+
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>],[union semun foo;], [mf_have_semun=1], [mf_have_semun=0])
diff --git a/libmudflap/mf-hooks2.c b/libmudflap/mf-hooks2.c
index ccd9931be86..ff08d42ef76 100644
--- a/libmudflap/mf-hooks2.c
+++ b/libmudflap/mf-hooks2.c
@@ -63,6 +63,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include <errno.h>
#include <limits.h>
#include <time.h>
+#include <ctype.h>
#include <dirent.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
@@ -1643,3 +1644,78 @@ WRAPPER2(int, shmdt, const void *shmaddr)
#endif /* HAVE_SYS_IPC/SEM/SHM_H */
+
+
+
+/* ctype stuff. This is host-specific by necessity, as the arrays
+ that is used by most is*()/to*() macros are implementation-defined. */
+
+/* GLIBC 2.3 */
+#ifdef HAVE___CTYPE_B_LOC
+WRAPPER2(unsigned short **, __ctype_b_loc, void)
+{
+ static unsigned short * last_buf = (void *) 0;
+ static unsigned short ** last_ptr = (void *) 0;
+ unsigned short ** ptr = (unsigned short **) __ctype_b_loc ();
+ unsigned short * buf = * ptr;
+ if (ptr != last_ptr)
+ {
+ /* XXX: unregister last_ptr? */
+ last_ptr = ptr;
+ __mf_register (last_ptr, sizeof(last_ptr), __MF_TYPE_STATIC, "ctype_b_loc **");
+ }
+ if (buf != last_buf)
+ {
+ last_buf = buf;
+ __mf_register ((void *) (last_buf - 128), 384 * sizeof(unsigned short), __MF_TYPE_STATIC,
+ "ctype_b_loc []");
+ }
+ return ptr;
+}
+#endif
+
+#ifdef HAVE___CTYPE_TOUPPER_LOC
+WRAPPER2(int **, __ctype_toupper_loc, void)
+{
+ static int * last_buf = (void *) 0;
+ static int ** last_ptr = (void *) 0;
+ int ** ptr = (int **) __ctype_toupper_loc ();
+ int * buf = * ptr;
+ if (ptr != last_ptr)
+ {
+ /* XXX: unregister last_ptr? */
+ last_ptr = ptr;
+ __mf_register (last_ptr, sizeof(last_ptr), __MF_TYPE_STATIC, "ctype_toupper_loc **");
+ }
+ if (buf != last_buf)
+ {
+ last_buf = buf;
+ __mf_register ((void *) (last_buf - 128), 384 * sizeof(int), __MF_TYPE_STATIC,
+ "ctype_toupper_loc []");
+ }
+ return ptr;
+}
+#endif
+
+#ifdef HAVE___CTYPE_TOLOWER_LOC
+WRAPPER2(int **, __ctype_tolower_loc, void)
+{
+ static int * last_buf = (void *) 0;
+ static int ** last_ptr = (void *) 0;
+ int ** ptr = (int **) __ctype_tolower_loc ();
+ int * buf = * ptr;
+ if (ptr != last_ptr)
+ {
+ /* XXX: unregister last_ptr? */
+ last_ptr = ptr;
+ __mf_register (last_ptr, sizeof(last_ptr), __MF_TYPE_STATIC, "ctype_tolower_loc **");
+ }
+ if (buf != last_buf)
+ {
+ last_buf = buf;
+ __mf_register ((void *) (last_buf - 128), 384 * sizeof(int), __MF_TYPE_STATIC,
+ "ctype_tolower_loc []");
+ }
+ return ptr;
+}
+#endif
diff --git a/libmudflap/mf-runtime.c b/libmudflap/mf-runtime.c
index ca42ab7ebbd..19e9fe28cc2 100644
--- a/libmudflap/mf-runtime.c
+++ b/libmudflap/mf-runtime.c
@@ -63,6 +63,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include <sys/types.h>
#include <signal.h>
#include <errno.h>
+#include <ctype.h>
#include "mf-runtime.h"
#include "mf-impl.h"
@@ -685,6 +686,11 @@ __wrap_main (int argc, char* argv[])
__mf_register (stdin, sizeof (*stdin), __MF_TYPE_STATIC, "stdin");
__mf_register (stdout, sizeof (*stdout), __MF_TYPE_STATIC, "stdout");
__mf_register (stderr, sizeof (*stderr), __MF_TYPE_STATIC, "stderr");
+
+ /* Make some effort to register ctype.h static arrays. */
+ /* XXX: e.g., on Solaris, may need to register __ctype, _ctype, __ctype_mask, __toupper, etc. */
+ /* On modern Linux GLIBC, these are thread-specific and changeable, and are dealt
+ with in mf-hooks2.c. */
}
#ifdef PIC
diff --git a/libmudflap/mf-runtime.h.in b/libmudflap/mf-runtime.h.in
index 11f1f8de5fe..7b0467b5e56 100644
--- a/libmudflap/mf-runtime.h.in
+++ b/libmudflap/mf-runtime.h.in
@@ -177,6 +177,9 @@ extern int __mf_set_options (const char *opts);
#pragma redefine_extname shmctl __mfwrap_shmctl
#pragma redefine_extname shmat __mfwrap_shmat
#pragma redefine_extname shmdt __mfwrap_shmdt
+#pragma redefine_extname __ctype_b_loc __mfwrap___ctype_b_loc
+#pragma redefine_extname __ctype_toupper_loc __mfwrap___ctype_toupper_loc
+#pragma redefine_extname __ctype_tolower_loc __mfwrap___ctype_tolower_loc
/* Disable glibc macros. */
#define __NO_STRING_INLINES
diff --git a/libmudflap/testsuite/libmudflap.c/pass47-frag.c b/libmudflap/testsuite/libmudflap.c/pass47-frag.c
new file mode 100644
index 00000000000..9e4ac50ef3f
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass47-frag.c
@@ -0,0 +1,10 @@
+#include <stdlib.h>
+#include <ctype.h>
+
+int main ()
+{
+ char* buf = "hello";
+ return ! ((toupper (buf[0]) == 'H' && toupper ('z') == 'Z' &&
+ tolower (buf[4]) == 'o' && tolower ('X') == 'x' &&
+ isdigit (buf[3])) == 0 && isalnum ('4'));
+}