Skip to content

Commit c92d979

Browse files
committed
additions and corrections in connection with spocq sae development.
remove implicity prerequisute loading leaving it instead to explicit build process. bsd: added getpid, syslog codecs/etf : generalize the transformation hooks to allow sse/bert/etf layered codecs; add interface operators encode/decode-bert-term lock : make-weak-hash-table mime/ : add binary abstract type to support stream-reader/writer distinctions test/rspec/ : further rspec.rd -> sbcl testing; add specials for streams
1 parent a5e85b4 commit c92d979

17 files changed

+394
-173
lines changed

bsd/bsd.lisp

+59-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
(:use :common-lisp :ccl)
6262
(:nicknames :bsd)
6363
(:export :*run-command-eol*
64+
:closelog
6465
:gethostname
6566
:popen
6667
:pclose
@@ -71,14 +72,17 @@
7172
:file-bsd-namestring
7273
:file-mac-namestring
7374
:getenv
75+
:getpid
76+
:openlog
7477
:pipe-input-stream
7578
:pipe-io-stream
7679
:pipe-output-stream
80+
:syslog
7781
:with-popen)
7882
(:documentation
7983
"The `:de.setf.utility.bsd` library component implements low-level support for a limited number
8084
of 'Berkeley' UNIX library primitive operators:
81-
- getenv
85+
- getenv, getpid
8286
- gethostname
8387
- popen
8488
- pclose
@@ -144,6 +148,10 @@
144148
;;; FFI
145149

146150
(eval-when (:compile-toplevel :load-toplevel :execute)
151+
(deftrap-inline "_closelog"
152+
()
153+
nil
154+
())
147155
(deftrap-inline "_feof"
148156
((file-pointer :pointer))
149157
:signed-word
@@ -166,11 +174,21 @@
166174
((string :pointer))
167175
:pointer
168176
())
177+
(deftrap-inline "_getpid"
178+
()
179+
:unsigned-word
180+
())
169181
(deftrap-inline "_gethostname"
170182
((returnArg :pointer)
171183
(length :unsigned-long))
172184
:unsigned-long
173185
())
186+
(deftrap-inline "_openlog"
187+
((string :pointer)
188+
(options :unsigned-word)
189+
(facility :unsigned-word))
190+
()
191+
())
174192
(deftrap-inline "_pclose"
175193
((file :pointer))
176194
:signed-word
@@ -179,6 +197,12 @@
179197
((command :pointer)
180198
(mode :pointer))
181199
:pointer
200+
())
201+
(deftrap-inline "_syslog"
202+
((priority :unsigned-word)
203+
(format :pointer)
204+
(message :pointer))
205+
()
182206
()))
183207

184208

@@ -188,6 +212,9 @@
188212
(unless (ccl:%null-ptr-p %value)
189213
(ccl:%get-cstring %value)))))
190214

