Skip to content

Commit

Permalink
crudely patched to run on OpenBSD (which was broken by dyn lib patches)
Browse files Browse the repository at this point in the history
  • Loading branch information
William Harold Newman committed Oct 2, 2000
1 parent d4aacd8 commit 3aba915
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 19 deletions.
2 changes: 2 additions & 0 deletions BUGS
Expand Up @@ -802,3 +802,5 @@ Error in function C::GET-LAMBDA-TO-COMPILE:
(This is particularly annoying because several Lisp functions like
PRINT *precede* their output with a newline, instead of following
it with a newline.)

* (SUBTYPEP '(AND ZILCH INTEGER) 'ZILCH) => NIL, NIL
3 changes: 3 additions & 0 deletions NEWS
Expand Up @@ -493,6 +493,9 @@ changes in sbcl-0.6.8 relative to sbcl-0.6.7:
have been added.
* Raymond Wiker's patches to port dynamic loading from Linux to
FreeBSD have been added.
?? $Header$ and other CVS tags have been removed from the sources,
because they have never saved me trouble and they've been a
nuisance working with patches and other diff-related operations.
?? The debugger now flushes standard output streams before it begins
its output ("debugger invoked" and so forth).
?? FINISH-OUTPUT now works better than it did before. (It used to
Expand Down
42 changes: 31 additions & 11 deletions src/code/run-program.lisp
Expand Up @@ -22,7 +22,7 @@
(options sb-c-call:int)
(rusage sb-c-call:int))

