ctype support.
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. From-SVN: r82848
This commit is contained in:
parent
0e5b7cfaab
commit
dc88d66f1a
@ -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.
|
||||
|
@ -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
|
||||
|
||||
|
92
libmudflap/configure
vendored
92
libmudflap/configure
vendored
@ -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=$?
|
||||
|
@ -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])
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
10
libmudflap/testsuite/libmudflap.c/pass47-frag.c
Normal file
10
libmudflap/testsuite/libmudflap.c/pass47-frag.c
Normal file
@ -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'));
|
||||
}
|
Loading…
Reference in New Issue
Block a user