Doxygen Source Code Documentation
efence.h File Reference
#include <sys/types.h>
Go to the source code of this file.
Defines | |
#define | C_LINKAGE |
Functions | |
void | Page_AllowAccess (void *address, size_t size) |
void * | Page_Create (size_t size) |
void | Page_Delete (void *address, size_t size) |
void | Page_DenyAccess (void *address, size_t size) |
size_t | Page_Size (void) |
void | EF_Abort (const char *message,...) |
void | EF_Exit (const char *message,...) |
void | EF_Print (const char *message,...) |
Define Documentation
|
|
Function Documentation
|
Definition at line 1045 of file efence.c. References args, EF_Print(), getpid(), and vprint(). Referenced by free(), internalError(), memalign(), printNumber(), and realloc().
01046 { 01047 va_list args; 01048 01049 va_start(args, pattern); 01050 01051 EF_Print("\nElectricFence Aborting: "); 01052 vprint(pattern, args); 01053 EF_Print("\n"); 01054 01055 va_end(args); 01056 01057 /* 01058 * I use kill(getpid(), SIGILL) instead of abort() because some 01059 * mis-guided implementations of abort() flush stdio, which can 01060 * cause malloc() or free() to be called. 01061 */ 01062 kill(getpid(), SIGILL); 01063 /* Just in case something handles SIGILL and returns, exit here. */ 01064 _exit(-1); 01065 } |
|
Definition at line 1068 of file efence.c. References args, EF_Print(), and vprint(). Referenced by mprotectFailed(), Page_Create(), and Page_Delete().
01069 { 01070 va_list args; 01071 01072 va_start(args, pattern); 01073 01074 EF_Print("\nElectricFence Exiting: "); 01075 vprint(pattern, args); 01076 EF_Print("\n"); 01077 01078 va_end(args); 01079 01080 /* 01081 * I use _exit() because the regular exit() flushes stdio, 01082 * which may cause malloc() or free() to be called. 01083 */ 01084 _exit(-1); 01085 } |
|
Definition at line 1088 of file efence.c. References args, and vprint(). Referenced by EF_Abort(), EF_Exit(), initialize(), and vprint().
|
|
Definition at line 888 of file efence.c. References mprotectFailed(). Referenced by allocateMoreSlots(), free(), memalign(), and realloc().
00889 { 00890 if ( mprotect((caddr_t)address, size, PROT_READ|PROT_WRITE) < 0 ) 00891 mprotectFailed(); 00892 } |
|
Definition at line 841 of file efence.c. References EF_Exit(), startAddr, and stringErrorReport(). Referenced by initialize(), and memalign().
00842 { 00843 static int devZeroFd = -1; 00844 caddr_t allocation; 00845 00846 if ( devZeroFd == -1 ) { 00847 devZeroFd = open("/dev/zero", O_RDWR); 00848 if ( devZeroFd < 0 ) 00849 EF_Exit( 00850 "open() on /dev/zero failed: %s" 00851 ,stringErrorReport()); 00852 } 00853 00854 /* 00855 * In this version, "startAddr" is a _hint_, not a demand. 00856 * When the memory I map here is contiguous with other 00857 * mappings, the allocator can coalesce the memory from two 00858 * or more mappings into one large contiguous chunk, and thus 00859 * might be able to find a fit that would not otherwise have 00860 * been possible. I could _force_ it to be contiguous by using 00861 * the MMAP_FIXED flag, but I don't want to stomp on memory mappings 00862 * generated by other software, etc. 00863 */ 00864 allocation = mmap( 00865 startAddr 00866 ,(int)size 00867 ,PROT_READ|PROT_WRITE 00868 ,MAP_PRIVATE 00869 ,devZeroFd 00870 ,0); 00871 00872 startAddr = allocation + size; 00873 00874 if ( allocation == (caddr_t)-1 ) 00875 EF_Exit("mmap() failed: %s", stringErrorReport()); 00876 00877 return (void *)allocation; 00878 } |
|
Definition at line 902 of file efence.c. References EF_Exit(), Page_DenyAccess(), and stringErrorReport(). Referenced by free(), and memalign().
00903 { 00904 /* 00905 * My SGI ONYX running IRIX 5.0 crashes reliably when "tstheap 3072" is 00906 * run with the munmap call below compiled in. I'd like to hear how well 00907 * other operating systems handle it, so that I can enable it on those 00908 * systems. 00909 */ 00910 #if ( defined(_AIX) ) 00911 if ( munmap((caddr_t)address, size) < 0 ) 00912 EF_Exit("munmap() failed: %s", stringErrorReport()); 00913 #else 00914 Page_DenyAccess(address, size); 00915 #endif 00916 } |
|
Definition at line 895 of file efence.c. References mprotectFailed(). Referenced by free(), initialize(), memalign(), Page_Delete(), and realloc().
00896 { 00897 if ( mprotect((caddr_t)address, size, PROT_NONE) < 0 ) 00898 mprotectFailed(); 00899 } |
|
Definition at line 933 of file efence.c. References getpagesize(). Referenced by initialize().
00934 { 00935 return getpagesize(); 00936 } |