Second try at removing common symbols.

This commit is contained in:
David Given 2019-02-10 13:11:03 +01:00
parent 8a7077d5a9
commit c8c48221b3
3 changed files with 133 additions and 95 deletions

View file

@ -12,8 +12,8 @@
/* User settable options */ /* User settable options */
/****************************************************************************/ /****************************************************************************/
#define FRONTENDS "fe" /* The front-end definitions */ #define FRONTENDS "fe" /* The front-end definitions */
#define TMPNAME "Ack_%x" /* Naming of temp. files */ #define TMPNAME "Ack_%x" /* Naming of temp. files */
/****************************************************************************/ /****************************************************************************/
/* Internal mnemonics, should not be tinkered with */ /* Internal mnemonics, should not be tinkered with */
@ -21,77 +21,76 @@
/* The names of some string variables */ /* The names of some string variables */
#define HOME "EM" #define HOME "EM"
#define RTS "RTS" #define RTS "RTS"
#define HEAD "HEAD" #define HEAD "HEAD"
#define TAIL "TAIL" #define TAIL "TAIL"
#define SRC "SOURCE" #define SRC "SOURCE"
#define LIBVAR "LNAME" #define LIBVAR "LNAME"
#define SUFFIX "SUFFIX" #define SUFFIX "SUFFIX"
/* Intended for flags, possibly in bit fields */ /* Intended for flags, possibly in bit fields */
#define YES 1 #define YES 1
#define NO 0 #define NO 0
#define MAYBE 2 #define MAYBE 2
#define EXTERN extern #define SUFCHAR '.' /* Start of SUFFIX in file name */
#define SPACE ' '
#define TAB '\t'
#define EQUAL '='
#define S_VAR '{' /* Start of variable */
#define C_VAR '}' /* End of variable */
#define A_VAR '?' /* Variable alternative */
#define BSLASH '\\' /* Backslash */
#define STAR '*' /* STAR */
#define C_IN '<' /* Token specifying input */
#define C_OUT '>' /* Token specifying output */
#define S_EXPR '(' /* Start of expression */
#define C_EXPR ')' /* End of expression */
#define M_EXPR ':' /* Middle of two suffix lists */
#define T_EXPR '=' /* Start of tail */
#define SUFCHAR '.' /* Start of SUFFIX in file name */ #define NO_SCAN 0200 /* Bit set in character to defeat recogn. */
#define SPACE ' '
#define TAB '\t'
#define EQUAL '='
#define S_VAR '{' /* Start of variable */
#define C_VAR '}' /* End of variable */
#define A_VAR '?' /* Variable alternative */
#define BSLASH '\\' /* Backslash */
#define STAR '*' /* STAR */
#define C_IN '<' /* Token specifying input */
#define C_OUT '>' /* Token specifying output */
#define S_EXPR '(' /* Start of expression */
#define C_EXPR ')' /* End of expression */
#define M_EXPR ':' /* Middle of two suffix lists */
#define T_EXPR '=' /* Start of tail */
#define NO_SCAN 0200 /* Bit set in character to defeat recogn. */ typedef struct
{
char* p_path; /* points to the full pathname */
int p_keeps : 1; /* The string should be thrown when unused */
int p_keep : 1; /* The file should be thrown away after use */
} path;
typedef struct { #define p_cont(elem) ((path*)l_content(elem))
char *p_path; /* points to the full pathname */
int p_keeps:1; /* The string should be thrown when unused */
int p_keep:1; /* The file should be thrown away after use */
} path ;
#define p_cont(elem) ((path *)l_content(elem))
/* Own routines */ /* Own routines */
/* rmach.c */ /* rmach.c */
void setlist(char *); extern void setlist(char*);
/* svars.c */ /* svars.c */
void setsvar(char *, char *); extern void setsvar(char*, char*);
void setpvar(char *, char *(*)(void)); extern void setpvar(char*, char* (*)(void));
char *getvar(const char *); extern char* getvar(const char*);
/* util.c */ /* util.c */
char *ack_basename(const char *); extern char* ack_basename(const char*);
char *skipblank(char *); extern char* skipblank(char*);
char *firstblank(char *); extern char* firstblank(char*);
void fatal(const char *, ...); extern void fatal(const char*, ...);
void vprint(const char *, ...); extern void vprint(const char*, ...);
void fuerror(const char *, ...); extern void fuerror(const char*, ...);
void werror(const char *, ...); extern void werror(const char*, ...);
void quit(int); extern void quit(int);
char *keeps(const char *); extern char* keeps(const char*);
#define throws(str) free(str) #define throws(str) free(str)
void *getcore(size_t); extern void* getcore(size_t);
void *changecore(void *, size_t); extern void* changecore(void*, size_t);
#define freecore(area) free(area) #define freecore(area) free(area)
#define DEBUG 1 /* Allow debugging of Ack */ #define DEBUG 1 /* Allow debugging of Ack */
#ifndef DEBUG #ifndef DEBUG
# define debug 0 /* To surprise all these 'if ( debug ) 's */ #define debug 0 /* To surprise all these 'if ( debug ) 's */
#else #else
extern int debug ; extern int debug;
#endif #endif

View file

