build.h 8.69 KB
Newer Older
1 2 3 4 5 6
/*
 * Copyright 1993 Robert J. Amstadt
 * Copyright 1995 Martin von Loewis
 * Copyright 1995, 1996, 1997 Alexandre Julliard
 * Copyright 1997 Eric Youngdale
 * Copyright 1999 Ulrich Weigand
7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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
21 22 23 24 25
 */

#ifndef __WINE_BUILD_H
#define __WINE_BUILD_H

26 27 28
#ifndef __WINE_CONFIG_H
# error You must include config.h to use this header
#endif
29

30 31
#include <stdio.h>
#include <stdlib.h>
32
#include <string.h>
33 34 35

typedef enum
{
36
    TYPE_VARIABLE,     /* variable */
37
    TYPE_PASCAL,       /* pascal function (Win16) */
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
    TYPE_ABS,          /* absolute value (Win16) */
    TYPE_STUB,         /* unimplemented stub */
    TYPE_STDCALL,      /* stdcall function (Win32) */
    TYPE_CDECL,        /* cdecl function (Win32) */
    TYPE_VARARGS,      /* varargs function (Win32) */
    TYPE_EXTERN,       /* external symbol (Win32) */
    TYPE_NBTYPES
} ORD_TYPE;

typedef enum
{
    SPEC_WIN16,
    SPEC_WIN32
} SPEC_TYPE;

typedef struct
{
    int n_values;
    int *values;
} ORD_VARIABLE;

typedef struct
{
61
    char arg_types[21];
62 63 64 65
} ORD_FUNCTION;

typedef struct
{
66
    unsigned short value;
67 68 69 70 71 72
} ORD_ABS;

typedef struct
{
    ORD_TYPE    type;
    int         ordinal;
73 74
    int         lineno;
    int         flags;
75 76 77
    char       *name;         /* public name of this function */
    char       *link_name;    /* name of the C symbol to link to */
    char       *export_name;  /* name exported under for noname exports */
78 79 80 81 82 83 84 85
    union
    {
        ORD_VARIABLE   var;
        ORD_FUNCTION   func;
        ORD_ABS        abs;
    } u;
} ORDDEF;

86 87
typedef struct
{
88
    char            *src_name;           /* file name of the source spec file */
89 90 91 92 93 94 95 96 97 98 99
    char            *file_name;          /* file name of the dll */
    char            *dll_name;           /* internal name of the dll */
    char            *init_func;          /* initialization routine */
    SPEC_TYPE        type;               /* type of dll (Win16/Win32) */
    int              base;               /* ordinal base */
    int              limit;              /* ordinal limit */
    int              stack_size;         /* exe stack size */
    int              heap_size;          /* exe heap size */
    int              nb_entry_points;    /* number of used entry points */
    int              alloc_entry_points; /* number of allocated entry points */
    int              nb_names;           /* number of entry points with names */
Jon Griffiths's avatar
Jon Griffiths committed
100
    unsigned int     nb_resources;       /* number of resources */
101
    int              characteristics;    /* characteristics for the PE header */
102
    int              dll_characteristics;/* DLL characteristics for the PE header */
103 104 105
    int              subsystem;          /* subsystem id */
    int              subsystem_major;    /* subsystem version major number */
    int              subsystem_minor;    /* subsystem version minor number */
106 107 108 109 110 111
    ORDDEF          *entry_points;       /* dll entry points */
    ORDDEF         **names;              /* array of entry point names (points into entry_points) */
    ORDDEF         **ordinals;           /* array of dll ordinals (points into entry_points) */
    struct resource *resources;          /* array of dll resources (format differs between Win16/Win32) */
} DLLSPEC;

112 113
enum target_cpu
{
114
    CPU_x86, CPU_x86_64, CPU_SPARC, CPU_ALPHA, CPU_POWERPC
115 116 117 118
};

enum target_platform
{
119
    PLATFORM_UNSPECIFIED, PLATFORM_APPLE, PLATFORM_SOLARIS, PLATFORM_WINDOWS
120 121 122 123 124
};

extern enum target_cpu target_cpu;
extern enum target_platform target_platform;

125
/* entry point flags */
126
#define FLAG_NORELAY   0x01  /* don't use relay debugging for this function */
127
#define FLAG_NONAME    0x02  /* don't export function by name */
128 129 130 131
#define FLAG_RET16     0x04  /* function returns a 16-bit value */
#define FLAG_RET64     0x08  /* function returns a 64-bit value */
#define FLAG_I386      0x10  /* function is i386 only */
#define FLAG_REGISTER  0x20  /* use register calling convention */
132
#define FLAG_PRIVATE   0x40  /* function is private (cannot be imported) */
133
#define FLAG_ORDINAL   0x80  /* function should be imported by ordinal */
134

135 136
#define FLAG_FORWARD   0x100  /* function is a forwarded name */
#define FLAG_EXT_LINK  0x200  /* function links to an external symbol */
137

