unix: pack uv structs more
Try to avoid alignment holes on x86_64. Shaves off 4-8 bytes from most structs.
This commit is contained in:
parent
752ac30ec8
commit
793a52f5df
@ -132,8 +132,8 @@ struct uv__io_s {
|
||||
#define UV_UDP_SEND_PRIVATE_FIELDS \
|
||||
ngx_queue_t queue; \
|
||||
struct sockaddr_in6 addr; \
|
||||
uv_buf_t* bufs; \
|
||||
int bufcnt; \
|
||||
uv_buf_t* bufs; \
|
||||
ssize_t status; \
|
||||
uv_udp_send_cb send_cb; \
|
||||
uv_buf_t bufsml[UV_REQ_BUFSML_SIZE]; \
|
||||
@ -143,7 +143,6 @@ struct uv__io_s {
|
||||
|
||||
/* TODO: union or classes please! */
|
||||
#define UV_HANDLE_PRIVATE_FIELDS \
|
||||
int fd; \
|
||||
int flags; \
|
||||
uv_handle_t* next_pending; \
|
||||
|
||||
@ -155,9 +154,10 @@ struct uv__io_s {
|
||||
uv__io_t write_watcher; \
|
||||
ngx_queue_t write_queue; \
|
||||
ngx_queue_t write_completed_queue; \
|
||||
int delayed_error; \
|
||||
uv_connection_cb connection_cb; \
|
||||
int delayed_error; \
|
||||
int accepted_fd; \
|
||||
int fd; \
|
||||
|
||||
|
||||
/* UV_TCP */
|
||||
@ -166,6 +166,7 @@ struct uv__io_s {
|
||||
|
||||
/* UV_UDP */
|
||||
#define UV_UDP_PRIVATE_FIELDS \
|
||||
int fd; \
|
||||
uv_alloc_cb alloc_cb; \
|
||||
uv_udp_recv_cb recv_cb; \
|
||||
uv__io_t read_watcher; \
|
||||
@ -181,6 +182,7 @@ struct uv__io_s {
|
||||
|
||||
/* UV_POLL */
|
||||
#define UV_POLL_PRIVATE_FIELDS \
|
||||
int fd; \
|
||||
uv__io_t io_watcher;
|
||||
|
||||
|
||||
@ -246,7 +248,8 @@ struct uv__io_s {
|
||||
struct uv_fs_event_s* rbe_parent; \
|
||||
int rbe_color; \
|
||||
} node; \
|
||||
uv_fs_event_cb cb;
|
||||
uv_fs_event_cb cb; \
|
||||
int fd; \
|
||||
|
||||
#elif defined(__APPLE__) \
|
||||
|| defined(__FreeBSD__) \
|
||||
@ -258,6 +261,7 @@ struct uv__io_s {
|
||||
ev_io event_watcher; \
|
||||
uv_fs_event_cb cb; \
|
||||
int fflags; \
|
||||
int fd;
|
||||
|
||||
#elif defined(__sun)
|
||||
|
||||
@ -265,7 +269,8 @@ struct uv__io_s {
|
||||
# define UV_FS_EVENT_PRIVATE_FIELDS \
|
||||
ev_io event_watcher; \
|
||||
uv_fs_event_cb cb; \
|
||||
file_obj_t fo;
|
||||
file_obj_t fo; \
|
||||
int fd;
|
||||
#else /* !PORT_SOURCE_FILE */
|
||||
# define UV_FS_EVENT_PRIVATE_FIELDS
|
||||
#endif
|
||||
|
||||
29
include/uv.h
29
include/uv.h
@ -341,13 +341,13 @@ UV_EXTERN const char* uv_err_name(uv_err_t err);
|
||||
#endif
|
||||
|
||||
#define UV_REQ_FIELDS \
|
||||
/* read-only */ \
|
||||
uv_req_type type; \
|
||||
/* public */ \
|
||||
void* data; \
|
||||
UV_REQ_EXTRA_FIELDS \
|
||||
/* private */ \
|
||||
UV_REQ_PRIVATE_FIELDS
|
||||
UV_REQ_PRIVATE_FIELDS \
|
||||
/* read-only */ \
|
||||
uv_req_type type; \
|
||||
|
||||
/* Abstract base class of all requests. */
|
||||
struct uv_req_s {
|
||||
@ -384,16 +384,17 @@ struct uv_shutdown_s {
|
||||
# define UV_HANDLE_EXTRA_FIELDS
|
||||
#endif
|
||||
|
||||
#define UV_HANDLE_FIELDS \
|
||||
/* read-only */ \
|
||||
uv_loop_t* loop; \
|
||||
uv_handle_type type; \
|
||||
/* public */ \
|
||||
uv_close_cb close_cb; \
|
||||
void* data; \
|
||||
UV_HANDLE_EXTRA_FIELDS \
|
||||
/* private */ \
|
||||
UV_HANDLE_PRIVATE_FIELDS
|
||||
#define UV_HANDLE_FIELDS \
|
||||
/* read-only */ \
|
||||
uv_loop_t* loop; \
|
||||
/* public */ \
|
||||
uv_close_cb close_cb; \
|
||||
void* data; \
|
||||
/* read-only */ \
|
||||
uv_handle_type type; \
|
||||
/* private */ \
|
||||
UV_HANDLE_PRIVATE_FIELDS \
|
||||
UV_HANDLE_EXTRA_FIELDS \
|
||||
|
||||
/* The abstract base class of all handles. */
|
||||
struct uv_handle_s {
|
||||
@ -1365,8 +1366,8 @@ typedef enum {
|
||||
/* uv_fs_t is a subclass of uv_req_t */
|
||||
struct uv_fs_s {
|
||||
UV_REQ_FIELDS
|
||||
uv_loop_t* loop;
|
||||
uv_fs_type fs_type;
|
||||
uv_loop_t* loop;
|
||||
uv_fs_cb cb;
|
||||
ssize_t result;
|
||||
void* ptr;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user