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

@ -35,8 +35,6 @@
#define NO 0 #define NO 0
#define MAYBE 2 #define MAYBE 2
#define EXTERN extern
#define SUFCHAR '.' /* Start of SUFFIX in file name */ #define SUFCHAR '.' /* Start of SUFFIX in file name */
#define SPACE ' ' #define SPACE ' '
#define TAB '\t' #define TAB '\t'
@ -55,7 +53,8 @@
#define NO_SCAN 0200 /* Bit set in character to defeat recogn. */ #define NO_SCAN 0200 /* Bit set in character to defeat recogn. */
typedef struct { typedef struct
{
char* p_path; /* points to the full pathname */ char* p_path; /* points to the full pathname */
int p_keeps : 1; /* The string should be thrown when unused */ int p_keeps : 1; /* The string should be thrown when unused */
int p_keep : 1; /* The file should be thrown away after use */ int p_keep : 1; /* The file should be thrown away after use */
@ -66,26 +65,26 @@ typedef struct {
/* 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 */

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