mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-02-04 22:50:39 -08:00
Coercions needed to compile on Windows with C++ compiler.
This commit is contained in:
parent
c020d37dda
commit
5f4c7eee93
1 changed files with 28 additions and 19 deletions
|
|
@ -25,6 +25,7 @@
|
|||
"#include <sys/types.h>"
|
||||
"#include <sys/socket.h>"
|
||||
"#include <sys/un.h>"
|
||||
"#define wincoerce(t,x) (x)"
|
||||
#-:win32
|
||||
"#include <sys/time.h>"
|
||||
"#include <netdb.h>"
|
||||
|
|
@ -52,6 +53,7 @@
|
|||
(clines
|
||||
"#include <winsock2.h>"
|
||||
"typedef unsigned int uint32_t;"
|
||||
"#define wincoerce(t,x) ((t)(x))"
|
||||
#-:mingw32
|
||||
"typedef int ssize_t;"
|
||||
"typedef int socklen_t;"
|
||||
|
|
@ -228,7 +230,7 @@ weird stuff - see gethostbyname(3) for grisly details."
|
|||
vector[2] = fixint(ecl_aref(#0,2));
|
||||
vector[3] = fixint(ecl_aref(#0,3));
|
||||
ecl_disable_interrupts();
|
||||
hostent = gethostbyaddr(vector,4,AF_INET);
|
||||
hostent = gethostbyaddr(wincoerce(const char *, vector),4,AF_INET);
|
||||
ecl_enable_interrupts();
|
||||
|
||||
if (hostent != NULL) {
|
||||
|
|
@ -481,7 +483,7 @@ safe_buffer_pointer(cl_object x, cl_index size)
|
|||
ssize_t len;
|
||||
|
||||
ecl_disable_interrupts();
|
||||
len = recvfrom(#0, safe_buffer_pointer(#1, #2),
|
||||
len = recvfrom(#0, wincoerce(char*, safe_buffer_pointer(#1, #2)),
|
||||
#2, flags, NULL,NULL);
|
||||
ecl_enable_interrupts();
|
||||
if (len >= 0) {
|
||||
|
|
@ -754,10 +756,12 @@ static void fill_inet_sockaddr(struct sockaddr_in *sockaddr, int port,
|
|||
##if (MSG_NOSIGNAL == 0) && defined(SO_NOSIGPIPE)
|
||||
{
|
||||
int sockopt = #c;
|
||||
setsockopt(#0,SOL_SOCKET,SO_NOSIGPIPE,&sockopt,sizeof(int));
|
||||
setsockopt(#0,SOL_SOCKET,SO_NOSIGPIPE,
|
||||
wincoerce(char *,&sockopt),
|
||||
sizeof(int));
|
||||
}
|
||||
##endif
|
||||
len = sendto(sock, buffer,
|
||||
len = sendto(sock, wincoerce(char *,buffer),
|
||||
length, flags,(struct sockaddr*)&sockaddr,
|
||||
sizeof(struct sockaddr_in));
|
||||
ecl_enable_interrupts();
|
||||
|
|
@ -787,10 +791,12 @@ static void fill_inet_sockaddr(struct sockaddr_in *sockaddr, int port,
|
|||
##if (MSG_NOSIGNAL == 0) && defined(SO_NOSIGPIPE)
|
||||
{
|
||||
int sockopt = #7;
|
||||
setsockopt(#0,SOL_SOCKET,SO_NOSIGPIPE,&sockopt,sizeof(int));
|
||||
setsockopt(#0,SOL_SOCKET,SO_NOSIGPIPE,
|
||||
wincoerce(char *,&sockopt),
|
||||
sizeof(int));
|
||||
}
|
||||
##endif
|
||||
len = send(sock, buffer, length, flags);
|
||||
len = send(sock, wincoerce(char *, buffer), length, flags);
|
||||
ecl_enable_interrupts();
|
||||
@(return) = len;
|
||||
}
|
||||
|
|
@ -1028,7 +1034,7 @@ also known as unix-domain sockets."))
|
|||
if (hnd == INVALID_HANDLE_VALUE)
|
||||
@(return) = -1;
|
||||
else
|
||||
@(return) = _open_osfhandle(hnd, O_RDWR);
|
||||
@(return) = _open_osfhandle((intptr_t)hnd, O_RDWR);
|
||||
}")))
|
||||
(when (= hnd -1)
|
||||
(socket-error "CreateNamedPipe"))
|
||||
|
|
@ -1040,7 +1046,7 @@ also known as unix-domain sockets."))
|
|||
(afd (c-inline (fd) (:int) :int
|
||||
"
|
||||
{
|
||||
HANDLE hnd = _get_osfhandle(#0), dupHnd;
|
||||
HANDLE hnd = (HANDLE)_get_osfhandle(#0), dupHnd;
|
||||
ecl_disable_interrupts();
|
||||
if (ConnectNamedPipe(hnd, NULL) != 0 || GetLastError() == ERROR_PIPE_CONNECTED) {
|
||||
@(return) = #0;
|
||||
|
|
@ -1085,7 +1091,7 @@ also known as unix-domain sockets."))
|
|||
if (hnd == INVALID_HANDLE_VALUE)
|
||||
@(return) = -1;
|
||||
else
|
||||
@(return) = _open_osfhandle(hnd, O_RDWR);
|
||||
@(return) = _open_osfhandle((intptr_t)hnd, O_RDWR);
|
||||
ecl_enable_interrupts();
|
||||
}")))
|
||||
(socket-error "connect")
|
||||
|
|
@ -1101,8 +1107,9 @@ also known as unix-domain sockets."))
|
|||
"
|
||||
{
|
||||
DWORD mode = PIPE_READMODE_BYTE | (#1 == ECL_T ? PIPE_NOWAIT : PIPE_WAIT);
|
||||
HANDLE h = (HANDLE)_get_osfhandle(#0);
|
||||
ecl_disable_interrupts();
|
||||
@(return) = SetNamedPipeHandleState(_get_osfhandle(#0), &mode, NULL, NULL);
|
||||
@(return) = SetNamedPipeHandleState(h, &mode, NULL, NULL);
|
||||
ecl_enable_interrupts();
|
||||
}"
|
||||
:one-liner nil))
|
||||
|
|
@ -1115,10 +1122,11 @@ also known as unix-domain sockets."))
|
|||
"
|
||||
{
|
||||
DWORD flags;
|
||||
HANDLE h = (HANDLE)_get_osfhandle(#0);
|
||||
ecl_disable_interrupts();
|
||||
if (!GetNamedPipeInfo(_get_osfhandle(#0), &flags, NULL, NULL, NULL))
|
||||
if (!GetNamedPipeInfo(h, &flags, NULL, NULL, NULL))
|
||||
@(return) = ECL_NIL;
|
||||
if (flags == PIPE_CLIENT_END || DisconnectNamedPipe(_get_osfhandle(#0)))
|
||||
if (flags == PIPE_CLIENT_END || DisconnectNamedPipe(h))
|
||||
@(return) = ECL_T;
|
||||
else
|
||||
@(return) = ECL_NIL;
|
||||
|
|
@ -1470,7 +1478,7 @@ GET-NAME-SERVICE-ERRNO")
|
|||
socklen_t socklen = sizeof(int);
|
||||
|
||||
ecl_disable_interrupts();
|
||||
ret = getsockopt(#0,#1,#2,&sockopt,&socklen);
|
||||
ret = getsockopt(#0,#1,#2,wincoerce(char*,&sockopt),&socklen);
|
||||
ecl_enable_interrupts();
|
||||
|
||||
@(return) = (ret == 0) ? ecl_make_integer(sockopt) : ECL_NIL;
|
||||
|
|
@ -1486,7 +1494,7 @@ GET-NAME-SERVICE-ERRNO")
|
|||
socklen_t socklen = sizeof(int);
|
||||
|
||||
ecl_disable_interrupts();
|
||||
ret = getsockopt(#0,#1,#2,&sockopt,&socklen);
|
||||
ret = getsockopt(#0,#1,#2,wincoerce(char*,&sockopt),&socklen);
|
||||
ecl_enable_interrupts();
|
||||
|
||||
@(return) = (ret == 0) ? ecl_make_integer(sockopt) : ECL_NIL;
|
||||
|
|
@ -1508,7 +1516,7 @@ GET-NAME-SERVICE-ERRNO")
|
|||
int ret;
|
||||
|
||||
ecl_disable_interrupts();
|
||||
ret = getsockopt(#0,#1,#2,&tv,&socklen);
|
||||
ret = getsockopt(#0,#1,#2,wincoerce(char*,&tv),&socklen);
|
||||
ecl_enable_interrupts();
|
||||
|
||||
@(return) = (ret == 0) ? ecl_make_doublefloat((double)tv.tv_sec
|
||||
|
|
@ -1526,7 +1534,7 @@ GET-NAME-SERVICE-ERRNO")
|
|||
int ret;
|
||||
|
||||
ecl_disable_interrupts();
|
||||
ret = getsockopt(#0,#1,#2,&sockopt,&socklen);
|
||||
ret = getsockopt(#0,#1,#2,wincoerce(char*,&sockopt),&socklen);
|
||||
ecl_enable_interrupts();
|
||||
|
||||
@(return) = (ret == 0) ? ecl_make_integer((sockopt.l_onoff != 0) ? sockopt.l_linger : 0) : ECL_NIL;
|
||||
|
|
@ -1542,7 +1550,7 @@ GET-NAME-SERVICE-ERRNO")
|
|||
int ret;
|
||||
|
||||
ecl_disable_interrupts();
|
||||
ret = setsockopt(#0,#1,#2,&sockopt,sizeof(int));
|
||||
ret = setsockopt(#0,#1,#2,wincoerce(char *,&sockopt),sizeof(int));
|
||||
ecl_enable_interrupts();
|
||||
|
||||
@(return) = (ret == 0) ? ECL_T : ECL_NIL;
|
||||
|
|
@ -1558,7 +1566,7 @@ GET-NAME-SERVICE-ERRNO")
|
|||
int ret;
|
||||
|
||||
ecl_disable_interrupts();
|
||||
ret = setsockopt(#0,#1,#2,&sockopt,sizeof(int));
|
||||
ret = setsockopt(#0,#1,#2,wincoerce(char *,&sockopt),sizeof(int));
|
||||
ecl_enable_interrupts();
|
||||
|
||||
@(return) = (ret == 0) ? ECL_T : ECL_NIL;
|
||||
|
|
@ -1604,7 +1612,8 @@ GET-NAME-SERVICE-ERRNO")
|
|||
}
|
||||
|
||||
ecl_disable_interrupts();
|
||||
ret = setsockopt(#0,#1,#2,&sockopt,sizeof(struct linger));
|
||||
ret = setsockopt(#0,#1,#2,wincoerce(char *,&sockopt),
|
||||
sizeof(struct linger));
|
||||
ecl_enable_interrupts();
|
||||
|
||||
@(return) = (ret == 0) ? ECL_T : ECL_NIL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue