Store an ngx_fd_t within the void *

Peter Leonov gojpeg at
Fri Apr 30 15:02:04 MSD 2010

Hi devels,

Wanna store the value of ngx_fd_t in the void * variable (on the SpiderMonkey “private” field).
Am doing the following trick to avoid the warning “cast to pointer from integer of different size”:

#if (NGX_PTR_SIZE == 8)
#define FD_TO_PTR(fd)  ((void *) (uint64_t) fd)
#elif (NGX_PTR_SIZE == 4)
#define FD_TO_PTR(fd)  ((void *) (uint32_t) fd)
#warning can't determine the proper fd to pointer conversion
#define FD_TO_PTR(fd)  ((void *) fd)

and somewhere in the code:
void *private = FD_TO_PTR(fd);

Is all this legal?

More information about the nginx-devel mailing list