138
#define MAX_ORDINALS  65535
139 140 141

/* global functions */

142 143 144 145
#ifndef __GNUC__
#define __attribute__(X)
#endif

146 147 148 149 150 151 152 153
#ifndef DECLSPEC_NORETURN
# if defined(_MSC_VER) && (_MSC_VER >= 1200) && !defined(MIDL_PASS)
#  define DECLSPEC_NORETURN __declspec(noreturn)
# else
#  define DECLSPEC_NORETURN __attribute__((noreturn))
# endif
#endif

154 155 156 157
extern void *xmalloc (size_t size);
extern void *xrealloc (void *ptr, size_t size);
extern char *xstrdup( const char *str );
extern char *strupper(char *s);
158
extern int strendswith(const char* str, const char* end);
159
extern DECLSPEC_NORETURN void fatal_error( const char *msg, ... )
160
   __attribute__ ((__format__ (__printf__, 1, 2)));
161
extern DECLSPEC_NORETURN void fatal_perror( const char *msg, ... )
162 163 164 165 166
   __attribute__ ((__format__ (__printf__, 1, 2)));
extern void error( const char *msg, ... )
   __attribute__ ((__format__ (__printf__, 1, 2)));
extern void warning( const char *msg, ... )
   __attribute__ ((__format__ (__printf__, 1, 2)));
167 168
extern int output( const char *format, ... )
   __attribute__ ((__format__ (__printf__, 1, 2)));
169
extern char *get_temp_file_name( const char *prefix, const char *suffix );
170
extern void output_standard_file_header(void);
171 172
extern FILE *open_input_file( const char *srcdir, const char *name );
extern void close_input_file( FILE *file );
173
extern void dump_bytes( const void *buffer, unsigned int size );
174
extern int remove_stdcall_decoration( char *name );
175
extern void assemble_file( const char *src_file, const char *obj_file );
176 177
extern DLLSPEC *alloc_dll_spec(void);
extern void free_dll_spec( DLLSPEC *spec );
178
extern const char *make_c_identifier( const char *str );
179
extern const char *get_stub_name( const ORDDEF *odp, const DLLSPEC *spec );
180 181
extern unsigned int get_alignment(unsigned int align);
extern unsigned int get_page_size(void);
182
extern unsigned int get_ptr_size(void);
183
extern const char *asm_name( const char *func );
184
extern const char *func_declaration( const char *func );
185
extern const char *asm_globl( const char *func );
186
extern const char *get_asm_ptr_keyword(void);
187 188
extern const char *get_asm_string_keyword(void);
extern const char *get_asm_short_keyword(void);
189
extern const char *get_asm_rodata_section(void);
190
extern const char *get_asm_string_section(void);
191 192
extern void output_function_size( const char *name );
extern void output_gnu_stack_note(void);
193

194 195
extern void add_import_dll( const char *name, const char *filename );
extern void add_delayed_import( const char *name );
196
extern void add_ignore_symbol( const char *name );
197
extern void add_extra_ld_symbol( const char *name );
198
extern void read_undef_symbols( DLLSPEC *spec, char **argv );
199
extern int resolve_imports( DLLSPEC *spec );
200
extern int has_imports(void);
201
extern int has_relays( DLLSPEC *spec );
202 203 204
extern void output_get_pc_thunk(void);
extern void output_stubs( DLLSPEC *spec );
extern void output_imports( DLLSPEC *spec );
205
extern int load_res32_file( const char *name, DLLSPEC *spec );
206
extern void output_resources( DLLSPEC *spec );
207
extern void load_res16_file( const char *name, DLLSPEC *spec );
208 209
extern void output_res16_data( DLLSPEC *spec );
extern void output_res16_directory( DLLSPEC *spec, const char *header_name );
210

211 212 213 214 215
extern void BuildRelays16(void);
extern void BuildRelays32(void);
extern void BuildSpec16File( DLLSPEC *spec );
extern void BuildSpec32File( DLLSPEC *spec );
extern void BuildDef32File( DLLSPEC *spec );
216 217 218

extern int parse_spec_file( FILE *file, DLLSPEC *spec );
extern int parse_def_file( FILE *file, DLLSPEC *spec );
219 220 221 222 223

/* global variables */

extern int current_line;
extern int UsePIC;
224
extern int nb_lib_paths;
225
extern int nb_errors;
226
extern int display_warnings;
227
extern int kill_at;
228 229
extern int verbose;
extern int save_temps;
230
extern int link_ext_symbols;
231

232
extern char *input_file_name;
233
extern char *spec_file_name;
234
extern FILE *output_file;
235
extern const char *output_file_name;
236
extern char **lib_path;
237

238
extern char *as_command;
239 240 241
extern char *ld_command;
extern char *nm_command;

242
#endif  /* __WINE_BUILD_H */