1/* as.h - global header file
2   Copyright (C) 1987 Free Software Foundation, Inc.
3
4This file is part of GAS, the GNU Assembler.
5
6GAS is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
11GAS is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GAS; see the file COPYING.  If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20#ifndef AS_H_
21#define AS_H_
22
23extern char *apple_flags;
24#define APPLE_INC_VERSION "Apple Inc version"
25/* apple_version is in apple_version.c which is created by the Makefile */
26extern char apple_version[];
27/* the GNU version is set in as.c */
28extern char version_string[];
29
30#define _(String) (String)
31#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
32
33/*
34 * CAPITALISED names are #defined.
35 * "lowercaseT" is a typedef of "lowercase" objects.
36 * "lowercaseP" is type "pointer to object of type 'lowercase'".
37 * "lowercaseS" is typedef struct ... lowercaseS.
38 *
39 * #define SUSPECT when debugging.
40 * If TEST is #defined, then we are testing a module.
41 */
42
43/* These #defines are for parameters of entire assembler. */
44
45/*
46 * asserts() from <assert.h> are DISabled when NDEBUG is defined and
47 * asserts() from <assert.h> are ENabled  when NDEBUG is undefined.
48 * For speed NDEBUG is defined so assert()'s are left out.
49#undef NDEBUG
50 */
51#define NDEBUG
52
53/*
54 * For speed SUSPECT is undefined.
55#define SUSPECT
56 */
57#undef SUSPECT
58
59/* These #imports are for type definitions etc. */
60#include <stdint.h>
61#import <stdio.h>
62#import <assert.h>
63#import <mach/machine.h>
64
65/* These defines are potentially useful */
66#undef FALSE
67#define FALSE	(0)
68#undef TRUE
69#define TRUE	(!FALSE)
70#define ASSERT	assert
71
72#define BAD_CASE(value)							\
73{									\
74  as_fatal ("Case value %d unexpected at line %d of file \"%s\"\n",	\
75	   value, __LINE__, __FILE__);					\
76}
77
78/* These are assembler-wide concepts */
79
80/* FROM line 206 */
81#ifdef BFD_ASSEMBLER
82extern bfd *stdoutput;
83typedef bfd_vma addressT;
84typedef bfd_signed_vma offsetT;
85#else
86/* These are 64-bit values so we can use 64-bit values with 32-bit targets. */
87typedef uint64_t addressT;
88typedef int64_t offsetT;
89#endif
90
91#ifdef SUSPECT
92#define register		/* no registers: helps debugging */
93#define know(p) ASSERT(p)	/* know() is less ugly than #ifdef SUSPECT/ */
94				/* assert()/#endif. */
95#else
96#define know(p)			/* know() checks are no-op.ed */
97#endif
98
99
100/* FROM line 262 */
101/*
102 * This table describes the use of segments as EXPRESSION types.
103 *
104 *	X_seg	X_add_symbol  X_subtract_symbol	X_add_number
105 * SEG_NONE						no (legal) expression
106 * SEG_BIG					*	> 32 bits const.
107 * SEG_ABSOLUTE				     	0
108 * SEG_SECT		*		     	0
109 * SEG_UNKNOWN		*			0
110 * SEG_DIFFSECT		0		*	0
111 *
112 * The blank fields MUST be 0, and are nugatory.
113 * The '0' fields MAY be 0. The '*' fields MAY NOT be 0.
114 *
115 * SEG_BIG: A floating point number or an integer larger than 32 bits.
116 *   For a floating point number:
117 *	X_add_number is < 0
118 * 	    The result is in the global variable generic_floating_point_number.
119 *	    The value in X_add_number is -'c' where c is the character that
120 *	    introduced the constant.  e.g. "0f6.9" will have  -'f' as a
121 *	    X_add_number value.
122 *   For an integer larger than 32 bits:
123 *	X_add_number > 0
124 *	    The result is in the global variable generic_bignum.
125 *	    The value in X_add_number is a count of how many littlenums it
126 *	    took to represent the bignum.
127 */
128typedef enum {
129    SEG_ABSOLUTE,	/* absolute */
130    SEG_SECT,		/* normal defined section */
131    SEG_DIFFSECT,	/* difference between symbols in sections */
132    SEG_UNKNOWN,	/* expression involving an undefined symbol */
133    SEG_NONE,		/* no expression */
134    SEG_BIG		/* bigger than 32 bits constant */
135} segT;
136
137#define absolute_section	SEG_ABSOLUTE
138
139/* FROM line 285 */
140typedef int subsegT;
141
142/* Type of debugging information we should generate.  We currently support
143   stabs, ECOFF, and DWARF2.
144
145   NOTE!  This means debug information about the assembly source code itself
146   and _not_ about possible debug information from a high-level language.
147   This is especially relevant to DWARF2, since the compiler may emit line
148   number directives that the assembler resolves.  */
149
150enum debug_info_type
151{
152  DEBUG_UNSPECIFIED,
153  DEBUG_NONE,
154  DEBUG_STABS,
155  DEBUG_ECOFF,
156  DEBUG_DWARF,
157  DEBUG_DWARF2
158};
159
160extern enum debug_info_type debug_type;
161
162/*
163 * main program "as.c" (command arguments etc)
164 */
165
166/* ['x'] TRUE if "-x" seen. */
167extern char flagseen[128];
168
169/* name of emitted object file, argument to -o if specified */
170extern char *out_file_name;
171
172typedef struct frag fragS;
173
174/* TRUE if -force_cpusubtype_ALL is specified */
175extern int force_cpusubtype_ALL;
176
177/* set to the corresponding cpusubtype if -arch flag is specified */
178extern cpu_subtype_t archflag_cpusubtype;
179extern char *specific_archflag;
180
181/* TRUE if the .subsections_via_symbols directive was seen */
182extern int subsections_via_symbols;
183
184/* -I path options for .includes */
185struct directory_stack {
186    struct directory_stack *next;
187    char *fname;
188};
189extern struct directory_stack include_defaults[];
190extern struct directory_stack *include;
191
192/* FROM 317 */
193#define undefined_section	SEG_UNKNOWN
194
195#include "expr.h"
196#include "write_object.h"
197
198/* STUFF from write.h */
199/* This is the name of a fake symbol which will never appear in the
200   assembler output.  S_IS_LOCAL detects it because of the \001.  */
201#ifndef FAKE_LABEL_NAME
202#define FAKE_LABEL_NAME "L0\001"
203#endif
204
205#ifdef __GNUC__
206#define as_bad_where(MY_FILE, MY_LINE, ...)	\
207  do {						\
208    layout_file = MY_FILE;			\
209    layout_line = MY_LINE;			\
210    as_bad (__VA_ARGS__);			\
211} while (0)
212#endif
213
214/* FROM 317 */
215#define undefined_section	SEG_UNKNOWN
216
217/* non-NULL if AS_SECURE_LOG_FILE is set */
218extern const char *secure_log_file;
219
220#ifndef OCTETS_PER_BYTE_POWER
221#define OCTETS_PER_BYTE_POWER 0
222#endif
223#ifndef OCTETS_PER_BYTE
224#define OCTETS_PER_BYTE (1<<OCTETS_PER_BYTE_POWER)
225#endif
226#if OCTETS_PER_BYTE != (1<<OCTETS_PER_BYTE_POWER)
227 #error "Octets per byte conflicts with its power-of-two definition!"
228#endif
229
230#endif /* AS_H_ */
231