gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] axiom extensions


From: Camm Maguire
Subject: [Gcl-devel] axiom extensions
Date: Wed, 30 Jul 2014 16:01:27 -0400

Greetings!

Congratulations on the release, Tim!  I was working on a patch to
suggest, but you beat me to the gates!

Might I be granted write access to some branch in git?

I have been unable to reproduce the protect failure so far.  The 1.8
machine showed a different issue, which has now been resolved.  These
all pertain to differences in compiler versions.  I will try shortly on
a Debian i386 porterbox.

As I mentioned earlier, while compiler::link is working, I would like to
suggest that we migrate to a simpler method of handling the axiom
extensions.  I have a working prototype on your machines.  The basic
idea is to include (clines "#include \"cfuns-c.c\"") at the top of
cfuns.lisp and similar for sockio.lisp, and compile-file and load as
normal.  This requires a few very minor changes to GCL and the -c.c
extension files, but presents the following advantages:

1) all axiom objects are compiled and loaded in the same way

2) it does not depend on gcl externally shipping its link libraries, as
it does now.  This was to support a much more complicated method of
supporting maxima, axiom, and acl2 on machines on which gcl could not
natively relocate binaries, which I'm happy to announce is now
obsolete.  All supported gcl targets have the #+native-reloc feature at
present.  We will continue to ship these libraries for compatibility
reasons for the foreseeable future, but the original motivation, the
dlopen link option, like bfd, is now deprecated, custreloc being the
universal default.
  
3) it does not open a hole for ld to undo what gcl and unexec have
done.  Some care is taken, for example, to eliminate any non-PIC
references to variables in external shared libraries to support prelink,
but this can be foiled by an external application running
compiler::link. 

4) it prepares the way for a unified foreign function interface mostly
ready in master.  The idea here being that everything in the gcl image
should be lisp, and if one really needs something in C, one can
explicitly define pointers to functions in external shared libraries
which will be relocated on image startup, and use these exclusively
within compiled lisp code.  I can repost examples of this if desired.

The only issue here is that this will introduce changes, albeit minor,
which will make axiom require gcl-2.6.11pre or higher.  Given our past
development cycle, I don't think this should be a problem.

Please let me know what you think, or if I might clarify anything.

This diff has the added feature that if the GCL environment variable is
set, the axiom build will use that external image in lieu of building
its own from source.

Take care,


=============================================================================
diff --git a/Makefile b/Makefile
index a26e500..e71365c 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,8 @@ BYE:=bye
 #GCLVERSION=gcl-2.6.8pre2
 #GCLVERSION=gcl-2.6.8pre3 
 #GCLVERSION=gcl-2.6.8pre4
-GCLVERSION=gcl-2.6.8pre7
+#GCLVERSION=gcl-2.6.8pre7
+GCLVERSION=gcl-cygwin
 GCLDIR:=${LSP}/${GCLVERSION}
 GCLOPTS="--enable-vssize=65536*2 --enable-locbfd --disable-dynsysbfd \
          --disable-statsysbfd --enable-maxpage=512*1024 --disable-xgcl \
@@ -294,4 +295,11 @@ clean:
        @ for i in `find src -name "Makefile.dvi"` ; do rm -f $$i ; done
        @ rm -f lastBuildDate
        @ rm -f books/tangle
+       @ rm -f Makefile.pdf books/Makefile.pdf 
+       @ rm -f lsp/Makefile.pdf lsp/Makefile.pdf src/Makefile.pdf
+       @ rm -f src/algebra/Makefile.pdf src/clef/Makefile.pdf 
+       @ rm -f src/doc/Makefile.pdf
+       @ rm -f src/etc/Makefile.pdf src/input/Makefile.pdf 
+       @ rm -f src/interp/Makefile.pdf
+       @ rm -f src/scripts/Makefile.pdf src/share/Makefile.pdf
 
diff --git a/Makefile.pamphlet b/Makefile.pamphlet
index 24b427a..cb21426 100644
--- a/Makefile.pamphlet
+++ b/Makefile.pamphlet
@@ -690,7 +690,7 @@ lspdir: ${MNT}/${SYS}/bin/document ${LSP}/Makefile
        @echo =====================================
        @echo lsp BUILDING GCL COMMON LISP
        @echo =====================================
