/[cmucl]/src/code/foreign.lisp
ViewVC logotype

Diff of /src/code/foreign.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by wlott, Mon Mar 2 02:27:23 1992 UTC revision 1.11 by ram, Wed Mar 4 18:15:41 1992 UTC
# Line 13  Line 13 
13  ;;;  ;;;
14  (in-package "SYSTEM")  (in-package "SYSTEM")
15    
16  (in-package "EXT")  (in-package "ALIEN")
17  (export '(load-foreign))  (export '(load-foreign))
18  (in-package "SYSTEM")  (in-package "SYSTEM")
19  (import 'ext:load-foreign)  (import 'alien:load-foreign)
20    
21  (defvar *previous-linked-object-file* nil)  (defvar *previous-linked-object-file* nil)
22  (defvar *foreign-segment-free-pointer* foreign-segment-start)  (defvar *foreign-segment-free-pointer* foreign-segment-start)
# Line 164  Line 164 
164              (setf (gethash symbol symbol-table) address)))))              (setf (gethash symbol symbol-table) address)))))
165      (setf lisp::*foreign-symbols* symbol-table)))      (setf lisp::*foreign-symbols* symbol-table)))
166    
167  (defun load-foreign (files &optional  (defun load-foreign (files &key
168                             (libraries '("-lc"))                             (libraries '("-lc"))
                            (linker "library:load-foreign.csh")  
169                             (base-file "path:lisp")                             (base-file "path:lisp")
170                             (env ext:*environment-list*))                             (env ext:*environment-list*))
171    "Load-foreign loads a list of C object files into a running Lisp.  The    "Load-foreign loads a list of C object files into a running Lisp.  The files
172    files argument should be a single file or a list of files.  The files    argument should be a single file or a list of files.  The files may be
173    may be specified as namestrings or as pathnames.  The libraries    specified as namestrings or as pathnames.  The libraries argument should be a
174    argument should be a list of library files as would be specified to    list of library files as would be specified to ld.  They will be searched in
175    ld.  They will be searched in the order given.  The default is just    the order given.  The default is just \"-lc\", i.e., the C library.  The
176    \"-lc\", i.e., the C library.  The linker argument is used to specifier    base-file argument is used to specify a file to use as the starting place for
177    the Unix linker to use to link the object files (the default is    defined symbols.  The default is the C start up code for Lisp.  The env
178    /usr/cs/bin/ld).  The base-file argument is used to specify a file to    argument is the Unix environment variable definitions for the invocation of
179    use as the starting place for defined symbols.  The default is the C    the linker.  The default is the environment passed to Lisp."
   start up code for Lisp.  The env argument is the Unix environment  
   variable definitions for the invocation of the linker.  The default is  
   the environment passed to Lisp."  
180    (let ((output-file (pick-temporary-file-name))    (let ((output-file (pick-temporary-file-name))
181          (symbol-table-file (pick-temporary-file-name))          (symbol-table-file (pick-temporary-file-name))
182          (error-output (make-string-output-stream)))          (error-output (make-string-output-stream)))
183    
184      (format t ";;; Running ~A...~%" linker)      (format t ";;; Running library:load-foreign.csh...~%")
185      (force-output)      (force-output)
186      (let ((proc (ext:run-program linker      (let ((proc (ext:run-program "library:load-foreign.csh"
187                                   (list* (or *previous-linked-object-file*                                   (list* (or *previous-linked-object-file*
188                                              (namestring (truename base-file)))                                              (namestring (truename base-file)))
189                                          (format nil "~X"                                          (format nil "~X"
# Line 203  Line 199 
199                                   :output error-output                                   :output error-output
200                                   :error :output)))                                   :error :output)))
201        (unless proc        (unless proc
202          (error "Could not run ~S" linker))          (error "Could not run library:load-foreign.csh"))
203        (unless (zerop (ext:process-exit-code proc))        (unless (zerop (ext:process-exit-code proc))
204          (system:serve-all-events 0)          (system:serve-all-events 0)
205          (error "~S failed:~%~A"          (error "library:load-foreign.csh failed:~%~A"
206                 linker (get-output-stream-string error-output)))                 (get-output-stream-string error-output)))
207        (load-object-file output-file)        (load-object-file output-file)
208        (parse-symbol-table symbol-table-file)        (parse-symbol-table symbol-table-file)
209        (unix:unix-unlink symbol-table-file)        (unix:unix-unlink symbol-table-file)

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.5