diff options
author | Frank Ch. Eigler <fche@gcc.gnu.org> | 2004-06-04 20:12:01 +0000 |
---|---|---|
committer | Frank Ch. Eigler <fche@gcc.gnu.org> | 2004-06-04 20:12:01 +0000 |
commit | 7954e85c0016deceecd4dafc8622292ad1363967 (patch) | |
tree | d248b4bcf141c1cec13d21a71e4945815f2ccb44 /libmudflap/mf-hooks2.c | |
parent | 28af2467e40311bbddd132788d0dcd7fe02f72d4 (diff) | |
download | gcc-7954e85c0016deceecd4dafc8622292ad1363967.zip gcc-7954e85c0016deceecd4dafc8622292ad1363967.tar.gz gcc-7954e85c0016deceecd4dafc8622292ad1363967.tar.bz2 |
Portability improvements, e.g., libmudflap/15293.
2004-06-04 Frank Ch. Eigler <fche@redhat.com>
Portability improvements, e.g., libmudflap/15293.
* configure.in: Look for glibc extension functions. Look for
support of -f{function,data}-sections. Look for more headers.
Create testsuite/mfconfig.exp. Correct more "test x.." thinkos.
* Makefile.am: Use $(SECTION_FLAGS). Collapse piecemeal-compiled
mf-hooks* into usual single object per source.
* mf-hooks*.c: Remove all #if WRAP_foo conditionals.
* mf-hooks2.c: #include a bunch more system headers. Define strnlen
if system doesn't provide one.
* mf-hooks3.c (struct pthread_info): Add stack_*_alloc fields.
(pthread_create): Use it to properly GC dead thread stacks.
* mf-runtime.c (__mf_violation): Correct snprintf type warning.
* testsuite/Makefile.am: Stop generating site.exp.
* testsuite/mfconfig.exp.in: New file.
* testsuite/config/default.exp: Load new mfconfig.exp.
* testsuite/lib/libmudflap.exp (libmudflap-init): Add extra libraries.
(prune_gcc_output): Add glibc static linking warnings.
* testsuite/libmudflap.*/*frags.exp: Enumerate needed -lmudflap* libs.
* testsuite/libmudflap.c/pass46-frag.c: Ditto.
* configure, Makefile, aclocal.m4, config.h.in, testsuite/Makefile.in:
Regenerated with autoconf 2.57 and automake 1.7.
From-SVN: r82632
Diffstat (limited to 'libmudflap/mf-hooks2.c')
-rw-r--r-- | libmudflap/mf-hooks2.c | 414 |
1 files changed, 138 insertions, 276 deletions
diff --git a/libmudflap/mf-hooks2.c b/libmudflap/mf-hooks2.c index 601dc24..ccd9931 100644 --- a/libmudflap/mf-hooks2.c +++ b/libmudflap/mf-hooks2.c @@ -1,5 +1,5 @@ /* Mudflap: narrow-pointer bounds-checking by tree rewriting. - Copyright (C) 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. Contributed by Frank Ch. Eigler <fche@redhat.com> and Graydon Hoare <graydon@redhat.com> @@ -47,12 +47,15 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #define __EXTENSIONS__ #define _ALL_SOURCE #define _LARGE_FILE_API +#define _LARGEFILE64_SOURCE #define _XOPEN_SOURCE_EXTENDED 1 #include <string.h> +#include <stdarg.h> #include <strings.h> #include <stdio.h> #include <stdlib.h> +#include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> @@ -60,6 +63,26 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include <errno.h> #include <limits.h> #include <time.h> +#include <dirent.h> +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif +#ifdef HAVE_NETDB_H +#include <netdb.h> +#endif +#ifdef HAVE_SYS_WAIT_H +#include <sys/wait.h> +#endif +#ifdef HAVE_SYS_IPC_H +#include <sys/ipc.h> +#endif +#ifdef HAVE_SYS_SEM_H +#include <sys/sem.h> +#endif +#ifdef HAVE_SYS_SHM_H +#include <sys/shm.h> +#endif + #include "mf-runtime.h" #include "mf-impl.h" @@ -72,10 +95,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA /* 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> +#ifndef HAVE_STRNLEN static inline size_t (strnlen) (const char* str, size_t n) { const char *s; @@ -86,9 +106,9 @@ static inline size_t (strnlen) (const char* str, size_t n) } #endif + /* str*,mem*,b* */ -#ifdef WRAP_memcpy WRAPPER2(void *, memcpy, void *dest, const void *src, size_t n) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -96,10 +116,8 @@ WRAPPER2(void *, memcpy, void *dest, const void *src, size_t n) MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "memcpy dest"); return memcpy (dest, src, n); } -#endif -#ifdef WRAP_memmove WRAPPER2(void *, memmove, void *dest, const void *src, size_t n) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -107,18 +125,16 @@ WRAPPER2(void *, memmove, void *dest, const void *src, size_t n) MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "memmove dest"); return memmove (dest, src, n); } -#endif -#ifdef WRAP_memset + WRAPPER2(void *, memset, void *s, int c, size_t n) { TRACE ("%s\n", __PRETTY_FUNCTION__); MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "memset dest"); return memset (s, c, n); } -#endif -#ifdef WRAP_memcmp + WRAPPER2(int, memcmp, const void *s1, const void *s2, size_t n) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -126,18 +142,17 @@ WRAPPER2(int, memcmp, const void *s1, const void *s2, size_t n) MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "memcmp 2nd arg"); return memcmp (s1, s2, n); } -#endif -#ifdef WRAP_memchr + WRAPPER2(void *, memchr, const void *s, int c, size_t n) { TRACE ("%s\n", __PRETTY_FUNCTION__); MF_VALIDATE_EXTENT(s, n, __MF_CHECK_READ, "memchr region"); return memchr (s, c, n); } -#endif -#ifdef WRAP_memrchr + +#ifdef HAVE_MEMRCHR WRAPPER2(void *, memrchr, const void *s, int c, size_t n) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -146,7 +161,7 @@ WRAPPER2(void *, memrchr, const void *s, int c, size_t n) } #endif -#ifdef WRAP_strcpy + WRAPPER2(char *, strcpy, char *dest, const char *src) { /* nb: just because strlen(src) == n doesn't mean (src + n) or (src + n + @@ -159,9 +174,9 @@ WRAPPER2(char *, strcpy, char *dest, const char *src) MF_VALIDATE_EXTENT(dest, CLAMPADD(n, 1), __MF_CHECK_WRITE, "strcpy dest"); return strcpy (dest, src); } -#endif -#ifdef WRAP_strncpy + +#ifdef HAVE_STRNCPY WRAPPER2(char *, strncpy, char *dest, const char *src, size_t n) { size_t len = strnlen (src, n); @@ -172,7 +187,7 @@ WRAPPER2(char *, strncpy, char *dest, const char *src, size_t n) } #endif -#ifdef WRAP_strcat + WRAPPER2(char *, strcat, char *dest, const char *src) { size_t dest_sz; @@ -185,9 +200,8 @@ WRAPPER2(char *, strcat, char *dest, const char *src) __MF_CHECK_WRITE, "strcat dest"); return strcat (dest, src); } -#endif -#ifdef WRAP_strncat + WRAPPER2(char *, strncat, char *dest, const char *src, size_t n) { @@ -221,9 +235,8 @@ WRAPPER2(char *, strncat, char *dest, const char *src, size_t n) __MF_CHECK_WRITE, "strncat dest"); return strncat (dest, src, n); } -#endif -#ifdef WRAP_strcmp + WRAPPER2(int, strcmp, const char *s1, const char *s2) { size_t s1_sz; @@ -235,9 +248,8 @@ WRAPPER2(int, strcmp, const char *s1, const char *s2) MF_VALIDATE_EXTENT(s2, CLAMPADD(s2_sz, 1), __MF_CHECK_WRITE, "strcmp 2nd arg"); return strcmp (s1, s2); } -#endif -#ifdef WRAP_strcasecmp + WRAPPER2(int, strcasecmp, const char *s1, const char *s2) { size_t s1_sz; @@ -249,9 +261,8 @@ WRAPPER2(int, strcasecmp, const char *s1, const char *s2) MF_VALIDATE_EXTENT(s2, CLAMPADD(s2_sz, 1), __MF_CHECK_READ, "strcasecmp 2nd arg"); return strcasecmp (s1, s2); } -#endif -#ifdef WRAP_strncmp + WRAPPER2(int, strncmp, const char *s1, const char *s2, size_t n) { size_t s1_sz; @@ -263,9 +274,8 @@ WRAPPER2(int, strncmp, const char *s1, const char *s2, size_t n) MF_VALIDATE_EXTENT(s2, s2_sz, __MF_CHECK_READ, "strncmp 2nd arg"); return strncmp (s1, s2, n); } -#endif -#ifdef WRAP_strncasecmp + WRAPPER2(int, strncasecmp, const char *s1, const char *s2, size_t n) { size_t s1_sz; @@ -277,9 +287,8 @@ WRAPPER2(int, strncasecmp, const char *s1, const char *s2, size_t n) MF_VALIDATE_EXTENT(s2, s2_sz, __MF_CHECK_READ, "strncasecmp 2nd arg"); return strncasecmp (s1, s2, n); } -#endif -#ifdef WRAP_strdup + WRAPPER2(char *, strdup, const char *s) { DECLARE(void *, malloc, size_t sz); @@ -301,9 +310,8 @@ WRAPPER2(char *, strdup, const char *s) __mf_register (result, CLAMPADD(n,1), __MF_TYPE_HEAP_I, "strdup region"); return result; } -#endif -#ifdef WRAP_strndup + WRAPPER2(char *, strndup, const char *s, size_t n) { DECLARE(void *, malloc, size_t sz); @@ -327,9 +335,8 @@ WRAPPER2(char *, strndup, const char *s, size_t n) __mf_register (result, CLAMPADD(n,1), __MF_TYPE_HEAP_I, "strndup region"); return result; } -#endif -#ifdef WRAP_strchr + WRAPPER2(char *, strchr, const char *s, int c) { size_t n; @@ -338,9 +345,8 @@ WRAPPER2(char *, strchr, const char *s, int c) MF_VALIDATE_EXTENT(s, CLAMPADD(n,1), __MF_CHECK_READ, "strchr region"); return strchr (s, c); } -#endif -#ifdef WRAP_strrchr + WRAPPER2(char *, strrchr, const char *s, int c) { size_t n; @@ -349,9 +355,8 @@ WRAPPER2(char *, strrchr, const char *s, int c) MF_VALIDATE_EXTENT(s, CLAMPADD(n,1), __MF_CHECK_READ, "strrchr region"); return strrchr (s, c); } -#endif -#ifdef WRAP_strstr + WRAPPER2(char *, strstr, const char *haystack, const char *needle) { size_t haystack_sz; @@ -363,9 +368,9 @@ WRAPPER2(char *, strstr, const char *haystack, const char *needle) MF_VALIDATE_EXTENT(needle, CLAMPADD(needle_sz, 1), __MF_CHECK_READ, "strstr needle"); return strstr (haystack, needle); } -#endif -#ifdef WRAP_memmem + +#ifdef HAVE_MEMMEM WRAPPER2(void *, memmem, const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) @@ -377,7 +382,7 @@ WRAPPER2(void *, memmem, } #endif -#ifdef WRAP_strlen + WRAPPER2(size_t, strlen, const char *s) { size_t result = strlen (s); @@ -385,9 +390,8 @@ WRAPPER2(size_t, strlen, const char *s) MF_VALIDATE_EXTENT(s, CLAMPADD(result, 1), __MF_CHECK_READ, "strlen region"); return result; } -#endif -#ifdef WRAP_strnlen + WRAPPER2(size_t, strnlen, const char *s, size_t n) { size_t result = strnlen (s, n); @@ -395,18 +399,16 @@ WRAPPER2(size_t, strnlen, const char *s, size_t n) MF_VALIDATE_EXTENT(s, result, __MF_CHECK_READ, "strnlen region"); return result; } -#endif -#ifdef WRAP_bzero + WRAPPER2(void, bzero, void *s, size_t n) { TRACE ("%s\n", __PRETTY_FUNCTION__); MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "bzero region"); bzero (s, n); } -#endif -#ifdef WRAP_bcopy + #undef bcopy WRAPPER2(void, bcopy, const void *src, void *dest, size_t n) { @@ -415,9 +417,8 @@ WRAPPER2(void, bcopy, const void *src, void *dest, size_t n) MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "bcopy dest"); bcopy (src, dest, n); } -#endif -#ifdef WRAP_bcmp + #undef bcmp WRAPPER2(int, bcmp, const void *s1, const void *s2, size_t n) { @@ -426,9 +427,8 @@ WRAPPER2(int, bcmp, const void *s1, const void *s2, size_t n) MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "bcmp 2nd arg"); return bcmp (s1, s2, n); } -#endif -#ifdef WRAP_index + WRAPPER2(char *, index, const char *s, int c) { size_t n = strlen (s); @@ -436,9 +436,8 @@ WRAPPER2(char *, index, const char *s, int c) MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "index region"); return index (s, c); } -#endif -#ifdef WRAP_rindex + WRAPPER2(char *, rindex, const char *s, int c) { size_t n = strlen (s); @@ -446,17 +445,13 @@ WRAPPER2(char *, rindex, const char *s, int c) MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "rindex region"); return rindex (s, c); } -#endif /* XXX: stpcpy, memccpy */ - /* XXX: *printf,*scanf */ - /* XXX: setjmp, longjmp */ -#ifdef WRAP_asctime WRAPPER2(char *, asctime, struct tm *tm) { static char *reg_result = NULL; @@ -471,9 +466,8 @@ WRAPPER2(char *, asctime, struct tm *tm) } return result; } -#endif -#ifdef WRAP_ctime + WRAPPER2(char *, ctime, const time_t *timep) { static char *reg_result = NULL; @@ -489,10 +483,8 @@ WRAPPER2(char *, ctime, const time_t *timep) } return result; } -#endif -#ifdef WRAP_localtime WRAPPER2(struct tm*, localtime, const time_t *timep) { static struct tm *reg_result = NULL; @@ -507,9 +499,8 @@ WRAPPER2(struct tm*, localtime, const time_t *timep) } return result; } -#endif -#ifdef WRAP_gmtime + WRAPPER2(struct tm*, gmtime, const time_t *timep) { static struct tm *reg_result = NULL; @@ -524,8 +515,6 @@ WRAPPER2(struct tm*, gmtime, const time_t *timep) } return result; } -#endif - /* EL start */ @@ -547,7 +536,6 @@ WRAPPER2(struct tm*, gmtime, const time_t *timep) #define MF_REGISTER_shmat __MF_TYPE_GUESS -#ifdef WRAP_time #include <time.h> WRAPPER2(time_t, time, time_t *timep) { @@ -557,9 +545,8 @@ WRAPPER2(time_t, time, time_t *timep) "time timep"); return time (timep); } -#endif -#ifdef WRAP_strerror + WRAPPER2(char *, strerror, int errnum) { char *p; @@ -576,9 +563,8 @@ WRAPPER2(char *, strerror, int errnum) } return p; } -#endif -#ifdef WRAP_fopen + WRAPPER2(FILE *, fopen, const char *path, const char *mode) { size_t n; @@ -601,10 +587,9 @@ WRAPPER2(FILE *, fopen, const char *path, const char *mode) return p; } -#endif + #ifdef HAVE_FOPEN64 -#ifdef WRAP_fopen64 WRAPPER2(FILE *, fopen64, const char *path, const char *mode) { size_t n; @@ -628,9 +613,8 @@ WRAPPER2(FILE *, fopen64, const char *path, const char *mode) return p; } #endif -#endif -#ifdef WRAP_fclose + WRAPPER2(int, fclose, FILE *stream) { int resp; @@ -644,9 +628,8 @@ WRAPPER2(int, fclose, FILE *stream) return resp; } -#endif -#ifdef WRAP_fread + WRAPPER2(size_t, fread, void *ptr, size_t size, size_t nmemb, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -655,9 +638,8 @@ WRAPPER2(size_t, fread, void *ptr, size_t size, size_t nmemb, FILE *stream) MF_VALIDATE_EXTENT (ptr, size * nmemb, __MF_CHECK_WRITE, "fread buffer"); return fread (ptr, size, nmemb, stream); } -#endif -#ifdef WRAP_fwrite + WRAPPER2(size_t, fwrite, const void *ptr, size_t size, size_t nmemb, FILE *stream) { @@ -667,9 +649,8 @@ WRAPPER2(size_t, fwrite, const void *ptr, size_t size, size_t nmemb, MF_VALIDATE_EXTENT (ptr, size * nmemb, __MF_CHECK_READ, "fwrite buffer"); return fwrite (ptr, size, nmemb, stream); } -#endif -#ifdef WRAP_fgetc + WRAPPER2(int, fgetc, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -677,9 +658,8 @@ WRAPPER2(int, fgetc, FILE *stream) "fgetc stream"); return fgetc (stream); } -#endif -#ifdef WRAP_fgets + WRAPPER2(char *, fgets, char *s, int size, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -688,9 +668,8 @@ WRAPPER2(char *, fgets, char *s, int size, FILE *stream) MF_VALIDATE_EXTENT (s, size, __MF_CHECK_WRITE, "fgets buffer"); return fgets (s, size, stream); } -#endif -#ifdef WRAP_getc + WRAPPER2(int, getc, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -698,9 +677,8 @@ WRAPPER2(int, getc, FILE *stream) "getc stream"); return getc (stream); } -#endif -#ifdef WRAP_gets + WRAPPER2(char *, gets, char *s) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -713,9 +691,8 @@ WRAPPER2(char *, gets, char *s) } return s; } -#endif -#ifdef WRAP_ungetc + WRAPPER2(int, ungetc, int c, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -723,9 +700,8 @@ WRAPPER2(int, ungetc, int c, FILE *stream) "ungetc stream"); return ungetc (c, stream); } -#endif -#ifdef WRAP_fputc + WRAPPER2(int, fputc, int c, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -733,9 +709,8 @@ WRAPPER2(int, fputc, int c, FILE *stream) "fputc stream"); return fputc (c, stream); } -#endif -#ifdef WRAP_fputs + WRAPPER2(int, fputs, const char *s, FILE *stream) { size_t n; @@ -746,9 +721,8 @@ WRAPPER2(int, fputs, const char *s, FILE *stream) "fputs stream"); return fputs (s, stream); } -#endif -#ifdef WRAP_putc + WRAPPER2(int, putc, int c, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -756,9 +730,8 @@ WRAPPER2(int, putc, int c, FILE *stream) "putc stream"); return putc (c, stream); } -#endif -#ifdef WRAP_puts + WRAPPER2(int, puts, const char *s) { size_t n; @@ -767,9 +740,8 @@ WRAPPER2(int, puts, const char *s) MF_VALIDATE_EXTENT (s, CLAMPADD(n, 1), __MF_CHECK_READ, "puts buffer"); return puts (s); } -#endif -#ifdef WRAP_clearerr + WRAPPER2(void, clearerr, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -777,9 +749,8 @@ WRAPPER2(void, clearerr, FILE *stream) "clearerr stream"); clearerr (stream); } -#endif -#ifdef WRAP_feof + WRAPPER2(int, feof, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -787,9 +758,8 @@ WRAPPER2(int, feof, FILE *stream) "feof stream"); return feof (stream); } -#endif -#ifdef WRAP_ferror + WRAPPER2(int, ferror, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -797,10 +767,8 @@ WRAPPER2(int, ferror, FILE *stream) "ferror stream"); return ferror (stream); } -#endif -#ifdef WRAP_fileno -#include <stdio.h> + WRAPPER2(int, fileno, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -808,11 +776,8 @@ WRAPPER2(int, fileno, FILE *stream) "fileno stream"); return fileno (stream); } -#endif -#ifdef WRAP_printf -#include <stdio.h> -#include <stdarg.h> + WRAPPER2(int, printf, const char *format, ...) { size_t n; @@ -827,11 +792,8 @@ WRAPPER2(int, printf, const char *format, ...) va_end (ap); return result; } -#endif -#ifdef WRAP_fprintf -#include <stdio.h> -#include <stdarg.h> + WRAPPER2(int, fprintf, FILE *stream, const char *format, ...) { size_t n; @@ -848,11 +810,8 @@ WRAPPER2(int, fprintf, FILE *stream, const char *format, ...) va_end (ap); return result; } -#endif -#ifdef WRAP_sprintf -#include <stdio.h> -#include <stdarg.h> + WRAPPER2(int, sprintf, char *str, const char *format, ...) { size_t n; @@ -870,11 +829,8 @@ WRAPPER2(int, sprintf, char *str, const char *format, ...) MF_VALIDATE_EXTENT (str, CLAMPADD(n, 1), __MF_CHECK_WRITE, "sprintf str"); return result; } -#endif -#ifdef WRAP_snprintf -#include <stdio.h> -#include <stdarg.h> + WRAPPER2(int, snprintf, char *str, size_t size, const char *format, ...) { size_t n; @@ -890,11 +846,8 @@ WRAPPER2(int, snprintf, char *str, size_t size, const char *format, ...) va_end (ap); return result; } -#endif -#ifdef WRAP_vprintf -#include <stdio.h> -#include <stdarg.h> + WRAPPER2(int, vprintf, const char *format, va_list ap) { size_t n; @@ -904,11 +857,8 @@ WRAPPER2(int, vprintf, const char *format, va_list ap) "vprintf format"); return vprintf (format, ap); } -#endif -#ifdef WRAP_vfprintf -#include <stdio.h> -#include <stdarg.h> + WRAPPER2(int, vfprintf, FILE *stream, const char *format, va_list ap) { size_t n; @@ -920,11 +870,8 @@ WRAPPER2(int, vfprintf, FILE *stream, const char *format, va_list ap) "vfprintf format"); return vfprintf (stream, format, ap); } -#endif -#ifdef WRAP_vsprintf -#include <stdio.h> -#include <stdarg.h> + WRAPPER2(int, vsprintf, char *str, const char *format, va_list ap) { size_t n; @@ -939,11 +886,8 @@ WRAPPER2(int, vsprintf, char *str, const char *format, va_list ap) MF_VALIDATE_EXTENT (str, CLAMPADD(n, 1), __MF_CHECK_WRITE, "vsprintf str"); return result; } -#endif -#ifdef WRAP_vsnprintf -#include <stdio.h> -#include <stdarg.h> + WRAPPER2(int, vsnprintf, char *str, size_t size, const char *format, va_list ap) { @@ -955,9 +899,8 @@ WRAPPER2(int, vsnprintf, char *str, size_t size, const char *format, "vsnprintf format"); return vsnprintf (str, size, format, ap); } -#endif -#ifdef WRAP_access + WRAPPER2(int , access, const char *path, int mode) { size_t n; @@ -966,9 +909,8 @@ WRAPPER2(int , access, const char *path, int mode) MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "access path"); return access (path, mode); } -#endif -#ifdef WRAP_remove + WRAPPER2(int , remove, const char *path) { size_t n; @@ -977,9 +919,8 @@ WRAPPER2(int , remove, const char *path) MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "remove path"); return remove (path); } -#endif -#ifdef WRAP_fflush + WRAPPER2(int, fflush, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -987,9 +928,8 @@ WRAPPER2(int, fflush, FILE *stream) "fflush stream"); return fflush (stream); } -#endif -#ifdef WRAP_fseek + WRAPPER2(int, fseek, FILE *stream, long offset, int whence) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -997,10 +937,9 @@ WRAPPER2(int, fseek, FILE *stream, long offset, int whence) "fseek stream"); return fseek (stream, offset, whence); } -#endif + #ifdef HAVE_FSEEKO64 -#ifdef WRAP_fseeko64 WRAPPER2(int, fseeko64, FILE *stream, off64_t offset, int whence) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1009,9 +948,8 @@ WRAPPER2(int, fseeko64, FILE *stream, off64_t offset, int whence) return fseeko64 (stream, offset, whence); } #endif -#endif -#ifdef WRAP_ftell + WRAPPER2(long, ftell, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1019,10 +957,9 @@ WRAPPER2(long, ftell, FILE *stream) "ftell stream"); return ftell (stream); } -#endif + #ifdef HAVE_FTELLO64 -#ifdef WRAP_ftello64 WRAPPER2(off64_t, ftello64, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1031,9 +968,8 @@ WRAPPER2(off64_t, ftello64, FILE *stream) return ftello64 (stream); } #endif -#endif -#ifdef WRAP_rewind + WRAPPER2(void, rewind, FILE *stream) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1041,9 +977,8 @@ WRAPPER2(void, rewind, FILE *stream) "rewind stream"); rewind (stream); } -#endif -#ifdef WRAP_fgetpos + WRAPPER2(int, fgetpos, FILE *stream, fpos_t *pos) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1052,9 +987,8 @@ WRAPPER2(int, fgetpos, FILE *stream, fpos_t *pos) MF_VALIDATE_EXTENT (pos, sizeof (*pos), __MF_CHECK_WRITE, "fgetpos pos"); return fgetpos (stream, pos); } -#endif -#ifdef WRAP_fsetpos + WRAPPER2(int, fsetpos, FILE *stream, fpos_t *pos) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1063,10 +997,8 @@ WRAPPER2(int, fsetpos, FILE *stream, fpos_t *pos) MF_VALIDATE_EXTENT (pos, sizeof (*pos), __MF_CHECK_READ, "fsetpos pos"); return fsetpos (stream, pos); } -#endif -#ifdef WRAP_stat -#include <sys/stat.h> + WRAPPER2(int , stat, const char *path, struct stat *buf) { size_t n; @@ -1076,11 +1008,9 @@ WRAPPER2(int , stat, const char *path, struct stat *buf) MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_READ, "stat buf"); return stat (path, buf); } -#endif + #ifdef HAVE_STAT64 -#ifdef WRAP_stat64 -#include <sys/stat.h> WRAPPER2(int , stat64, const char *path, struct stat64 *buf) { size_t n; @@ -1091,20 +1021,16 @@ WRAPPER2(int , stat64, const char *path, struct stat64 *buf) return stat64 (path, buf); } #endif -#endif -#ifdef WRAP_fstat -#include <sys/stat.h> + WRAPPER2(int , fstat, int filedes, struct stat *buf) { TRACE ("%s\n", __PRETTY_FUNCTION__); MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_READ, "fstat buf"); return fstat (filedes, buf); } -#endif -#ifdef WRAP_lstat -#include <sys/stat.h> + WRAPPER2(int , lstat, const char *path, struct stat *buf) { size_t n; @@ -1114,10 +1040,8 @@ WRAPPER2(int , lstat, const char *path, struct stat *buf) MF_VALIDATE_EXTENT (buf, sizeof (*buf), __MF_CHECK_READ, "lstat buf"); return lstat (path, buf); } -#endif -#ifdef WRAP_mkfifo -#include <sys/stat.h> + WRAPPER2(int , mkfifo, const char *path, mode_t mode) { size_t n; @@ -1126,9 +1050,8 @@ WRAPPER2(int , mkfifo, const char *path, mode_t mode) MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "mkfifo path"); return mkfifo (path, mode); } -#endif -#ifdef WRAP_setvbuf + WRAPPER2(int, setvbuf, FILE *stream, char *buf, int mode , size_t size) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1138,9 +1061,8 @@ WRAPPER2(int, setvbuf, FILE *stream, char *buf, int mode , size_t size) MF_VALIDATE_EXTENT (buf, size, __MF_CHECK_READ, "setvbuf buf"); return setvbuf (stream, buf, mode, size); } -#endif -#ifdef WRAP_setbuf + WRAPPER2(void, setbuf, FILE *stream, char *buf) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1150,10 +1072,8 @@ WRAPPER2(void, setbuf, FILE *stream, char *buf) MF_VALIDATE_EXTENT (buf, BUFSIZ, __MF_CHECK_READ, "setbuf buf"); setbuf (stream, buf); } -#endif -#ifdef WRAP_opendir -#include <dirent.h> + WRAPPER2(DIR *, opendir, const char *path) { DIR *p; @@ -1173,10 +1093,8 @@ WRAPPER2(DIR *, opendir, const char *path) } return p; } -#endif -#ifdef WRAP_closedir -#include <dirent.h> + WRAPPER2(int, closedir, DIR *dir) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1186,10 +1104,8 @@ WRAPPER2(int, closedir, DIR *dir) #endif return closedir (dir); } -#endif -#ifdef WRAP_readdir -#include <dirent.h> + WRAPPER2(struct dirent *, readdir, DIR *dir) { struct dirent *p; @@ -1204,22 +1120,18 @@ WRAPPER2(struct dirent *, readdir, DIR *dir) } return p; } -#endif + #ifdef HAVE_SYS_SOCKET_H -#ifdef WRAP_recv -#include <sys/socket.h> WRAPPER2(int, recv, int s, void *buf, size_t len, int flags) { TRACE ("%s\n", __PRETTY_FUNCTION__); MF_VALIDATE_EXTENT (buf, len, __MF_CHECK_WRITE, "recv buf"); return recv (s, buf, len, flags); } -#endif -#ifdef WRAP_recvfrom -#include <sys/socket.h> + WRAPPER2(int, recvfrom, int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen) { @@ -1229,30 +1141,24 @@ WRAPPER2(int, recvfrom, int s, void *buf, size_t len, int flags, "recvfrom from"); return recvfrom (s, buf, len, flags, from, fromlen); } -#endif -#ifdef WRAP_recvmsg -#include <sys/socket.h> + WRAPPER2(int, recvmsg, int s, struct msghdr *msg, int flags) { TRACE ("%s\n", __PRETTY_FUNCTION__); MF_VALIDATE_EXTENT (msg, sizeof (*msg), __MF_CHECK_WRITE, "recvmsg msg"); return recvmsg (s, msg, flags); } -#endif -#ifdef WRAP_send -#include <sys/socket.h> + WRAPPER2(int, send, int s, const void *msg, size_t len, int flags) { TRACE ("%s\n", __PRETTY_FUNCTION__); MF_VALIDATE_EXTENT (msg, len, __MF_CHECK_READ, "send msg"); return send (s, msg, len, flags); } -#endif -#ifdef WRAP_sendto -#include <sys/socket.h> + WRAPPER2(int, sendto, int s, const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) { @@ -1261,20 +1167,16 @@ WRAPPER2(int, sendto, int s, const void *msg, size_t len, int flags, MF_VALIDATE_EXTENT (to, (size_t)tolen, __MF_CHECK_WRITE, "sendto to"); return sendto (s, msg, len, flags, to, tolen); } -#endif -#ifdef WRAP_sendmsg -#include <sys/socket.h> + WRAPPER2(int, sendmsg, int s, const void *msg, int flags) { TRACE ("%s\n", __PRETTY_FUNCTION__); MF_VALIDATE_EXTENT (msg, sizeof (*msg), __MF_CHECK_READ, "sendmsg msg"); return sendmsg (s, msg, flags); } -#endif -#ifdef WRAP_setsockopt -#include <sys/socket.h> + WRAPPER2(int, setsockopt, int s, int level, int optname, const void *optval, socklen_t optlen) { @@ -1283,10 +1185,8 @@ WRAPPER2(int, setsockopt, int s, int level, int optname, const void *optval, "setsockopt optval"); return setsockopt (s, level, optname, optval, optlen); } -#endif -#ifdef WRAP_getsockopt -#include <sys/socket.h> + WRAPPER2(int, getsockopt, int s, int level, int optname, void *optval, socklen_t *optlen) { @@ -1295,30 +1195,24 @@ WRAPPER2(int, getsockopt, int s, int level, int optname, void *optval, "getsockopt optval"); return getsockopt (s, level, optname, optval, optlen); } -#endif -#ifdef WRAP_accept -#include <sys/socket.h> + WRAPPER2(int, accept, int s, struct sockaddr *addr, socklen_t *addrlen) { TRACE ("%s\n", __PRETTY_FUNCTION__); MF_VALIDATE_EXTENT (addr, (size_t)*addrlen, __MF_CHECK_WRITE, "accept addr"); return accept (s, addr, addrlen); } -#endif -#ifdef WRAP_bind -#include <sys/socket.h> + WRAPPER2(int, bind, int sockfd, struct sockaddr *addr, socklen_t addrlen) { TRACE ("%s\n", __PRETTY_FUNCTION__); MF_VALIDATE_EXTENT (addr, (size_t)addrlen, __MF_CHECK_WRITE, "bind addr"); return bind (sockfd, addr, addrlen); } -#endif -#ifdef WRAP_connect -#include <sys/socket.h> + WRAPPER2(int, connect, int sockfd, const struct sockaddr *addr, socklen_t addrlen) { @@ -1327,20 +1221,19 @@ WRAPPER2(int, connect, int sockfd, const struct sockaddr *addr, "connect addr"); return connect (sockfd, addr, addrlen); } -#endif #endif /* HAVE_SYS_SOCKET_H */ -#ifdef WRAP_gethostname + WRAPPER2(int, gethostname, char *name, size_t len) { TRACE ("%s\n", __PRETTY_FUNCTION__); MF_VALIDATE_EXTENT (name, len, __MF_CHECK_WRITE, "gethostname name"); return gethostname (name, len); } -#endif -#ifdef WRAP_sethostname + +#ifdef HAVE_SETHOSTNAME WRAPPER2(int, sethostname, const char *name, size_t len) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1349,10 +1242,9 @@ WRAPPER2(int, sethostname, const char *name, size_t len) } #endif + #ifdef HAVE_NETDB_H -#ifdef WRAP_gethostbyname -#include <netdb.h> WRAPPER2(struct hostent *, gethostbyname, const char *name) { struct hostent *p; @@ -1429,14 +1321,12 @@ WRAPPER2(struct hostent *, gethostbyname, const char *name) } return p; } -#endif #endif /* HAVE_NETDB_H */ -#ifdef SYS_WAIT_H -#ifdef WRAP_wait -#include <sys/wait.h> +#ifdef HAVE_SYS_WAIT_H + WRAPPER2(pid_t, wait, int *status) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1445,10 +1335,8 @@ WRAPPER2(pid_t, wait, int *status) "wait status"); return wait (status); } -#endif -#ifdef WRAP_waitpid -#include <sys/wait.h> + WRAPPER2(pid_t, waitpid, pid_t pid, int *status, int options) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1457,11 +1345,10 @@ WRAPPER2(pid_t, waitpid, pid_t pid, int *status, int options) "waitpid status"); return waitpid (pid, status, options); } -#endif #endif /* HAVE_SYS_WAIT_H */ -#ifdef WRAP_popen + WRAPPER2(FILE *, popen, const char *command, const char *mode) { size_t n; @@ -1483,9 +1370,8 @@ WRAPPER2(FILE *, popen, const char *command, const char *mode) } return p; } -#endif -#ifdef WRAP_pclose + WRAPPER2(int, pclose, FILE *stream) { int resp; @@ -1498,9 +1384,8 @@ WRAPPER2(int, pclose, FILE *stream) #endif return resp; } -#endif -#ifdef WRAP_execve + WRAPPER2(int, execve, const char *path, char *const argv [], char *const envp[]) { @@ -1531,9 +1416,8 @@ WRAPPER2(int, execve, const char *path, char *const argv [], } return execve (path, argv, envp); } -#endif -#ifdef WRAP_execv + WRAPPER2(int, execv, const char *path, char *const argv []) { size_t n; @@ -1554,9 +1438,8 @@ WRAPPER2(int, execv, const char *path, char *const argv []) } return execv (path, argv); } -#endif -#ifdef WRAP_execvp + WRAPPER2(int, execvp, const char *path, char *const argv []) { size_t n; @@ -1577,9 +1460,8 @@ WRAPPER2(int, execvp, const char *path, char *const argv []) } return execvp (path, argv); } -#endif -#ifdef WRAP_system + WRAPPER2(int, system, const char *string) { size_t n; @@ -1589,9 +1471,8 @@ WRAPPER2(int, system, const char *string) "system string"); return system (string); } -#endif -#ifdef WRAP_dlopen + WRAPPER2(void *, dlopen, const char *path, int flags) { void *p; @@ -1608,9 +1489,8 @@ WRAPPER2(void *, dlopen, const char *path, int flags) } return p; } -#endif -#ifdef WRAP_dlclose + WRAPPER2(int, dlclose, void *handle) { int resp; @@ -1622,9 +1502,8 @@ WRAPPER2(int, dlclose, void *handle) #endif return resp; } -#endif -#ifdef WRAP_dlerror + WRAPPER2(char *, dlerror) { char *p; @@ -1641,9 +1520,8 @@ WRAPPER2(char *, dlerror) } return p; } -#endif -#ifdef WRAP_dlsym + WRAPPER2(void *, dlsym, void *handle, char *symbol) { size_t n; @@ -1661,13 +1539,10 @@ WRAPPER2(void *, dlsym, void *handle, char *symbol) } return p; } -#endif -#if defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SEM_H) -#ifdef WRAP_semop -#include <sys/ipc.h> -#include <sys/sem.h> +#if defined (HAVE_SYS_IPC_H) && defined (HAVE_SYS_SEM_H) && defined (HAVE_SYS_SHM_H) + WRAPPER2(int, semop, int semid, struct sembuf *sops, unsigned nsops) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1675,11 +1550,8 @@ WRAPPER2(int, semop, int semid, struct sembuf *sops, unsigned nsops) "semop sops"); return semop (semid, sops, nsops); } -#endif -#ifdef WRAP_semctl -#include <sys/ipc.h> -#include <sys/sem.h> + #ifndef HAVE_UNION_SEMUN union semun { int val; /* value for SETVAL */ @@ -1721,11 +1593,8 @@ WRAPPER2(int, semctl, int semid, int semnum, int cmd, union semun arg) } return semctl (semid, semnum, cmd, arg); } -#endif -#ifdef WRAP_shmctl -#include <sys/ipc.h> -#include <sys/shm.h> + WRAPPER2(int, shmctl, int shmid, int cmd, struct shmid_ds *buf) { TRACE ("%s\n", __PRETTY_FUNCTION__); @@ -1743,11 +1612,8 @@ WRAPPER2(int, shmctl, int shmid, int cmd, struct shmid_ds *buf) } return shmctl (shmid, cmd, buf); } -#endif -#ifdef WRAP_shmat -#include <sys/ipc.h> -#include <sys/shm.h> + WRAPPER2(void *, shmat, int shmid, const void *shmaddr, int shmflg) { void *p; @@ -1762,11 +1628,8 @@ WRAPPER2(void *, shmat, int shmid, const void *shmaddr, int shmflg) #endif return p; } -#endif -#ifdef WRAP_shmdt -#include <sys/ipc.h> -#include <sys/shm.h> + WRAPPER2(int, shmdt, const void *shmaddr) { int resp; @@ -1777,7 +1640,6 @@ WRAPPER2(int, shmdt, const void *shmaddr) #endif return resp; } -#endif -#endif /* defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SEM_H) */ +#endif /* HAVE_SYS_IPC/SEM/SHM_H */ |