@ -5,12 +5,48 @@
#include "ack.h" #include "ack.h"
#include "list.h" #include "list.h"
#include "trans.h" #include "trans.h"
/* Include once without redefining EXTERN, to declare all the symbols as extern. */
#include "data.h" #include "data.h"
/* And again without EXTERN, to define them here. Without the extern versions above char* stopsuffix = NULL; /* Suffix to stop at */
* then these symbols will all end up as COMMON, which is poorly supported on OSX. */ char* machine = NULL; /* The machine id */
#undef EXTERN char* callname = NULL; /* argv[0] */
#define EXTERN char* rts = NULL; /* The runtime-system */
#include "data.h" char* rtsuf = NULL; /* The runtime-system module suffix */
char* Optlist = NULL; /* Which optimizers */
list_head arguments = {}; /* List of arguments */
list_head flags = {}; /* List of flags */
list_head tr_list = {}; /* List of transformations */
list_head R_list = {}; /* List of -R flags */
list_head head_list = {}; /* List of suffices for headers */
list_head tail_list = {}; /* List of suffices for tails */
int k_flag = 0; /* Like -k of lint */
int t_flag = 0; /* Preserve intermediate files */
int v_flag = 0; /* Verbose */
int w_flag = 0; /* Don't print warnings */
int nill_flag = 0; /* Don't print file names */
int Optlevel = 0; /* Optimizing */
#ifdef DEBUG
int debug = 0; /* Debugging control */
#endif
int n_error = 0; /* Number of errors encountered */
char* progname = NULL; /* The program call name */
char* outfile = NULL; /* The result file e.g. a.out */
char template[20] = {}; /* The template for temporary file
names */
trf* linker = NULL; /* Pointer to the Loader/Linker */
trf* cpp_trafo = NULL; /* Pointer to C-preprocessor */
path in = {}; /* The current single input pathname */
path out = {}; /* The current output pathname */
path orig = {}; /* The original input path */
char* p_basename = NULL; /* The current basename */
const char* p_suffix = NULL; /* The current input suffix */

View file

@ -3,48 +3,51 @@
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
*/ */
/* WARNING: don't put guards around this file (there are reasons). See data.c. */ #ifndef DATA_H
#define DATA_H
EXTERN char *stopsuffix; /* Suffix to stop at */ extern char* stopsuffix; /* Suffix to stop at */
EXTERN char *machine; /* The machine id */ extern char* machine; /* The machine id */
EXTERN char *callname; /* argv[0] */ extern char* callname; /* argv[0] */
EXTERN char *rts; /* The runtime-system */ extern char* rts; /* The runtime-system */
EXTERN char *rtsuf; /* The runtime-system module suffix */ extern char* rtsuf; /* The runtime-system module suffix */
EXTERN char *Optlist; /* Which optimizers */ extern char* Optlist; /* Which optimizers */
EXTERN list_head arguments; /* List of arguments */ extern list_head arguments; /* List of arguments */
EXTERN list_head flags; /* List of flags */ extern list_head flags; /* List of flags */
EXTERN list_head tr_list; /* List of transformations */ extern list_head tr_list; /* List of transformations */
EXTERN list_head R_list; /* List of -R flags */ extern list_head R_list; /* List of -R flags */
EXTERN list_head head_list; /* List of suffices for headers */ extern list_head head_list; /* List of suffices for headers */
EXTERN list_head tail_list; /* List of suffices for tails */ extern list_head tail_list; /* List of suffices for tails */
EXTERN int k_flag; /* Like -k of lint */ extern int k_flag; /* Like -k of lint */
EXTERN int t_flag; /* Preserve intermediate files */ extern int t_flag; /* Preserve intermediate files */
EXTERN int v_flag; /* Verbose */ extern int v_flag; /* Verbose */
EXTERN int w_flag; /* Don't print warnings */ extern int w_flag; /* Don't print warnings */
EXTERN int nill_flag; /* Don't print file names */ extern int nill_flag; /* Don't print file names */
EXTERN int Optlevel; /* Optimizing */ extern int Optlevel; /* Optimizing */
#ifdef DEBUG #ifdef DEBUG
EXTERN int debug; /* Debugging control */ extern int debug; /* Debugging control */
#endif #endif
EXTERN int n_error; /* Number of errors encountered */ extern int n_error; /* Number of errors encountered */
EXTERN char *progname; /* The program call name */ extern char* progname; /* The program call name */
EXTERN char *outfile; /* The result file e.g. a.out */ extern char* outfile; /* The result file e.g. a.out */
EXTERN char template[20]; /* The template for temporary file extern char template[20]; /* The template for temporary file
names */ names */
EXTERN trf *linker; /* Pointer to the Loader/Linker */ extern trf* linker; /* Pointer to the Loader/Linker */
EXTERN trf *cpp_trafo; /* Pointer to C-preprocessor */ extern trf* cpp_trafo; /* Pointer to C-preprocessor */
EXTERN path in; /* The current single input pathname */ extern path in; /* The current single input pathname */
EXTERN path out; /* The current output pathname */ extern path out; /* The current output pathname */
EXTERN path orig; /* The original input path */ extern path orig; /* The original input path */
EXTERN char *p_basename; /* The current basename */ extern char* p_basename; /* The current basename */
EXTERN const char *p_suffix; /* The current input suffix */ extern const char* p_suffix; /* The current input suffix */
#endif