aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Cross <cross@gajendra.net>2025-07-23 06:47:21 -0400
committerDan Cross <cross@gajendra.net>2025-07-25 12:25:11 -0400
commit156e745be9f6a1b19b0f8e2a931148786d7acad4 (patch)
treec853bc58f9d7e88d84de2da625bc4dddcdf46780
parent1e6e30e91e7a2712d9507072b5ff3b59a73e5dfe (diff)
all: remove need for `-fcommon`
Use `extern` where appropriate so that we can remove `-fcommon` on macOS and others. On macOS, `-fcommon` generates a number of linker warnings. I've tested building on macOS, Linux, FreeBSD, NetBSD, OpenBSD and illumos. I am not in a position to test on AIX or other more esoteric platforms, however.
-rwxr-xr-xbin/9c4
-rw-r--r--src/cmd/9660/dump9660.c2
-rw-r--r--src/cmd/9pfuse/main.c1
-rw-r--r--src/cmd/9term/dat.h16
-rw-r--r--src/cmd/acid/acid.h14
-rw-r--r--src/cmd/acme/dat.c62
-rw-r--r--src/cmd/acme/dat.h122
-rw-r--r--src/cmd/acme/ecmd.c2
-rw-r--r--src/cmd/acme/mail/mail.c2
-rw-r--r--src/cmd/acme/mkfile1
-rw-r--r--src/cmd/astro/astro.h98
-rw-r--r--src/cmd/astro/main.c48
-rw-r--r--src/cmd/db/setup.c10
-rw-r--r--src/cmd/diff/diff.h10
-rw-r--r--src/cmd/diff/main.c6
-rw-r--r--src/cmd/fontsrv/a.h4
-rw-r--r--src/cmd/fontsrv/main.c3
-rw-r--r--src/cmd/fossil/9fsys.c2
-rw-r--r--src/cmd/hoc/code.c2
-rw-r--r--src/cmd/htmlroff/a.h6
-rw-r--r--src/cmd/htmlroff/roff.c1
-rw-r--r--src/cmd/htmlroff/t16.c5
-rw-r--r--src/cmd/ndb/dns.c3
-rw-r--r--src/cmd/ndb/dnstcp.c3
-rw-r--r--src/cmd/plumb/plumber.c3
-rw-r--r--src/cmd/plumb/plumber.h16
-rw-r--r--src/cmd/rc/exec.c18
-rw-r--r--src/cmd/rc/exec.h10
-rw-r--r--src/cmd/rc/io.h2
-rw-r--r--src/cmd/rc/rc.h24
-rw-r--r--src/cmd/rio/winwatch.c2
-rw-r--r--src/cmd/sam/sam.c2
-rw-r--r--src/cmd/scat/dssread.c1
-rw-r--r--src/cmd/scat/scat.c5
-rw-r--r--src/cmd/scat/sky.h18
-rw-r--r--src/cmd/tcs/tcs.c1
-rw-r--r--src/cmd/venti/srv/part.c1
-rw-r--r--src/lib9/argv0.c1
-rw-r--r--src/libthread/thread.c1
39 files changed, 339 insertions, 193 deletions
diff --git a/bin/9c b/bin/9c
index 195fec81..656ba84d 100755
--- a/bin/9c
+++ b/bin/9c
@@ -23,7 +23,7 @@ usegcc()
-Wno-deprecated-declarations \
-fno-omit-frame-pointer \
-fsigned-char \
- -fcommon \
+ -fno-common \
-std=gnu11 \
"
# want to put -fno-optimize-sibling-calls here but
@@ -85,7 +85,7 @@ useclang()
-Wno-unused-but-set-variable \
-fsigned-char \
-fno-caret-diagnostics \
- -fcommon \
+ -fno-common \
"
cflags="$cflags -g"
cflags="$cflags $CC9FLAGS"
diff --git a/src/cmd/9660/dump9660.c b/src/cmd/9660/dump9660.c
index 59ee31c0..228d56c6 100644
--- a/src/cmd/9660/dump9660.c
+++ b/src/cmd/9660/dump9660.c
@@ -15,8 +15,6 @@ Conform *map;
static void addprotofile(char *new, char *old, Dir *d, void *a);
void usage(void);
-char *argv0;
-
void
usage(void)
{
diff --git a/src/cmd/9pfuse/main.c b/src/cmd/9pfuse/main.c
index 4fa330a0..ca9f3872 100644
--- a/src/cmd/9pfuse/main.c
+++ b/src/cmd/9pfuse/main.c
@@ -60,7 +60,6 @@
#endif
int debug;
-char *argv0;
char *aname = "";
void fusedispatch(void*);
Channel *fusechan;
diff --git a/src/cmd/9term/dat.h b/src/cmd/9term/dat.h
index a215253f..1e22a424 100644
--- a/src/cmd/9term/dat.h
+++ b/src/cmd/9term/dat.h
@@ -209,19 +209,19 @@ struct Timer
#define Extern extern
#endif
-Extern Font *font;
+extern Font *font;
Extern Mousectl *mousectl;
Extern Mouse *mouse;
Extern Keyboardctl *keyboardctl;
-Extern Display *display;
+extern Display *display;
Extern Image *view;
Extern Screen *wscreen;
-Extern Cursor boxcursor;
-Extern Cursor crosscursor;
-Extern Cursor sightcursor;
-Extern Cursor whitearrow;
-Extern Cursor query;
-Extern Cursor *corners[9];
+extern Cursor boxcursor;
+extern Cursor crosscursor;
+extern Cursor sightcursor;
+extern Cursor whitearrow;
+extern Cursor query;
+extern Cursor *corners[9];
Extern Image *background;
Extern Image *lightgrey;
Extern Image *red;
diff --git a/src/cmd/acid/acid.h b/src/cmd/acid/acid.h
index 5b1339fe..da7e314d 100644
--- a/src/cmd/acid/acid.h
+++ b/src/cmd/acid/acid.h
@@ -47,14 +47,14 @@ Extern Node* code;
Extern int na;
Extern int wtflag;
Extern Regs* acidregs;
-Extern Regs* correg;
-Extern Map* cormap;
-Extern Map* symmap;
+extern Regs* correg;
+extern Map* cormap;
+extern Map* symmap;
Extern Lsym* hash[Hashsize];
Extern long dogc;
Extern Rplace* ret;
-Extern char* symfil;
-Extern char* corfil;
+extern char* symfil;
+extern char* corfil;
Extern int gotint;
Extern long flen;
Extern Gc* gcl;
@@ -66,8 +66,8 @@ Extern Node* fomt;
Extern List* tracelist;
Extern int initialising;
Extern int quiet;
-Extern Fhdr* corhdr;
-Extern Fhdr* symhdr;
+extern Fhdr* corhdr;
+extern Fhdr* symhdr;
extern void (*expop[])(Node*, Node*);
#define expr(n, r) (r)->store.comt=0; (*expop[(unsigned char)((n)->op)])(n, r);
diff --git a/src/cmd/acme/dat.c b/src/cmd/acme/dat.c
new file mode 100644
index 00000000..537f7d75
--- /dev/null
+++ b/src/cmd/acme/dat.c
@@ -0,0 +1,62 @@
+#include <u.h>
+#include <libc.h>
+#include <draw.h>
+#include <thread.h>
+#include <cursor.h>
+#include <mouse.h>
+#include <keyboard.h>
+#include <frame.h>
+#include <fcall.h>
+#include <plumb.h>
+#include <libsec.h>
+#include "dat.h"
+
+uint globalincref;
+uint seq;
+uint maxtab; /* size of a tab, in units of the '0' character */
+
+Mouse *mouse;
+Mousectl *mousectl;
+Keyboardctl *keyboardctl;
+Reffont reffont;
+Image *modbutton;
+Image *colbutton;
+Image *button;
+Image *but2col;
+Image *but3col;
+Row row;
+int timerpid;
+Disk *disk;
+Text *seltext;
+Text *argtext;
+Text *mousetext; /* global because Text.close needs to clear it */
+Text *typetext; /* global because Text.close needs to clear it */
+Text *barttext; /* shared between mousetask and keyboardthread */
+int bartflag;
+Window *activewin;
+Column *activecol;
+Rectangle nullrect;
+int fsyspid;
+char *cputype;
+char *objtype;
+char *acmeshell;
+//char *fontnames[2];
+extern char wdir[]; /* must use extern because no dimension given */
+int globalautoindent;
+int dodollarsigns;
+
+Channel *cplumb; /* chan(Plumbmsg*) */
+Channel *cwait; /* chan(Waitmsg) */
+Channel *ccommand; /* chan(Command*) */
+Channel *ckill; /* chan(Rune*) */
+Channel *cxfidalloc; /* chan(Xfid*) */
+Channel *cxfidfree; /* chan(Xfid*) */
+Channel *cnewwindow; /* chan(Channel*) */
+Channel *mouseexit0; /* chan(int) */
+Channel *mouseexit1; /* chan(int) */
+Channel *cexit; /* chan(int) */
+Channel *cerr; /* chan(char*) */
+Channel *cedit; /* chan(int) */
+Channel *cwarn; /* chan(void*)[1] (really chan(unit)[1]) */
+
+QLock editoutlk;
diff --git a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h
index 03150aa6..8f11d6a3 100644
--- a/src/cmd/acme/dat.h
+++ b/src/cmd/acme/dat.h
@@ -509,53 +509,53 @@ enum /* editing */
Collecting
};
-uint globalincref;
-uint seq;
-uint maxtab; /* size of a tab, in units of the '0' character */
-
-Display *display;
-Image *screen;
-Font *font;
-Mouse *mouse;
-Mousectl *mousectl;
-Keyboardctl *keyboardctl;
-Reffont reffont;
-Image *modbutton;
-Image *colbutton;
-Image *button;
-Image *but2col;
-Image *but3col;
-Cursor boxcursor;
-Cursor2 boxcursor2;
-Row row;
-int timerpid;
-Disk *disk;
-Text *seltext;
-Text *argtext;
-Text *mousetext; /* global because Text.close needs to clear it */
-Text *typetext; /* global because Text.close needs to clear it */
-Text *barttext; /* shared between mousetask and keyboardthread */
-int bartflag;
-int swapscrollbuttons;
-Window *activewin;
-Column *activecol;
-Buffer snarfbuf;
-Rectangle nullrect;
-int fsyspid;
-char *cputype;
-char *objtype;
-char *home;
-char *acmeshell;
-char *fontnames[2];
-Image *tagcols[NCOL];
-Image *textcols[NCOL];
+extern uint globalincref;
+extern uint seq;
+extern uint maxtab; /* size of a tab, in units of the '0' character */
+
+extern Display *display;
+extern Image *screen;
+extern Font *font;
+extern Mouse *mouse;
+extern Mousectl *mousectl;
+extern Keyboardctl *keyboardctl;
+extern Reffont reffont;
+extern Image *modbutton;
+extern Image *colbutton;
+extern Image *button;
+extern Image *but2col;
+extern Image *but3col;
+extern Cursor boxcursor;
+extern Cursor2 boxcursor2;
+extern Row row;
+extern int timerpid;
+extern Disk *disk;
+extern Text *seltext;
+extern Text *argtext;
+extern Text *mousetext; /* global because Text.close needs to clear it */
+extern Text *typetext; /* global because Text.close needs to clear it */
+extern Text *barttext; /* shared between mousetask and keyboardthread */
+extern int bartflag;
+extern int swapscrollbuttons;
+extern Window *activewin;
+extern Column *activecol;
+extern Buffer snarfbuf;
+extern Rectangle nullrect;
+extern int fsyspid;
+extern char *cputype;
+extern char *objtype;
+extern char *home;
+extern char *acmeshell;
+extern char *fontnames[2];
+extern Image *tagcols[NCOL];
+extern Image *textcols[NCOL];
extern char wdir[]; /* must use extern because no dimension given */
-int editing;
-int erroutfd;
-int messagesize; /* negotiated in 9P version setup */
-int globalautoindent;
-int dodollarsigns;
-char* mtpt;
+extern int editing;
+extern int erroutfd;
+extern int messagesize; /* negotiated in 9P version setup */
+extern int globalautoindent;
+extern int dodollarsigns;
+extern char* mtpt;
enum
{
@@ -563,20 +563,20 @@ enum
Kscrollonedown = KF|0x21
};
-Channel *cplumb; /* chan(Plumbmsg*) */
-Channel *cwait; /* chan(Waitmsg) */
-Channel *ccommand; /* chan(Command*) */
-Channel *ckill; /* chan(Rune*) */
-Channel *cxfidalloc; /* chan(Xfid*) */
-Channel *cxfidfree; /* chan(Xfid*) */
-Channel *cnewwindow; /* chan(Channel*) */
-Channel *mouseexit0; /* chan(int) */
-Channel *mouseexit1; /* chan(int) */
-Channel *cexit; /* chan(int) */
-Channel *cerr; /* chan(char*) */
-Channel *cedit; /* chan(int) */
-Channel *cwarn; /* chan(void*)[1] (really chan(unit)[1]) */
-
-QLock editoutlk;
+extern Channel *cplumb; /* chan(Plumbmsg*) */
+extern Channel *cwait; /* chan(Waitmsg) */
+extern Channel *ccommand; /* chan(Command*) */
+extern Channel *ckill; /* chan(Rune*) */
+extern Channel *cxfidalloc; /* chan(Xfid*) */
+extern Channel *cxfidfree; /* chan(Xfid*) */
+extern Channel *cnewwindow; /* chan(Channel*) */
+extern Channel *mouseexit0; /* chan(int) */
+extern Channel *mouseexit1; /* chan(int) */
+extern Channel *cexit; /* chan(int) */
+extern Channel *cerr; /* chan(char*) */
+extern Channel *cedit; /* chan(int) */
+extern Channel *cwarn; /* chan(void*)[1] (really chan(unit)[1]) */
+
+extern QLock editoutlk;
#define STACK 65536
diff --git a/src/cmd/acme/ecmd.c b/src/cmd/acme/ecmd.c
index f7613172..42f79960 100644
--- a/src/cmd/acme/ecmd.c
+++ b/src/cmd/acme/ecmd.c
@@ -19,7 +19,7 @@ char Enoname[] = "no file name given";
Address addr;
File *menu;
-Rangeset sel;
+extern Rangeset sel;
extern Text* curtext;
Rune *collection;
int ncollection;
diff --git a/src/cmd/acme/mail/mail.c b/src/cmd/acme/mail/mail.c
index e1047bb8..6d051821 100644
--- a/src/cmd/acme/mail/mail.c
+++ b/src/cmd/acme/mail/mail.c
@@ -18,7 +18,7 @@ char *srvname;
Window *wbox;
Message mbox;
Message replies;
-char *home;
+extern char *home;
CFid *plumbsendfd;
CFid *plumbseemailfd;
CFid *plumbshowmailfd;
diff --git a/src/cmd/acme/mkfile b/src/cmd/acme/mkfile
index 18bea9e0..ba5877c2 100644
--- a/src/cmd/acme/mkfile
+++ b/src/cmd/acme/mkfile
@@ -25,6 +25,7 @@ OFILES=\
util.$O\
wind.$O\
xfid.$O\
+ dat.$O\
HFILES=dat.h\
edit.h\
diff --git a/src/cmd/astro/astro.h b/src/cmd/astro/astro.h
index 4648e34e..248dbd88 100644
--- a/src/cmd/astro/astro.h
+++ b/src/cmd/astro/astro.h
@@ -85,55 +85,55 @@ struct Tim
char tz[4];
};
-double converge;
-
-char flags[128];
-int nperiods;
-double wlong, awlong, nlat, elev;
-double obliq, phi, eps, tobliq;
-double dphi, deps;
-double day, deld, per;
-double eday, capt, capt2, capt3, gst;
-double pi, pipi, radian, radsec, deltat;
-double erad, glat;
-double xms, yms, zms;
-double xdot, ydot, zdot;
-
-double ecc, incl, node, argp, mrad, anom, motion;
-
-double lambda, beta, rad, mag, semi;
-double alpha, delta, rp, hp;
-double ra, decl, semi2;
-double lha, decl2, lmb2;
-double az, el;
-
-double meday, seday, mhp, salph, sdelt, srad;
-
-double* cafp;
-char* cacp;
-
-double rah, ram, ras, dday, dmin, dsec;
-long sao;
-double da, dd, px, epoch;
-char line[100];
-Obj2 osun;
-Obj2 omoon;
-Obj2 oshad;
-Obj2 omerc;
-Obj2 ovenus;
-Obj2 omars;
-Obj2 osat;
-Obj2 ouran;
-Obj2 onept;
-Obj2 oplut;
-Obj2 ojup;
-Obj2 ostar;
-Obj2 ocomet;
-Obj3 occ;
-Obj2* eobj1;
-Obj2* eobj2;
-
-char* startab;
+extern double converge;
+
+extern char flags[128];
+extern int nperiods;
+extern double wlong, awlong, nlat, elev;
+extern double obliq, phi, eps, tobliq;
+extern double dphi, deps;
+extern double day, deld, per;
+extern double eday, capt, capt2, capt3, gst;
+extern double pi, pipi, radian, radsec, deltat;
+extern double erad, glat;
+extern double xms, yms, zms;
+extern double xdot, ydot, zdot;
+
+extern double ecc, incl, node, argp, mrad, anom, motion;
+
+extern double lambda, beta, rad, mag, semi;
+extern double alpha, delta, rp, hp;
+extern double ra, decl, semi2;
+extern double lha, decl2, lmb2;
+extern double az, el;
+
+extern double meday, seday, mhp, salph, sdelt, srad;
+
+extern double* cafp;
+extern char* cacp;
+
+extern double rah, ram, ras, dday, dmin, dsec;
+extern long sao;
+extern double da, dd, px, epoch;
+extern char line[100];
+extern Obj2 osun;
+extern Obj2 omoon;
+extern Obj2 oshad;
+extern Obj2 omerc;
+extern Obj2 ovenus;
+extern Obj2 omars;
+extern Obj2 osat;
+extern Obj2 ouran;
+extern Obj2 onept;
+extern Obj2 oplut;
+extern Obj2 ojup;
+extern Obj2 ostar;
+extern Obj2 ocomet;
+extern Obj3 occ;
+extern Obj2* eobj1;
+extern Obj2* eobj2;
+
+extern char* startab;
extern int dmo[];
extern Obj2* objlst[];
diff --git a/src/cmd/astro/main.c b/src/cmd/astro/main.c
index 43ce4cc4..c9fbf2a5 100644
--- a/src/cmd/astro/main.c
+++ b/src/cmd/astro/main.c
@@ -1,5 +1,53 @@
#include "astro.h"
+double converge;
+
+char flags[128];
+int nperiods;
+double wlong, awlong, nlat, elev;
+double obliq, phi, eps, tobliq;
+double dphi, deps;
+double day, deld, per;
+double eday, capt, capt2, capt3, gst;
+double pi, pipi, radian, radsec, deltat;
+double erad, glat;
+double xms, yms, zms;
+double xdot, ydot, zdot;
+
+double ecc, incl, node, argp, mrad, anom, motion;
+
+double lambda, beta, rad, mag, semi;
+double alpha, delta, rp, hp;
+double ra, decl, semi2;
+double lha, decl2, lmb2;
+double az, el;
+
+double meday, seday, mhp, salph, sdelt, srad;
+
+double* cafp;
+char* cacp;
+
+double rah, ram, ras, dday, dmin, dsec;
+long sao;
+double da, dd, px, epoch;
+char line[100];
+Obj2 osun;
+Obj2 omoon;
+Obj2 oshad;
+Obj2 omerc;
+Obj2 ovenus;
+Obj2 omars;
+Obj2 osat;
+Obj2 ouran;
+Obj2 onept;
+Obj2 oplut;
+Obj2 ojup;
+Obj2 ostar;
+Obj2 ocomet;
+Obj3 occ;
+Obj2* eobj1;
+Obj2* eobj2;
+
char* herefile;
int
diff --git a/src/cmd/db/setup.c b/src/cmd/db/setup.c
index 15a196e1..892e2c9f 100644
--- a/src/cmd/db/setup.c
+++ b/src/cmd/db/setup.c
@@ -4,12 +4,12 @@
#include "defs.h"
#include "fns.h"
-char *symfil;
-char *corfil;
+extern char *symfil;
+extern char *corfil;
-Map *symmap;
-Map *cormap;
-Regs *correg;
+extern Map *symmap;
+extern Map *cormap;
+extern Regs *correg;
Map *dotmap;
void
diff --git a/src/cmd/diff/diff.h b/src/cmd/diff/diff.h
index 25e39c6c..94c7bf0d 100644
--- a/src/cmd/diff/diff.h
+++ b/src/cmd/diff/diff.h
@@ -1,10 +1,10 @@
#define stdout bstdout
-char mode; /* '\0', 'e', 'f', 'h' */
-char bflag; /* ignore multiple and trailing blanks */
-char rflag; /* recurse down directory trees */
-char mflag; /* pseudo flag: doing multiple files, one dir */
-int anychange;
+extern char mode; /* '\0', 'e', 'f', 'h' */
+extern char bflag; /* ignore multiple and trailing blanks */
+extern char rflag; /* recurse down directory trees */
+extern char mflag; /* pseudo flag: doing multiple files, one dir */
+extern int anychange;
extern Biobuf stdout;
extern int binary;
diff --git a/src/cmd/diff/main.c b/src/cmd/diff/main.c
index 2697cb88..fe1161aa 100644
--- a/src/cmd/diff/main.c
+++ b/src/cmd/diff/main.c
@@ -8,6 +8,12 @@
Biobuf stdout;
+char mode; /* '\0', 'e', 'f', 'h' */
+char bflag; /* ignore multiple and trailing blanks */
+char rflag; /* recurse down directory trees */
+char mflag; /* pseudo flag: doing multiple files, one dir */
+int anychange;
+
static char *tmp[] = {"/tmp/diff1XXXXXXXXXXX", "/tmp/diff2XXXXXXXXXXX"};
static int whichtmp;
static char *progname;
diff --git a/src/cmd/fontsrv/a.h b/src/cmd/fontsrv/a.h
index 2eeb404f..5dc82f35 100644
--- a/src/cmd/fontsrv/a.h
+++ b/src/cmd/fontsrv/a.h
@@ -1,6 +1,6 @@
typedef struct XFont XFont;
-XFont *xfont;
-int nxfont;
+extern XFont *xfont;
+extern int nxfont;
enum {
SubfontSize = 32,
diff --git a/src/cmd/fontsrv/main.c b/src/cmd/fontsrv/main.c
index fd629801..e6f7b9c5 100644
--- a/src/cmd/fontsrv/main.c
+++ b/src/cmd/fontsrv/main.c
@@ -13,6 +13,9 @@
#include "a.h"
+XFont *xfont;
+int nxfont;
+
void
usage(void)
{
diff --git a/src/cmd/fossil/9fsys.c b/src/cmd/fossil/9fsys.c
index 121e5b66..293f675f 100644
--- a/src/cmd/fossil/9fsys.c
+++ b/src/cmd/fossil/9fsys.c
@@ -22,7 +22,7 @@ struct Fsys {
Fsys* next;
};
-int mempcnt; /* from fossil.c */
+extern int mempcnt; /* from fossil.c */
int fsGetBlockSize(Fs *fs);
diff --git a/src/cmd/hoc/code.c b/src/cmd/hoc/code.c
index af60c194..0de502a3 100644
--- a/src/cmd/hoc/code.c
+++ b/src/cmd/hoc/code.c
@@ -15,7 +15,7 @@ Inst *progp; /* next free spot for code generation */
Inst *pc; /* program counter during execution */
Inst *progbase = prog; /* start of current subprogram */
int returning; /* 1 if return stmt seen */
-int indef; /* 1 if parsing a func or proc */
+extern int indef; /* 1 if parsing a func or proc */
typedef struct Frame { /* proc/func call stack frame */
Symbol *sp; /* symbol table entry */
diff --git a/src/cmd/htmlroff/a.h b/src/cmd/htmlroff/a.h
index a4209178..1df612c2 100644
--- a/src/cmd/htmlroff/a.h
+++ b/src/cmd/htmlroff/a.h
@@ -30,7 +30,9 @@ enum
ArgMode = 1<<3,
HtmlMode = 1<<4,
- MaxLine = 1024
+ MaxLine = 1024,
+
+ MAXIF = 20
};
Rune* L(char*);
@@ -77,7 +79,7 @@ int linefmt(Fmt*);
void nr(Rune*, int);
void _nr(Rune*, Rune*);
void out(Rune*);
-void (*outcb)(Rune);
+extern void (*outcb)(Rune);
void outhtml(Rune*);
void outrune(Rune);
void outtrap(void);
diff --git a/src/cmd/htmlroff/roff.c b/src/cmd/htmlroff/roff.c
index f52e0734..4ac4f980 100644
--- a/src/cmd/htmlroff/roff.c
+++ b/src/cmd/htmlroff/roff.c
@@ -6,7 +6,6 @@ enum
MAXRAW = 40,
MAXESC = 60,
MAXLINE = 1024,
- MAXIF = 20,
MAXARG = 10
};
diff --git a/src/cmd/htmlroff/t16.c b/src/cmd/htmlroff/t16.c
index 9389a59a..8da1d1ff 100644
--- a/src/cmd/htmlroff/t16.c
+++ b/src/cmd/htmlroff/t16.c
@@ -16,9 +16,8 @@
* .if .ie .el
*
*/
-
-int iftrue[20];
-int niftrue;
+extern int iftrue[MAXIF];
+extern int niftrue;
void
startbody(void)
diff --git a/src/cmd/ndb/dns.c b/src/cmd/ndb/dns.c
index 723989b9..f05d4c22 100644
--- a/src/cmd/ndb/dns.c
+++ b/src/cmd/ndb/dns.c
@@ -101,7 +101,8 @@ char *udpaddr = "udp!*!domain";
char *logfile = "dns";
char *dbfile;
char mntpt[Maxpath];
-char *LOG;
+
+extern char *LOG;
void
usage(void)
diff --git a/src/cmd/ndb/dnstcp.c b/src/cmd/ndb/dnstcp.c
index 3d4d1e90..18224d49 100644
--- a/src/cmd/ndb/dnstcp.c
+++ b/src/cmd/ndb/dnstcp.c
@@ -23,11 +23,12 @@ char mntpt[Maxpath];
ulong now;
int maxage;
uchar ipaddr[IPaddrlen]; /* my ip address */
-char *LOG;
char *zonerefreshprogram;
char *tcpaddr;
char *udpaddr;
+extern char *LOG;
+
void
usage(void)
{
diff --git a/src/cmd/plumb/plumber.c b/src/cmd/plumb/plumber.c
index 5ead2e93..86bec15c 100644
--- a/src/cmd/plumb/plumber.c
+++ b/src/cmd/plumb/plumber.c
@@ -7,10 +7,11 @@
#include "plumber.h"
int debug;
+int nports;
+char **ports;
int foreground=0;
char *plumbfile;
char *user;
-char *home;
char *progname;
Ruleset **rules;
int printerrors=1;
diff --git a/src/cmd/plumb/plumber.h b/src/cmd/plumb/plumber.h
index 9ffe74d2..4eb7f131 100644
--- a/src/cmd/plumb/plumber.h
+++ b/src/cmd/plumb/plumber.h
@@ -89,11 +89,11 @@ void makeports(Ruleset*[]);
void printinputstack(void);
int popinput(void);
-Ruleset **rules;
-char *user;
-char *home;
-jmp_buf parsejmp;
-char *lasterror;
-char **ports;
-int nports;
-int debug;
+extern Ruleset **rules;
+extern char *user;
+extern char *home;
+extern jmp_buf parsejmp;
+extern char *lasterror;
+extern char **ports;
+extern int nports;
+extern int debug;
diff --git a/src/cmd/rc/exec.c b/src/cmd/rc/exec.c
index 0320976a..94d3321a 100644
--- a/src/cmd/rc/exec.c
+++ b/src/cmd/rc/exec.c
@@ -8,6 +8,24 @@
*/
char *argv0="rc";
+thread *runq;
+code *codebuf; /* compiler output */
+int ntrap; /* number of outstanding traps */
+int trap[NSIG]; /* number of outstanding traps per type */
+int eflagok; /* kludge flag so that -e doesn't exit in startup */
+tree *cmdtree;
+char *promptstr;
+char tok[NTOK];
+var *gvar[NVAR]; /* hash for globals */
+int mypid;
+char **argp;
+char **args;
+int nerror; /* number of errors encountered during compilation */
+int ndot;
+int lastc;
+int kidpid;
+io *err;
+
void
start(code *c, int pc, var *local)
{
diff --git a/src/cmd/rc/exec.h b/src/cmd/rc/exec.h
index 06cfd64e..f9a9dfb0 100644
--- a/src/cmd/rc/exec.h
+++ b/src/cmd/rc/exec.h
@@ -56,17 +56,17 @@ struct thread{
tree *treenodes; /* tree nodes created by this process */
thread *ret; /* who continues when this finishes */
};
-thread *runq;
+extern thread *runq;
code *codecopy(code*);
-code *codebuf; /* compiler output */
-int ntrap; /* number of outstanding traps */
-int trap[NSIG]; /* number of outstanding traps per type */
+extern code *codebuf; /* compiler output */
+extern int ntrap; /* number of outstanding traps */
+extern int trap[NSIG]; /* number of outstanding traps per type */
struct builtin{
char *name;
void (*fnc)(void);
};
extern struct builtin Builtin[];
-int eflagok; /* kludge flag so that -e doesn't exit in startup */
+extern int eflagok; /* kludge flag so that -e doesn't exit in startup */
extern int havefork;
void execcd(void), execwhatis(void), execeval(void), execexec(void);
diff --git a/src/cmd/rc/io.h b/src/cmd/rc/io.h
index 6c75cc5b..c970132f 100644
--- a/src/cmd/rc/io.h
+++ b/src/cmd/rc/io.h
@@ -10,7 +10,7 @@ struct io{
int fd;
char *bufp, *ebuf, *strp, buf[NBUF];
};
-io *err;
+extern io *err;
io *openfd(int), *openstr(void), *opencore(char *, int);
int emptybuf(io*);
void pchr(io*, int);
diff --git a/src/cmd/rc/rc.h b/src/cmd/rc/rc.h
index 2fd6758b..dd8b064c 100644
--- a/src/cmd/rc/rc.h
+++ b/src/cmd/rc/rc.h
@@ -65,7 +65,7 @@ tree *mung1(tree*, tree*), *mung2(tree*, tree*, tree*);
tree *mung3(tree*, tree*, tree*, tree*), *epimung(tree*, tree*);
tree *simplemung(tree*), *heredoc(tree*);
void freetree(tree*);
-tree *cmdtree;
+extern tree *cmdtree;
/*
* The first word of any code vector is a reference count.
* Always create a new reference to a code vector by calling codecopy(.).
@@ -76,9 +76,9 @@ union code{
int i;
char *s;
};
-char *promptstr;
+extern char *promptstr;
#define NTOK 8192
-char tok[NTOK];
+extern char tok[NTOK];
#define APPEND 1
#define WRITE 2
#define READ 3
@@ -98,7 +98,7 @@ struct var{
};
var *vlook(char*), *gvlook(char*), *newvar(char*, var*);
#define NVAR 521
-var *gvar[NVAR]; /* hash for globals */
+extern var *gvar[NVAR]; /* hash for globals */
#define new(type) ((type *)emalloc(sizeof(type)))
char *emalloc(long);
void *Malloc(ulong);
@@ -109,7 +109,7 @@ struct here{
char *name;
struct here *next;
};
-int mypid;
+extern int mypid;
/*
* Glob character escape in strings:
* In a string, GLOB must be followed by *?[ or GLOB.
@@ -128,9 +128,9 @@ int mypid;
#define threebyte(c) ((c&0xf0)==0xe0)
#define fourbyte(c) ((c&0xf8)==0xf0)
-char **argp;
-char **args;
-int nerror; /* number of errors encountered during compilation */
+extern char **argp;
+extern char **args;
+extern int nerror; /* number of errors encountered during compilation */
extern int doprompt; /* is it time for a prompt? */
/*
* Which fds are the reading/writing end of a pipe?
@@ -146,8 +146,8 @@ extern char *Rcmain(), Fdprefix[];
* How many dot commands have we executed?
* Used to ensure that -v flag doesn't print rcmain.
*/
-int ndot;
+extern int ndot;
char *getstatus(void);
-int lastc;
-int lastword;
-int kidpid;
+extern int lastc;
+extern int lastword;
+extern int kidpid;
diff --git a/src/cmd/rio/winwatch.c b/src/cmd/rio/winwatch.c
index 410f7bd7..da021278 100644
--- a/src/cmd/rio/winwatch.c
+++ b/src/cmd/rio/winwatch.c
@@ -33,7 +33,7 @@ int onwin;
int rows, cols;
int sortlabels;
int showwmnames;
-Font *font;
+extern Font *font;
Image *lightblue;
diff --git a/src/cmd/sam/sam.c b/src/cmd/sam/sam.c
index a660e4e3..9b5b3e39 100644
--- a/src/cmd/sam/sam.c
+++ b/src/cmd/sam/sam.c
@@ -20,7 +20,7 @@ int downloaded;
int dflag;
int Rflag;
char *machine;
-char *home;
+extern char *home;
int bpipeok;
int termlocked;
char *samterm = SAMTERM;
diff --git a/src/cmd/scat/dssread.c b/src/cmd/scat/dssread.c
index bd72132a..4ccd38c2 100644
--- a/src/cmd/scat/dssread.c
+++ b/src/cmd/scat/dssread.c
@@ -5,7 +5,6 @@
static void dodecode(Biobuf*, Pix*, int, int, uchar*);
static int32 getlong(uchar*);
-int debug;
Img*
dssread(char *file)
diff --git a/src/cmd/scat/scat.c b/src/cmd/scat/scat.c
index dff596b1..a21b8cb9 100644
--- a/src/cmd/scat/scat.c
+++ b/src/cmd/scat/scat.c
@@ -34,6 +34,11 @@ Record *rec;
Record *orec;
Record *cur;
+int nplate;
+Plate plate[2000]; /* needs to go to 2000 when the north comes */
+int debug;
+Gam gam;
+
char *dir;
int saodb;
int ngcdb;
diff --git a/src/cmd/scat/sky.h b/src/cmd/scat/sky.h
index bc55fbfc..21b1904c 100644
--- a/src/cmd/scat/sky.h
+++ b/src/cmd/scat/sky.h
@@ -303,13 +303,14 @@ struct Img
#define ARCSECONDS_PER_RADIAN (DEG(1)*3600)
#define MILLIARCSEC (1000*60*60)
-int nplate;
-Plate plate[2000]; /* needs to go to 2000 when the north comes */
-double PI_180;
-double TWOPI;
-double LN2;
-int debug;
-struct
+extern int nplate;
+extern Plate plate[2000]; /* needs to go to 2000 when the north comes */
+extern double PI_180;
+extern double TWOPI;
+extern double LN2;
+extern int debug;
+typedef struct Gam Gam;
+struct Gam
{
float min;
float max;
@@ -318,7 +319,8 @@ struct
float mult1;
float mult2;
int neg;
-} gam;
+};
+extern Gam gam;
typedef struct Picture Picture;
struct Picture
diff --git a/src/cmd/tcs/tcs.c b/src/cmd/tcs/tcs.c
index d796ba63..682e108f 100644
--- a/src/cmd/tcs/tcs.c
+++ b/src/cmd/tcs/tcs.c
@@ -28,7 +28,6 @@ int clean = 0;
int verbose = 0;
long ninput, noutput, nrunes, nerrors;
char *file = "stdin";
-char *argv0;
Rune runes[N];
char obuf[UTFmax*N]; /* maximum bloat from N runes */
long tab[NRUNE];
diff --git a/src/cmd/venti/srv/part.c b/src/cmd/venti/srv/part.c
index c1fb929f..68ffbc53 100644
--- a/src/cmd/venti/srv/part.c
+++ b/src/cmd/venti/srv/part.c
@@ -17,6 +17,7 @@
#include "fns.h"
u32int maxblocksize;
+#pragma weak readonly
int readonly;
int findsubpart(Part *part, char *name);
diff --git a/src/lib9/argv0.c b/src/lib9/argv0.c
index 4c61f444..b9a9b8b4 100644
--- a/src/lib9/argv0.c
+++ b/src/lib9/argv0.c
@@ -1,5 +1,6 @@
#include <lib9.h>
+#pragma weak argv0
char *argv0;
/*
diff --git a/src/libthread/thread.c b/src/libthread/thread.c
index 79e0ec71..b5bfed3e 100644
--- a/src/libthread/thread.c
+++ b/src/libthread/thread.c
@@ -690,6 +690,7 @@ threadrwakeup(Rendez *r, int all, ulong pc)
static int threadargc;
static char **threadargv;
+#pragma weak mainstacksize
int mainstacksize;
extern int _p9usepwlibrary; /* getgrgid etc. smash the stack - tell _p9dir just say no */
static void