Skip to content

Commit

Permalink
Merge branch 'fricas:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanuxem authored Feb 4, 2025
2 parents c9c0257 + c8cb270 commit 89ea011
Show file tree
Hide file tree
Showing 18 changed files with 150 additions and 112 deletions.
16 changes: 16 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
2025-02-04 Waldek Hebisch <[email protected]>

* src/interp/i-map.boot: Fix multiple assignment in
interpreter functions

2025-02-03 Camm Maguire <[email protected]>

* src/include/com.h, src/lib/cfuns-c.c, src/lib/sockio-c.c,
src/lisp/fricas-lisp.lisp, src/lisp/fricas-package.lisp,
src/lisp/primitives.lisp, src/lisp/Makefile.in,
src/interp/foam_l.lisp, src/interp/i-funsel.boot,
src/interp/i-toplev.boot, src/interp/lisplib.boot,
src/interp/macros.lisp, src/interp/nlib.lisp,
src/interp/util.lisp, src/interp/vmlisp.lisp: Update
GCL support

2025-01-28 Waldek Hebisch <[email protected]>

* src/algebra/intpar.spad: Add check for no solution
Expand Down
11 changes: 10 additions & 1 deletion src/include/com.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,16 @@ typedef struct {

/* table of dedicated socket types */

#ifndef GCL_SOURCE
#define STATIC
extern Sock *purpose_table[];
extern Sock server[];
extern Sock clients[];
extern fd_set socket_mask;
extern fd_set server_mask;
#else
#define STATIC static
#endif

/* Commands sent over the FRICAS session manager or menu socket */

Expand Down Expand Up @@ -160,7 +165,11 @@ fricas_write(Sock* s, const char* buf, size_t n)
static inline int
fricas_read(Sock* s, char* buf, size_t n)
{
return recv(s->socket, buf, n, 0);
#ifdef GCL_SOURCE
return read(s->socket, buf, n);
#else
return recv(s->socket, buf, n, 0);
#endif
}

#endif
8 changes: 7 additions & 1 deletion src/interp/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ makeint.lisp: ../boot/lobj_lst
@ echo '#+:GCL (si::gbc-time 0)' >> makeint.lisp

${SAVESYS}:
echo '(load "makeint.lisp") #-:ecl(BOOT::reclaim)' \
echo '#+gcl(setq si::*optimize-maximum-pages* nil)' \
'(load "makeint.lisp") #-:ecl(BOOT::reclaim)' \
'#+:ecl(FRICAS-LISP::make-program "$(BASE)$@" nil)' \
'#+:gcl(progn (setq si::*code-block-reserve* "")(si::gbc t)(setq si::*code-block-reserve* (make-array 10000000 :element-type (quote character) :static t) si::*optimize-maximum-pages* t))' \
'#-:ecl(BOOT::spad-save "$(BASE)$@" t)' | \
DAASE='$(fricas_src_datadir)' ${BOOTSYS}
ls $@
Expand All @@ -153,7 +155,11 @@ all-fricassys: ${FRICASSYS}

${FRICASSYS}: ../etc/stamp-databases
echo '(defparameter FRICAS-LISP::*building-fricassys* t)' \
'#+gcl(setq si::*optimize-maximum-pages* nil)' \
'(load "makeint.lisp") #-:ecl(BOOT::reclaim)' \
'#+:gcl(progn (setq si::*code-block-reserve* "")(si::gbc t)(setq si::*code-block-reserve* (make-array 10000000 :element-type (quote character) :static t) si::*optimize-maximum-pages* t))' \
'#+:cmu (setf (ext:search-list "libspad:")' \
'(list "${FRICAS}/lib/" "${libdir}/fricas/target/${target}/lib/"))' \
'#+:cmu (setq ext:*top-level-auto-declare* t)' \
'#+:cmu (setq *compile-verbose* nil)' \
'#+:cmu (setq *compile-print* nil)' \
Expand Down
6 changes: 0 additions & 6 deletions src/interp/foam_l.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,10 @@
(deftype |HInt| () '(integer #.(- (expt 2 15)) #.(1- (expt 2 15))))
(deftype |SInt| () '(integer #.(- (expt 2 31)) #.(1- (expt 2 31))))

#+:GCL
(deftype |BInt| () t)
#-:GCL
(deftype |BInt| () 'integer)

(deftype |SFlo| () 'short-float)

#+:GCL
(deftype |DFlo| () t)
#-:GCL
(deftype |DFlo| () 'double-float)

(deftype |Level| () t) ;; structure??
Expand Down
2 changes: 1 addition & 1 deletion src/interp/i-funsel.boot
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ orderMmCatStack st ==
if not mem then haventvars := cons(s,haventvars)
null havevars => st
st := nreverse nconc(haventvars,havevars)
SORT(st, function mmCatComp)
STABLE_-SORT(st, function mmCatComp)

mmCatComp(c1, c2) ==
b1 := ASSQ(CADR c1, $Subst)
Expand Down
5 changes: 4 additions & 1 deletion src/interp/i-map.boot
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,10 @@ genMapCode(op,body,sig,fnName,parms,isRecursive) ==
locals := SETDIFFERENCE(COPY $localVars, parms)
if locals then
lets := [['LET, l, ''UNINITIALIZED__VARIABLE, op] for l in locals]
-- we should have more sensible $localVars, but ATM just skip
-- non-symbols
lets := [['LET, l, ''UNINITIALIZED__VARIABLE, op] for l in locals
| SYMBOLP(l)]
body := ['PROGN, :lets, body]
reportFunctionCompilation(op,fnName,parms,
Expand Down
2 changes: 1 addition & 1 deletion src/interp/i-toplev.boot
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ from scratch.
$spadroot := '""

-- Prefix a filename with the {\bf |$spadroot|} variable.
make_absolute_filename(name) == STRCONC($spadroot, '"/", name)
make_absolute_filename(name) == append_directory_name($spadroot,name)

reroot(dir) ==
$spadroot := dir
Expand Down
2 changes: 1 addition & 1 deletion src/interp/lisplib.boot
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ mkEvalableCategoryForm(c, e) == --from DEFINE
c is [op,:argl] =>
op="Join" =>
nargs := [mkEvalableCategoryForm(x, e) or return nil for x in argl]
nargs => ["Join", :nargs]
nargs => ["JoinInner", ["LIST", :nargs]]
op is "DomainSubstitutionMacro" =>
mkEvalableCategoryForm(CADR argl, e)
op is "mkCategory" => c
Expand Down
3 changes: 0 additions & 3 deletions src/interp/macros.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,10 @@ This function respects intermediate #\Newline characters and drops
*standard-output*))
(*compile-verbose* nil))
(declare (special |$comp370_apply|))
#-:GCL
(handler-bind ((warning #'muffle-warning)
#+:sbcl (sb-ext::compiler-note #'muffle-warning))
(funcall driver fn)
)
#+:GCL
(funcall driver fn)
))

(defun |compQuietly| (fn)
Expand Down
7 changes: 2 additions & 5 deletions src/interp/nlib.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@
;; E.g. "/" "/u/smwatt" "../src"
(defun |DirToString| (d)
(cond
((equal d '(:root)) "/")
((equal d '(:absolute)) "/")
((null d) "")
('t (string-right-trim "/" (namestring (make-pathname :directory d)))) ))

(defun |StringToDir| (s)
(cond
((string= s "/") '(:root))
((string= s "/") '(:absolute))
((string= s "") nil)
('t
(let ((lastc (aref s (- (length s) 1))))
Expand Down Expand Up @@ -288,10 +288,7 @@

(defun |fnameReadable?| (f)
(let ((s
#-:GCL
(ignore-errors (open f :direction :input :if-does-not-exist nil))
#+:GCL
(open f :direction :input :if-does-not-exist nil)
))
(cond (s (close s) 't) ('t nil)) )
)
Expand Down
3 changes: 0 additions & 3 deletions src/interp/util.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,9 @@ After this function is called the image is clean and can be saved.
(apply cname args))))

(defun |eval|(x)
#-:GCL
(handler-bind ((warning #'muffle-warning)
#+:sbcl (sb-ext::compiler-note #'muffle-warning))
(eval x))
#+:GCL
(eval x)
)

;;; For evaluating categories we need to bind %.
Expand Down
29 changes: 16 additions & 13 deletions src/interp/vmlisp.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@
; 14.1 Creation

;;; needed for SPAD compiler output
(define-function '|construct| #'list)
#-gcl(define-function '|construct| #'list)
#+gcl(define-function '|construct| #'cl::list)

(defun VEC2LIST (vec) (coerce vec 'list))

Expand Down Expand Up @@ -289,19 +290,9 @@

(defun GETZEROVEC (n) (MAKE-ARRAY n :initial-element 0))

#-:GCL
(defun LIST2VEC (list) (coerce list 'vector))

;;; At least in gcl 2.6.8 coerce is slow, so we roll our own version
#+:GCL
(defun LIST2VEC (list)
(if (consp list)
(let* ((len (length list))
(vec (make-array len)))
(dotimes (i len)
(setf (aref vec i) (pop list)))
vec)
(coerce list 'vector)))


(define-function 'LIST2REFVEC #'LIST2VEC)
Expand Down Expand Up @@ -673,8 +664,20 @@
#+:poplog
(defun reclaim () nil)


#+(OR IBCL KCL)
#+gcl
(defun BPINAME (func)
(typecase func
(symbol func)
((cons (eql lambda-block) t) (cadr func))
(function
(cond (#.(fboundp 'function-lambda-expression)
(multiple-value-bind (x y z) (function-lambda-expression func)
(or (and (symbolp z) (fboundp z) z) func)))
((compiled-function-p func)
(system:compiled-function-name func))
(func)))))

#+(OR IBCL)
(defun BPINAME (func)
(if (functionp func)
(cond ((symbolp func) func)
Expand Down
28 changes: 15 additions & 13 deletions src/lib/cfuns-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "cfuns-c.H1"

#ifdef GCL_SOURCE
#undef HOST_HAS_DIRFD_FCHDIR
#endif

/* Most versions of Windows don't have the POSIX functions getuid(),
geteuid(), getgid(), and getegid(). The following definitions are
approximations, to patch for the deficiencies of Windows
Expand Down Expand Up @@ -193,7 +197,7 @@ static char * fricas_copy_string(char *str)
if (res) {
strcpy(res, str);
} else {
fprintf(stderr, "Malloc failed (fricas_copy_string)\n");
perror("Malloc failed (fricas_copy_string)\n");
}
return res;
}
Expand All @@ -217,25 +221,25 @@ remove_directory(char * name)
struct file_list * flst = 0;
#ifdef HOST_HAS_DIRFD_FCHDIR
if (!cur_dir) {
fprintf(stderr, "Unable to open current directory\n");
perror("Unable to open current directory\n");
return -1;
}
#else
if (name_len > INT_MAX/5) {
fprintf(stderr, "directory name too long\n");
perror("directory name too long\n");
return -1;
}
#endif
dir = opendir(name);
if (!dir) {
fprintf(stderr, "Unable to open directory to be removed\n");
perror("Unable to open directory to be removed\n");
goto err1;
}
#ifdef HOST_HAS_DIRFD_FCHDIR
cur_dir_fd = dirfd(cur_dir);
dir_fd = dirfd(dir);
if (cur_dir_fd == -1 || dir_fd == -1) {
fprintf(stderr, "dirfd failed\n");
perror("dirfd failed\n");
goto err2;
}
#endif
Expand All @@ -251,7 +255,7 @@ remove_directory(char * name)
} else {
struct file_list * npos = malloc(sizeof(*npos));
if (!npos) {
fprintf(stderr, "Malloc failed (npos)\n");
perror("Malloc failed (npos)\n");
break;
}
npos->file = fricas_copy_string(fname);
Expand Down Expand Up @@ -284,14 +288,12 @@ remove_directory(char * name)
#else
char pathbuf[PATH_MAX];
if (strlen(flst->file) + name_len + 1 < PATH_MAX) {
strcpy(pathbuf, name);
strcat(pathbuf, "/");
strcat(pathbuf, flst->file);
if (unlink(pathbuf)) {
perror("Unlink failed");
}
snprintf(pathbuf,sizeof(pathbuf),"%s/%s",name,flst->file);
if (unlink(pathbuf)) {
perror("Unlink failed");
}
} else {
fprintf(stderr, "panthname too long\n");
perror("pathname too long\n");
}
#endif
free(flst->file);
Expand Down
Loading

0 comments on commit 89ea011

Please sign in to comment.