anchor.diff:        (error-code (array sb-alien:int 10)))) ; 10 = fd-max-events
   
     (sb-alien:define-alien-routine ("WSACreateEvent" wsa-event-create)
  -      sb-alien::hinstance) ; return type only
  +      ws-event) ; return type only
  +
  +  (sb-alien:define-alien-routine ("WSAResetEvent" wsa-event-reset)
  +      (boolean #.sb-vm::n-machine-word-bits)
  +    (event-object ws-event))
   
     (sb-alien:define-alien-routine ("WSACloseEvent" wsa-event-close)
  -      (sb-alien:boolean #.sb-vm::n-machine-word-bits)
  -    (event-object sb-alien::hinstance))
  +      (boolean #.sb-vm::n-machine-word-bits)
  +    (event-object ws-event))
   
     (sb-alien:define-alien-routine ("WSAEnumNetworkEvents" wsa-enum-network-events)
         sb-alien:int
       (socket ws-socket)
  -    (event-object sb-alien::hinstance)
  +    (event-object ws-event)
       (network-events (* (sb-alien:struct wsa-network-events))))
   
     (sb-alien:define-alien-routine ("WSAEventSelect" wsa-event-select)
         sb-alien:int
       (socket ws-socket)
  -    (event-object sb-alien::hinstance)
  +    (event-object ws-event)
       (network-events sb-alien:long))
   
  -  (sb-alien:define-alien-routine ("WaitForSingleObject" wait-for-single-object)
  -      sb-alien:long
  -    (object sb-alien::hinstance)
  -    (timeout sb-alien:long))
  +  (sb-alien:define-alien-routine ("WSAWaitForMultipleEvents" wsa-wait-for-multiple-events)
  +      ws-dword
  +    (number-of-events ws-dword)
  +    (events (* ws-event))
  +    (wait-all-p (boolean #.sb-vm::n-machine-word-bits))
  +    (timeout ws-dword)
  +    (alertable-p (boolean #.sb-vm::n-machine-word-bits)))
   
     (sb-alien:define-alien-routine ("ioctlsocket" wsa-ioctlsocket)
         sb-alien:int
  
positive.code: #+ecl
  (eval-when (:compile-toplevel :load-toplevel :execute)
    (require :sockets))
  
  #+(and sbcl win32) ; for "WaitForSingleObject"
  (eval-when (:compile-toplevel :load-toplevel :execute)
    (sb-alien:load-shared-object "kernel32.dll"))
  
  #+sbcl
  (progn
  
negative.code:                                       network-events)
                  (maybe-wsa-error rv socket)))))))
  
    (defun os-wait-list-%wait (wait-list)
      (sb-alien:deref (wait-list-%wait wait-list)))
  
    (defun (setf os-wait-list-%wait) (value wait-list)
      (setf (sb-alien:deref (wait-list-%wait wait-list)) value))
  
    (defun %setup-wait-list (wait-list)
      (setf (wait-list-%wait wait-list) (sb-alien:make-alien ws-event))
      (setf (os-wait-list-%wait wait-list) (wsa-event-create))
      (sb-ext:finalize wait-list
                       #'(lambda () (unless (null (wait-list-%wait wait-list))
                                      (wsa-event-close (os-wait-list-%wait wait-list))
                                      (sb-alien:free-alien (wait-list-%wait wait-list))))))
  
    (defun %add-waiter (wait-list waiter)
      (let ((events (etypecase waiter
                      (stream-server-usocket (logior fd-connect fd-accept fd-close))
                      (stream-usocket (logior fd-read))
                      (datagram-usocket (logior fd-read)))))
        (maybe-wsa-error
         (wsa-event-select (os-socket-handle waiter) (os-wait-list-%wait wait-list) events)
         waiter)))
  
    (defun %remove-waiter (wait-list waiter)
      (maybe-wsa-error
       (wsa-event-select (os-socket-handle waiter) (os-wait-list-%wait wait-list) 0)
       waiter))
  ) ; progn
  
  