- Timestamp:
- Mar 30, 2008, 4:06:49 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/electric.c
r915 r1453 29 29 # else 30 30 # include <sys/mman.h> 31 # include <errno.h> 31 32 # endif 32 33 # include <string.h> … … 47 48 static void fatal_error (const char *msg) 48 49 { 50 #ifdef _MSC_VER 49 51 fprintf (stderr, "electric heap error: %s\n", msg); 50 52 __debugbreak (); 53 #else 54 fprintf (stderr, "electric heap error: %s (errno=%d)\n", msg, errno); 55 __asm__ ("int3"); /* not portable... */ 56 #endif 51 57 abort (); 52 58 exit (1); … … 59 65 fatal_error ("VirtualFree failed"); 60 66 # else 67 if (munmap(ptr, aligned)) 68 fatal_error ("munmap failed"); 61 69 # endif 62 70 } … … 99 107 fatal_error ("failed to protect freed memory"); 100 108 # else 109 if (mprotect(hdr, aligned - 0x1000, PROT_NONE)) 110 fatal_error ("failed to protect freed memory"); 101 111 # endif 102 112 … … 124 134 fatal_error ("failed to set guard page protection"); 125 135 # else 136 hdr = mmap(NULL, aligned, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); 137 if (hdr == MAP_FAILED) 138 hdr = 0; 139 if (hdr 140 && mprotect((char *)hdr + aligned - 0x1000, 0x1000, PROT_NONE)) 141 fatal_error ("failed to set guard page protection"); 126 142 # endif 127 143 if (hdr)
Note:
See TracChangeset
for help on using the changeset viewer.