Subject: bin/5566: fix for externs in sail
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dholland@eecs.harvard.edu>
List: netbsd-bugs
Date: 06/10/1998 20:22:59
>Number: 5566
>Category: bin
>Synopsis: sail(6) relies heavily on linker "commons"; patch
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Jun 10 18:05:01 1998
>Last-Modified:
>Originator: David A. Holland
>Organization:
- David A. Holland | VINO project home page:
dholland@eecs.harvard.edu | http://www.eecs.harvard.edu/vino
>Release: 1.3
>Environment:
NetBSD 1.3 release (on x86, but cross-compiling for VINO)
>Description:
sail is missing "extern" on most of its global variables
(of which it has a lot). Some of these were causing the
VINO ELF linker to issue warnings, so I went in and fixed
the lot. The patch is appended.
>How-To-Repeat:
Compiling and linking sail with gnu binutils compiled for
ELF causes warnings about the sizes of some symbols changing.
>Fix:
You may wish to leave off the Makefile patch (which adds -fno-common to
CFLAGS).
Index: Makefile
===================================================================
RCS file: /home/vino/repo/src/utils/bsd/games/sail/Makefile,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 Makefile
--- Makefile 1998/05/28 23:30:37 1.1.1.2
+++ Makefile 1998/06/11 00:40:01
@@ -2,6 +2,7 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= sail
+CFLAGS+=-fno-common
SRCS= main.c pl_main.c pl_1.c pl_2.c pl_3.c pl_4.c pl_5.c pl_6.c pl_7.c \
dr_main.c dr_1.c dr_2.c dr_3.c dr_4.c dr_5.c lo_main.c \
assorted.c game.c globals.c misc.c parties.c sync.c version.c
Index: driver.h
===================================================================
RCS file: /home/vino/repo/src/utils/bsd/games/sail/driver.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 driver.h
--- driver.h 1997/04/10 18:35:19 1.1.1.1
+++ driver.h 1998/06/11 00:36:27
@@ -37,4 +37,4 @@
#include "extern.h"
-int dtab[];
+extern int dtab[];
Index: extern.h
===================================================================
RCS file: /home/vino/repo/src/utils/bsd/games/sail/extern.h,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 extern.h
--- extern.h 1998/05/28 23:30:47 1.1.1.2
+++ extern.h 1998/06/11 00:46:21
@@ -43,20 +43,20 @@
#include "machdep.h"
/* program mode */
-int mode;
-jmp_buf restart;
+extern int mode;
+extern jmp_buf restart;
#define MODE_PLAYER 1
#define MODE_DRIVER 2
#define MODE_LOGGER 3
/* command line flags */
-char debug; /* -D */
-char randomize; /* -x, give first available ship */
-char longfmt; /* -l, print score in long format */
-char nobells; /* -b, don't ring bell before Signal */
+extern char debug; /* -D */
+extern char randomize; /* -x, give first available ship */
+extern char longfmt; /* -l, print score in long format */
+extern char nobells; /* -b, don't ring bell before Signal */
/* other initial modes */
-char issetuid; /* running setuid */
+extern char issetuid; /* running setuid */
#define die() ((rand() >> 3) % 6 + 1)
#define sqr(a) ((a) * (a))
@@ -231,8 +231,8 @@
char *name; /* 14 */
struct ship ship[NSHIP]; /* 16 */
};
-struct scenario scene[];
-int nscene;
+extern struct scenario scene[];
+extern int nscene;
struct shipspecs {
char bs;
@@ -255,10 +255,10 @@
int rig4;
short pts;
};
-struct shipspecs specs[];
+extern struct shipspecs specs[];
-struct scenario *cc; /* the current scenario */
-struct ship *ls; /* &cc->ship[cc->vessels] */
+extern struct scenario *cc; /* the current scenario */
+extern struct ship *ls; /* &cc->ship[cc->vessels] */
#define SHIP(s) (&cc->ship[s])
#define foreachship(sp) for ((sp) = cc->ship; (sp) < ls; (sp)++)
@@ -266,37 +266,37 @@
struct windeffects {
char A, B, C, D;
};
-struct windeffects WET[7][6];
+extern struct windeffects WET[7][6];
struct Tables {
char H, G, C, R;
};
-struct Tables RigTable[11][6];
-struct Tables HullTable[11][6];
+extern struct Tables RigTable[11][6];
+extern struct Tables HullTable[11][6];
-char AMMO[9][4];
-char HDT[9][10];
-char HDTrake[9][10];
-char QUAL[9][5];
-char MT[9][3];
-
-char *countryname[];
-char *classname[];
-char *directionname[];
-char *qualname[];
-char loadname[];
-
-char rangeofshot[];
-
-char dr[], dc[];
-
-int winddir;
-int windspeed;
-int turn;
-int game;
-int alive;
-int people;
-char hasdriver;
+extern char AMMO[9][4];
+extern char HDT[9][10];
+extern char HDTrake[9][10];
+extern char QUAL[9][5];
+extern char MT[9][3];
+
+extern char *countryname[];
+extern char *classname[];
+extern char *directionname[];
+extern char *qualname[];
+extern char loadname[];
+
+extern char rangeofshot[];
+
+extern char dr[], dc[];
+
+extern int winddir;
+extern int windspeed;
+extern int turn;
+extern int game;
+extern int alive;
+extern int people;
+extern char hasdriver;
/* assorted.c */
void table __P((int, int, int, struct ship *, struct ship *, int));
Index: globals.c
===================================================================
RCS file: /home/vino/repo/src/utils/bsd/games/sail/globals.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 globals.c
--- globals.c 1998/05/28 23:30:49 1.1.1.2
+++ globals.c 1998/06/11 00:54:56
@@ -544,3 +544,23 @@
char dr[] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 };
char dc[] = { 0, 0, -1, -1, -1, 0, 1, 1, 1 };
+
+/* non-initialized globals */
+int mode;
+jmp_buf restart;
+char debug;
+char randomize;
+char longfmt;
+char nobells;
+char issetuid;
+
+struct scenario *cc;
+struct ship *ls;
+
+int winddir;
+int windspeed;
+int turn;
+int game;
+int alive;
+int people;
+char hasdriver;
Index: pl_7.c
===================================================================
RCS file: /home/vino/repo/src/utils/bsd/games/sail/pl_7.c,v
retrieving revision 1.3
diff -u -r1.3 pl_7.c
--- pl_7.c 1998/05/29 01:04:55 1.3
+++ pl_7.c 1998/06/11 00:56:07
@@ -56,6 +56,12 @@
* Display interface
*/
+static WINDOW *view_w;
+/*static*/ WINDOW *slot_w; /* used in pl_5.c */
+static WINDOW *scroll_w;
+static WINDOW *stat_w;
+static WINDOW *turn_w;
+
static char sc_hasprompt;
static char *sc_prompt;
static char *sc_buf;
Index: pl_main.c
===================================================================
RCS file: /home/vino/repo/src/utils/bsd/games/sail/pl_main.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 pl_main.c
--- pl_main.c 1998/05/28 23:30:59 1.1.1.2
+++ pl_main.c 1998/06/11 00:52:59
@@ -48,6 +48,18 @@
#include <stdlib.h>
#include <unistd.h>
+/* player.h externs */
+char done_curses;
+char loaded, fired, changed, repaired;
+char dont_adjust;
+int viewrow, viewcol;
+char movebuf[sizeof SHIP(0)->file->movebuf];
+int player;
+struct ship *ms;
+struct File *mf;
+struct shipspecs *mc;
+
+
/*ARGSUSED*/
int
pl_main()
Index: player.h
===================================================================
RCS file: /home/vino/repo/src/utils/bsd/games/sail/player.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 player.h
--- player.h 1997/04/10 18:35:21 1.1.1.1
+++ player.h 1998/06/11 00:56:13
@@ -98,22 +98,18 @@
#define SCREENTEST() (initscr() != ERR && STAT_R < COLS && SCROLL_Y > 0)
#endif
-WINDOW *view_w;
-WINDOW *slot_w;
-WINDOW *scroll_w;
-WINDOW *stat_w;
-WINDOW *turn_w;
+extern WINDOW *slot_w;
-char done_curses;
-char loaded, fired, changed, repaired;
-char dont_adjust;
-int viewrow, viewcol;
-char movebuf[sizeof SHIP(0)->file->movebuf];
-char version[];
-int player;
-struct ship *ms; /* memorial structure, &cc->ship[player] */
-struct File *mf; /* ms->file */
-struct shipspecs *mc; /* ms->specs */
+extern char done_curses;
+extern char loaded, fired, changed, repaired;
+extern char dont_adjust;
+extern int viewrow, viewcol;
+extern char movebuf[];
+extern char version[];
+extern int player;
+extern struct ship *ms; /* memorial structure, &cc->ship[player] */
+extern struct File *mf; /* ms->file */
+extern struct shipspecs *mc; /* ms->specs */
/* condition codes for leave() */
#define LEAVE_QUIT 0
>Audit-Trail:
>Unformatted: