From 545e58873eab8d9aaae4cd10a3f130e5b3120835 Mon Sep 17 00:00:00 2001 From: "U-C4\\Administrator" Date: Fri, 21 Sep 2007 17:00:47 -0500 Subject: [PATCH] Fix launcher and windows bootstrap Fix native io on Vista Add missing use --- extra/io/windows/launcher/launcher.factor | 3 +- extra/io/windows/nt/backend/backend.factor | 52 +++++++++++++++++++--- extra/io/windows/nt/nt.factor | 47 ++----------------- extra/windows/opengl32/opengl32.factor | 3 +- 4 files changed, 52 insertions(+), 53 deletions(-) diff --git a/extra/io/windows/launcher/launcher.factor b/extra/io/windows/launcher/launcher.factor index 98d241c8f6..f012f8d736 100644 --- a/extra/io/windows/launcher/launcher.factor +++ b/extra/io/windows/launcher/launcher.factor @@ -1,6 +1,7 @@ USING: alien alien.c-types destructors io.windows libc io.nonblocking io.streams.duplex windows.types math -windows.kernel32 windows namespaces io.launcher kernel ; +windows.kernel32 windows namespaces io.launcher kernel +io.windows.nt.backend ; IN: io.windows.launcher ! From MSDN: "Handles in PROCESS_INFORMATION must be closed with CloseHandle when they are no longer needed." diff --git a/extra/io/windows/nt/backend/backend.factor b/extra/io/windows/nt/backend/backend.factor index 06d508e757..9ec0a63c40 100644 --- a/extra/io/windows/nt/backend/backend.factor +++ b/extra/io/windows/nt/backend/backend.factor @@ -1,9 +1,35 @@ USING: alien alien.c-types arrays assocs combinators continuations -destructors io io.backend io.nonblocking io.windows io.windows.nt libc +destructors io io.backend io.nonblocking io.windows libc kernel math namespaces sequences threads tuples.lib windows windows.errors windows.kernel32 prettyprint ; IN: io.windows.nt.backend +: unicode-prefix ( -- seq ) + "\\\\?\\" ; inline + +M: windows-nt-io normalize-pathname ( string -- string ) + dup string? [ "pathname must be a string" throw ] unless + "/" split "\\" join + { + ! empty + { [ dup empty? ] [ "empty path" throw ] } + ! .\\foo + { [ dup ".\\" head? ] [ + >r unicode-prefix cwd r> 1 tail 3append + ] } + ! c:\\ + { [ dup 1 tail ":" head? ] [ >r unicode-prefix r> append ] } + ! \\\\?\\c:\\foo + { [ dup unicode-prefix head? ] [ ] } + ! foo.txt ..\\foo.txt + { [ t ] [ + [ + unicode-prefix % cwd % + dup first CHAR: \\ = [ CHAR: \\ , ] unless % + ] "" make + ] } + } cond [ "/\\." member? ] rtrim ; + SYMBOL: io-hash TUPLE: io-callback port continuation ; @@ -63,9 +89,9 @@ C: GetQueuedCompletionStatusParams GetQueuedCompletionStatus ] keep swap ; -: lookup-callback ( GetQueuedCompletion-args -- callback ? ) +: lookup-callback ( GetQueuedCompletion-args -- callback ) GetQueuedCompletionStatusParams-lpOverlapped* *void* - \ io-hash get-global delete-at* ; + \ io-hash get-global delete-at drop ; : wait-for-io ( timeout -- continuation/f ) wait-for-overlapped @@ -73,15 +99,18 @@ C: GetQueuedCompletionStatusParams GetLastError dup (expected-io-error?) [ 2drop f ] [ - (win32-error-string) swap lookup-callback [ + dup ERROR_HANDLE_EOF = [ + drop lookup-callback [ + io-callback-port t swap set-port-eof? + ] keep io-callback-continuation + ] [ + (win32-error-string) swap lookup-callback [ io-callback-port set-port-error ] keep io-callback-continuation - ] [ - drop "No callback found" 2array throw ] if ] if ] [ - lookup-callback [ io-callback-continuation ] when + lookup-callback io-callback-continuation ] if ; : maybe-expire ( io-callbck -- ) @@ -99,3 +128,12 @@ M: windows-nt-io io-multiplex ( ms -- ) cancel-timedout [ wait-for-io ] [ global [ "error: " write . flush ] bind drop f ] recover [ schedule-thread ] when* ; + +M: windows-nt-io init-io ( -- ) + #! Should only be called on startup. Calling this at any + #! other time can have unintended consequences. + global [ + master-completion-port \ master-completion-port set + H{ } clone \ io-hash set + init-winsock + ] bind ; diff --git a/extra/io/windows/nt/nt.factor b/extra/io/windows/nt/nt.factor index 5370580f10..7469410238 100644 --- a/extra/io/windows/nt/nt.factor +++ b/extra/io/windows/nt/nt.factor @@ -1,51 +1,10 @@ ! Copyright (C) 2004, 2007 Mackenzie Straight, Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: alien alien.c-types assocs byte-arrays combinators -io.backend io.files io.nonblocking io.windows -kernel libc math namespaces qualified sequences -splitting strings threads windows windows.errors windows.winsock -windows.kernel32 ; -QUALIFIED: windows.winsock -IN: io.windows.nt - -: unicode-prefix ( -- seq ) - "\\\\?\\" ; inline - -M: windows-nt-io normalize-pathname ( string -- string ) - dup string? [ "pathname must be a string" throw ] unless - "/" split "\\" join - { - ! empty - { [ dup empty? ] [ "empty path" throw ] } - ! .\\foo - { [ dup ".\\" head? ] [ - >r unicode-prefix cwd r> 1 tail 3append - ] } - ! c:\\ - { [ dup 1 tail ":" head? ] [ >r unicode-prefix r> append ] } - ! \\\\?\\c:\\foo - { [ dup unicode-prefix head? ] [ ] } - ! foo.txt ..\\foo.txt - { [ t ] [ - [ - unicode-prefix % cwd % - dup first CHAR: \\ = [ CHAR: \\ , ] unless % - ] "" make - ] } - } cond [ "/\\." member? ] rtrim ; - +USE: io.windows USE: io.windows.nt.backend USE: io.windows.nt.files USE: io.windows.nt.sockets +USE: io.backend +USE: namespaces T{ windows-nt-io } io-backend set-global - -M: windows-nt-io init-io ( -- ) - #! Should only be called on startup. Calling this at any - #! other time can have unintended consequences. - global [ - master-completion-port \ master-completion-port set - H{ } clone \ io-hash set - init-winsock - ] bind ; - diff --git a/extra/windows/opengl32/opengl32.factor b/extra/windows/opengl32/opengl32.factor index fcda38ca53..93473a4fd3 100644 --- a/extra/windows/opengl32/opengl32.factor +++ b/extra/windows/opengl32/opengl32.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2005, 2006 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.c-types alien.syntax parser namespaces kernel -math windows.types windows.types init assocs sequences opengl.gl ; +math windows.types windows.types init assocs sequences opengl.gl +libc ; IN: windows.opengl32 ! PIXELFORMATDESCRIPTOR flags