On Wed, Jul 25, 2001 at 08:38:02AM -0700, Ryan Bloom wrote:
>
> We usually don't cast for cases like this. If a cast is required, then
> something is
> usually wrong.
I don't like casting, but the types just don't match up in any way.
With Solaris' sendfilev, you use a sendfilevec_t struct:
/*
* Structure used by sendfilev()
*/
typedef struct sendfilevec {
int sfv_fd;
uint_t sfv_flag;
off_t sfv_off;
size_t sfv_len;
} sendfilevec_t;
Solaris defines the iovecs as:
#if defined(_XPG4_2)
typedef struct iovec {
void *iov_base;
size_t iov_len;
} iovec_t;
#else
typedef struct iovec {
caddr_t iov_base;
#if defined(_LP64)
size_t iov_len;
#else
long iov_len;
#endif
} iovec_t;
#endif /* defined(_XPG4_2) */
which I believe condenses down into:
typedef struct iovec {
caddr_t iov_base;
long iov_len;
} iovec_t;
And a caddr_t is:
typedef char *caddr_t; /* ?<core address> type */
We want to pass the address of the iov_base pointer to sendfilev
via the off_t (Solaris knows that it is a pointer to our address
space via a special fd). Since, off_t refers to an offset in our
own memory space and it isn't a pointer, well....
This just seems to be a Solaris-specific wackiness. Any tips on
how to avoid this are appreciated. I just couldn't think of any.
-- justin