[GDI32_APITEST] Add a PCH.
[reactos.git] / subsystems / mvdm / dos / asmxtras.inc
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel
4 * FILE: asmxtras.inc
5 * PURPOSE: Extended ASM macros for GAS and MASM/ML64
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7 *
8 * NOTE: This file is an extension to our well-known asm.inc that defines
9 * a set of macros allowing us to assemble specially-crafted ASM files
10 * with both GAS and MASM/ML.
11 *
12 * The additions introduced here are:
13 * - a 'long' define for MASM/ML that aliases to DWORD, and a 'dword'
14 * and 'DWORD' defines for GAS that alias to long.
15 * - an OFF(...) macro that is used for initializing global symbols with
16 * the offset value of another symbol.
17 * - a set of macros for defining and using structures.
18 */
19
20 #ifndef __ASMXTRAS_INC__
21 #define __ASMXTRAS_INC__
22
23 /* 'long' / 'dword'|'DWORD' macros for MASM/ML and GAS */
24 #ifdef _USE_ML
25 #define long dword
26 #else
27 #define dword long
28 #define DWORD long
29 #endif
30
31 /* OFFset macro */
32 #ifdef _USE_ML
33 #define OFF(x) offset x
34 #else
35 #define OFF(x) x
36 #endif
37
38 /*
39 * Set of macros for defining and using structures:
40 * - STRUCT(name, ...) defines a structure of name 'name'.
41 * - FIELD_DECL(field, type, value) adds a new structure member 'field'
42 * of type 'type', with the default value 'value'.
43 * - ENDS(name) terminates the definition of the structure 'name'.
44 * - A symbol 'name' of type 'struct' is declared with VAR_STRUCT(name, struct).
45 * - Referencing a member 'field' of a symbol 'name' is done with FIELD(name, field).
46 */
47 #ifdef _USE_ML
48
49 #define STRUCT(name, ...) \
50 name STRUCT __VA_ARGS__
51
52 #define FIELD_DECL(field, type, value) \
53 field type value
54
55 #define ENDS(name) \
56 name ENDS
57
58 #define VAR_STRUCT(name, struct) \
59 name struct <>
60
61 #define FIELD(name, field) \
62 name##.##field
63
64 #else
65
66 #define STRUCT(name, ...) \
67 MACRO(name, VarName)
68
69 #define FIELD_DECL(field, type, value) \
70 VarName\()_\()field: .type value
71
72 #define ENDS(...) ENDM
73
74 #define VAR_STRUCT(name, struct) \
75 name: struct name
76
77 #define FIELD(name, field) \
78 name##_##field
79
80 #endif
81
82 #endif /* __ASMXTRAS_INC__ */