Changed the GDI driver interface to pass an opaque PHYSDEV pointer
[wine] / tools / winebuild / build.h
1 /*
2  * Copyright 1993 Robert J. Amstadt
3  * Copyright 1995 Martin von Loewis
4  * Copyright 1995, 1996, 1997 Alexandre Julliard
5  * Copyright 1997 Eric Youngdale
6  * Copyright 1999 Ulrich Weigand
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #ifndef __WINE_BUILD_H
24 #define __WINE_BUILD_H
25
26 #ifndef __WINE_CONFIG_H  
27 # error You must include config.h to use this header  
28 #endif  
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #ifdef HAVE_DIRECT_H
34 # include <direct.h>
35 #endif
36 #ifdef HAVE_IO_H
37 # include <io.h>
38 #endif
39 #ifdef HAVE_UNISTD_H
40 # include <unistd.h>
41 #endif
42
43 #if !defined(HAVE_POPEN) && defined(HAVE__POPEN)
44 #define popen _popen
45 #endif
46
47 #if !defined(HAVE_PCLOSE) && defined(HAVE__PCLOSE)
48 #define pclose _pclose
49 #endif
50
51 #if !defined(HAVE_STRNCASECMP) && defined(HAVE__STRNICMP)
52 # define strncasecmp _strnicmp
53 #endif
54
55 #if !defined(HAVE_STRCASECMP) && defined(HAVE__STRICMP)
56 # define strcasecmp _stricmp
57 #endif
58
59 #define PUT_WORD(ptr, w)  (*(WORD *)(ptr) = (w))
60 #define PUT_LE_WORD(ptr, w) \
61         do { ((BYTE *)(ptr))[0] = LOBYTE(w); \
62              ((BYTE *)(ptr))[1] = HIBYTE(w); } while (0)
63 #define PUT_BE_WORD(ptr, w) \
64         do { ((BYTE *)(ptr))[1] = LOBYTE(w); \
65              ((BYTE *)(ptr))[0] = HIBYTE(w); } while (0)
66
67 #if defined(ALLOW_UNALIGNED_ACCESS)
68 #define PUT_UA_WORD(ptr, w)  PUT_WORD(ptr, w)
69 #elif defined(WORDS_BIGENDIAN)
70 #define PUT_UA_WORD(ptr, w)  PUT_BE_WORD(ptr, w)
71 #else
72 #define PUT_UA_WORD(ptr, w)  PUT_LE_WORD(ptr, w)
73 #endif
74
75 #ifdef NEED_UNDERSCORE_PREFIX
76 # define __ASM_NAME(name) "_" name
77 #else
78 # define __ASM_NAME(name) name
79 #endif
80
81 #ifdef NEED_TYPE_IN_DEF
82 # define __ASM_FUNC(name) ".def " __ASM_NAME(name) "; .scl 2; .type 32; .endef"
83 #else
84 # define __ASM_FUNC(name) ".type " __ASM_NAME(name) ",@function"
85 #endif
86
87 #ifdef NEED_UNDERSCORE_PREFIX
88 # define PREFIX "_"
89 #else
90 # define PREFIX
91 #endif
92
93 #ifdef HAVE_ASM_STRING
94 # define STRING ".string"
95 #else
96 # define STRING ".ascii"
97 #endif
98
99 #if defined(__GNUC__) && !defined(__svr4__)
100 # define USE_STABS
101 #else
102 # undef USE_STABS
103 #endif
104
105 typedef enum
106 {
107     TYPE_VARIABLE,     /* variable */
108     TYPE_PASCAL_16,    /* pascal function with 16-bit return (Win16) */
109     TYPE_PASCAL,       /* pascal function with 32-bit return (Win16) */
110     TYPE_ABS,          /* absolute value (Win16) */
111     TYPE_STUB,         /* unimplemented stub */
112     TYPE_STDCALL,      /* stdcall function (Win32) */
113     TYPE_CDECL,        /* cdecl function (Win32) */
114     TYPE_VARARGS,      /* varargs function (Win32) */
115     TYPE_EXTERN,       /* external symbol (Win32) */
116     TYPE_FORWARD,      /* forwarded function (Win32) */
117     TYPE_NBTYPES
118 } ORD_TYPE;
119
120 typedef enum
121 {
122     SPEC_INVALID,
123     SPEC_WIN16,
124     SPEC_WIN32
125 } SPEC_TYPE;
126
127 typedef enum
128 {
129     SPEC_MODE_DLL,
130     SPEC_MODE_GUIEXE,
131     SPEC_MODE_CUIEXE,
132     SPEC_MODE_GUIEXE_UNICODE,
133     SPEC_MODE_CUIEXE_UNICODE
134 } SPEC_MODE;
135
136 typedef struct
137 {
138     int n_values;
139     int *values;
140 } ORD_VARIABLE;
141
142 typedef struct
143 {
144     int  n_args;
145     char arg_types[21];
146 } ORD_FUNCTION;
147
148 typedef struct
149 {
150     int value;
151 } ORD_ABS;
152
153 typedef struct
154 {
155     ORD_TYPE    type;
156     int         ordinal;
157     int         offset;
158     int         lineno;
159     int         flags;
160     char       *name;
161     char       *link_name;
162     union
163     {
164         ORD_VARIABLE   var;
165         ORD_FUNCTION   func;
166         ORD_ABS        abs;
167     } u;
168 } ORDDEF;
169
170 /* entry point flags */
171 #define FLAG_NOIMPORT  0x01  /* don't make function available for importing */
172 #define FLAG_NORELAY   0x02  /* don't use relay debugging for this function */
173 #define FLAG_RET64     0x04  /* function returns a 64-bit value */
174 #define FLAG_I386      0x08  /* function is i386 only */
175 #define FLAG_REGISTER  0x10  /* use register calling convention */
176 #define FLAG_INTERRUPT 0x20  /* function is an interrupt handler */
177
178   /* Offset of a structure field relative to the start of the struct */
179 #define STRUCTOFFSET(type,field) ((int)&((type *)0)->field)
180
181   /* Offset of register relative to the start of the CONTEXT struct */
182 #define CONTEXTOFFSET(reg)  STRUCTOFFSET(CONTEXT86,reg)
183
184   /* Offset of register relative to the start of the STACK16FRAME struct */
185 #define STACK16OFFSET(reg)  STRUCTOFFSET(STACK16FRAME,reg)
186
187   /* Offset of register relative to the start of the STACK32FRAME struct */
188 #define STACK32OFFSET(reg)  STRUCTOFFSET(STACK32FRAME,reg)
189
190   /* Offset of the stack pointer relative to %fs:(0) */
191 #define STACKOFFSET (STRUCTOFFSET(TEB,cur_stack))
192
193
194 #define MAX_ORDINALS  65535
195
196 /* global functions */
197
198 extern void *xmalloc (size_t size);
199 extern void *xrealloc (void *ptr, size_t size);
200 extern char *xstrdup( const char *str );
201 extern char *strupper(char *s);
202 extern void fatal_error( const char *msg, ... );
203 extern void fatal_perror( const char *msg, ... );
204 extern void warning( const char *msg, ... );
205 extern void output_standard_file_header( FILE *outfile );
206 extern void dump_bytes( FILE *outfile, const unsigned char *data, int len,
207                         const char *label, int constant );
208 extern int get_alignment(int alignBoundary);
209
210 extern void add_import_dll( const char *name, int delay );
211 extern void add_ignore_symbol( const char *name );
212 extern int resolve_imports( void );
213 extern int output_imports( FILE *outfile );
214 extern void load_res32_file( const char *name );
215 extern int output_resources( FILE *outfile );
216 extern void load_res16_file( const char *name );
217 extern int output_res16_data( FILE *outfile );
218 extern int output_res16_directory( unsigned char *buffer );
219
220 extern void BuildGlue( FILE *outfile, FILE *infile );
221 extern void BuildRelays16( FILE *outfile );
222 extern void BuildRelays32( FILE *outfile );
223 extern void BuildSpec16File( FILE *outfile );
224 extern void BuildSpec32File( FILE *outfile );
225 extern void BuildDef32File( FILE *outfile );
226 extern SPEC_TYPE ParseTopLevel( FILE *file, int def_only );
227
228 /* global variables */
229
230 extern int current_line;
231 extern int nb_entry_points;
232 extern int nb_names;
233 extern int Base;
234 extern int Limit;
235 extern int DLLHeapSize;
236 extern int UsePIC;
237 extern int debugging;
238 extern int stack_size;
239 extern int nb_debug_channels;
240 extern int nb_lib_paths;
241 extern int display_warnings;
242
243 extern char DLLName[80];
244 extern char DLLFileName[80];
245 extern char owner_name[80];
246 extern char *init_func;
247 extern const char *input_file_name;
248 extern const char *output_file_name;
249 extern char **debug_channels;
250 extern char **lib_path;
251
252 extern ORDDEF *EntryPoints[MAX_ORDINALS];
253 extern ORDDEF *Ordinals[MAX_ORDINALS];
254 extern ORDDEF *Names[MAX_ORDINALS];
255 extern SPEC_MODE SpecMode;
256
257 #endif  /* __WINE_BUILD_H */