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
43 #if !defined(HAVE_POPEN) && defined(HAVE__POPEN)
47 #if !defined(HAVE_PCLOSE) && defined(HAVE__PCLOSE)
48 #define pclose _pclose
51 #if !defined(HAVE_STRNCASECMP) && defined(HAVE__STRNICMP)
52 # define strncasecmp _strnicmp
55 #if !defined(HAVE_STRCASECMP) && defined(HAVE__STRICMP)
56 # define strcasecmp _stricmp
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)
72 #define PUT_UA_WORD(ptr, w) PUT_LE_WORD(ptr, w)
75 #ifdef NEED_UNDERSCORE_PREFIX
76 # define __ASM_NAME(name) "_" name
78 # define __ASM_NAME(name) name
81 #ifdef NEED_TYPE_IN_DEF
82 # define __ASM_FUNC(name) ".def " __ASM_NAME(name) "; .scl 2; .type 32; .endef"
84 # define __ASM_FUNC(name) ".type " __ASM_NAME(name) ",@function"
87 #ifdef NEED_UNDERSCORE_PREFIX
93 #ifdef HAVE_ASM_STRING
94 # define STRING ".string"
96 # define STRING ".ascii"
99 #if defined(__GNUC__) && !defined(__svr4__)
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) */
132 SPEC_MODE_GUIEXE_UNICODE,
133 SPEC_MODE_CUIEXE_UNICODE
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 */
178 /* Offset of a structure field relative to the start of the struct */
179 #define STRUCTOFFSET(type,field) ((int)&((type *)0)->field)
181 /* Offset of register relative to the start of the CONTEXT struct */
182 #define CONTEXTOFFSET(reg) STRUCTOFFSET(CONTEXT86,reg)
184 /* Offset of register relative to the start of the STACK16FRAME struct */
185 #define STACK16OFFSET(reg) STRUCTOFFSET(STACK16FRAME,reg)
187 /* Offset of register relative to the start of the STACK32FRAME struct */
188 #define STACK32OFFSET(reg) STRUCTOFFSET(STACK32FRAME,reg)
190 /* Offset of the stack pointer relative to %fs:(0) */
191 #define STACKOFFSET (STRUCTOFFSET(TEB,cur_stack))
194 #define MAX_ORDINALS 65535
196 /* global functions */
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);
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 );
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 );
228 /* global variables */
230 extern int current_line;
231 extern int nb_entry_points;
235 extern int DLLHeapSize;
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;
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;
252 extern ORDDEF *EntryPoints[MAX_ORDINALS];
253 extern ORDDEF *Ordinals[MAX_ORDINALS];
254 extern ORDDEF *Names[MAX_ORDINALS];
255 extern SPEC_MODE SpecMode;
257 #endif /* __WINE_BUILD_H */