build.h 6.4 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 20
 *
 * 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
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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
    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 enum
{
    SPEC_MODE_DLL,
    SPEC_MODE_GUIEXE,
57
    SPEC_MODE_CUIEXE,
58 59
    SPEC_MODE_GUIEXE_UNICODE,
    SPEC_MODE_CUIEXE_UNICODE
60 61 62 63 64 65 66 67 68 69 70
} SPEC_MODE;

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

typedef struct
{
    int  n_args;
71
    char arg_types[21];
72 73 74 75 76 77 78 79 80 81 82 83
} ORD_FUNCTION;

typedef struct
{
    int value;
} ORD_ABS;

typedef struct
{
    ORD_TYPE    type;
    int         ordinal;
    int         offset;
84 85
    int         lineno;
    int         flags;
86 87 88
    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 */
89 90 91 92 93 94 95 96
    union
    {
        ORD_VARIABLE   var;
        ORD_FUNCTION   func;
        ORD_ABS        abs;
    } u;
} ORDDEF;

97
/* entry point flags */
98 99
#define FLAG_NORELAY   0x01  /* don't use relay debugging for this function */
#define FLAG_NONAME    0x02  /* don't import function by name */
100 101 102 103 104 105
#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 */
#define FLAG_INTERRUPT 0x40  /* function is an interrupt handler */
#define FLAG_PRIVATE   0x80  /* function is private (cannot be imported) */
106

107
#define FLAG_FORWARD   0x100 /* function is a forwarded name */
108

109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
  /* Offset of a structure field relative to the start of the struct */
#define STRUCTOFFSET(type,field) ((int)&((type *)0)->field)

  /* Offset of register relative to the start of the CONTEXT struct */
#define CONTEXTOFFSET(reg)  STRUCTOFFSET(CONTEXT86,reg)

  /* Offset of register relative to the start of the STACK16FRAME struct */
#define STACK16OFFSET(reg)  STRUCTOFFSET(STACK16FRAME,reg)

  /* Offset of register relative to the start of the STACK32FRAME struct */
#define STACK32OFFSET(reg)  STRUCTOFFSET(STACK32FRAME,reg)

  /* Offset of the stack pointer relative to %fs:(0) */
#define STACKOFFSET (STRUCTOFFSET(TEB,cur_stack))


125
#define MAX_ORDINALS  65535
126 127 128

/* global functions */

129 130 131 132
#ifndef __GNUC__
#define __attribute__(X)
#endif

133 134 135 136
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);
137 138 139 140 141 142 143 144
extern void fatal_error( const char *msg, ... )
   __attribute__ ((__format__ (__printf__, 1, 2)));
extern void fatal_perror( const char *msg, ... )
   __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)));
145
extern void output_standard_file_header( FILE *outfile );
146 147
extern FILE *open_input_file( const char *srcdir, const char *name );
extern void close_input_file( FILE *file );
148 149
extern void dump_bytes( FILE *outfile, const unsigned char *data, int len,
                        const char *label, int constant );
150
extern const char *make_c_identifier( const char *str );
151 152
extern int get_alignment(int alignBoundary);

153
extern void add_import_dll( const char *name, int delay );
154
extern void add_ignore_symbol( const char *name );
155
extern void read_undef_symbols( char **argv );
Dmitry Timoshkov's avatar
Dmitry Timoshkov committed
156
extern int resolve_imports( void );
157
extern int output_imports( FILE *outfile );
158
extern int load_res32_file( const char *name );
159
extern int output_resources( FILE *outfile );
160 161 162
extern void load_res16_file( const char *name );
extern int output_res16_data( FILE *outfile );
extern int output_res16_directory( unsigned char *buffer );
163
extern void output_dll_init( FILE *outfile, const char *constructor, const char *destructor );
164
extern int parse_debug_channels( const char *srcdir, const char *filename );
165

166 167
extern void BuildRelays16( FILE *outfile );
extern void BuildRelays32( FILE *outfile );
168
extern void BuildSpec16File( FILE *outfile );
169
extern void BuildSpec32File( FILE *outfile );
170
extern void BuildDef32File( FILE *outfile );
171
extern void BuildDebugFile( FILE *outfile, const char *srcdir, char **argv );
172
extern int ParseTopLevel( FILE *file );
173 174 175 176 177 178 179 180 181 182 183

/* global variables */

extern int current_line;
extern int nb_entry_points;
extern int nb_names;
extern int Base;
extern int Limit;
extern int DLLHeapSize;
extern int UsePIC;
extern int debugging;
184
extern int stack_size;
185
extern int nb_debug_channels;
186
extern int nb_lib_paths;
187
extern int nb_errors;
188
extern int display_warnings;
189
extern int kill_at;
190

191 192 193
extern char *owner_name;
extern char *dll_name;
extern char *dll_file_name;
194
extern const char *init_func;
195
extern char *input_file_name;
196
extern const char *output_file_name;
197
extern char **debug_channels;
198
extern char **lib_path;
199

200
extern ORDDEF *EntryPoints[MAX_ORDINALS];
201 202 203
extern ORDDEF *Ordinals[MAX_ORDINALS];
extern ORDDEF *Names[MAX_ORDINALS];
extern SPEC_MODE SpecMode;
204
extern SPEC_TYPE SpecType;
205 206

#endif  /* __WINE_BUILD_H */