Changeset 10034


Ignore:
Timestamp:
Jul 15, 2008, 1:23:06 PM (11 years ago)
Author:
gb
Message:

Start trying to make this work on Windows; still all conditionalized out.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/win64/level-1/l1-sockets.lisp

    r9113 r10034  
    1717(in-package "CCL")
    1818
     19#-windows-target                        ; needs lots of work
     20(progn
     21
    1922(eval-when (:compile-toplevel :execute)
    2023  #+linuxppc-target
     
    3033  )
    3134
    32 #-windows-target                        ; needs lots of work
    33 (progn
    3435
    3536;;; basic socket API
     
    192193        #$EACCES :access-denied
    193194        #$EPERM :access-denied))
     195
     196
    194197
    195198
     
    11161119
    11171120#+linuxppc-target
    1118 (defun _inet_ntoa (addr)
    1119   (rlet ((addrp :unsigned))
    1120     (setf (pref addrp :unsigned) addr)
    1121     (with-macptrs ((p))
     1121(defun _inet_ntoa (u32)
     1122  (rlet ((addrp :in_addr))
     1123    (setf (pref addrp #>in_addr.S_un.S_addr) u32)
     1124    (with-macptrs ((p (%null-ptr)))
    11221125      (%setf-macptr p (#_inet_ntoa addrp))
    11231126      (unless (%null-ptr-p p) (%get-cstring p)))))
     
    11271130;;; seems to lose the :struct, so just using #_ doesn't work (that
    11281131;;; sounds like a bug in the FFI translator.)
    1129 #+(or darwin-target linuxx8664-target freebsd-target)
     1132#-linuxppc-target
    11301133(defun _inet_ntoa (addr)
    11311134  (with-macptrs ((p))
     
    11461149
    11471150(defun c_socket_1 (domain type protocol)
    1148   #-linuxppc-target
     1151  #-(or windows-target linuxppc-target)
    11491152  (syscall syscalls::socket domain type protocol)
    11501153  #+linuxppc-target
     
    11531156          (paref params (:* :unsigned-long) 1) type
    11541157          (paref params (:* :unsigned-long) 2) protocol)
    1155     (syscall syscalls::socketcall 1 params)))
     1158    (syscall syscalls::socketcall 1 params))
     1159  #+windows-target
     1160  (let* ((handle (#_socket domain type protocol)))
     1161    (if (< handle 0)
     1162      (- (#_WSAGetLastError))
     1163      (let* ((fd (#__open_osfhandle handle #$O_RDWR)))
     1164        (if (< fd 0)
     1165          (progn (#_CloseHandle fd) (%get-errno))
     1166          fd)))))
    11561167
    11571168(defun c_socket (domain type protocol)
     
    11991210
    12001211(defun c_bind (sockfd sockaddr addrlen)
    1201   #+(or darwin-target linuxx8664-target freebsd-target)
     1212  #-(or linuxppc-target windows-target)
    12021213  (progn
    12031214    #+(or darwin-target freebsd-target)
     
    12171228            (%get-ptr params 8) sockaddr
    12181229            (%%get-unsigned-longlong params 16) addrlen)
    1219       (syscall syscalls::socketcall 2 params))))
     1230      (syscall syscalls::socketcall 2 params)))
     1231  #+windows-target
     1232  (let* ((res (#_bind (#__get_osfhandle sockfd) sockaddr addrlen)))
     1233    (if (< res 0)
     1234      (- (#_WSAGetLastError))
     1235      res)))
    12201236
    12211237
     
    12541270
    12551271(defun c_listen (sockfd backlog)
    1256   #+(or darwin-target linuxx8664-target freebsd-target)
     1272  #-(or linuxppc-target windows-target)
    12571273  (syscall syscalls::listen sockfd backlog)
    12581274  #+linuxppc-target
     
    12671283      (setf (%%get-unsigned-longlong params 0) sockfd
    12681284            (%%get-unsigned-longlong params 8) backlog)
    1269       (syscall syscalls::socketcall 4 params))))
     1285      (syscall syscalls::socketcall 4 params)))
     1286  #+windows-target
     1287  (let* ((res (#_listen (#__get_osfhandle sockfd) backlog)))
     1288    (if (< res 0)
     1289      (- (#_WSAGetLastError))
     1290      res)))
    12701291
    12711292(defun c_accept (sockfd addrp addrlenp)
    12721293  (ignoring-eintr
    1273    #+(or darwin-target linuxx8664-target freebsd-target)
     1294   #-(or linuxppc-target windows-target)
    12741295   (syscall syscalls::accept sockfd addrp addrlenp)
    12751296   #+linuxppc-target
     
    12861307             (%get-ptr params 8) addrp
    12871308             (%get-ptr params 16) addrlenp)
    1288        (syscall syscalls::socketcall 5 params)))))
     1309       (syscall syscalls::socketcall 5 params)))
     1310   #+windows-target
     1311   (let* ((res (#_accept (#__get_osfhandle sockfd addrp addrlenp))))
     1312     (if (< res 0)
     1313       (- (#_WSAGetLastError))
     1314       res))))
    12891315
    12901316(defun c_getsockname (sockfd addrp addrlenp)
    1291   #+(or darwin-target linuxx8664-target freebsd-target)
     1317  #-(or linuxppc-target windows-target)
    12921318  (syscall syscalls::getsockname sockfd addrp addrlenp)
    12931319  #+linuxppc-target
     
    13041330            (%get-ptr params 8) addrp
    13051331            (%get-ptr params 16) addrlenp)
    1306       (syscall syscalls::socketcall 6 params))))
     1332      (syscall syscalls::socketcall 6 params)))
     1333  #+windows-target
     1334  (let* ((res (#_getsockname (#__get_osfhandle sockfd) addrp addrlenp)))
     1335    (if (< res 0)
     1336      (- (#_WSAGetLastError))
     1337      res))
     1338  )
    13071339
    13081340(defun c_getpeername (sockfd addrp addrlenp)
Note: See TracChangeset for help on using the changeset viewer.