Release 941017
[wine/gsoc-2012-control.git] / include / segmem.h
blob047fea052454f435f936515a124b85afed0e0dd4
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 MAX_SELECTORS 512
30 #define SELECTOR_ISFREE 0x8000
31 #define SELECTOR_INDEXMASK 0x0fff
33 extern unsigned short SelectorMap[MAX_SELECTORS];
35 #ifdef HAVE_IPC
36 #define SAFEMAKEPTR(s, o) (((int) (s) << 16) | ((o) & 0xffff))
37 #define FIXPTR(p) (p)
38 #else
39 #define SAFEMAKEPTR(s, o) \
40 (((int) SelectorMap[SelectorMap[(s) >> 3] & SELECTOR_INDEXMASK] << 19) \
41 | 0x70000 | ((o) & 0xffff))
42 #define FIXPTR(p) SAFEMAKEPTR((unsigned long) (p) >> 16, (p))
43 #endif
46 * Structure to hold info about each selector we create.
49 typedef struct segment_descriptor_s
51 void *base_addr; /* Pointer to segment in flat memory */
52 unsigned int length; /* Length of segment */
53 unsigned int flags; /* Segment flags (see neexe.h and below)*/
54 unsigned short selector; /* Selector used to access this segment */
55 unsigned short owner; /* Handle of owner program */
56 unsigned char type; /* DATA or CODE */
57 #ifdef HAVE_IPC
58 key_t shm_key; /* Shared memory key or -1 */
59 #endif
60 } SEGDESC;
62 extern int IPCCopySelector(int i_old, unsigned long new, int swap_type);
65 * Additional flags
67 #define NE_SEGFLAGS_MALLOCED 0x00010000 /* Memory allocated with malloc() */
70 * Global memory flags
72 #define GLOBAL_FLAGS_MOVEABLE 0x0002
73 #define GLOBAL_FLAGS_ZEROINIT 0x0040
74 #define GLOBAL_FLAGS_CODE 0x00010000
75 #define GLOBAL_FLAGS_EXECUTEONLY 0x00020000
76 #define GLOBAL_FLAGS_READONLY 0x00020000
78 #define FIRST_SELECTOR 8
80 extern SEGDESC Segments[];
82 #endif /* SEGMEM_H */