Ignore:
Timestamp:
Oct 14, 2008, 2:00:40 AM (13 years ago)
Author:
gb
Message:

Stop wrapping (pseudo) file-descriptors around Windows file handlers;
there seem to be cases where this definitely loses, because the MSVCRT
runtime tries to flush buffers associated with (e.g.) a listening socket
when it's closed, and we often have to do I/O in Windows-specific ways
and can't always use the C runtime, anyway.

Handles are (depending on which function you're dealing with) either
pointers or pointer-sized integers; they can be used interchangably
with ints on Win32, but porting this change to Win64 may require some
changes (in l1-io.lisp, in the PIPE function, perhaps elsewhere.)

Supporting this requires some changss in the kernel (mostly in
windows-calls.c) To bootstrap it, most of the I/O functions in
that file assume that very small integers [0 .. 31] are fds wrapped
around a handle and that anything larger is the handle itself. All
of the actual work done by those functions is done on the handle,
without involving the C runtime.

I'll check in a win32 kernel and image in a few minutes. Mixing
older kernels/images won't work, but I don't want to change the
kernel/image compatibility stuff until this is further along.

SLIME sort of works, but not very reliably yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-1/l1-boot-2.lisp

    r10894 r11081  
    9797  (let* ((encoding (lookup-character-encoding *terminal-character-encoding-name*))
    9898         (encoding-name (if encoding (character-encoding-name encoding))))
    99     (setq *stdin* (make-fd-stream 0
     99    (setq *stdin* (make-fd-stream #-windows-target 0
     100                                  #+windows-target (%ptr-to-int
     101                                                    (#_GetStdHandle #$STD_INPUT_HANDLE))
    100102                                  :basic t
    101103                                  :sharing :lock
     
    103105                                  :interactive (not *batch-flag*)
    104106                                  :encoding encoding-name))
    105     (setq *stdout* (make-fd-stream 1 :basic t :direction :output :sharing :lock :encoding encoding-name))
    106 
    107     (setq *stderr* (make-fd-stream 2 :basic t :direction :output :sharing :lock :encoding encoding-name))
     107    (setq *stdout* (make-fd-stream #-windows-target 1
     108                                   #+windows-target (%ptr-to-int
     109                                                     (#_GetStdHandle #$STD_OUTPUT_HANDLE))
     110                                   :basic t :direction :output :sharing :lock :encoding encoding-name))
     111
     112    (setq *stderr* (make-fd-stream #-windows-target 2
     113                                   #+windows-target (%ptr-to-int
     114                                                     (#_GetStdHandle #$STD_ERROR_HANDLE))
     115                    :basic t :direction :output :sharing :lock :encoding encoding-name))
    108116    (if *batch-flag*
    109117      (let* ((tty-fd
Note: See TracChangeset for help on using the changeset viewer.