Fixed typo in wine_get_unix_file_name().
[wine] / tools / winebuild / build.h
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
7  */
8
9 #ifndef __WINE_BUILD_H
10 #define __WINE_BUILD_H
11
12 #include "config.h"
13 #include <stdio.h>
14 #include <stdlib.h>
15
16 #ifdef NEED_UNDERSCORE_PREFIX
17 # define PREFIX "_"
18 #else
19 # define PREFIX
20 #endif
21
22 #ifdef HAVE_ASM_STRING
23 # define STRING ".string"
24 #else
25 # define STRING ".ascii"
26 #endif
27
28 #if defined(__GNUC__) && !defined(__svr4__)
29 # define USE_STABS
30 #else
31 # undef USE_STABS
32 #endif
33
34 typedef enum
35 {
36     TYPE_VARIABLE,     /* variable */
37     TYPE_PASCAL_16,    /* pascal function with 16-bit return (Win16) */
38     TYPE_PASCAL,       /* pascal function with 32-bit return (Win16) */
39     TYPE_ABS,          /* absolute value (Win16) */
40     TYPE_REGISTER,     /* register function */
41     TYPE_INTERRUPT,    /* interrupt handler function (Win16) */
42     TYPE_STUB,         /* unimplemented stub */
43     TYPE_STDCALL,      /* stdcall function (Win32) */
44     TYPE_CDECL,        /* cdecl function (Win32) */
45     TYPE_VARARGS,      /* varargs function (Win32) */
46     TYPE_EXTERN,       /* external symbol (Win32) */
47     TYPE_FORWARD,      /* forwarded function (Win32) */
48     TYPE_NBTYPES
49 } ORD_TYPE;
50
51 typedef enum
52 {
53     SPEC_INVALID,
54     SPEC_WIN16,
55     SPEC_WIN32
56 } SPEC_TYPE;
57
58 typedef enum
59 {
60     SPEC_MODE_DLL,
61     SPEC_MODE_GUIEXE,
62     SPEC_MODE_CUIEXE,
63     SPEC_MODE_GUIEXE_UNICODE,
64     SPEC_MODE_CUIEXE_UNICODE
65 } SPEC_MODE;
66
67 typedef struct
68 {
69     int n_values;
70     int *values;
71 } ORD_VARIABLE;
72
73 typedef struct
74 {
75     int  n_args;
76     char arg_types[17];
77 } ORD_FUNCTION;
78
79 typedef struct
80 {
81     int value;
82 } ORD_ABS;
83
84 typedef struct
85 {
86     ORD_TYPE    type;
87     int         ordinal;
88     int         offset;
89     int         lineno;
90     int         flags;
91     char       *name;
92     char       *link_name;
93     union
94     {
95         ORD_VARIABLE   var;
96         ORD_FUNCTION   func;
97         ORD_ABS        abs;
98     } u;
99 } ORDDEF;
100
101 /* entry point flags */
102 #define FLAG_NOIMPORT  0x01  /* don't make function available for importing */
103 #define FLAG_NORELAY   0x02  /* don't use relay debugging for this function */
104 #define FLAG_RET64     0x04  /* function returns a 64-bit value */
105 #define FLAG_I386      0x08  /* function is i386 only */
106
107   /* Offset of a structure field relative to the start of the struct */
108 #define STRUCTOFFSET(type,field) ((int)&((type *)0)->field)
109
110   /* Offset of register relative to the start of the CONTEXT struct */
111 #define CONTEXTOFFSET(reg)  STRUCTOFFSET(CONTEXT86,reg)
112
113   /* Offset of register relative to the start of the STACK16FRAME struct */
114 #define STACK16OFFSET(reg)  STRUCTOFFSET(STACK16FRAME,reg)
115
116   /* Offset of register relative to the start of the STACK32FRAME struct */
117 #define STACK32OFFSET(reg)  STRUCTOFFSET(STACK32FRAME,reg)
118
119   /* Offset of the stack pointer relative to %fs:(0) */
120 #define STACKOFFSET (STRUCTOFFSET(TEB,cur_stack))
121
122
123 #define MAX_ORDINALS  65535
124
125 /* global functions */
126
127 extern void *xmalloc (size_t size);
128 extern void *xrealloc (void *ptr, size_t size);
129 extern char *xstrdup( const char *str );
130 extern char *strupper(char *s);
131 extern void fatal_error( const char *msg, ... );
132 extern void fatal_perror( const char *msg, ... );
133 extern void warning( const char *msg, ... );
134 extern void dump_bytes( FILE *outfile, const unsigned char *data, int len,
135                         const char *label, int constant );
136 extern void add_import_dll( const char *name, int delay );
137 extern void add_ignore_symbol( const char *name );
138 extern int resolve_imports( FILE *outfile );
139 extern int output_imports( FILE *outfile );
140 extern void load_res32_file( const char *name );
141 extern int output_resources( FILE *outfile );
142 extern void load_res16_file( const char *name );
143 extern int output_res16_data( FILE *outfile );
144 extern int output_res16_directory( unsigned char *buffer );
145
146 extern void BuildGlue( FILE *outfile, FILE *infile );
147 extern void BuildRelays( FILE *outfile );
148 extern void BuildSpec16File( FILE *outfile );
149 extern void BuildSpec32File( FILE *outfile );
150 extern SPEC_TYPE ParseTopLevel( FILE *file );
151
152 /* global variables */
153
154 extern int current_line;
155 extern int nb_entry_points;
156 extern int nb_names;
157 extern int Base;
158 extern int Limit;
159 extern int DLLHeapSize;
160 extern int UsePIC;
161 extern int debugging;
162 extern int nb_debug_channels;
163 extern int nb_lib_paths;
164
165 extern char DLLName[80];
166 extern char DLLFileName[80];
167 extern char owner_name[80];
168 extern char *init_func;
169 extern const char *input_file_name;
170 extern const char *output_file_name;
171 extern char **debug_channels;
172 extern char **lib_path;
173
174 extern ORDDEF *EntryPoints[MAX_ORDINALS];
175 extern ORDDEF *Ordinals[MAX_ORDINALS];
176 extern ORDDEF *Names[MAX_ORDINALS];
177 extern SPEC_MODE SpecMode;
178
179 #endif  /* __WINE_BUILD_H */