-       @(cd lsp ; ${ENV} ${MAKE} gcldir ) 1>/dev/null 2>/dev/null
+       @(cd lsp ; ${ENV} DESTDIR= ${MAKE} gcldir ) 
 #      @(cd lsp ; ${ENV} ${MAKE} ccldir )
 
 \getchunk{LSPMakefile}
@@ -876,7 +876,8 @@ forget to erase the lsp/Makefile the wrong patches will be 
applied.
 #GCLVERSION=gcl-2.6.8pre2
 #GCLVERSION=gcl-2.6.8pre3 
 #GCLVERSION=gcl-2.6.8pre4
-GCLVERSION=gcl-2.6.8pre7
+#GCLVERSION=gcl-2.6.8pre7
+GCLVERSION=gcl-cygwin
 \end{chunk}
 
 \subsubsection{The GCLOPTS configure variable}
diff --git a/lsp/Makefile.pamphlet b/lsp/Makefile.pamphlet
index 2b2764e..58e169a 100644
--- a/lsp/Makefile.pamphlet
+++ b/lsp/Makefile.pamphlet
@@ -1681,6 +1681,89 @@ clean:
        @echo 25 cleaning ${LSP}/ccl
        @( cd ccl ; ${ENV} ${MAKE} clean )
 \end{chunk}
