Mercurial > mplayer.hg
annotate loader/wine/ldt.h @ 36779:f5320e43d458
Simplify code.
Use a variable and cast once.
author | ib |
---|---|
date | Mon, 17 Feb 2014 14:33:03 +0000 |
parents | 26f673ba0675 |
children |
rev | line source |
---|---|
1 | 1 /* |
2 * LDT copy | |
3 * | |
4 * Copyright 1995 Alexandre Julliard | |
5 */ | |
6 | |
26045 | 7 #ifndef MPLAYER_LDT_H |
8 #define MPLAYER_LDT_H | |
1 | 9 |
10 #include "windef.h" | |
11 enum seg_type | |
12 { | |
13 SEGMENT_DATA = 0, | |
14 SEGMENT_STACK = 1, | |
15 SEGMENT_CODE = 2 | |
16 }; | |
17 | |
18 /* This structure represents a real LDT entry. */ | |
19 /* It is used by get_ldt_entry() and set_ldt_entry(). */ | |
20 typedef struct | |
21 { | |
22 unsigned long base; /* base address */ | |
23 unsigned long limit; /* segment limit (in pages or bytes) */ | |
24 int seg_32bit; /* is segment 32-bit? */ | |
25 int read_only; /* is segment read-only? */ | |
26 int limit_in_pages; /* is the limit in pages or bytes? */ | |
27 enum seg_type type; /* segment type */ | |
28 } ldt_entry; | |
28051 | 29 void LDT_BytesToEntry( const unsigned long *buffer, ldt_entry *content ); |
30 void LDT_EntryToBytes( unsigned long *buffer, const ldt_entry *content ); | |
31 int LDT_GetEntry( int entry, ldt_entry *content ); | |
32 int LDT_SetEntry( int entry, const ldt_entry *content ); | |
33 void LDT_Print( int start, int length ); | |
1 | 34 |
35 | |
36 /* This structure is used to build the local copy of the LDT. */ | |
37 typedef struct | |
38 { | |
39 unsigned long base; /* base address or 0 if entry is free */ | |
40 unsigned long limit; /* limit in bytes or 0 if entry is free */ | |
41 } ldt_copy_entry; | |
42 | |
43 #define LDT_SIZE 8192 | |
44 | |
45 extern ldt_copy_entry ldt_copy[LDT_SIZE]; | |
46 | |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24422
diff
changeset
|
47 #define AHSHIFT 3 /* don't change! */ |
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24422
diff
changeset
|
48 #define AHINCR (1 << AHSHIFT) |
1 | 49 |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24422
diff
changeset
|
50 #define SELECTOR_TO_ENTRY(sel) (((int)(sel) & 0xffff) >> AHSHIFT) |
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24422
diff
changeset
|
51 #define ENTRY_TO_SELECTOR(i) ((i) ? (((int)(i) << AHSHIFT) | 7) : 0) |
1 | 52 #define IS_LDT_ENTRY_FREE(i) (!(ldt_flags_copy[(i)] & LDT_FLAGS_ALLOCATED)) |
53 #define IS_SELECTOR_FREE(sel) (IS_LDT_ENTRY_FREE(SELECTOR_TO_ENTRY(sel))) | |
54 #define GET_SEL_BASE(sel) (ldt_copy[SELECTOR_TO_ENTRY(sel)].base) | |
55 #define GET_SEL_LIMIT(sel) (ldt_copy[SELECTOR_TO_ENTRY(sel)].limit) | |
56 | |
57 /* Convert a segmented ptr (16:16) to a linear (32) pointer */ | |
58 | |
59 #define PTR_SEG_OFF_TO_LIN(seg,off) \ | |
60 ((void*)(GET_SEL_BASE(seg) + (unsigned int)(off))) | |
61 #define PTR_SEG_TO_LIN(ptr) \ | |
62 PTR_SEG_OFF_TO_LIN(SELECTOROF(ptr),OFFSETOF(ptr)) | |
63 #define PTR_SEG_OFF_TO_SEGPTR(seg,off) \ | |
64 ((SEGPTR)MAKELONG(off,seg)) | |
65 #define PTR_SEG_OFF_TO_HUGEPTR(seg,off) \ | |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24422
diff
changeset
|
66 PTR_SEG_OFF_TO_SEGPTR( (seg) + (HIWORD(off) << AHSHIFT), LOWORD(off) ) |
1 | 67 |
68 #define W32S_APPLICATION() (PROCESS_Current()->flags & PDB32_WIN32S_PROC) | |
69 #define W32S_OFFSET 0x10000 | |
70 #define W32S_APP2WINE(addr, offset) ((addr)? (DWORD)(addr) + (DWORD)(offset) : 0) | |
71 #define W32S_WINE2APP(addr, offset) ((addr)? (DWORD)(addr) - (DWORD)(offset) : 0) | |
72 | |
73 extern unsigned char ldt_flags_copy[LDT_SIZE]; | |
74 | |
75 #define LDT_FLAGS_TYPE 0x03 /* Mask for segment type */ | |
76 #define LDT_FLAGS_READONLY 0x04 /* Segment is read-only (data) */ | |
77 #define LDT_FLAGS_EXECONLY 0x04 /* Segment is execute-only (code) */ | |
78 #define LDT_FLAGS_32BIT 0x08 /* Segment is 32-bit (code or stack) */ | |
79 #define LDT_FLAGS_BIG 0x10 /* Segment is big (limit is in pages) */ | |
80 #define LDT_FLAGS_ALLOCATED 0x80 /* Segment is allocated (no longer free) */ | |
81 | |
82 #define GET_SEL_FLAGS(sel) (ldt_flags_copy[SELECTOR_TO_ENTRY(sel)]) | |
83 | |
84 #define FIRST_LDT_ENTRY_TO_ALLOC 17 | |
85 | |
86 /* Determine if sel is a system selector (i.e. not managed by Wine) */ | |
87 #define IS_SELECTOR_SYSTEM(sel) \ | |
88 (!((sel) & 4) || (SELECTOR_TO_ENTRY(sel) < FIRST_LDT_ENTRY_TO_ALLOC)) | |
89 #define IS_SELECTOR_32BIT(sel) \ | |
90 (IS_SELECTOR_SYSTEM(sel) || (GET_SEL_FLAGS(sel) & LDT_FLAGS_32BIT)) | |
26045 | 91 |
92 #endif /* MPLAYER_LDT_H */ |