(eval-when (load eval compile)
(eval-when (:compile-toplevel :load-toplevel :execute)
(defconstant wait-wnohang #-svr4 1 #+svr4 #o100)
(defconstant wait-wuntraced #-svr4 2 #+svr4 4)
(defconstant wait-wstopped #-svr4 #o177 #+svr4 wait-wuntraced))
Expand Down Expand Up @@ -213,13 +213,18 @@

#+FreeBSD
(def-alien-type nil
(struct sgttyb
(sg-ispeed sb-c-call:char) ; input speed
(sg-ospeed sb-c-call:char) ; output speed
(sg-erase sb-c-call:char) ; erase character
(sg-kill sb-c-call:char) ; kill character
(sg-flags sb-c-call:short) ; mode flags
))
(struct sgttyb
(sg-ispeed sb-c-call:char) ; input speed
(sg-ospeed sb-c-call:char) ; output speed
(sg-erase sb-c-call:char) ; erase character
(sg-kill sb-c-call:char) ; kill character
(sg-flags sb-c-call:short))) ; mode flags
#+OpenBSD
(def-alien-type nil
(struct sgttyb
(sg-four sb-c-call:int)
(sg-chars (array sb-c-call:char 4))
(sg-flags sb-c-call:int)))

;;; Find a pty that is not in use. Return three values: the file
;;; descriptor for the master side of the pty, the file descriptor for
Expand All @@ -238,17 +243,32 @@
sb-unix:o_rdwr
#o666)))
(when slave-fd
; Maybe put a vhangup here?
#-linux
;; comment from classic CMU CL:
;; Maybe put a vhangup here?
;;
;; FIXME: It seems as though this logic should be in
;; OPEN-PTY, not FIND-A-PTY (both from the comments
;; documenting DEFUN FIND-A-PTY, and from the
;; connotations of the function names).
;;
;; FIXME: It would be nice to have a note, and/or a pointer
;; to some reference material somewhere, explaining
;; why we need this on *BSD and not on Linux.
#+bsd
(sb-alien:with-alien ((stuff (sb-alien:struct sgttyb)))
(let ((sap (sb-alien:alien-sap stuff)))
(sb-unix:unix-ioctl slave-fd sb-unix:TIOCGETP sap)
(setf (sb-alien:slot stuff 'sg-flags)
#o300) ; EVENP|ODDP
;; This is EVENP|ODDP, the same numeric code
;; both on FreeBSD and on OpenBSD. -- WHN 20000929
#o300) ; EVENP|ODDP
(sb-unix:unix-ioctl slave-fd sb-unix:TIOCSETP sap)
(sb-unix:unix-ioctl master-fd sb-unix:TIOCGETP sap)
(setf (sb-alien:slot stuff 'sg-flags)
(logand (sb-alien:slot stuff 'sg-flags)
;; This is ~ECHO, the same numeric
;; code both on FreeBSD and on OpenBSD.
;; -- WHN 20000929
(lognot 8))) ; ~ECHO
(sb-unix:unix-ioctl master-fd sb-unix:TIOCSETP sap)))
(return-from find-a-pty
Expand Down
2 changes: 1 addition & 1 deletion src/code/unix.lisp
Expand Up @@ -979,8 +979,8 @@
(def-unix-error ESRCH 3 "No such process")
|#
(def-unix-error EINTR 4 "Interrupted system call")
#|
(def-unix-error EIO 5 "I/O error")
#|
(def-unix-error ENXIO 6 "No such device or address")
(def-unix-error E2BIG 7 "Arg list too long")
(def-unix-error ENOEXEC 8 "Exec format error")
Expand Down
2 changes: 2 additions & 0 deletions src/cold/warm.lisp
Expand Up @@ -202,7 +202,9 @@
"src/code/inspect" ; FIXME: should be byte compiled
"src/code/profile"
"src/code/ntrace"
#+nil ; REMOVEME (for debugging 0.6.7.6 on OpenBSD only)
"src/code/foreign"
#+nil ; REMOVEME (for debugging 0.6.7.6 on OpenBSD only)
"src/code/run-program"
;; Code derived from PCL's pre-ANSI DESCRIBE-OBJECT
;; facility is still used in our ANSI DESCRIBE
Expand Down
9 changes: 4 additions & 5 deletions src/compiler/x86/parms.lisp
Expand Up @@ -125,17 +125,16 @@
;;; Note: Mostly these values are black magic, inherited from CMU CL
;;; without any documentation. However, there have been a few changes
;;; since the fork:
;;; * The non-Linux *TARGET-STATIC-SPACE-START* value was bumped up
;;; from #x28000000 to #x30000000 when non-Linux ld.so dynamic linking
;;; * The FreeBSD *TARGET-STATIC-SPACE-START* value was bumped up
;;; from #x28000000 to #x30000000 when FreeBSD ld.so dynamic linking
;;; support was added for FreeBSD ca. 20000910. This was to keep from
;;; stomping on an address range that the dynamic libraries want to use.
;;; (They want to use this address range even if we try to reserve it
;;; with a call to validate() as the first operation in main().)
#!-linux (defparameter *target-read-only-space-start* #x10000000)
#!-linux (defparameter *target-static-space-start*
;; FIXME: was #x28000000 until RAW's RUN-PROGRAM
;; patches, why the change?
#x30000000)
#!+freebsd #x30000000
#!+openbsd #x28000000)
#!-linux (defparameter *target-dynamic-space-start* #x48000000)
#!+linux (defparameter *target-read-only-space-start* #x01000000)
#!+linux (defparameter *target-static-space-start* #x05000000)
Expand Down
5 changes: 4 additions & 1 deletion src/runtime/Config.x86-bsd
Expand Up @@ -16,7 +16,10 @@ OS_SRC = bsd-os.c os-common.c undefineds.c
# worked fine for most things, but LOAD-FOREIGN & friends require
# dlopen() etc., which in turn depend on dynamic linking of the
# runtime.
OS_LINK_FLAGS=-dynamic -export-dynamic
#for OpenBSD:
OS_LINK_FLAGS=-static
#for FreeBSD:
#OS_LINK_FLAGS=-dynamic -export-dynamic
OS_LIBS=-lm # -ldl

GC_SRC= gencgc.c
12 changes: 12 additions & 0 deletions src/runtime/bsd-os.c
Expand Up @@ -245,6 +245,10 @@ os_install_interrupt_handlers(void)
}

#endif /* !defined GENCGC */

/*
* stuff to help work with dynamically linked libraries
*/

/* feh!
*
Expand All @@ -254,7 +258,15 @@ os_install_interrupt_handlers(void)
* sbcl.nm).
*
* FIXME: This flag should be set in Config.bsd */
#if defined __FreeBSD__
#define DL_WORKAROUND 1
#elif defined __OpenBSD__
/* SBCL doesn't (yet?) work at all with dynamic libs on OpenBSD, so we
* wouldn't get any use out of these stubs. -- WHN 20001001 */
#define DL_WORKAROUND 0
#else
#error unsupported BSD variant
#endif

#if DL_WORKAROUND
#include <unistd.h>
Expand Down
11 changes: 11 additions & 0 deletions src/runtime/x86-validate.h
Expand Up @@ -27,6 +27,9 @@
* 0x48000000->0xC8000000 2GB Dynamic Space.
* 0xE0000000-> 256M C stack - Alien stack.
*
* OpenBSD:
* almost the same as FreeBSD
*
* Linux: Note that this map has some problems and requires some further
* development so is not implemented below.
* 0x00000000->0x08000000 128M Unused.
Expand All @@ -47,8 +50,16 @@
#define READ_ONLY_SPACE_START (0x10000000)
#define READ_ONLY_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */

#if defined __FreeBSD__
#define STATIC_SPACE_START (0x30000000)
#define STATIC_SPACE_SIZE (0x07fff000) /* 128M - 1 page */
#elif defined __OpenBSD__
#define STATIC_SPACE_START (0x28000000)
#define STATIC_SPACE_SIZE (0x0ffff000) /* 256M - 1 page */
#else
#error unsupported BSD variant
#endif


#define BINDING_STACK_START (0x38000000)
#define BINDING_STACK_SIZE (0x07fff000) /* 128MB - 1 page */
Expand Down
2 changes: 1 addition & 1 deletion version.lisp-expr
Expand Up @@ -15,4 +15,4 @@
;;; versions, and a string a la "0.6.5.12" is used for versions which
;;; aren't released but correspond only to CVS tags or snapshots.

"0.6.7.5"
"0.6.7.6"

0 comments on commit 3aba915

Please sign in to comment.