[Ecls-list] c-inline bug?
Julian Stecklina
der_julian at web.de
Tue Jan 25 17:00:02 UTC 2005
Hallo,
I have this function:
(defmethod socket-connect ((socket inet-socket) &rest address)
(let ((ip (first address))
(port (second address)))
(if (= -1
(c-inline (port (aref ip 0) (aref ip 1) (aref ip 2) (aref ip 3)
(socket-file-descriptor socket))
(:int :int :int :int :int)
:int
"
{
struct sockaddr_in sockaddr;
printf(\"fd = %d\\n\",#5);
fill_inet_sockaddr(&sockaddr, #0, #1, #2, #3, #4);
@(return) = connect(#5,&sockaddr, sizeof(struct sockaddr_in));
}"
:side-effects t))
(socket-error "connect"))))
Now I got confused why I always got "Bad file descriptor" from the
call to connect. But the C code shows that #5 (the file descriptor) is
passed in its boxed form to connect and printf (which is only there
for debugging), apparent by the missing call to object_to_fixnum.
/* local function SOCKET-CONNECT */
static cl_object LC24(cl_narg narg, cl_object V1, ...)
{ VT25 VLEX25 CLSR25
cl_object value0;
if(narg<1) FEwrong_num_arguments_anonym();
{int i=1;
cl_object V2;
cl_va_list args; cl_va_start(args,V1,narg,1);
narg -=1;
V2=cl_grab_rest_args(args);
{cl_object V3; /* IP */
cl_object V4; /* NIL */
cl_object V5; /* PORT */
V4= cl_first(V2) /* FIRST */;
V5= cl_second(V2) /* SECOND */;
V3= V4;
{cl_object V6= aref1(V3,0);
{cl_object V7= aref1(V3,1);
{cl_object V8= aref1(V3,2);
{cl_object V9= aref1(V3,3);
T1= (*LK7)(1,V1) /* SOCKET-FILE-DESCRIPTOR */;
{int V10;
{
struct sockaddr_in sockaddr;
printf("fd = %d\n",T1);
fill_inet_sockaddr(&sockaddr, object_to_fixnum(V5), object_to_fixnum(V6), object_to_fixnum(V7), object_to_fixnum(V8), object_to_fixnum(V9));
V10= connect(T1,&sockaddr, sizeof(struct sockaddr_in));
}
T0= make_integer(V10);}}}}}
if(!(number_equalp(MAKE_FIXNUM(-1),T0))){
goto L206;}
value0=L11(VV[74]) /* SOCKET-ERROR */;
return value0;
L206:;
value0=Cnil; NVALUES=1;
return value0;
}
}
}
Regards,
--
____________________________
Julian Stecklina / _________________________/
________________/ /
\_________________/ LISP - truly beautiful
More information about the ecl-devel
mailing list