PDP-10 / its

Incompatible Timesharing System
Other
834 stars 80 forks source link

LIBLSP; LINK FASL (LIBDOC; LINK GLS) gets undefined symbols when assembled #727

Open eswenson1 opened 6 years ago

eswenson1 commented 6 years ago

Assembling LIBDOC; LINK GLS to et LIBLSP; LINK FASL results in two undefined symbols:

            0        0.     1-007   2MERGE  Undefined

LINK1+7 15 0. 1-021 XCIOL Undefined

The FASL file is created and loads into a lisp. Not sure what, if any, the consequences are.

eswenson1 commented 5 years ago

Attempting to call the LINK function gives an ILOPR error. It is pretty clear that those two undefined symbols are critical. They are defined in LISP;QIO >. However, I don't see how LIBDOC; LINK GLS is supposed to gain access to them.

eswenson1 commented 5 years ago

Ok, I managed to get this to compile. It required making changes to L;DEFNS > and rebuilding a new LISP. I defined exposed the two symbols 2MERGE and XCIOL in DEFNS and then I'm able to, with an updated .FASL DEFS, successfully compile LIBDOC; LINK GLS and successfully use the LINK function. An example invocation of LINK is:

(LINK '((ejs) xxx 1) '((ejs) yyy 1))

That creates a link from EJS; XXX 1 to EJS; YYY 1.

Now, before doing anything about making this work in DB, I need to understand why these symbols were dropped from .FASL DEFS and L; DEFNS >. It must be that LINK is no longer needed. I'll look around for a replacement function.

eswenson1 commented 5 years ago

I don't see any LINK functionality in L; QIO (I see DELETEF and other file system operations). I see no evidence that it is possible to create file system links from within LISP -- except through LIBDOC; LINK GLS.

So I guess we should decide on whether to update L;DEFNS > and LISP;.FASL DEFS in order to support LIBDOC; LINK GLS -- this would allow lisp to create file system links through the LINK function. @larsbrinkhoff @atsampson

eswenson1 commented 5 years ago

@larsbrinkhoff and @atsampson I would like your opinion here. It seems reasonable to expose the ability to merge two filenames (2MERGE) and the ability to report IO errors (lossages). Should we add them to the external symbols in QIO (lisp)? This would allow them to be exposed in .FASL DEFS and therefore used in LISP code like LIBDOC; LINK GLS. I don't see why these symbols were removed. And I don't actually see that they were ever exposed -- except that LIBDOC; LINK GLS was assembled into a FASL file (in 1976). I don't see any other way to create a file system link from within lisp. Alternatively, we could ignore this completely and document why LINK GLS won't assemble (successfully).

larsbrinkhoff commented 5 years ago

I don't have any objections to making those symbols external.

Is LINK GLS needed anywhere?

atsampson commented 5 years ago

Exposing those symbols sounds sensible to me - it's not going to break anything else, and it's obviously useful. (For example, we'd definitely want the ability to create links if we wanted to use LISP to automate more of the build in the future.)

eswenson1 commented 5 years ago

Good question (point). I haven't seen any dependencies on it as of yet. It was just that LIBLSP; LINK FASL was in the PI distribution and the source for it was present there as LIBDOC; LINK GLS. And the reason I'd think to include it in DB is because there is no support for file system linking in LISP that I can find.

On the other hand, I had originally thought that one couldn't implement LINK (in LISP) without the two exported symbols. It would appear that 2MERGE just makes it easy to do defaulting of target filenames (by merging). This could clearly be implemented in LISP. XCIOL appears to just allow you to deal with errors from the .CALL [SETZ / SIXBIT \MLINK\ / ...] system call. So maybe one could implement LINK without either of those two symbols. There has got to be some reason why they were removed as external symbols.

I guess it would be interesting to see if one could implement LINK without 2MERGE and XCIOL.

eswenson1 commented 5 years ago

I now believe we should rewrite LIBDOC; LINK GLS to not use the now obsolete symbols. The SYSCALL maclisp function should allow us to implement LINK. A expression like:

(SYSCALL 4 'MLINK device from-fn1 from-fn2 from-dir to-fn1 to-fn2 to-dir)

Should allow us to implement the LINK. Now the LINK GLS supplied took two file references (of the form '((dir) fn1 fn2), merged them for default handling, and then called the MLINK system call. So there will be a bit of lisp to write to mimic this behavior. But I suspect the reason why the 2MERGE and XCIOL symbols were removed from .FASL DEFS (and no longer made external symbols in L; DEFNS >) was because they were no longer needed -- you can implement in lisp with no need to use Midas.

eswenson1 commented 5 years ago

I implemented a LINK using SYSCALL. Here is the code:

(eval-when (load eval)
  (load '((liblsp) 6bit fasl)))

(defun link (from to)
  (let* ((def (list (list 'dsk (status udir))))
         (from1 (mergef from def))
         (to1 (mergef to def))
         (from2 (append (car from1) (cdr from1)))
         (to2 (append (car to1) (cdr to1)))
         (from3 (mapcar 'symbol->6bit from2))
         (to3 (mapcar 'symbol->6bit to2))
         (from-dev (nth 0 from3))
         (from-dir (nth 1 from3))
         (from-fn1 (nth 2 from3))
         (from-fn2 (nth 3 from3))
         (to-dev (nth 0 to3))
         (to-dir (nth 1 to3))
         (to-fn1 (nth 2 to3))
         (to-fn2 (nth 3 to3)))
    (if (not (equal from-dev to-dev))
        (break "link: devices must be the same"))
    (let ((result (syscall 4 'mlink from-dev from-fn1 from-fn2 from-dir to-fn1 to-fn2 to-dir)))
      (if (numberp result)
          result
          t))))

I'll replace LIBDOC; LINK GLS with this new version. It doesn't require any new LISP or .FASL DEFS.

eswenson1 commented 5 years ago

Of course, the above can be made more concise with:

(eval-when (load eval)
  (load '((liblsp) 6bit fasl)))

(defun link (from to)
  (let* ((def (list (list 'dsk (status udir))))
         (from1 (mergef from def))
         (to1 (mergef to def))
         (from2 (mapcar 'symbol->6bit (append (car from1) (cdr from1))))
         (to2 (mapcar 'symbol->6bit (append (car to1) (cdr to1))))
         ((from-dev from-dir from-fn1 from-fn2) from2)
         ((to-dev to-dir to-fn1 to-fn2) to2))
    (if (not (equal from-dev to-dev))
        (break "link: devices must be the same"))
    (let ((result (syscall 4 'mlink from-dev from-fn1 from-fn2 from-dir to-fn1 to-fn2 to-dir)))
      (if (numberp result)
          result
          t))))

I had forgotten that Maclisp had destructuring let.