Ticket #514: ldt_keeper_darwin.2.patch
| File ldt_keeper_darwin.2.patch, 2.1 KB (added by , 20 years ago) |
|---|
-
ldt_keeper.c
old new 102 102 #define LDT_SEL(idx) ((idx) << 3 | 1 << 2 | 3) 103 103 104 104 /* i got this value from wine sources, it's the first free LDT entry */ 105 #if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC)105 #if (defined(__FreeBSD__) || defined(CONFIG_DARWIN)) && defined(LDT_AUTO_ALLOC) 106 106 #define TEB_SEL_IDX LDT_AUTO_ALLOC 107 107 #endif 108 108 … … 167 167 #endif 168 168 #endif 169 169 170 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined( __OpenBSD__) || defined(__DragonFly__)170 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(CONFIG_DARWIN) || defined(__OpenBSD__) || defined(__DragonFly__) 171 171 static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt_s *content ) 172 172 { 173 173 *buffer++ = ((content->base_addr & 0x0000ffff) << 16) | … … 193 193 194 194 if (!ldt_fs) 195 195 return NULL; 196 197 ldt_fs->fd = -1; 196 #ifndef CONFIG_DARWIN 197 ldt_fs->fd = open("/dev/zero", O_RDWR); 198 if(ldt_fs->fd<0){ 199 perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: "); 200 return NULL; 201 } 202 fs_seg= 203 ldt_fs->fs_seg = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE, 204 ldt_fs->fd, 0); 205 #else 198 206 fs_seg= 199 207 ldt_fs->fs_seg = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); 208 #endif /* CONFIG_DARWIN */ 200 209 if (ldt_fs->fs_seg == (void*)-1) 201 210 { 202 211 perror("ERROR: Couldn't allocate memory for fs segment"); … … 224 233 } 225 234 #endif /*linux*/ 226 235 227 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined( __OpenBSD__) || defined(__DragonFly__)236 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(CONFIG_DARWIN) || defined(__OpenBSD__) || defined(__DragonFly__) 228 237 { 229 238 unsigned long d[2]; 230 239 231 240 LDT_EntryToBytes( d, &array ); 232 #if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC)241 #if (defined(__FreeBSD__) || defined(CONFIG_DARWIN)) && defined(LDT_AUTO_ALLOC) 233 242 ret = i386_set_ldt(LDT_AUTO_ALLOC, (union descriptor *)d, 1); 234 243 array.entry_number = ret; 235 244 fs_ldt = ret;