+
+\subsection{The GCL-cygwin stanza}
+This stanza will be written when the GCLVERSION variable is
+``gcl-cygwin''. It will overwrite the default version. See the 
+top level Makefile.pamphlet.
+
+The compiler::link function call was suggested by Camm as a
+way around patching the lisp system. The function creates a
+new lisp image ld and C objects prior to save-system. 
+\begin{verbatim}
+       echo '(compiler::link \
+\end{verbatim}
+The first argument can be used to compile and load lisp code.
+\begin{verbatim}
+               (list (compile-file "${BOOKS}/tangle.lisp")) \
+\end{verbatim}
+The second argument gives the file location for the save-system
+\begin{verbatim}
+               "${OUT}/lisp" \
+\end{verbatim}
+The third argument sets up various internal variables, including
+the 
+\begin{verbatim}
+               (format nil \
+                "(progn \
+                  (let ((*load-path* (cons ~S *load-path*)) \
+                        (si::*load-types* ~S)) \
+                    (compiler::emit-fn t)) \
+                  (setq *tmp-dir* "${TMP}") \
+                  (makunbound (quote *system-banner*)) \
+                  (when (fboundp (quote si::sgc-on)) (si::sgc-on t)) \
+                  #-native-reloc (setq compiler::*default-system-p* t))" \
+                si::*system-directory* \
+                (quote (list #+native-reloc".o" ".lsp"))) \
+\end{verbatim}
+The fourth argument is a list of binaries to link
+\begin{verbatim}
+               "${OBJ}/${SYS}/lib/cfuns-c.o \
+                ${OBJ}/${SYS}/lib/sockio-c.o \
+                ${OBJ}/${SYS}/lib/libspad.a")' \
+\end{verbatim}
+and the compiler::link command is piped into the lisp image.
+\begin{verbatim}
+           | unixport/saved_gcl )
+\end{verbatim}
+
+\begin{chunk}{gcl-cygwin}
+# gcl version cygwin
+OUT=${OBJ}/${SYS}/bin
+
+all:
+       @echo 1 building ${LSP} ${GCLVERSION}
+
+${BOOKS}/tangle1.lisp: ${BOOKS}/tangle.lisp
+       cp $< $@                       
+
+GCL?=$(GCLVERSION)/bin/gcl
+
+$(GCLVERSION)/bin/gcl:
+       @echo 2 building ${GCLVERSION}
+       @tar -zxf ${ZIPS}/${GCLVERSION}.tgz
+       cd ${GCLVERSION} && ./configure ${GCLOPTS} && ${ENV} DESTDIR= ${MAKE}
+
+${OUT}/lisp: ${GCL} ${BOOKS}/tangle1.lisp
+       echo "(progn \
+                    (load (compile-file \"${BOOKS}/tangle1.lisp\"))\
+                    (compiler::emit-fn t)\
+                    (when (fboundp 'si::sgc-on)(si::sgc-on t))\
+                    (si::save-system \"${OUT}/lisp\"))" | ${GCL}
+
+gcldir: ${OUT}/lisp
+       @echo 13 finished system build on `date` | tee >gcldir
+
+clean-gcl-external:
+
+clean-gcl-cygwin:
+       rm -rf $(GCLVERSION)
+
+clean: clean-$(GCLVERSION)
+       rm gcldir build-* gcl-link
+
+\end{chunk}
+
 \eject
 \begin{thebibliography}{99}
 \bibitem{1} nothing
diff --git a/src/include/com.h b/src/include/com.h
index c974f07..241438d 100755
--- a/src/include/com.h
+++ b/src/include/com.h
@@ -92,11 +92,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 AXIOM session manager or menu socket */
 
diff --git a/src/interp/Makefile.pamphlet b/src/interp/Makefile.pamphlet
index eced320..3db9715 100644
--- a/src/interp/Makefile.pamphlet
+++ b/src/interp/Makefile.pamphlet
@@ -828,7 +828,7 @@ ${OUT}/%.${LISP}: ${MID}/%.lisp
 ${OUT}/%.lisp: ${IN}/%.lisp.pamphlet
        @ echo siOUTfromIN making ${OUT}/$*.lisp from ${IN}/$*.lisp.pamphlet
        @ rm -f ${OUT}/$*.${O}
-       @( cd ${OUT} ; \
+       @ ( cd ${OUT} ; \
           echo '(tangle "${IN}/$*.lisp.pamphlet" "*" "$*.lisp")' \
         | ${OBJ}/${SYS}/bin/lisp ) 1>/dev/null 
 
@@ -836,13 +836,15 @@ ${OUT}/%.o: ${MID}/%.lisp
        @ echo siOUTfromMID making ${OUT}/$*.o from ${MID}/$*.lisp
        @ if [ -z "${NOISE}" ] ; then \
           (cd ${MID} ; \
-           echo '(progn  (compile-file "$*.lisp"' \
-             ':output-file "${OUT}/$*.o") (${BYE}))' | ${DEPSYS} ) ; \
+          echo "(let ((compiler::*cc* (concatenate 'string compiler::*cc* \" 
-I ${INC} -I ../lib\")))\
+                 (compile-file \"$<\" \
+             :output-file \"address@hidden") (${BYE}))" | ${DEPSYS}) ; \
           else \
            (cd ${MID} ; \
-            echo '(progn  (compile-file "$*.lisp"' \
-             ':output-file "${OUT}/$I.o") (${BYE}))' | ${DEPSYS} ) \
-              1>/dev/null 2>/dev/null ; \
+          echo "(let ((compiler::*cc* (concatenate 'string compiler::*cc* \" 
-I ${INC} -I ../lib\")))\
+                 (compile-file \"$<\" \
+             :output-file \"address@hidden") (${BYE}))" | ${DEPSYS} \
+              1>$$(echo "$(NOISE)" | $(AWK) '{print $$2}') 2>&1) ; \
           fi 
 
 ${MID}/%.lisp: ${IN}/%.lisp.pamphlet
@@ -857,15 +859,17 @@ ${AUTO}/%.${O}: ${OUT}/%.${O}
 
 ${OUT}/%.${O}: ${MID}/%.${LISP}
        @ echo si123 making ${OUT}/$*.${O} from ${MID}/$*.${LISP}
-       @  if [ -z "${NOISE}" ] ; then \
+       @ if [ -z "${NOISE}" ] ; then \
         (cd ${MID} ; \
-          echo '(progn  (compile-file "${MID}/$*.${LISP}"' \
-             ':output-file "${OUT}/$*.${O}") (${BYE}))' | ${DEPSYS} ) ; \
+          echo "(let ((compiler::*cc* (concatenate 'string compiler::*cc* \" 
-I ${INC} -I ../lib\")))\
+                 (compile-file \"$<\" \
+             :output-file \"address@hidden") (${BYE}))" | ${DEPSYS}) \
          else \
          (cd ${MID} ; \
-          echo '(progn  (compile-file "${MID}/$*.${LISP}"' \
-             ':output-file "${OUT}/$*.${O}") (${BYE}))' | ${DEPSYS} ) \
-              1>/dev/null 2>/dev/null ; \
+          echo "(let ((compiler::*cc* (concatenate 'string compiler::*cc* \" 
-I ${INC} -I ../lib\")))\
+                 (compile-file \"$<\" \
+             :output-file \"address@hidden") (${BYE}))" | ${DEPSYS} \
+              1>$$(echo "$(NOISE)" | $(AWK) '{print $$2}') 2>&1) ; \
          fi 
 
 \end{chunk}
diff --git a/src/interp/cfuns.lisp.pamphlet b/src/interp/cfuns.lisp.pamphlet
index f0885e9..bbedc3e 100644
--- a/src/interp/cfuns.lisp.pamphlet
+++ b/src/interp/cfuns.lisp.pamphlet
@@ -45,6 +45,10 @@
 \end{verbatim}
 \begin{chunk}{*}
 
+(clines "
+#define GCL_SOURCE
+#include \"cfuns-c.c\"
+")
 
 (in-package "BOOT")
 
diff --git a/src/interp/sockio.lisp.pamphlet b/src/interp/sockio.lisp.pamphlet
index aff6848..11d6e5c 100644
--- a/src/interp/sockio.lisp.pamphlet
+++ b/src/interp/sockio.lisp.pamphlet
@@ -47,6 +47,11 @@
 
 
 ;; load C socket functions
+(clines "
+#define GCL_SOURCE
+#include \"sockio-c.c\"
+#include \"bsdsignal.c\"
+")
 
 (in-package "BOOT")
 
@@ -90,24 +95,24 @@ string with data read from connection, therefore needs 
address of
 actual string buffer. We use [[sock_get_string_buf_wrapper]] to
 resolve the problem
 \begin{chunk}{*}
-  (clines "int sock_get_string_buf_wrapper(int i, object x, int j)"
+  (clines "fixnum sock_get_string_buf_wrapper(int i, object x, int j)"
           "{ if (type_of(x)!=t_string) FEwrong_type_argument(sLstring,x);"
           "  if (x->st.st_fillp<j)"
           "    FEerror(\"string too small in sock_get_string_buf_wrapper\",0);"
-          "  return sock_get_string_buf(i, x->st.st_self, j); }")
+          "  return (fixnum)sock_get_string_buf(i, x->st.st_self, j); }")
   (defentry open_server (string) (int "open_server"))
   (defentry sock_get_int (int) (int "sock_get_int"))
   (defentry sock_send_int (int int) (int "sock_send_int"))
   (defentry sock_get_string_buf (int object int) 
-     (int "sock_get_string_buf_wrapper"))
+     (fixnum "sock_get_string_buf_wrapper"))
   (defentry sock_send_string_len (int string int) (int "sock_send_string_len"))
   (defentry sock_get_float (int) (double "sock_get_float"))
   (defentry sock_send_float (int double) (int "sock_send_float"))
-  (defentry sock_send_wakeup (int int) (int "sock_send_wakeup"))
+  (defentry sock_send_wakeup (int) (int "sock_send_wakeup"))
   (defentry server_switch () (int "server_switch"))
-  (defentry flush_stdout () (int "flush_stdout"))
+  (defentry flush_stdout () (void "flush_stdout"))
   (defentry sock_send_signal (int int) (int "sock_send_signal"))
-  (defentry print_line (string) (int "print_line"))
+  (defentry print_line (string) (void "print_line"))
   (defentry plus_infinity () (double "plus_infinity"))
   (defentry minus_infinity () (double "minus_infinity"))
   (defentry NANQ () (double "NANQ"))
diff --git a/src/lib/cfuns-c.c.pamphlet b/src/lib/cfuns-c.c.pamphlet
index 486fe09..21c1760 100644
--- a/src/lib/cfuns-c.c.pamphlet
+++ b/src/lib/cfuns-c.c.pamphlet
@@ -123,7 +123,11 @@ int make_path_from_file(char *s, char *t) {
         return (-1);
     }
     /** now just do the copying **/
+#ifdef GCL_SOURCE
+    memcpy(s, t, pos - t);
+#else       
     strncpy(s, t, pos - t);
+#endif
     return 1;
 }
 
diff --git a/src/lib/sockio-c.c.pamphlet b/src/lib/sockio-c.c.pamphlet
index 6841293..4549bd7 100644
--- a/src/lib/sockio-c.c.pamphlet
+++ b/src/lib/sockio-c.c.pamphlet
@@ -89,17 +89,17 @@ of files are badly broken with respect to the 
[[/usr/include]] versions.
   ( purpose_table[purpose] == NULL ? sock_accept_connection(purpose) : 1 )
 
 
-Sock clients[MaxClients];       /* socket description of spad clients */
-Sock server[2];                 /* AF_UNIX and AF_INET sockets for server */
-Sock *purpose_table[TotalMaxPurposes]; /* table of dedicated socket types */
-fd_set socket_mask;             /* bit mask of active sockets */
-fd_set server_mask;             /* bit mask of server sockets */
-int socket_closed;              /* used to identify closed socket on SIGPIPE */
-int spad_server_number = -1;    /* spad server number used in sman */
-int str_len = 0;
-int still_reading  = 0;
-
-
+STATIC Sock clients[MaxClients];       /* socket description of spad clients */
+STATIC Sock server[2];                 /* AF_UNIX and AF_INET sockets for 
server */
+STATIC Sock *purpose_table[TotalMaxPurposes]; /* table of dedicated socket 
types */
+STATIC fd_set socket_mask;             /* bit mask of active sockets */
+STATIC fd_set server_mask;             /* bit mask of server sockets */
+STATIC int socket_closed;              /* used to identify closed socket on 
SIGPIPE */
+STATIC int spad_server_number = -1;    /* spad server number used in sman */
+STATIC int str_len = 0;
+#ifndef GCL_SOURCE
+STATIC int still_reading  = 0;
+#endif
 
 #include "bsdsignal.h1"
 #include "sockio-c.h1"
@@ -303,14 +303,22 @@ send_string_len(Sock *sock,char *str,int len)
   if (len > 1023) {
     char *buf;
     buf = malloc(len+1);
+#ifdef GCL_SOURCE
+    memcpy(buf,str,len);
+#else
     strncpy(buf,str,len);
+#endif
     buf[len]='\0';
     send_int(sock,len+1);
     val = swrite(sock, buf, len+1, NULL);
     free(buf);
   } else {
     static char buf[1024];
-    strncpy(buf, str, len);
+#ifdef GCL_SOURCE
+    memcpy(buf,str,len);
+#else
+    strncpy(buf,str,len);
+#endif
     buf[len] = '\0';
     send_int(sock, len+1);
     val = swrite(sock, buf, len+1, NULL);
@@ -730,7 +738,11 @@ remote_stdio(Sock *sock)
       return;
     }
     if (FD_ISSET(0, &rd)) {
+#ifdef GCL_SOURCE
+       gcl_gets(buf,1024);
+#else
       fgets(buf,1024,stdin);
+#endif
       len = strlen(buf);
       /*
           gets(buf);
@@ -746,8 +758,12 @@ remote_stdio(Sock *sock)
         return;
       else {
         *(buf + len) = '\0';
-        fputs(buf, stdout);
-        fflush(stdout);
+#ifdef GCL_SOURCE
+       gcl_puts(buf);
+#else
+       fputs(buf, stdout);
+       fflush(stdout);
+#endif
       }
     }
   }
@@ -938,15 +954,15 @@ redirect_stdio(Sock *sock)
 /*  setbuf(stdout, NULL);  */
   fd = dup2(sock->socket, 1);
   if (fd != 1) {
-    fprintf(stderr, "Error connecting stdout to socket\n");
+    perror("Error connecting stdout to socket\n");
     return;
   }
   fd = dup2(sock->socket, 0);
   if (fd != 0) {
-    fprintf(stderr, "Error connecting stdin to socket\n");
+    perror("Error connecting stdin to socket\n");
     return;
   }
-  fprintf(stderr, "Redirected standard IO\n");
+  perror("Redirected standard IO\n");
   FD_CLR(sock->socket, &socket_mask);
 }
 
=============================================================================
-- 
Camm Maguire                                        address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah



reply via email to

[Prev in Thread] Current Thread [Next in Thread]