215+
(defun bsd:getpid ()
216+
(#_getpid))
217+
191218

192219
(defun bsd:gethostname ()
193220
"Return the system hostname as a string.
@@ -291,6 +318,37 @@
291318
(#_fwrite %buffer length 1 %file))))
292319

293320

321+
;;; syslog
322+
;;;
323+
;;; facility
324+
(defparameter log-user (ash 1 3))
325+
(defparameter log-daemon (ash 3 3))
326+
327+
;;; level
328+
(defparameter log-emerg 0)
329+
(defparameter log-alert 1)
330+
(defparameter log-crit 2)
331+
(defparameter log-err 3)
332+
(defparameter log-warning 4)
333+
(defparameter log-notice 5)
334+
(defparameter log-info 6)
335+
(defparameter log-debug 7)
336+
337+
;;; interface
338+
(defun closelog ()
339+
(#_closelog))
340+
341+
(defun openlog (identity options &optional (facility log-user))
342+
(ccl:with-cstrs ((%identity identity))
343+
(#_openlog %identity options facility)))
344+
345+
(defun syslog (priority format &rest args)
346+
(ccl:with-cstrs ((%format (apply #'format nil format args))
347+
(%cformat "%s"))
348+
(#_syslog priority %cformat %format)))
349+
350+
;;; external commands
351+
294352
(defun bsd:run-command (program &rest args)
295353
"run a unix command and return the standard output as a string.
296354

build-init.lisp

+37-6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
*load-truename*
3636
*default-pathname-defaults*
3737
(error "Indeterminate load pathname...")))
38+
3839
(setq *build-init-pathname* (truename *build-init-pathname*))
3940

4041
(when *load-verbose*
@@ -44,6 +45,16 @@
4445
;;; load the production asdf version for building images
4546
;;; in a dev tree, this mens to go upwards to look for the production tree
4647

48+
(defun compile-and-load-file (source-pathname)
49+
(let ((binary-pathname (compile-file-pathname source-pathname)))
50+
(if (probe-file binary-pathname)
51+
(if (probe-file source-pathname)
52+
(if (> (file-write-date binary-pathname) (file-write-date source-pathname))
53+
(load binary-pathname)
54+
(load (compile-file source-pathname)))
55+
(load binary-pathname))
56+
(load (compile-file source-pathname)))))
57+
4758
(defparameter *asdf-pathname*
4859
(make-pathname :directory (append (pathname-directory *build-init-pathname*)
4960
'("net" "common-lisp" "asdf"))
@@ -55,26 +66,46 @@
5566
(cond ((probe-file *asdf-pathname*)
5667
(when *load-verbose*
5768
(format *trace-output* "~&;Incorporating asdf anew from ~s." *asdf-pathname*))
58-
(load (compile-file *asdf-pathname*))
69+
(compile-and-load-file *asdf-pathname*)
5970
#+ecl
60-
(load (compile-file (make-pathname :name "asdf-ecl" :defaults *asdf-pathname*))))
71+
(compile-and-load-file (make-pathname :name "asdf-ecl" :defaults *asdf-pathname*)))
6172
(t
6273
(cerror "Continue anyway." "ASDF is missing: ~s." *asdf-pathname*))))
6374

6475

6576
;;;
6677
;;; incorporate support for hierarchical names
67-
#+(or :clozure :allegro sbcl) ;; for now
78+
79+
#+(or :clozure :allegro :sbcl) ;; for now
6880
(unless (fboundp (find-symbol (string :sysdef-hierarchical-search-function) :asdf))
69-
(loop for (path name) in '((("de" "setf" "utility") "pathnames")
81+
(loop for (path name) in '((("de" "setf" "utility") "package")
82+
(("de" "setf" "utility") "pathnames")
7083
(("de" "setf" "utility" "asdf") "hierarchical-names"))
7184
do (let ((pathname (make-pathname :directory (append (pathname-directory *build-init-pathname*) path)
7285
:name name :type "lisp"
7386
:defaults *build-init-pathname*)))
7487
(if (probe-file pathname)
75-
(load pathname)
88+
(compile-and-load-file pathname)
7689
(cerror "Continue anyway." "Hierarchical name component is missing: ~s." pathname)))))
7790

91+
;;;
92+
;;; define logical hosts for the dev sources and, optionally, production sources
93+
94+
(or (ignore-errors (logical-pathname-translations "LIBRARY"))
95+
(de.setf.utility:define-library-host *build-init-pathname* "LIBRARY"))
96+
97+
;; nb. clisp neither merges :up relative pathnames, nor (by default) correctly parses logical namestrings
98+
(or (ignore-errors (logical-pathname-translations "P-LIBRARY"))
99+
(let* ((library (truename (make-pathname :host "LIBRARY" :directory '(:absolute))))
100+
(production (make-pathname :directory (substitute "production" "dev"
101+
(pathname-directory *build-init-pathname*)
102+
:test #'string-equal)
103+
:name nil :type nil :defaults *build-init-pathname*)))
104+
(when (and (#-clisp probe-file #+clisp ext:probe-directory production)
105+
(not (equalp production library)))
106+
(de.setf.utility:define-library-host production "P-LIBRARY"))))
107+
108+
78109

79110
;;;
80111
;;; augment the asdf central registry.
@@ -87,7 +118,7 @@
87118
(when (#-clisp probe-file #+clisp probe-directory pathname)
88119
(pushnew (truename pathname) asdf:*central-registry* :test #'equalp)))
89120
(list (make-pathname :directory (append (pathname-directory *build-init-pathname*)
90-
'("asdf-registry"))
121+
'("asdf-registry"))
91122
:defaults *build-init-pathname*)
92123
*build-init-pathname*))
93124

0 commit comments

Comments
 (0)