ws2_32: Test wait alertability in WSAGetOverlappedResult().
[wine.git] / tools / winebuild / build.h
blob733cd34e614df0f0befde27366336c0ed0a1e034
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #ifndef __WINE_BUILD_H
24 #define __WINE_BUILD_H
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include "../tools.h"
30 typedef enum
32 TYPE_VARIABLE, /* variable */
33 TYPE_PASCAL, /* pascal function (Win16) */
34 TYPE_ABS, /* absolute value (Win16) */
35 TYPE_STUB, /* unimplemented stub */
36 TYPE_STDCALL, /* stdcall function (Win32) */
37 TYPE_CDECL, /* cdecl function (Win32) */
38 TYPE_VARARGS, /* varargs function (Win32) */
39 TYPE_EXTERN, /* external symbol (Win32) */
40 TYPE_NBTYPES
41 } ORD_TYPE;
43 typedef enum
45 SPEC_WIN16,
46 SPEC_WIN32
47 } SPEC_TYPE;
49 enum arg_type
51 ARG_WORD, /* 16-bit word */
52 ARG_SWORD, /* 16-bit signed word */
53 ARG_SEGPTR, /* segmented pointer */
54 ARG_SEGSTR, /* segmented pointer to Ansi string */
55 ARG_LONG, /* long */
56 ARG_PTR, /* pointer */
57 ARG_STR, /* pointer to Ansi string */
58 ARG_WSTR, /* pointer to Unicode string */
59 ARG_INT64, /* 64-bit integer */
60 ARG_INT128, /* 128-bit integer */
61 ARG_FLOAT, /* 32-bit float */
62 ARG_DOUBLE, /* 64-bit float */
63 ARG_MAXARG = ARG_DOUBLE
66 #define MAX_ARGUMENTS 32
68 typedef struct
70 int n_values;
71 unsigned int *values;
72 } ORD_VARIABLE;
74 typedef struct
76 int nb_args;
77 int args_str_offset;
78 enum arg_type args[MAX_ARGUMENTS];
79 } ORD_FUNCTION;
81 typedef struct
83 unsigned short value;
84 } ORD_ABS;
86 typedef struct
88 ORD_TYPE type;
89 int ordinal;
90 int hint;
91 int lineno;
92 int flags;
93 char *name; /* public name of this function */
94 char *link_name; /* name of the C symbol to link to */
95 char *export_name; /* name exported under for noname exports */
96 union
98 ORD_VARIABLE var;
99 ORD_FUNCTION func;
100 ORD_ABS abs;
101 } u;
102 } ORDDEF;
104 struct apiset_entry
106 unsigned int name_off;
107 unsigned int name_len;
108 unsigned int hash;
109 unsigned int hash_len;
110 unsigned int val_count;
111 struct apiset_value
113 unsigned int name_off;
114 unsigned int name_len;
115 unsigned int val_off;
116 unsigned int val_len;
117 } values[4];
120 struct apiset
122 unsigned int count;
123 unsigned int size;
124 struct apiset_entry *entries;
125 unsigned int str_pos;
126 unsigned int str_size;
127 char *strings;
130 static const unsigned int apiset_hash_factor = 31;
132 typedef struct
134 char *src_name; /* file name of the source spec file */
135 char *file_name; /* file name of the dll */
136 char *dll_name; /* internal name of the dll */
137 char *c_name; /* internal name of the dll, as a C-compatible identifier */
138 char *init_func; /* initialization routine */
139 char *main_module; /* main Win32 module for Win16 specs */
140 SPEC_TYPE type; /* type of dll (Win16/Win32) */
141 int base; /* ordinal base */
142 int limit; /* ordinal limit */
143 int stack_size; /* exe stack size */
144 int heap_size; /* exe heap size */
145 int nb_entry_points; /* number of used entry points */
146 int alloc_entry_points; /* number of allocated entry points */
147 int nb_names; /* number of entry points with names */
148 unsigned int nb_resources; /* number of resources */
149 int characteristics; /* characteristics for the PE header */
150 int dll_characteristics;/* DLL characteristics for the PE header */
151 int subsystem; /* subsystem id */
152 int subsystem_major; /* subsystem version major number */
153 int subsystem_minor; /* subsystem version minor number */
154 int syscall_table; /* syscall table id */
155 int unicode_app; /* default to unicode entry point */
156 ORDDEF *entry_points; /* dll entry points */
157 ORDDEF **names; /* array of entry point names (points into entry_points) */
158 ORDDEF **ordinals; /* array of dll ordinals (points into entry_points) */
159 struct resource *resources; /* array of dll resources (format differs between Win16/Win32) */
160 struct apiset apiset; /* list of defined api sets */
161 } DLLSPEC;
163 extern char *target_alias;
164 extern struct target target;
166 static inline unsigned int get_ptr_size(void)
168 return get_target_ptr_size( target );
171 static inline int is_pe(void)
173 return target.platform == PLATFORM_MINGW || target.platform == PLATFORM_WINDOWS;
176 /* entry point flags */
177 #define FLAG_NORELAY 0x0001 /* don't use relay debugging for this function */
178 #define FLAG_NONAME 0x0002 /* don't export function by name */
179 #define FLAG_RET16 0x0004 /* function returns a 16-bit value */
180 #define FLAG_RET64 0x0008 /* function returns a 64-bit value */
181 #define FLAG_REGISTER 0x0010 /* use register calling convention */
182 #define FLAG_PRIVATE 0x0020 /* function is private (cannot be imported) */
183 #define FLAG_ORDINAL 0x0040 /* function should be imported by ordinal */
184 #define FLAG_THISCALL 0x0080 /* function uses thiscall calling convention */
185 #define FLAG_FASTCALL 0x0100 /* function uses fastcall calling convention */
186 #define FLAG_SYSCALL 0x0200 /* function is a system call */
187 #define FLAG_IMPORT 0x0400 /* export is imported from another module */
189 #define FLAG_FORWARD 0x1000 /* function is a forwarded name */
190 #define FLAG_EXT_LINK 0x2000 /* function links to an external symbol */
191 #define FLAG_EXPORT32 0x4000 /* 32-bit export in 16-bit spec file */
193 #define FLAG_CPU(cpu) (0x10000 << (cpu))
194 #define FLAG_CPU_MASK (FLAG_CPU_WIN32 | FLAG_CPU_WIN64)
195 #define FLAG_CPU_WIN64 (FLAG_CPU(CPU_x86_64) | FLAG_CPU(CPU_ARM64))
196 #define FLAG_CPU_WIN32 (FLAG_CPU(CPU_i386) | FLAG_CPU(CPU_ARM))
198 #define MAX_ORDINALS 65535
200 /* some Windows constants */
202 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
203 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
204 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
205 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
206 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
207 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
208 #define IMAGE_FILE_16BIT_MACHINE 0x0040
209 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
210 #define IMAGE_FILE_32BIT_MACHINE 0x0100
211 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
212 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
213 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
214 #define IMAGE_FILE_SYSTEM 0x1000
215 #define IMAGE_FILE_DLL 0x2000
216 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
217 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
219 #define IMAGE_DLLCHARACTERISTICS_PREFER_NATIVE 0x0010 /* Wine extension */
220 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
222 #define IMAGE_SUBSYSTEM_NATIVE 1
223 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2
224 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3
225 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9
227 /* global functions */
229 #ifndef DECLSPEC_NORETURN
230 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
231 # define DECLSPEC_NORETURN __declspec(noreturn)
232 # else
233 # define DECLSPEC_NORETURN __attribute__((noreturn))
234 # endif
235 #endif
236 extern char *strupper(char *s);
237 extern DECLSPEC_NORETURN void fatal_error( const char *msg, ... )
238 __attribute__ ((__format__ (__printf__, 1, 2)));
239 extern DECLSPEC_NORETURN void fatal_perror( const char *msg, ... )
240 __attribute__ ((__format__ (__printf__, 1, 2)));
241 extern void error( const char *msg, ... )
242 __attribute__ ((__format__ (__printf__, 1, 2)));
243 extern void warning( const char *msg, ... )
244 __attribute__ ((__format__ (__printf__, 1, 2)));
245 extern int output( const char *format, ... )
246 __attribute__ ((__format__ (__printf__, 1, 2)));
247 extern void output_cfi( const char *format, ... )
248 __attribute__ ((__format__ (__printf__, 1, 2)));
249 extern void output_rva( const char *format, ... )
250 __attribute__ ((__format__ (__printf__, 1, 2)));
251 extern void output_thunk_rva( int ordinal, const char *format, ... )
252 __attribute__ ((__format__ (__printf__, 2, 3)));
253 extern void spawn( struct strarray array );
254 extern struct strarray find_tool( const char *name, const char * const *names );
255 extern struct strarray find_link_tool(void);
256 extern struct strarray get_as_command(void);
257 extern struct strarray get_ld_command(void);
258 extern const char *get_nm_command(void);
259 extern void output_standard_file_header(void);
260 extern FILE *open_input_file( const char *srcdir, const char *name );
261 extern void close_input_file( FILE *file );
262 extern void open_output_file(void);
263 extern void close_output_file(void);
264 extern char *open_temp_output_file( const char *suffix );
265 extern void dump_bytes( const void *buffer, unsigned int size );
266 extern int remove_stdcall_decoration( char *name );
267 extern void assemble_file( const char *src_file, const char *obj_file );
268 extern DLLSPEC *alloc_dll_spec(void);
269 extern void free_dll_spec( DLLSPEC *spec );
270 extern char *make_c_identifier( const char *str );
271 extern const char *get_stub_name( const ORDDEF *odp, const DLLSPEC *spec );
272 extern const char *get_abi_name( const ORDDEF *odp, const char *name );
273 extern const char *get_link_name( const ORDDEF *odp );
274 extern int sort_func_list( ORDDEF **list, int count, int (*compare)(const void *, const void *) );
275 extern unsigned int get_alignment(unsigned int align);
276 extern unsigned int get_page_size(void);
277 extern unsigned int get_args_size( const ORDDEF *odp );
278 extern const char *asm_name( const char *func );
279 extern const char *func_declaration( const char *func );
280 extern const char *asm_globl( const char *func );
281 extern const char *get_asm_ptr_keyword(void);
282 extern const char *get_asm_string_keyword(void);
283 extern const char *get_asm_export_section(void);
284 extern const char *get_asm_rodata_section(void);
285 extern const char *get_asm_rsrc_section(void);
286 extern const char *get_asm_string_section(void);
287 extern const char *arm64_page( const char *sym );
288 extern const char *arm64_pageoff( const char *sym );
289 extern void output_function_size( const char *name );
290 extern void output_gnu_stack_note(void);
292 extern void add_import_dll( const char *name, const char *filename );
293 extern void add_delayed_import( const char *name );
294 extern void add_extra_ld_symbol( const char *name );
295 extern void add_spec_extra_ld_symbol( const char *name );
296 extern void read_undef_symbols( DLLSPEC *spec, struct strarray files );
297 extern void resolve_imports( DLLSPEC *spec );
298 extern int is_undefined( const char *name );
299 extern int has_imports(void);
300 extern int has_delay_imports(void);
301 extern void output_get_pc_thunk(void);
302 extern void output_module( DLLSPEC *spec );
303 extern void output_stubs( DLLSPEC *spec );
304 extern void output_syscalls( DLLSPEC *spec );
305 extern void output_imports( DLLSPEC *spec );
306 extern void output_import_lib( DLLSPEC *spec, struct strarray files );
307 extern void output_static_lib( const char *output_name, struct strarray files, int create );
308 extern void output_exports( DLLSPEC *spec );
309 extern int load_res32_file( const char *name, DLLSPEC *spec );
310 extern void output_resources( DLLSPEC *spec );
311 extern void output_bin_resources( DLLSPEC *spec, unsigned int start_rva );
312 extern void output_spec32_file( DLLSPEC *spec );
313 extern void output_fake_module( DLLSPEC *spec );
314 extern void output_data_module( DLLSPEC *spec );
315 extern void output_def_file( DLLSPEC *spec, int import_only );
316 extern void output_apiset_lib( DLLSPEC *spec, const struct apiset *apiset );
317 extern void load_res16_file( const char *name, DLLSPEC *spec );
318 extern void output_res16_data( DLLSPEC *spec );
319 extern void output_bin_res16_data( DLLSPEC *spec );
320 extern void output_res16_directory( DLLSPEC *spec );
321 extern void output_bin_res16_directory( DLLSPEC *spec, unsigned int data_offset );
322 extern void output_spec16_file( DLLSPEC *spec );
323 extern void output_fake_module16( DLLSPEC *spec16 );
324 extern void output_res_o_file( DLLSPEC *spec );
325 extern void output_asm_relays16(void);
326 extern void make_builtin_files( struct strarray files );
327 extern void fixup_constructors( struct strarray files );
329 extern void add_16bit_exports( DLLSPEC *spec32, DLLSPEC *spec16 );
330 extern int parse_spec_file( FILE *file, DLLSPEC *spec );
331 extern int parse_def_file( FILE *file, DLLSPEC *spec );
333 /* buffer management */
335 extern int byte_swapped;
336 extern const char *input_buffer_filename;
337 extern const unsigned char *input_buffer;
338 extern size_t input_buffer_pos;
339 extern size_t input_buffer_size;
341 extern void init_input_buffer( const char *file );
342 extern unsigned char get_byte(void);
343 extern unsigned short get_word(void);
344 extern unsigned int get_dword(void);
345 extern void put_pword( unsigned int val );
347 /* global variables */
349 extern int current_line;
350 extern int UsePIC;
351 extern int nb_errors;
352 extern int display_warnings;
353 extern int kill_at;
354 extern int verbose;
355 extern int link_ext_symbols;
356 extern int force_pointer_size;
357 extern int unwind_tables;
358 extern int use_dlltool;
359 extern int use_msvcrt;
360 extern int safe_seh;
361 extern int prefer_native;
362 extern int data_only;
364 extern char *input_file_name;
365 extern char *spec_file_name;
366 extern FILE *output_file;
367 extern const char *output_file_name;
369 extern struct strarray lib_path;
370 extern struct strarray tools_path;
371 extern struct strarray as_command;
372 extern struct strarray cc_command;
373 extern struct strarray ld_command;
374 extern struct strarray nm_command;
375 extern char *cpu_option;
376 extern char *fpu_option;
377 extern char *arch_option;
378 extern const char *float_abi_option;
379 extern int thumb_mode;
380 extern int needs_get_pc_thunk;
382 #endif /* __WINE_BUILD_H */