2006-11-03 Paul Brook <paul@codesourcery.com>
[official-gcc.git] / libmudflap / mf-runtime.h
blob3dd9154011ea274b14c82916c139c39df97dd1a9
1 /* Implementation header for mudflap runtime library.
2 Mudflap: narrow-pointer bounds-checking by tree rewriting.
3 Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 Contributed by Frank Ch. Eigler <fche@redhat.com>
5 and Graydon Hoare <graydon@redhat.com>
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
12 version.
14 In addition to the permissions in the GNU General Public License, the
15 Free Software Foundation gives you unlimited permission to link the
16 compiled version of this file into combinations with other programs,
17 and to distribute those combinations without any restriction coming
18 from the use of this file. (The General Public License restrictions
19 do apply in other respects; for example, they cover modification of
20 the file, and distribution when not linked into a combine
21 executable.)
23 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
24 WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 for more details.
28 You should have received a copy of the GNU General Public License
29 along with GCC; see the file COPYING. If not, write to the Free
30 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
31 02110-1301, USA. */
33 /* Public libmudflap declarations -*- C -*- */
35 #ifndef MF_RUNTIME_H
36 #define MF_RUNTIME_H
38 typedef void *__mf_ptr_t;
39 typedef unsigned int __mf_uintptr_t __attribute__ ((__mode__ (__pointer__)));
40 typedef __SIZE_TYPE__ __mf_size_t;
42 /* Global declarations used by instrumentation. When _MUDFLAP is
43 defined, these have been auto-declared by the compiler and we
44 should not declare them again (ideally we *would* declare them
45 again, to verify that the compiler's declarations match the
46 library's, but the C++ front end has no mechanism for allowing
47 the re-definition of a structure type). */
48 #ifndef _MUDFLAP
49 struct __mf_cache { __mf_uintptr_t low; __mf_uintptr_t high; };
50 extern struct __mf_cache __mf_lookup_cache [];
51 extern __mf_uintptr_t __mf_lc_mask;
52 extern unsigned char __mf_lc_shift;
53 #endif
55 /* Multithreading support. */
56 #ifdef _MUDFLAPTH
57 /* extern pthread_mutex_t __mf_biglock; */
58 #ifndef _REENTRANT
59 #define _REENTRANT
60 #endif
61 #ifndef _THREAD_SAFE
62 #define _THREAD_SAFE
63 #endif
64 #endif
66 /* Codes to describe the type of access to check: __mf_check arg 3 */
68 #define __MF_CHECK_READ 0
69 #define __MF_CHECK_WRITE 1
72 /* Codes to describe a region of memory being registered: __mf_*register arg 3 */
74 #define __MF_TYPE_NOACCESS 0
75 #define __MF_TYPE_HEAP 1
76 #define __MF_TYPE_HEAP_I 2
77 #define __MF_TYPE_STACK 3
78 #define __MF_TYPE_STATIC 4
79 #define __MF_TYPE_GUESS 5
82 /* The public mudflap API */
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
88 extern void __mf_check (void *ptr, __mf_size_t sz, int type, const char *location)
89 __attribute((nothrow));
90 extern void __mf_register (void *ptr, __mf_size_t sz, int type, const char *name)
91 __attribute((nothrow));
92 extern void __mf_unregister (void *ptr, __mf_size_t sz, int type)
93 __attribute((nothrow));
94 extern unsigned __mf_watch (void *ptr, __mf_size_t sz);
95 extern unsigned __mf_unwatch (void *ptr, __mf_size_t sz);
96 extern void __mf_report ();
97 extern int __mf_set_options (const char *opts);
100 /* Redirect some standard library functions to libmudflap. These are
101 done by simple #define rather than linker wrapping, since only
102 instrumented modules are meant to be affected. */
104 #ifdef _MUDFLAP
105 #pragma redefine_extname memcpy __mfwrap_memcpy
106 #pragma redefine_extname memmove __mfwrap_memmove
107 #pragma redefine_extname memset __mfwrap_memset
108 #pragma redefine_extname memcmp __mfwrap_memcmp
109 #pragma redefine_extname memchr __mfwrap_memchr
110 #pragma redefine_extname memrchr __mfwrap_memrchr
111 #pragma redefine_extname strcpy __mfwrap_strcpy
112 #pragma redefine_extname strncpy __mfwrap_strncpy
113 #pragma redefine_extname strcat __mfwrap_strcat
114 #pragma redefine_extname strncat __mfwrap_strncat
115 #pragma redefine_extname strcmp __mfwrap_strcmp
116 #pragma redefine_extname strcasecmp __mfwrap_strcasecmp
117 #pragma redefine_extname strncmp __mfwrap_strncmp
118 #pragma redefine_extname strncasecmp __mfwrap_strncasecmp
119 #pragma redefine_extname strdup __mfwrap_strdup
120 #pragma redefine_extname strndup __mfwrap_strndup
121 #pragma redefine_extname strchr __mfwrap_strchr
122 #pragma redefine_extname strrchr __mfwrap_strrchr
123 #pragma redefine_extname strstr __mfwrap_strstr
124 #pragma redefine_extname memmem __mfwrap_memmem
125 #pragma redefine_extname strlen __mfwrap_strlen
126 #pragma redefine_extname strnlen __mfwrap_strnlen
127 #pragma redefine_extname bzero __mfwrap_bzero
128 #pragma redefine_extname bcopy __mfwrap_bcopy
129 #pragma redefine_extname bcmp __mfwrap_bcmp
130 #pragma redefine_extname index __mfwrap_index
131 #pragma redefine_extname rindex __mfwrap_rindex
132 #pragma redefine_extname asctime __mfwrap_asctime
133 #pragma redefine_extname ctime __mfwrap_ctime
134 #pragma redefine_extname gmtime __mfwrap_gmtime
135 #pragma redefine_extname localtime __mfwrap_localtime
136 #pragma redefine_extname time __mfwrap_time
137 #pragma redefine_extname strerror __mfwrap_strerror
138 #pragma redefine_extname fopen __mfwrap_fopen
139 #pragma redefine_extname fdopen __mfwrap_fdopen
140 #pragma redefine_extname freopen __mfwrap_freopen
141 #pragma redefine_extname fclose __mfwrap_fclose
142 #pragma redefine_extname fread __mfwrap_fread
143 #pragma redefine_extname fwrite __mfwrap_fwrite
144 #pragma redefine_extname fgetc __mfwrap_fgetc
145 #pragma redefine_extname fgets __mfwrap_fgets
146 #pragma redefine_extname getc __mfwrap_getc
147 #pragma redefine_extname gets __mfwrap_gets
148 #pragma redefine_extname ungetc __mfwrap_ungetc
149 #pragma redefine_extname fputc __mfwrap_fputc
150 #pragma redefine_extname fputs __mfwrap_fputs
151 #pragma redefine_extname putc __mfwrap_putc
152 #pragma redefine_extname puts __mfwrap_puts
153 #pragma redefine_extname clearerr __mfwrap_clearerr
154 #pragma redefine_extname feof __mfwrap_feof
155 #pragma redefine_extname ferror __mfwrap_ferror
156 #pragma redefine_extname fileno __mfwrap_fileno
157 #pragma redefine_extname printf __mfwrap_printf
158 #pragma redefine_extname fprintf __mfwrap_fprintf
159 #pragma redefine_extname sprintf __mfwrap_sprintf
160 #pragma redefine_extname snprintf __mfwrap_snprintf
161 #pragma redefine_extname vprintf __mfwrap_vprintf
162 #pragma redefine_extname vfprintf __mfwrap_vfprintf
163 #pragma redefine_extname vsprintf __mfwrap_vsprintf
164 #pragma redefine_extname vsnprintf __mfwrap_vsnprintf
165 #pragma redefine_extname access __mfwrap_access
166 #pragma redefine_extname remove __mfwrap_remove
167 #pragma redefine_extname fflush __mfwrap_fflush
168 #pragma redefine_extname fseek __mfwrap_fseek
169 #pragma redefine_extname ftell __mfwrap_ftell
170 #pragma redefine_extname rewind __mfwrap_rewind
171 #pragma redefine_extname fgetpos __mfwrap_fgetpos
172 #pragma redefine_extname fsetpos __mfwrap_fsetpos
173 #pragma redefine_extname stat __mfwrap_stat
174 #pragma redefine_extname fstat __mfwrap_fstat
175 #pragma redefine_extname lstat __mfwrap_lstat
176 #pragma redefine_extname mkfifo __mfwrap_mkfifo
177 #pragma redefine_extname setvbuf __mfwrap_setvbuf
178 #pragma redefine_extname setbuf __mfwrap_setbuf
179 #pragma redefine_extname setbuffer __mfwrap_setbuffer
180 #pragma redefine_extname setlinebuf __mfwrap_setlinebuf
181 #pragma redefine_extname opendir __mfwrap_opendir
182 #pragma redefine_extname closedir __mfwrap_closedir
183 #pragma redefine_extname readdir __mfwrap_readdir
184 #pragma redefine_extname recv __mfwrap_recv
185 #pragma redefine_extname recvfrom __mfwrap_recvfrom
186 #pragma redefine_extname recvmsg __mfwrap_recvmsg
187 #pragma redefine_extname send __mfwrap_send
188 #pragma redefine_extname sendto __mfwrap_sendto
189 #pragma redefine_extname sendmsg __mfwrap_sendmsg
190 #pragma redefine_extname setsockopt __mfwrap_setsockopt
191 #pragma redefine_extname getsockopt __mfwrap_getsockopt
192 #pragma redefine_extname accept __mfwrap_accept
193 #pragma redefine_extname bind __mfwrap_bind
194 #pragma redefine_extname connect __mfwrap_connect
195 #pragma redefine_extname gethostname __mfwrap_gethostname
196 #pragma redefine_extname sethostname __mfwrap_sethostname
197 #pragma redefine_extname gethostbyname __mfwrap_gethostbyname
198 #pragma redefine_extname wait __mfwrap_wait
199 #pragma redefine_extname waitpid __mfwrap_waitpid
200 #pragma redefine_extname popen __mfwrap_popen
201 #pragma redefine_extname pclose __mfwrap_pclose
202 #pragma redefine_extname execve __mfwrap_execve
203 #pragma redefine_extname execv __mfwrap_execv
204 #pragma redefine_extname execvp __mfwrap_execvp
205 #pragma redefine_extname system __mfwrap_system
206 #pragma redefine_extname dlopen __mfwrap_dlopen
207 #pragma redefine_extname dlerror __mfwrap_dlerror
208 #pragma redefine_extname dlsym __mfwrap_dlsym
209 #pragma redefine_extname dlclose __mfwrap_dlclose
210 #pragma redefine_extname fopen64 __mfwrap_fopen64
211 #pragma redefine_extname freopen64 __mfwrap_freopen64
212 #pragma redefine_extname stat64 __mfwrap_stat64
213 #pragma redefine_extname fseeko64 __mfwrap_fseeko64
214 #pragma redefine_extname ftello64 __mfwrap_ftello64
215 #pragma redefine_extname semop __mfwrap_semop
216 #pragma redefine_extname semctl __mfwrap_semctl
217 #pragma redefine_extname shmctl __mfwrap_shmctl
218 #pragma redefine_extname shmat __mfwrap_shmat
219 #pragma redefine_extname shmdt __mfwrap_shmdt
220 #pragma redefine_extname __ctype_b_loc __mfwrap___ctype_b_loc
221 #pragma redefine_extname __ctype_toupper_loc __mfwrap___ctype_toupper_loc
222 #pragma redefine_extname __ctype_tolower_loc __mfwrap___ctype_tolower_loc
223 #pragma redefine_extname getlogin __mfwrap_getlogin
224 #pragma redefine_extname cuserid __mfwrap_cuserid
225 #pragma redefine_extname getpwnam __mfwrap_getpwnam
226 #pragma redefine_extname getpwuid __mfwrap_getpwuid
227 #pragma redefine_extname getgrnam __mfwrap_getgrnam
228 #pragma redefine_extname getgrgid __mfwrap_getgrgid
229 #pragma redefine_extname getservent __mfwrap_getservent
230 #pragma redefine_extname getservbyname __mfwrap_getservbyname
231 #pragma redefine_extname getservbyport __mfwrap_getservbyport
232 #pragma redefine_extname gai_strerror __mfwrap_gai_strerror
233 #pragma redefine_extname getmntent __mfwrap_getmntent
234 #pragma redefine_extname inet_ntoa __mfwrap_inet_ntoa
235 #pragma redefine_extname getprotoent __mfwrap_getprotoent
236 #pragma redefine_extname getprotobyname __mfwrap_getprotobyname
237 #pragma redefine_extname getprotobynumber __mfwrap_getprotobynumber
239 /* Disable glibc macros. */
240 #define __NO_STRING_INLINES
242 #endif /* _MUDFLAP */
245 #ifdef __cplusplus
247 #endif
249 #endif /* MF_RUNTIME_H */