Release 950302
[wine/hacks.git] / include / segmem.h
blob583adc94885f0315ad0c27c877351fb2c9af3ab3
1 /* $Id: segmem.h,v 1.3 1993/07/04 04:04:21 root Exp root $
2 */
3 /*
4 * Copyright Robert J. Amstadt, 1993
5 */
6 #ifndef SEGMEM_H
7 #define SEGMEM_H
9 #include "wine.h"
11 #ifdef __linux__
12 #define HAVE_IPC
13 #include <sys/ipc.h>
14 #include <sys/shm.h>
15 #endif
17 #if defined(__NetBSD__) || defined(__FreeBSD__)
18 #define HAVE_IPC
19 #include <sys/types.h>
20 #include <sys/ipc.h>
21 #include <sys/shm.h>
22 #define SHMSEG 32 /* XXX SEMMNI /usr/src/sys/conf/param.h */
23 #define SHM_RANGE_START 0x40000000
24 #endif
27 * Array to track selector allocation.
29 #define SELECTOR_ISFREE 0x8000
30 #define SELECTOR_IS32BIT 0x4000
31 #define SELECTOR_INDEXMASK 0x0fff
33 #define __AHSHIFT 3
34 #define __AHINCR (1 << __AHSHIFT)
36 extern unsigned short* SelectorMap;
38 #ifdef HAVE_IPC
39 #define SAFEMAKEPTR(s, o) ((void *)(((int) (s) << 16) | ((o) & 0xffff)))
40 #define FIXPTR(p) (p)
41 #else
42 #define SAFEMAKEPTR(s, o) \
43 ((void*)(((int)SelectorMap[SelectorMap[(s)>>__AHSHIFT] & SELECTOR_INDEXMASK]\
44 << (16 + __AHSHIFT)) | 0x70000 | ((o) & 0xffff)))
45 #define FIXPTR(p) SAFEMAKEPTR((unsigned long) (p) >> 16, (p))
46 #endif
48 #define MAKESELECTOR(fp) ((unsigned short) (fp >> (16 + __AHSHIFT)))
52 * Structure to hold info about each selector we create.
55 typedef struct segment_descriptor_s
57 void *base_addr; /* Pointer to segment in flat memory */
58 unsigned int length; /* Length of segment */
59 unsigned int flags; /* Segment flags (see neexe.h and below)*/
60 unsigned short selector; /* Selector used to access this segment */
61 unsigned short owner; /* Handle of owner program */
62 unsigned char type; /* DATA or CODE */
63 #ifdef HAVE_IPC
64 key_t shm_key; /* Shared memory key or -1 */
65 #endif
66 } SEGDESC;
68 extern int IPCCopySelector(int i_old, unsigned long new, int swap_type);
71 * Additional flags
73 #define NE_SEGFLAGS_MALLOCED 0x00010000 /* Memory allocated with malloc() */
76 * Global memory flags
78 #define GLOBAL_FLAGS_MOVEABLE 0x0002
79 #define GLOBAL_FLAGS_ZEROINIT 0x0040
80 #define GLOBAL_FLAGS_CODE 0x00010000
81 #define GLOBAL_FLAGS_EXECUTEONLY 0x00020000
82 #define GLOBAL_FLAGS_READONLY 0x00020000
84 #ifdef __ELF__
85 #define FIRST_SELECTOR 2
86 #define IS_16_BIT_ADDRESS(addr) \
87 (!(SelectorMap[(unsigned int)(addr) >> (16+__AHSHIFT)]& SELECTOR_IS32BIT))
88 #else
89 #define FIRST_SELECTOR 8
90 #define IS_16_BIT_ADDRESS(addr) \
91 ((unsigned int)(addr) >= (((FIRST_SELECTOR << __AHSHIFT) | 7) << 16))
92 #endif
95 extern SEGDESC* Segments;
97 #endif /* SEGMEM_H */