Article View: gnu.bash.bug
Article #669Re: Bash on a 3b2/300 (Porting help needed)
From: Dave Mack
Date: Wed, 18 Oct 1989 15:44
Date: Wed, 18 Oct 1989 15:44
1285 lines
40108 bytes
40108 bytes
In article <1989Oct16.184048.20862@rpi.edu> heechee@clotho.acm.rpi.edu (Stephen Underwood) writes:
>
>I'm in the process of trying to port Bash (the bourne again shell) from
>the gnu project to a 3b2 300 runing SYS V rel 3.1. After about a week of
>serious hacking around I have the thinkg compiling, but it refuses
>to link due to the lack of 4 symbols.
>
> sigblock
> sigsetmask
> sys_siglist
> sigpause
>
>Does anyone know A) What theese routines do? B) How to get around them?
These are BSDisms. You shouldn't be getting them.
I have bash-1.03 99% operational on a 3b2/600 running SysVR3.2.
I applied the UNICOS 5.0 patches that Hal Peterson posted a short time
back. After that, it was a matter of some minor hacking (mainly on
the Makefile to get rid of the malloc/alloca stuff.) Accolades
to Hal Peterson for a fine bit of work.
The main remaining problem is an occasional failure ("got errno 10
while waiting for <pid>") that I haven't found yet - probably a
difference between the BSD and SysV wait(2). Oddly enough, piping
the output of a command that has this problem into "less" seems to
semi-cure it. Bash sends the warning out, but everything continues to
operate. Having a shell with working history and command-line editing
makes this problem seem trivial compared to the agony of using sh.
Apply the following patch using "patch -p1 -l -N". This is a patch to
the raw bash-1.03 source as it would appear on a SysV system, including
truncated filenames. The usual Makefile twiddling will be necessary.
-------------------------------- cut here --------------------------------
Only in bash-1.03: .build
diff -rc bashorig/Makefile bash-1.03/Makefile
*** bashorig/Makefile Wed Oct 18 11:26:13 1989
--- bash-1.03/Makefile Wed Oct 11 13:43:33 1989
***************
*** 37,43 ****
# Destination installation directory. The shell is copied here if
# you do a `make install'. The directory name does NOT end in a slash.
! DESTDIR = /usr/gnu/bin
# The name of the target hardware. It makes a difference. If your
# machine doesn't seem to be represented by one of the machines here,
--- 37,43 ----
# Destination installation directory. The shell is copied here if
# you do a `make install'. The directory name does NOT end in a slash.
! DESTDIR = /usr/local/bin
# The name of the target hardware. It makes a difference. If your
# machine doesn't seem to be represented by one of the machines here,
***************
*** 45,56 ****
# Use i386 for PC type 386 boxes. (Compaq, etc.)
# SUN3, SUN4, SUN386i, VAX, SONY, CONVEX, HP, HP9KS300, i386, NeXT, AIX,
# ATT3B, ATT386
! TARGET = SUN3
# The name of the target operating system. There isn't such a big
# difference between SUNOS3 and Bsd. But there might be in the future.
# SUNOS3, SUNOS4, SYSV, Bsd, HPUX, UNIXPC
! OS = SUNOS4
# You only need this if you are hacking the shell in a location
# that doesn't do enough backups, or does a poor job. In that
--- 45,56 ----
# Use i386 for PC type 386 boxes. (Compaq, etc.)
# SUN3, SUN4, SUN386i, VAX, SONY, CONVEX, HP, HP9KS300, i386, NeXT, AIX,
# ATT3B, ATT386
! TARGET = ATT3B
# The name of the target operating system. There isn't such a big
# difference between SUNOS3 and Bsd. But there might be in the future.
# SUNOS3, SUNOS4, SYSV, Bsd, HPUX, UNIXPC
! OS = SYSV
# You only need this if you are hacking the shell in a location
# that doesn't do enough backups, or does a poor job. In that
***************
*** 57,63 ****
# case, BACKUP_DIR should be the name of a directory on another
# device (i.e. different than the one you are building the shell
# on), and you should do `make backup' at least once a day.
! BACKUP_DIR = /home/gogol/bash
#
####################################################################
--- 57,63 ----
# case, BACKUP_DIR should be the name of a directory on another
# device (i.e. different than the one you are building the shell
# on), and you should do `make backup' at least once a day.
! BACKUP_DIR = /usr/local/bin
#
####################################################################
***************
*** 75,91 ****
# Xenix requires -lx -ldir. It is also required in the readline Makefile.
#LOCAL_LIBS = -lx -ldir
! GCC_SUNOS4_FLAG = -Bstatic
! DEBUG_FLAGS = $(PROFILE_FLAGS) -g $(GCC_SUNOS4_FLAG)
LDFLAGS = $(DEBUG_FLAGS)
CFLAGS = $(DEBUG_FLAGS) -D${TARGET} -DTARGET=${TARGET} -D${OS}
CPPFLAGS= -I$(LIBSRC)
# If you don't have Bison use "yacc". Otherwise use "bison -y".
! BISON = bison -y
# If you don't have Gcc use cc.
! CC = gcc -traditional
####################################################################
--- 75,94 ----
# Xenix requires -lx -ldir. It is also required in the readline Makefile.
#LOCAL_LIBS = -lx -ldir
!
! GCC_SUNOS4_FLAG =
! PCCDEBUG =
! SCCDEBUG =
! DEBUG_FLAGS = $(PROFILE_FLAGS) $(SCCDEBUG) $(GCC_SUNOS4_FLAG)
LDFLAGS = $(DEBUG_FLAGS)
CFLAGS = $(DEBUG_FLAGS) -D${TARGET} -DTARGET=${TARGET} -D${OS}
CPPFLAGS= -I$(LIBSRC)
# If you don't have Bison use "yacc". Otherwise use "bison -y".
! BISON = yacc
# If you don't have Gcc use cc.
! CC = cc
####################################################################
***************
*** 110,143 ****
ALLOC_SOURCE = ./alloc-files/
# Our malloc.
! MALLOC = $(ALLOC_SOURCE)malloc.o
! MALLOC_FLAGS = -Drcheck -Dbotch=programming_error
#MALLOC= $(ALLOC_SOURCE)malloc.o
! #ALLOCA= $(ALLOC_SOURCE)alloca.o
! ALLOC_HEADERS = $(ALLOC_SOURCE)getpagesize.h
! ALLOC_FILES = $(ALLOC_SOURCE)malloc.c $(ALLOC_SOURCE)alloca.c\
! $(ALLOC_SOURCE)i386-alloca.s
# Anticipated library for alloca if you do not use an alloc from this package.
# E.g. "-lPW" for AT&T 3B's. The AT&T 6386 systems can use i386-alloca.o.
# If you are using gcc, then leave ALLOCA_LIB undefined, as __builtin_alloca
# will do the trick.
! #ALLOCA_LIB = -lPW
! ALLOCA_LIB =
# If your system doesn't have a sys_siglist, then define SIGLIST
# as siglist.o
! #SIGLIST = siglist.o
RM = rm
AR = ar
! RANLIB = ranlib
# Support libraries required. Termcap and Readline.
# We would like to use GNU's termcap library. Where is it?
# If you don't have -ltermcap, you might try -lcurses.
! TERMCAP = /usr/lib/libtermcap.a
READLINE= ./readline/libreadline.a
# The source code for the support libraries.
--- 113,146 ----
ALLOC_SOURCE = ./alloc-files/
# Our malloc.
! #MALLOC = malloc.o
! #MALLOC_FLAGS = -Drcheck -Dbotch=programming_error
#MALLOC= $(ALLOC_SOURCE)malloc.o
! #ALLOCA= alloca.o
! #ALLOC_HEADERS = $(ALLOC_SOURCE)getpagesize.h
! #ALLOC_FILES = $(ALLOC_SOURCE)malloc.c $(ALLOC_SOURCE)alloca.c\
! # $(ALLOC_SOURCE)i386-alloca.s
# Anticipated library for alloca if you do not use an alloc from this package.
# E.g. "-lPW" for AT&T 3B's. The AT&T 6386 systems can use i386-alloca.o.
# If you are using gcc, then leave ALLOCA_LIB undefined, as __builtin_alloca
# will do the trick.
! ALLOCA_LIB = -lPW
! #ALLOCA_LIB =
# If your system doesn't have a sys_siglist, then define SIGLIST
# as siglist.o
! SIGLIST = siglist.o
RM = rm
AR = ar
! RANLIB = true
# Support libraries required. Termcap and Readline.
# We would like to use GNU's termcap library. Where is it?
# If you don't have -ltermcap, you might try -lcurses.
! TERMCAP = /usr/lib/libcurses.a
READLINE= ./readline/libreadline.a
# The source code for the support libraries.
***************
*** 180,186 ****
OBJECTS = shell.o y.tab.o general.o make_cmd.o print_cmd.o\
dispose_cmd.o execute_cmd.o variables.o builtins.o copy_cmd.o\
flags.o jobs.o subst.o glob.o hash.o mailcheck.o test.o\
! trap.o alias.o $(MALLOC) $(ALLOCA) braces.o unwind_prot.o\
$(SIGLIST) bashline.o version.o
# Documentation for the shell.
--- 183,189 ----
OBJECTS = shell.o y.tab.o general.o make_cmd.o print_cmd.o\
dispose_cmd.o execute_cmd.o variables.o builtins.o copy_cmd.o\
flags.o jobs.o subst.o glob.o hash.o mailcheck.o test.o\
! trap.o alias.o $(ALLOCA) $(MALLOC) braces.o unwind_prot.o\
$(SIGLIST) bashline.o version.o
# Documentation for the shell.
***************
*** 208,220 ****
$(RM) .make
.build: newversion.aux .make $(SOURCES)
! if newversion.aux -build; then mv -f newversion.h version.h; fi
.make:
touch .make
version.h: newversion.aux
! if newversion.aux -build; then mv -f newversion.h version.h; fi
shell.h: general.h variables.h config.h
touch shell.h
--- 211,223 ----
$(RM) .make
.build: newversion.aux .make $(SOURCES)
! if ./newversion.aux -build; then mv -f newversion.h version.h; fi
.make:
touch .make
version.h: newversion.aux
! if ./newversion.aux -build; then mv -f newversion.h version.h; fi
shell.h: general.h variables.h config.h
touch shell.h
***************
*** 228,236 ****
(cd $(RLIBSRC); $(MAKE) $(MFLAGS) CC='$(CC)'\
CFLAGS='$(CFLAGS) -DSHELL')
! $(TERMCAP): $(TERMCAP_SOURCE)
! (cd $(LIBSRC); $(MAKE) $(MFLAGS) CC='$(CC)'\
! CFLAGS='$(CFLAGS) -I.')
shell.o: shell.h flags.h shell.c
$(CC) $(CFG_FLAGS) $(CFLAGS) $(CPPFLAGS) -c shell.c
--- 231,239 ----
(cd $(RLIBSRC); $(MAKE) $(MFLAGS) CC='$(CC)'\
CFLAGS='$(CFLAGS) -DSHELL')
! #$(TERMCAP): $(TERMCAP_SOURCE)
! # (cd $(LIBSRC); $(MAKE) $(MFLAGS) CC='$(CC)'\
! # CFLAGS='$(CFLAGS) -I.')
shell.o: shell.h flags.h shell.c
$(CC) $(CFG_FLAGS) $(CFLAGS) $(CPPFLAGS) -c shell.c
***************
*** 241,252 ****
keymaps.c: emacs_keymap.c vi_keymap.c
touch keymaps.c
! $(MALLOC): $(ALLOC_FILES)
! $(CC) -I$(ALLOC_SOURCE) $(CFLAGS) $(MALLOC_FLAGS) -c $*.c &&\
! mv `basename $*`.o $(MALLOC)
#$(ALLOCA): $(ALLOC_FILES)
! # $(CC) -I$(ALLOC_SOURCE) $(CFLAGS) -o $(ALLOCA) -c $*.c
bashline.o: bashline.c config.h $(RLIBSRC)readline.h
$(CC) -I../ $(CFLAGS) $(CPPFLAGS) -c bashline.c
--- 244,254 ----
keymaps.c: emacs_keymap.c vi_keymap.c
touch keymaps.c
! #$(MALLOC): $(ALLOC_FILES)
! # $(CC) -I$(ALLOC_SOURCE) $(CFLAGS) $(MALLOC_FLAGS) -c $(ALLOC_SOURCE)malloc.c
#$(ALLOCA): $(ALLOC_FILES)
! # $(CC) -I$(ALLOC_SOURCE) $(CFLAGS) -c $(ALLOC_SOURCE)alloca.c
bashline.o: bashline.c config.h $(RLIBSRC)readline.h
$(CC) -I../ $(CFLAGS) $(CPPFLAGS) -c bashline.c
***************
*** 309,315 ****
$(SHELL) -c 'f=$(PROGRAM)-`cat .distribution`.tar.Z;uuencode $$f $$f | split -800 - uuencoded/$$f.uu.'
.distribution: newversion.aux
! newversion.aux -dist `$(PROGRAM) -c 'echo $$BASH_VERSION'`
distribution: $(PROGRAM).tar.Z .distribution
cp $(PROGRAM).tar.Z $(PROGRAM)-`cat .distribution`.tar.Z
--- 311,317 ----
$(SHELL) -c 'f=$(PROGRAM)-`cat .distribution`.tar.Z;uuencode $$f $$f | split -800 - uuencoded/$$f.uu.'
.distribution: newversion.aux
! ./newversion.aux -dist `$(PROGRAM) -c 'echo $$BASH_VERSION'`
distribution: $(PROGRAM).tar.Z .distribution
cp $(PROGRAM).tar.Z $(PROGRAM)-`cat .distribution`.tar.Z
***************
*** 319,325 ****
newversion: newversion.aux
rm -f .build
! newversion.aux -dist
mv -f newversion.h version.h
make $(PROGRAM)
--- 321,327 ----
newversion: newversion.aux
rm -f .build
! ./newversion.aux -dist
mv -f newversion.h version.h
make $(PROGRAM)
***************
*** 334,336 ****
--- 336,341 ----
dist-clean:
rm -f $(OBJECTS) $(PROGRAM) y.tab.c newversion.aux
rm -rf uuencoded
+
+ alloca.o: $(ALLOC_SOURCE)alloca.c
+ malloc.o: $(ALLOC_SOURCE)malloc.c
Common subdirectories: bashorig/alloc-files and bash-1.03/alloc-files
diff -rc bashorig/builtins.c bash-1.03/builtins.c
*** bashorig/builtins.c Wed Oct 18 11:25:58 1989
--- bash-1.03/builtins.c Wed Oct 11 15:41:28 1989
***************
*** 265,270 ****
--- 265,272 ----
If N is omitted, the return status is that of the last command" },
{ "set", set_builtin, 1, "set [-aefhkntuvx] [arg ...]",
+ " See hardcopy documentation for details" },
+ /*
" -a Mark variables which are modified or created for export\n\
-e Exit immediately if a command exits with a non-zero status\n\
-f Disable file name generation (globbing)\n\
***************
*** 290,295 ****
--- 292,298 ----
set of flags may be found in $-. The remaining ARGs are positional\n\
parameters and are assigned, in order, to $1, $2, ... $9. If no\n\
ARGs are given, all shell variables are printed" },
+ */
{ "shift", shift_builtin, 1, "shift [n]",
" The positional parameters from $N+1 ... are renamed to $1 .... If\n\
***************
*** 309,314 ****
--- 312,319 ----
" Synonym for `test'" },
{ "test", test_builtin, 1, "test [expr]",
+ " See hardcopy documentation" },
+ /*
" Exits with a status of 0 (trueness) or 1 (falseness) depending on\n\
the evaluation of EXPR. Expressions may be unary or binary. Unary\n\
expressions are often used to examine the status of a file. There\n\
***************
*** 362,367 ****
--- 367,373 ----
Arithmetic binary operators return true if arg1\n\
is equal, not-equal, less-than, less-than-or-equal,\n\
greater-than, or greater-than-or-equal than arg2" },
+ */
{ "times", times_builtin, 1, "times",
" Print the accumulated user and system times for processes run from\n\
***************
*** 3222,3227 ****
--- 3228,3234 ----
suspend_builtin (list)
WORD_LIST *list;
{
+ extern int shell_pgrp;
if (list)
if (strcmp (list->word->word, "-f") == 0)
***************
*** 3236,3242 ****
do_suspend:
old_cont = (SigHandler *)signal (SIGCONT, suspend_continue);
old_tstp = (SigHandler *)signal (SIGTSTP, SIG_DFL);
! kill (getpid (), SIGTSTP);
}
/* How to bring a job into the foreground. */
--- 3243,3249 ----
do_suspend:
old_cont = (SigHandler *)signal (SIGCONT, suspend_continue);
old_tstp = (SigHandler *)signal (SIGTSTP, SIG_DFL);
! killpg (shell_pgrp, SIGTSTP);
}
/* How to bring a job into the foreground. */
diff -rc bashorig/config.h bash-1.03/config.h
*** bashorig/config.h Wed Oct 18 11:26:07 1989
--- bash-1.03/config.h Tue Oct 10 14:01:11 1989
***************
*** 57,64 ****
/* Define NO_WAIT_H if your system doesn't seem to have sys/wait.h.
This is true for HPUX and ALTOS. */
! #if defined (HPUX) || defined (ALTOS)
#define NO_WAIT_H
#endif
#endif /* _CONFIG_ */
--- 57,69 ----
/* Define NO_WAIT_H if your system doesn't seem to have sys/wait.h.
This is true for HPUX and ALTOS. */
! #if defined (HPUX) || defined (ALTOS) || defined (CRAY)
#define NO_WAIT_H
+ #ifdef CRAY
+ #define FILL_BITS 48
+ #else
+ #define FILL_BITS 16
+ #endif /* CRAY */
#endif
#endif /* _CONFIG_ */
Common subdirectories: bashorig/documentation and bash-1.03/documentation
Common subdirectories: bashorig/examples and bash-1.03/examples
diff -rc bashorig/flags.c bash-1.03/flags.c
*** bashorig/flags.c Wed Oct 18 11:25:58 1989
--- bash-1.03/flags.c Tue Oct 10 14:00:58 1989
***************
*** 22,27 ****
--- 22,28 ----
/* Flags hacking. */
#include <stdio.h> /* For `NULL'. Can you believe this? */
+ #include "general.h"
#include "quit.h"
#include "flags.h"
#include "config.h"
diff -rc bashorig/general.h bash-1.03/general.h
*** bashorig/general.h Wed Oct 18 11:26:06 1989
--- bash-1.03/general.h Tue Oct 10 14:01:11 1989
***************
*** 39,49 ****
#endif
/* The output of `signal' is different on different systems. Yechh. */
! #if defined(SUNOS4) || defined (NeXT)
#define sighandler void
#else
#define sighandler int
#endif
typedef sighandler SigHandler ();
--- 39,54 ----
#endif
/* The output of `signal' is different on different systems. Yechh. */
! #if defined(SUNOS4) || defined (NeXT) || defined (CRAY)
#define sighandler void
#else
#define sighandler int
#endif
+
+ #ifdef CRAY
+ /* "word" is a type defined in <sys/types.h> on UNICOS. */
+ #define word bash_word
+ #endif CRAY
typedef sighandler SigHandler ();
diff -rc bashorig/jobs.h bash-1.03/jobs.h
*** bashorig/jobs.h Wed Oct 18 11:26:06 1989
--- bash-1.03/jobs.h Tue Oct 10 14:01:10 1989
***************
*** 38,44 ****
struct
{
unsigned short
! w_Fill1 : 16, /* high 16 bits unused */
w_Retcode : 8, /* exit code if w_termsig==0 */
w_Coredump : 1, /* core dump indicator */
w_Termsig : 7; /* termination signal */
--- 38,44 ----
struct
{
unsigned short
! w_Fill1 : FILL_BITS, /* high FILL_BITS bits unused */
w_Retcode : 8, /* exit code if w_termsig==0 */
w_Coredump : 1, /* core dump indicator */
w_Termsig : 7; /* termination signal */
***************
*** 50,56 ****
struct
{
unsigned short
! w_Fill2 : 16, /* high 16 bits unused */
w_Stopsig : 8, /* signal that stopped us */
w_Stopval : 8; /* == W_STOPPED if stopped */
} w_S;
--- 50,56 ----
struct
{
unsigned short
! w_Fill2 : FILL_BITS, /* high FILL_BITS bits unused */
w_Stopsig : 8, /* signal that stopped us */
w_Stopval : 8; /* == W_STOPPED if stopped */
} w_S;
diff -rc bashorig/nojobs.c bash-1.03/nojobs.c
*** bashorig/nojobs.c Wed Oct 18 11:26:02 1989
--- bash-1.03/nojobs.c Wed Oct 11 15:41:17 1989
***************
*** 23,28 ****
--- 23,31 ----
#include <signal.h>
#include <setjmp.h>
#include <errno.h>
+ #ifdef SYSV
+ #include <sys/termio.h>
+ #endif
#include "config.h"
#include "general.h"
#include "jobs.h"
***************
*** 31,37 ****
#define SIGABRT SIGIOT
#endif
! #ifndef SYSV
#include <sys/time.h>
#include <sys/resource.h>
/* The total amount of system time spent running processes for me. */
--- 34,42 ----
#define SIGABRT SIGIOT
#endif
! #ifdef SYSV
! #include <sys/fcntl.h>
! #else
#include <sys/time.h>
#include <sys/resource.h>
/* The total amount of system time spent running processes for me. */
***************
*** 43,49 ****
struct timeval total_usertime = {0, 0};
long user_minutes_used = 0;
int user_seconds_used = 0;
! #endif
int last_made_pid;
int last_asynchronous_pid;
--- 48,54 ----
struct timeval total_usertime = {0, 0};
long user_minutes_used = 0;
int user_seconds_used = 0;
! #endif /* SYSV */
int last_made_pid;
int last_asynchronous_pid;
***************
*** 61,67 ****
initialize_job_signals ()
{
extern int login_shell;
! int throw_to_top_level ();
signal (SIGINT, throw_to_top_level);
signal (SIGQUIT, SIG_IGN);
--- 66,72 ----
initialize_job_signals ()
{
extern int login_shell;
! sighandler throw_to_top_level ();
signal (SIGINT, throw_to_top_level);
signal (SIGQUIT, SIG_IGN);
***************
*** 129,135 ****
* In the parent.
*/
last_made_pid = pid;
! remember_pid (pid);
if (async_p)
last_asynchronous_pid = pid;
--- 134,140 ----
* In the parent.
*/
last_made_pid = pid;
! /* remember_pid (pid); */ /* What's this? */
if (async_p)
last_asynchronous_pid = pid;
***************
*** 137,142 ****
--- 142,175 ----
return (pid);
}
+ wait_for_single_pid (pid)
+ int pid;
+ {
+ int got_pid, return_val;
+ union wait status;
+
+ while ((got_pid = wait (&status)) != pid)
+ {
+ if (got_pid < 0)
+ {
+ if (errno != EINTR && errno != ECHILD)
+ file_error ("wait");
+ break;
+ }
+ QUIT;
+ }
+ QUIT;
+ }
+
+ wait_for_background_pids ()
+ {
+ while ((wait (0) >= 0))
+ /* empty body */;
+ if ((errno != ECHILD) && (errno != EINTR))
+ file_error ("wait");
+ QUIT;
+ }
+
/*
* Wait for pid (one of our children) to terminate.
*/
***************
*** 186,192 ****
--- 219,231 ----
/* When we end a job abnormally, or if we stop a job, we set the tty to the
state kept in here. When a job ends normally, we set the state in here
to the state of the tty. */
+ #ifdef SYSV
+ static struct termio shell_tty_info;
+ #define TIOCGETP TCGETA
+ #define TIOCSETN TCSETAW
+ #else
static struct sgttyb shell_tty_info;
+ #endif
/* Fill the contents of shell_tty_info with the current tty info. */
get_tty_state ()
Only in bash-1.03: patch.bash
diff -rc bashorig/quit.h bash-1.03/quit.h
*** bashorig/quit.h Wed Oct 18 11:26:07 1989
--- bash-1.03/quit.h Tue Oct 10 14:01:11 1989
***************
*** 2,7 ****
--- 2,10 ----
#ifndef __QUIT__
#define __QUIT__
+ /* We need to declare throw_top_level */
+ extern sighandler throw_to_top_level ();
+
/* Non-zero means SIGINT has already ocurred. */
extern int interrupt_state;
Common subdirectories: bashorig/readline and bash-1.03/readline
diff -rc bashorig/siglist.c bash-1.03/siglist.c
*** bashorig/siglist.c Wed Oct 18 11:26:04 1989
--- bash-1.03/siglist.c Tue Oct 10 14:01:08 1989
***************
*** 1,47 ****
/* siglist.c -- signal list for those machines that don't have one. */
- /* Copyright (C) 1989 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 1, or (at your option) any later
- version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
char *sys_siglist[] = {
! "bogus signal", /* 0 */
! "hangup", /* 1 SIGHUP */
! "interrupt", /* 2 SIGINT */
! "quit", /* 3 SIGQUIT */
! "illegal instruction", /* 4 SIGILL */
! "trace trap", /* 5 SIGTRAP */
! "IOT instruction", /* 6 SIGIOT */
! "EMT instruction", /* 7 SIGEMT */
! "floating point exception", /* 8 SIGFPE */
! "kill", /* 9 SIGKILL */
! "bus error", /* 10 SIGBUS */
! "segmentation violation", /* 11 SIGSEGV */
! "bad argument to system call", /* 12 SIGSYS */
! "write on a pipe with no one to read it", /* 13 SIGPIPE */
! "alarm clock", /* 14 SIGALRM */
! "software termination signum", /* 15 SIGTERM */
! "user defined signal 1", /* 16 SIGUSR1 */
! "user defined signal 2", /* 17 SIGUSR2 */
! "death of a child", /* 18 SIGCLD */
! "power-fail restart", /* 19 SIGPWR */
! "virtual timer alarm", /* 20 SIGVTALRM */
! "profiling timer alarm", /* 21 SIGPROF */
! "asynchronous I/O", /* 22 SIGIO */
! "window change or mouse signal", /* 23 SIGWINDOW */
(char *)0x0
};
--- 1,39 ----
/* siglist.c -- signal list for those machines that don't have one. */
+ /* this version is specific to Cray Research UNICOS. */
char *sys_siglist[] = {
! "bogus signal", /* 0 */
! "hangup", /* 1 SIGHUP */
! "interrupt", /* 2 SIGINT */
! "quit", /* 3 SIGQUIT */
! "illegal instruction", /* 4 SIGILL */
! "trace trap", /* 5 SIGTRAP */
! "user abort", /* 6 SIGABRT */
! "error exit", /* 7 SIGERR */
! "floating point exception", /* 8 SIGFPE */
! "kill (no REG or IGN)", /* 9 SIGKILL */
! "program range error", /* 10 SIGPRE */
! "operand range error", /* 11 SIGORE */
! "bad argument to system call", /* 12 SIGSYS */
! "write on a pipe with no one to read it", /* 13 SIGPIPE */
! "alarm clock", /* 14 SIGALRM */
! "software termination signal from kill", /* 15 SIGTERM */
! "user defined signal 1", /* 16 SIGUSR1 */
! "user defined signal 2", /* 17 SIGUSR2 */
! "death of a child", /* 18 SIGCLD */
! "power failure", /* 19 SIGPWR */
! "multitasking wakeup signal", /* 20 SIGMT */
! "multitasking kill signal", /* 21 SIGMTKILL */
! "FORTRAN asynchronous I/O completion", /* 22 SIGBUFIO */
! "recovery signal (advisory)", /* 23 SIGRECOVERY */
! "uncorrectable memory err (CMDB, LMP, FPT)", /* 24 SIGUME */
! "reserved for Cray Research, Inc.", /* 25 SIGCRAY7 */
! "cpu limit exceeded", /* 26 SIGCPULIM */
! "system shutdown imminent (advisory)", /* 27 SIGSHUTDN */
! "SuperLink IPC library I/O completion.", /* 28 SIGSL */
! "reserved for Cray Research, Inc.", /* 29 SIGCRAY3 */
! "reserved for Cray Research, Inc.", /* 30 SIGCRAY2 */
! "reserved for Cray Research, Inc.", /* 31 SIGCRAY1 */
! "reserved for Cray Research, Inc.", /* 32 SIGCRAY0 */
(char *)0x0
};
diff -rc bashorig/version.h bash-1.03/version.h
*** bashorig/version.h Wed Oct 18 11:26:07 1989
--- bash-1.03/version.h Wed Oct 11 15:44:33 1989
***************
*** 2,7 ****
`make newversion' to the Makefile. It is created by newversion.aux. */
/* The distribution version number of this shell. */
! #define DISTVERSION 1.13
/* The last built version of this shell. */
! #define BUILDVERSION 0
--- 2,7 ----
`make newversion' to the Makefile. It is created by newversion.aux. */
/* The distribution version number of this shell. */
! #define DISTVERSION 1.03
/* The last built version of this shell. */
! #define BUILDVERSION 6
diff -rc bashorig/alloc-files/alloca.c bash-1.03/alloc-files/alloca.c
*** bashorig/alloc-files/alloca.c Wed Oct 18 11:26:03 1989
--- bash-1.03/alloc-files/alloca.c Tue Oct 10 14:01:06 1989
***************
*** 55,60 ****
--- 55,66 ----
extern void free();
extern pointer xmalloc();
+ #ifdef CRAY
+ extern int depth_on_entry;
+ static int call_depth;
+ #define INCR_CALL_DEPTH \
+ call_depth += (depth_on_entry == call_depth) ? 1 : 0
+ #endif
/*
Define STACK_DIRECTION if you know the direction of stack
***************
*** 93,99 ****
--- 99,109 ----
find_stack_direction (); /* recurse once */
}
else /* second entry */
+ #ifdef CRAY
+ if (getbytes (&dummy) > getbytes (addr))
+ #else
if (&dummy > addr)
+ #endif
stack_dir = 1; /* stack grew upward */
else
stack_dir = -1; /* stack grew downward */
***************
*** 140,147 ****
--- 150,165 ----
unsigned size; /* # bytes to allocate */
{
auto char probe; /* probes stack depth: */
+ #ifdef CRAY
+ register char *depth;
+ #else
register char *depth = &probe;
+ #endif
+ #ifdef CRAY
+ depth = (char *) call_depth;
+ #endif
+
#if STACK_DIRECTION == 0
if (STACK_DIR == 0) /* unknown growth direction */
find_stack_direction ();
***************
*** 179,186 ****
/* address of header */
((header *)new)->h.next = last_alloca_header;
((header *)new)->h.deep = depth;
!
last_alloca_header = (header *)new;
/* User storage begins just after header. */
--- 197,207 ----
/* address of header */
((header *)new)->h.next = last_alloca_header;
+ #ifdef CRAY
+ ((header *)new)->h.deep = (char *) call_depth;
+ #else
((header *)new)->h.deep = depth;
! #endif
last_alloca_header = (header *)new;
/* User storage begins just after header. */
Only in bash-1.03/alloc-files: alloca.c.orig
diff -rc bashorig/alloc-files/i386-alloca.s bash-1.03/alloc-files/i386-alloca.s
*** bashorig/alloc-files/i386-alloca.s Wed Oct 18 11:26:04 1989
--- bash-1.03/alloc-files/i386-alloca.s Tue Oct 10 14:01:06 1989
***************
*** 1,16 ****
- .file "alloca.s"
- .text
- .align 4
- .def alloca; .val alloca; .scl 2; .type 044; .endef
- .globl alloca
- alloca:
- popl %edx
- popl %eax
- addl $3,%eax
- andl $0xfffffffc,%eax
- subl %eax,%esp
- movl %esp,%eax
- pushl %eax
- pushl %edx
- ret
- .def alloca; .val .; .scl -1; .endef
--- 0 ----
Only in bash-1.03/alloc-files: i386-alloca.s.
diff -rc bashorig/alloc-files/malloc.c bash-1.03/alloc-files/malloc.c
*** bashorig/alloc-files/malloc.c Wed Oct 18 11:26:03 1989
--- bash-1.03/alloc-files/malloc.c Tue Oct 10 14:01:05 1989
***************
*** 127,132 ****
--- 127,151 ----
* Call malloc_stats to get info on memory stats if MSTATS turned on.
* realloc knows how to return same block given, just changing its size,
* if the power of 2 is correct.
+ *
+ * Aug 87, MJM: for Cray UNICOS
+ * If USE_LIBC-MALLOC is #defined, then just provide dummy interfaces
+ * for externals needed by emacs source code. This includes:
+ * int malloc_sbrk_used, int malloc_sbrk_unused;
+ * malloc_init (start, warnfun)
+ * malloc_stats () #ifdef MSTATS
+ * Cannot use GNU malloc.c with current Cray xmp C compiler because the
+ * calling sequence uses malloc (and mshrink) when passing large structures
+ * and cannot have a user program calling sbrk() or sbreak ().
+ * Only lose warning messages about running out of space and mstat stuff.
+ *
+ * Note: in src/alloc.c it says for example --
+ * Each cons_block is just under 1020 bytes long,
+ * since malloc really allocates in units of powers of two
+ * and uses 4 bytes for its own overhead.
+ * #define CONS_BLOCK_SIZE \
+ * ((1020 - sizeof (struct cons_block *)) / sizeof (struct Lisp_Cons))
+ * -- I think this is only for efficiency ???
*/
/*
***************
*** 144,153 ****
#include "config.h"
#endif /* emacs */
- #ifdef HPUX
- #define USG
- #endif
-
/* Determine which kind of system this is. */
#include <signal.h>
#ifndef SIGTSTP
--- 163,168 ----
***************
*** 182,191 ****
#endif
#endif
- #ifndef emacs
- #define start_of_data() &etext
- #endif
-
#define ISALLOC ((char) 0xf7) /* magic byte that implies allocation */
#define ISFREE ((char) 0x54) /* magic byte that implies free block */
/* this is for error checking only */
--- 197,202 ----
***************
*** 238,247 ****
(*(struct mhead **) (sizeof (char *) + (char *) (a)))
#ifdef rcheck
- #include <stdio.h>
- #ifndef botch
- #define botch(x) abort ()
- #endif
/* To implement range checking, we write magic values in at the beginning and
end of each allocated block, and make sure they are undisturbed whenever a
--- 249,254 ----
***************
*** 313,318 ****
--- 320,369 ----
return blocksize - sizeof (struct mhead) - EXTRA;
}
+ #ifdef USE_LIBC_MALLOC
+ malloc_check () /* called in alloc.c xmalloc(), xrealloc() */
+ {
+ char *sbrk ();
+ register char *cp;
+ register int siz;
+ extern char *start_of_data (); /* start of initialized data */
+
+ if (!data_space_start)
+ data_space_start = start_of_data ();
+ if (lim_data == 0)
+ get_lim_data ();
+
+ /* Find current end of memory and issue warning if getting near max */
+
+ cp = sbrk (0);
+ siz = cp - data_space_start;
+ malloc_sbrk_used = siz;
+ malloc_sbrk_unused = lim_data - siz;
+
+ if (warnfunction) /* malloc_init sets */
+ switch (warnlevel) {
+ case 0:
+ if (siz > (lim_data /4) * 3) {
+ warnlevel++;
+ (*warnfunction) ("Warning: past 75% of memory limit");
+ }
+ break;
+ case 1:
+ if (siz > (lim_data /20) * 17) {
+ warnlevel++;
+ (*warnfunction) ("Warning: past 85% of memory limit");
+ }
+ break;
+ case 2:
+ if (siz > (lim_data /20) * 19) {
+ warnlevel++;
+ (*warnfunction) ("Warning: past 95% of memory limit");
+ }
+ break;
+ }
+
+ }
+ #else USE_LIBC_MALLOC
static void
morecore (nu) /* ask system for more memory */
register int nu; /* size index to get more of */
***************
*** 323,328 ****
--- 374,383 ----
register unsigned int siz;
int oldmask;
+ #ifdef CRAY2
+ int bytes;
+ #endif
+
#ifdef BSD
#ifndef BSD4_1
oldmask = sigsetmask (-1);
***************
*** 380,387 ****
--- 435,448 ----
break;
}
+ #ifdef CRAY2
+ bytes = getbytes (cp);
+ if (bytes & 0x3ff) /* land on 1k boundaries */
+ sbrk (1024 - (bytes & 0xff));
+ #else
if ((int) cp & 0x3ff) /* land on 1K boundaries */
sbrk (1024 - ((int) cp & 0x3ff));
+ #endif /* CRAY2 */
#endif /* not VMS */
/* Take at least 2k, and figure out how many blocks of the desired size
***************
*** 393,403 ****
--- 454,466 ----
if ((cp = sbrk (1 << (siz + 3))) == (char *) -1)
return; /* no more room! */
#ifndef VMS
+ #ifndef CRAY
if ((int) cp & 7)
{ /* shouldn't happen, but just in case */
cp = (char *) (((int) cp + 8) & ~7);
nblks--;
}
+ #endif /* CRAY */
#endif /* not VMS */
/* save new header and link the nblks blocks together */
***************
*** 427,434 ****
char * sbrk ();
register char *cp = sbrk (0);
! if ((int) cp & 0x3ff) /* land on 1K boundaries */
! sbrk (1024 - ((int) cp & 0x3ff));
/* Record address of start of space allocated by malloc. */
if (_malloc_base == 0)
--- 490,504 ----
char * sbrk ();
register char *cp = sbrk (0);
! #ifdef CRAY2
! int bytes;
! bytes = getbytes (cp);
! if (bytes & 0x3ff) /* land on 1k boundaries */
! sbrk (1024 - (bytes & 0x3ff));
! #else
! if ((int) cp & 0x3ff) /* land on 1K boundaries */
! sbrk (1024 - ((int) cp & 0x3ff));
! #endif
/* Record address of start of space allocated by malloc. */
if (_malloc_base == 0)
***************
*** 545,563 ****
p = (struct mhead *) ap - 1;
}
- #ifndef rcheck
if (p -> mh_alloc != ISALLOC)
abort ();
! #else rcheck
! if (p -> mh_alloc != ISALLOC)
! {
! if (p -> mh_alloc == ISFREE)
! botch ("free: Called with already freed block argument\n");
! else
! botch ("free: Called with bad argument\n");
! }
!
ASSERT (p -> mh_magic4 == MAGIC4);
ap += p -> mh_nbytes;
ASSERT (*ap++ == MAGIC1); ASSERT (*ap++ == MAGIC1);
--- 615,624 ----
p = (struct mhead *) ap - 1;
}
if (p -> mh_alloc != ISALLOC)
abort ();
! #ifdef rcheck
ASSERT (p -> mh_magic4 == MAGIC4);
ap += p -> mh_nbytes;
ASSERT (*ap++ == MAGIC1); ASSERT (*ap++ == MAGIC1);
***************
*** 657,663 ****
--- 718,730 ----
if (ptr == 0)
return 0;
/* If entire block has the desired alignment, just accept it. */
+
+ #ifdef CRAY2
+ if (((long) ptr & (alignment - 1)) == 0)
+ #else
if (((int) ptr & (alignment - 1)) == 0)
+ #endif
+
return ptr;
/* Otherwise, get address of byte in the block that has that alignment. */
aligned = (char *) (((int) ptr + alignment - 1) & -alignment);
***************
*** 679,684 ****
--- 746,752 ----
return memalign (getpagesize (), size);
}
#endif /* not HPUX */
+ #endif USE_LIBC_MALLOC
#endif /* not VMS */
#ifdef MSTATS
***************
*** 731,738 ****
--- 799,815 ----
{
extern long ulimit ();
+ #ifdef CRAY
+ lim_data = (ulimit (3,0)) >> 3; /* convert to words */
+ #else
lim_data = ulimit (3, 0);
+ #endif
+
lim_data -= (long) data_space_start;
+
+ #ifdef CRAY
+ lim_data <<= 3; /* convert to bytes */
+ #endif
}
#else /* not USG */
***************
*** 759,764 ****
--- 836,856 ----
#endif /* BSD42 */
#endif /* not USG */
+
+ #ifdef CRAY
+ int getbytes (cp)
+ char *cp;
+ {
+ long tp;
+ int bytes, word;
+
+ tp = (long) cp;
+ bytes = tp >> 61;
+ word = tp & 037777777777;
+ bytes += (word <<3); /* multiply by 8 */
+ return (bytes);
+ }
+ #endif
#ifdef VMS
/* There is a problem when dumping and restoring things on VMS. Calls
***************
*** 831,833 ****
--- 923,972 ----
return temp;
}
#endif /* VMS */
+
+ /*
+ * Return the address of the start of the data segment prior to
+ * doing an unexec(). After unexec() the return value is undefined.
+ * See crt0.c for further information and definition of data_start.
+ *
+ * Apparently, on BSD systems this is etext at startup. On
+ * USG systems (swapping) this is highly mmu dependent and
+ * is also dependent on whether or not the program is running
+ * with shared text. Generally there is a (possibly large)
+ * gap between end of text and start of data with shared text.
+ *
+ * On Uniplus+ systems with shared text, data starts at a
+ * fixed address. Each port (from a given oem) is generally
+ * different, and the specific value of the start of data can
+ * be obtained via the UniPlus+ specific "uvar(2)" system call,
+ * however the method outlined in crt0.c seems to be more portable.
+ *
+ * Probably what will have to happen when a USG unexec is available,
+ * at least on UniPlus, is temacs will have to be made unshared so
+ * that text and data are contiguous. Then once loadup is complete,
+ * unexec will produce a shared executable where the data can be
+ * at the normal shared text boundry and the startofdata variable
+ * will be patched by unexec to the correct value.
+ *
+ */
+
+ char *
+ start_of_data ()
+ {
+ #ifdef DATA_START
+ return ((char *) DATA_START);
+ #else
+ #ifdef CRAY2
+ extern int zzzzzztx;
+ return ((char *) &zzzzzztx);
+ #else
+ #ifdef CRAY1
+ extern struct exec exec_hdr;
+ return ((char *) (exec_hdr.a_text));
+ #else
+ extern int data_start;
+ return ((char *) &data_start);
+ #endif
+ #endif
+ #endif
+ }
Only in bash-1.03/alloc-files: malloc.c.orig
diff -rc bashorig/readline/readline.c bash-1.03/readline/readline.c
*** bashorig/readline/readline.c Wed Oct 18 11:26:09 1989
--- bash-1.03/readline/readline.c Tue Oct 10 14:01:14 1989
***************
*** 35,40 ****
--- 35,41 ----
#include <fcntl.h>
#include <sys/file.h>
#include <signal.h>
+ #include <errno.h>
#ifdef __GNUC__
#define alloca __builtin_alloca
***************
*** 59,67 ****
#include <sys/stat.h>
#include <pwd.h>
! #ifdef SYSV
struct pwd *getpwuid (), *getpwent ();
#endif
#define HACK_TERMCAP_MOTION
--- 60,70 ----
#include <sys/stat.h>
#include <pwd.h>
! #if defined (SYSV) && !defined (CRAY)
struct pwd *getpwuid (), *getpwent ();
#endif
+
+ extern int errno; /* Not always in <errno.h>. Bogusness. */
#define HACK_TERMCAP_MOTION
--
Dave Mack McDonnell Douglas Electronic Systems
uunet!inco!mack, inco%mack@uunet.uu.net (703)883-3911
All opinions expressed are my own and do not reflect those of MDESC. Ever.
Technical Details
Message-ID:
<5712@inco.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!inco!mackReferences:
<1989Oct16.184048.20862@rpi.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!inco!mack From: mack@inco.UUCP (Dave Mack) Newsgroups: gnu.bash.bug Subject: Re: Bash on a 3b2/300 (Porting help needed) Message-ID: <5712@inco.UUCP> Date: 18 Oct 89 15:44:50 GMT References: <1989Oct16.184048.20862@rpi.edu> Reply-To: mack@inco.UUCP (Dave Mack) Organization: McDonnell Douglas Electronic Systems Co. McLean VA Lines: 1285