po: Update Turkish translation.
[wine.git] / tools / winebuild / build.h
blobfbc2cd9a001431f3f87051583af3adedfcdfed09
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 #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>
34 #ifndef max
35 #define max(a,b) (((a) > (b)) ? (a) : (b))
36 #endif
37 #ifndef min
38 #define min(a,b) (((a) < (b)) ? (a) : (b))
39 #endif
41 typedef enum
43 TYPE_VARIABLE, /* variable */
44 TYPE_PASCAL, /* pascal function (Win16) */
45 TYPE_ABS, /* absolute value (Win16) */
46 TYPE_STUB, /* unimplemented stub */
47 TYPE_STDCALL, /* stdcall function (Win32) */
48 TYPE_CDECL, /* cdecl function (Win32) */
49 TYPE_VARARGS, /* varargs function (Win32) */
50 TYPE_THISCALL, /* thiscall function (Win32 on i386) */
51 TYPE_EXTERN, /* external symbol (Win32) */
52 TYPE_NBTYPES
53 } ORD_TYPE;
55 typedef enum
57 SPEC_WIN16,
58 SPEC_WIN32
59 } SPEC_TYPE;
61 enum arg_type
63 ARG_WORD, /* 16-bit word */
64 ARG_SWORD, /* 16-bit signed word */
65 ARG_SEGPTR, /* segmented pointer */
66 ARG_SEGSTR, /* segmented pointer to Ansi string */
67 ARG_LONG, /* long */
68 ARG_PTR, /* pointer */
69 ARG_STR, /* pointer to Ansi string */
70 ARG_WSTR, /* pointer to Unicode string */
71 ARG_INT64, /* 64-bit integer */
72 ARG_INT128, /* 128-bit integer */
73 ARG_FLOAT, /* 32-bit float */
74 ARG_DOUBLE, /* 64-bit float */
75 ARG_MAXARG = ARG_DOUBLE
78 #define MAX_ARGUMENTS 32
80 typedef struct
82 int n_values;
83 unsigned int *values;
84 } ORD_VARIABLE;
86 typedef struct
88 int nb_args;
89 int args_str_offset;
90 enum arg_type args[MAX_ARGUMENTS];
91 } ORD_FUNCTION;
93 typedef struct
95 unsigned short value;
96 } ORD_ABS;
98 typedef struct
100 ORD_TYPE type;
101 int ordinal;
102 int lineno;
103 int flags;
104 char *name; /* public name of this function */
105 char *link_name; /* name of the C symbol to link to */
106 char *export_name; /* name exported under for noname exports */
107 union
109 ORD_VARIABLE var;
110 ORD_FUNCTION func;
111 ORD_ABS abs;
112 } u;
113 } ORDDEF;
115 typedef struct
117 char *src_name; /* file name of the source spec file */
118 char *file_name; /* file name of the dll */
119 char *dll_name; /* internal name of the dll */
120 char *c_name; /* internal name of the dll, as a C-compatible identifier */
121 char *init_func; /* initialization routine */
122 char *main_module; /* main Win32 module for Win16 specs */
123 SPEC_TYPE type; /* type of dll (Win16/Win32) */
124 int base; /* ordinal base */
125 int limit; /* ordinal limit */
126 int stack_size; /* exe stack size */
127 int heap_size; /* exe heap size */
128 int nb_entry_points; /* number of used entry points */
129 int alloc_entry_points; /* number of allocated entry points */
130 int nb_names; /* number of entry points with names */
131 unsigned int nb_resources; /* number of resources */
132 int characteristics; /* characteristics for the PE header */
133 int dll_characteristics;/* DLL characteristics for the PE header */
134 int subsystem; /* subsystem id */
135 int subsystem_major; /* subsystem version major number */
136 int subsystem_minor; /* subsystem version minor number */
137 ORDDEF *entry_points; /* dll entry points */
138 ORDDEF **names; /* array of entry point names (points into entry_points) */
139 ORDDEF **ordinals; /* array of dll ordinals (points into entry_points) */
140 struct resource *resources; /* array of dll resources (format differs between Win16/Win32) */
141 } DLLSPEC;
143 enum target_cpu
145 CPU_x86, CPU_x86_64, CPU_POWERPC, CPU_ARM, CPU_ARM64, CPU_LAST = CPU_ARM64
148 enum target_platform
150 PLATFORM_UNSPECIFIED,
151 PLATFORM_APPLE,
152 PLATFORM_FREEBSD,
153 PLATFORM_SOLARIS,
154 PLATFORM_WINDOWS
157 extern char *target_alias;
158 extern enum target_cpu target_cpu;
159 extern enum target_platform target_platform;
161 struct strarray
163 const char **str;
164 unsigned int count;
165 unsigned int max;
168 /* entry point flags */
169 #define FLAG_NORELAY 0x01 /* don't use relay debugging for this function */
170 #define FLAG_NONAME 0x02 /* don't export function by name */
171 #define FLAG_RET16 0x04 /* function returns a 16-bit value */
172 #define FLAG_RET64 0x08 /* function returns a 64-bit value */
173 #define FLAG_REGISTER 0x10 /* use register calling convention */
174 #define FLAG_PRIVATE 0x20 /* function is private (cannot be imported) */
175 #define FLAG_ORDINAL 0x40 /* function should be imported by ordinal */
177 #define FLAG_FORWARD 0x100 /* function is a forwarded name */
178 #define FLAG_EXT_LINK 0x200 /* function links to an external symbol */
179 #define FLAG_EXPORT32 0x400 /* 32-bit export in 16-bit spec file */
181 #define FLAG_CPU(cpu) (0x01000 << (cpu))
182 #define FLAG_CPU_MASK (FLAG_CPU(CPU_LAST + 1) - FLAG_CPU(0))
183 #define FLAG_CPU_WIN64 (FLAG_CPU(CPU_x86_64) | FLAG_CPU(CPU_ARM64))
184 #define FLAG_CPU_WIN32 (FLAG_CPU_MASK & ~FLAG_CPU_WIN64)
186 #define MAX_ORDINALS 65535
188 /* some Windows constants */
190 #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
191 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
192 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
193 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
194 #define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
195 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
196 #define IMAGE_FILE_16BIT_MACHINE 0x0040
197 #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
198 #define IMAGE_FILE_32BIT_MACHINE 0x0100
199 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200
200 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
201 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
202 #define IMAGE_FILE_SYSTEM 0x1000
203 #define IMAGE_FILE_DLL 0x2000
204 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
205 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
207 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100
209 #define IMAGE_SUBSYSTEM_NATIVE 1
210 #define IMAGE_SUBSYSTEM_WINDOWS_GUI 2
211 #define IMAGE_SUBSYSTEM_WINDOWS_CUI 3
212 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9
214 /* global functions */
216 #ifndef __GNUC__
217 #define __attribute__(X)
218 #endif
220 #ifndef DECLSPEC_NORETURN
221 # if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
222 # define DECLSPEC_NORETURN __declspec(noreturn)
223 # else
224 # define DECLSPEC_NORETURN __attribute__((noreturn))
225 # endif
226 #endif
228 extern void *xmalloc (size_t size);
229 extern void *xrealloc (void *ptr, size_t size);
230 extern char *xstrdup( const char *str );
231 extern char *strupper(char *s);
232 extern int strendswith(const char* str, const char* end);
233 extern char *strmake(const char* fmt, ...) __attribute__((__format__ (__printf__, 1, 2 )));
234 extern struct strarray strarray_fromstring( const char *str, const char *delim );
235 extern void strarray_add( struct strarray *array, ... );
236 extern void strarray_addv( struct strarray *array, char * const *argv );
237 extern void strarray_addall( struct strarray *array, struct strarray args );
238 extern DECLSPEC_NORETURN void fatal_error( const char *msg, ... )
239 __attribute__ ((__format__ (__printf__, 1, 2)));
240 extern DECLSPEC_NORETURN void fatal_perror( const char *msg, ... )
241 __attribute__ ((__format__ (__printf__, 1, 2)));
242 extern void error( const char *msg, ... )
243 __attribute__ ((__format__ (__printf__, 1, 2)));
244 extern void warning( const char *msg, ... )
245 __attribute__ ((__format__ (__printf__, 1, 2)));
246 extern int output( const char *format, ... )
247 __attribute__ ((__format__ (__printf__, 1, 2)));
248 extern void output_cfi( const char *format, ... )
249 __attribute__ ((__format__ (__printf__, 1, 2)));
250 extern void spawn( struct strarray array );
251 extern struct strarray find_tool( const char *name, const char * const *names );
252 extern struct strarray get_as_command(void);
253 extern struct strarray get_ld_command(void);
254 extern const char *get_nm_command(void);
255 extern void cleanup_tmp_files(void);
256 extern char *get_temp_file_name( const char *prefix, const char *suffix );
257 extern void output_standard_file_header(void);
258 extern FILE *open_input_file( const char *srcdir, const char *name );
259 extern void close_input_file( FILE *file );
260 extern void dump_bytes( const void *buffer, unsigned int size );
261 extern int remove_stdcall_decoration( char *name );
262 extern void assemble_file( const char *src_file, const char *obj_file );
263 extern DLLSPEC *alloc_dll_spec(void);
264 extern void free_dll_spec( DLLSPEC *spec );
265 extern char *make_c_identifier( const char *str );
266 extern const char *get_stub_name( const ORDDEF *odp, const DLLSPEC *spec );
267 extern int get_cpu_from_name( const char *name );
268 extern unsigned int get_alignment(unsigned int align);
269 extern unsigned int get_page_size(void);
270 extern unsigned int get_ptr_size(void);
271 extern unsigned int get_args_size( const ORDDEF *odp );
272 extern const char *asm_name( const char *func );
273 extern const char *func_declaration( const char *func );
274 extern const char *asm_globl( const char *func );
275 extern const char *get_asm_ptr_keyword(void);
276 extern const char *get_asm_string_keyword(void);
277 extern const char *get_asm_rodata_section(void);
278 extern const char *get_asm_string_section(void);
279 extern void output_function_size( const char *name );
280 extern void output_gnu_stack_note(void);
282 extern void add_import_dll( const char *name, const char *filename );
283 extern void add_delayed_import( const char *name );
284 extern void add_extra_ld_symbol( const char *name );
285 extern void read_undef_symbols( DLLSPEC *spec, char **argv );
286 extern void resolve_imports( DLLSPEC *spec );
287 extern int is_undefined( const char *name );
288 extern int has_imports(void);
289 extern void output_get_pc_thunk(void);
290 extern void output_module( DLLSPEC *spec );
291 extern void output_stubs( DLLSPEC *spec );
292 extern void output_imports( DLLSPEC *spec );
293 extern void output_import_lib( DLLSPEC *spec, char **argv );
294 extern void output_exports( DLLSPEC *spec );
295 extern int load_res32_file( const char *name, DLLSPEC *spec );
296 extern void output_resources( DLLSPEC *spec );
297 extern void output_bin_resources( DLLSPEC *spec, unsigned int start_rva );
298 extern void output_fake_module( DLLSPEC *spec );
299 extern void output_def_file( DLLSPEC *spec, int include_private );
300 extern void load_res16_file( const char *name, DLLSPEC *spec );
301 extern void output_res16_data( DLLSPEC *spec );
302 extern void output_bin_res16_data( DLLSPEC *spec );
303 extern void output_res16_directory( DLLSPEC *spec );
304 extern void output_bin_res16_directory( DLLSPEC *spec, unsigned int data_offset );
305 extern void output_spec16_file( DLLSPEC *spec );
306 extern void output_fake_module16( DLLSPEC *spec16 );
307 extern void output_res_o_file( DLLSPEC *spec );
308 extern void output_asm_relays16(void);
310 extern void BuildSpec32File( DLLSPEC *spec );
312 extern void add_16bit_exports( DLLSPEC *spec32, DLLSPEC *spec16 );
313 extern int parse_spec_file( FILE *file, DLLSPEC *spec );
314 extern int parse_def_file( FILE *file, DLLSPEC *spec );
316 /* buffer management */
318 extern int byte_swapped;
319 extern const char *input_buffer_filename;
320 extern const unsigned char *input_buffer;
321 extern size_t input_buffer_pos;
322 extern size_t input_buffer_size;
323 extern unsigned char *output_buffer;
324 extern size_t output_buffer_pos;
325 extern size_t output_buffer_size;
327 extern void init_input_buffer( const char *file );
328 extern void init_output_buffer(void);
329 extern void flush_output_buffer(void);
330 extern unsigned char get_byte(void);
331 extern unsigned short get_word(void);
332 extern unsigned int get_dword(void);
333 extern void put_data( const void *data, size_t size );
334 extern void put_byte( unsigned char val );
335 extern void put_word( unsigned short val );
336 extern void put_dword( unsigned int val );
337 extern void put_qword( unsigned int val );
338 extern void put_pword( unsigned int val );
339 extern void align_output( unsigned int align );
341 /* global variables */
343 extern int current_line;
344 extern int UsePIC;
345 extern int nb_errors;
346 extern int display_warnings;
347 extern int kill_at;
348 extern int verbose;
349 extern int link_ext_symbols;
350 extern int force_pointer_size;
351 extern int unwind_tables;
353 extern char *input_file_name;
354 extern char *spec_file_name;
355 extern FILE *output_file;
356 extern const char *output_file_name;
358 extern struct strarray lib_path;
359 extern struct strarray as_command;
360 extern struct strarray cc_command;
361 extern struct strarray ld_command;
362 extern struct strarray nm_command;
363 extern char *cpu_option;
364 extern char *fpu_option;
365 extern char *arch_option;
366 extern const char *float_abi_option;
367 extern int thumb_mode;
368 extern int needs_get_pc_thunk;
370 #endif /* __WINE_BUILD_H */