curl-library
ioctl includes missing #ifdefs
Date: Fri, 14 Nov 2008 12:02:33 -0800
In porting over to Cell I noticed a few includes missing ifdef's around
them like the following:
lib\dict.c
lib\file.c
lib\telnet.c
lib\tftp.c
are all missing checks around ioctl.h
#include <sys/ioctl.h>
should be
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
lib\transfer.c is missing a check around
#include <signal.h>
should be
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
Lastly I got stuck on a line of code that *should* compile but for some
reason using ProDG's GCC compiler it's not compiling and I was looking for
some help.
In connect.c the function singleipconnect()
has the following line:
#if defined(EAGAIN) && EAGAIN != EWOULDBLOCK
that's checking to see if EAGAIN and EWOULDBLOCK are different to see if it
can add the EAGAIN case.
On Cell these expand out to:
sys/return_code.h
#define EAGAIN -2147418111 /* 0x80010001 */
netex/errno.h
#define EWOULDBLOCK SYS_NET_ERROR_EWOULDBLOCK
#define SYS_NET_ERROR_EWOULDBLOCK SYS_NET_ERROR_EAGAIN
#define SYS_NET_ERROR_EAGAIN CELL_ERROR_CAST(0x80010223)
error.h
#ifdef __cplusplus
/* Static-cast for C++ */
#define CELL_ERROR_CAST(err) (static_cast<int>(err))
#elif __ASSEMBLER__
/* Cast for Assembler */
#define CELL_ERROR_CAST(err) err
#else
/* Cast for C */
#define CELL_ERROR_CAST(err) ((int)(err))
#endif /* __cplusplus */
which results in the following line from the preprocessor:
#if defined(-2147418111) && -2147418111 != ((int)(0x80010223))
which generates the following compilation error:
c:/Copy of curl-7.19.1/lib/connect.c(876,34): error: missing binary
operator before token "("
hand editing the #define CELL_ERROR_CAST to the assembler version for C
solves the issue but obviously this isn't a good fix since this is a Sony
SDK file. But to be verbose the compiler allows the following:
#if defined(-2147418111) && -2147418111 != 0x80010223
This is also fixable by checking for the platform type and making a Cell
specific change to this area of the code, but I'm wondering if there's
another way that I've missed that would keep from having an ugly check for
Cell in this function.
Secondly, if you look closely at this code you will see that EAGAIN is
defined to the value 0x80010001, but on Cell there is a
SYS_NET_ERROR_EAGAIN that is used and indeed is the same value as
EWOULDBLOCK. That is to say Cell defines EAGAIN as one value, and
SYS_NET_ERROR_EAGAIN as another value. EAGAIN on Cell isn't a valid return
value for the connect function, in fact neither is SYS_NET_ERROR_EAGAIN. So
in other words on Cell we'll need to avoid adding the EAGAIN case for
connect() calls.
Thanks for your time.
--Jeff Curley
Sony Computer Entertainment America
Senior Programmer
(858) 824-5692
Received on 2008-11-14