Make the testing framework thread safe.
[wine/gsoc_dplay.git] / tools / winebuild / build.h
blob1842b9c3783d509beb27d0a4bccb95dc0d7797ab
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
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.
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.
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
23 #ifndef __WINE_BUILD_H
24 #define __WINE_BUILD_H
26 #ifndef __WINE_CONFIG_H
27 # error You must include config.h to use this header
28 #endif
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
43 #if !defined(HAVE_POPEN) && defined(HAVE__POPEN)
44 #define popen _popen
45 #endif
47 #if !defined(HAVE_PCLOSE) && defined(HAVE__PCLOSE)
48 #define pclose _pclose
49 #endif
51 #if !defined(HAVE_STRNCASECMP) && defined(HAVE__STRNICMP)
52 # define strncasecmp _strnicmp
53 #endif
55 #if !defined(HAVE_STRCASECMP) && defined(HAVE__STRICMP)
56 # define strcasecmp _stricmp
57 #endif
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)
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
75 #ifdef NEED_UNDERSCORE_PREFIX
76 # define __ASM_NAME(name) "_" name
77 #else
78 # define __ASM_NAME(name) name
79 #endif
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
87 #ifdef NEED_UNDERSCORE_PREFIX
88 # define PREFIX "_"
89 #else
90 # define PREFIX
91 #endif
93 #ifdef HAVE_ASM_STRING
94 # define STRING ".string"
95 #else
96 # define STRING ".ascii"
97 #endif
99 typedef enum
101 TYPE_VARIABLE, /* variable */
102 TYPE_PASCAL_16, /* pascal function with 16-bit return (Win16) */
103 TYPE_PASCAL, /* pascal function with 32-bit return (Win16) */
104 TYPE_ABS, /* absolute value (Win16) */
105 TYPE_STUB, /* unimplemented stub */
106 TYPE_STDCALL, /* stdcall function (Win32) */
107 TYPE_CDECL, /* cdecl function (Win32) */
108 TYPE_VARARGS, /* varargs function (Win32) */
109 TYPE_EXTERN, /* external symbol (Win32) */
110 TYPE_FORWARD, /* forwarded function (Win32) */
111 TYPE_NBTYPES
112 } ORD_TYPE;
114 typedef enum
116 SPEC_INVALID,
117 SPEC_WIN16,
118 SPEC_WIN32
119 } SPEC_TYPE;
121 typedef enum
123 SPEC_MODE_DLL,
124 SPEC_MODE_GUIEXE,
125 SPEC_MODE_CUIEXE,
126 SPEC_MODE_GUIEXE_UNICODE,
127 SPEC_MODE_CUIEXE_UNICODE
128 } SPEC_MODE;
130 typedef struct
132 int n_values;
133 int *values;
134 } ORD_VARIABLE;
136 typedef struct
138 int n_args;
139 char arg_types[21];
140 } ORD_FUNCTION;
142 typedef struct
144 int value;
145 } ORD_ABS;
147 typedef struct
149 ORD_TYPE type;
150 int ordinal;
151 int offset;
152 int lineno;
153 int flags;
154 char *name;
155 char *link_name;
156 union
158 ORD_VARIABLE var;
159 ORD_FUNCTION func;
160 ORD_ABS abs;
161 } u;
162 } ORDDEF;
164 /* entry point flags */
165 #define FLAG_NOIMPORT 0x01 /* don't make function available for importing */
166 #define FLAG_NORELAY 0x02 /* don't use relay debugging for this function */
167 #define FLAG_RET64 0x04 /* function returns a 64-bit value */
168 #define FLAG_I386 0x08 /* function is i386 only */
169 #define FLAG_REGISTER 0x10 /* use register calling convention */
170 #define FLAG_INTERRUPT 0x20 /* function is an interrupt handler */
172 /* Offset of a structure field relative to the start of the struct */
173 #define STRUCTOFFSET(type,field) ((int)&((type *)0)->field)
175 /* Offset of register relative to the start of the CONTEXT struct */
176 #define CONTEXTOFFSET(reg) STRUCTOFFSET(CONTEXT86,reg)
178 /* Offset of register relative to the start of the STACK16FRAME struct */
179 #define STACK16OFFSET(reg) STRUCTOFFSET(STACK16FRAME,reg)
181 /* Offset of register relative to the start of the STACK32FRAME struct */
182 #define STACK32OFFSET(reg) STRUCTOFFSET(STACK32FRAME,reg)
184 /* Offset of the stack pointer relative to %fs:(0) */
185 #define STACKOFFSET (STRUCTOFFSET(TEB,cur_stack))
188 #define MAX_ORDINALS 65535
190 /* global functions */
192 extern void *xmalloc (size_t size);
193 extern void *xrealloc (void *ptr, size_t size);
194 extern char *xstrdup( const char *str );
195 extern char *strupper(char *s);
196 extern void fatal_error( const char *msg, ... );
197 extern void fatal_perror( const char *msg, ... );
198 extern void warning( const char *msg, ... );
199 extern void output_standard_file_header( FILE *outfile );
200 extern void dump_bytes( FILE *outfile, const unsigned char *data, int len,
201 const char *label, int constant );
202 extern int get_alignment(int alignBoundary);
204 extern void add_import_dll( const char *name, int delay );
205 extern void add_ignore_symbol( const char *name );
206 extern int resolve_imports( void );
207 extern int output_imports( FILE *outfile );
208 extern void load_res32_file( const char *name );
209 extern int output_resources( FILE *outfile );
210 extern void load_res16_file( const char *name );
211 extern int output_res16_data( FILE *outfile );
212 extern int output_res16_directory( unsigned char *buffer );
214 extern void BuildGlue( FILE *outfile, FILE *infile );
215 extern void BuildRelays16( FILE *outfile );
216 extern void BuildRelays32( FILE *outfile );
217 extern void BuildSpec16File( FILE *outfile );
218 extern void BuildSpec32File( FILE *outfile );
219 extern void BuildDef32File( FILE *outfile );
220 extern SPEC_TYPE ParseTopLevel( FILE *file, int def_only );
222 /* global variables */
224 extern int current_line;
225 extern int nb_entry_points;
226 extern int nb_names;
227 extern int Base;
228 extern int Limit;
229 extern int DLLHeapSize;
230 extern int UsePIC;
231 extern int debugging;
232 extern int stack_size;
233 extern int nb_debug_channels;
234 extern int nb_lib_paths;
235 extern int display_warnings;
237 extern char DLLName[80];
238 extern char DLLFileName[80];
239 extern char owner_name[80];
240 extern char *init_func;
241 extern const char *input_file_name;
242 extern const char *output_file_name;
243 extern char **debug_channels;
244 extern char **lib_path;
246 extern ORDDEF *EntryPoints[MAX_ORDINALS];
247 extern ORDDEF *Ordinals[MAX_ORDINALS];
248 extern ORDDEF *Names[MAX_ORDINALS];
249 extern SPEC_MODE SpecMode;
251 #endif /* __WINE_BUILD_H */