diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-02-10 15:55:15 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-02-10 16:11:47 -0500 |
commit | a1c042bfe9238949a02a1050b9b4d3a1d36f5091 (patch) | |
tree | e88406e491dc01789b1ed00d11f0c1562a1c9086 /util-internal.h | |
parent | e465623a9c5ebc4bc85b7011c25d557a24a677d0 (diff) | |
download | libevent-a1c042bfe9238949a02a1050b9b4d3a1d36f5091.tar.gz |
Infrastructure for using faster/fewer syscalls when creating sockets
Linux provides some features that allow avoiding extra calls to
fcntl when creating new nonblocking/close-on-exec sockets, so
we can add wrapper functions to emulate those when they are not
available.
Additionally, even when we are emulating those functions, we can
take a fast path that cuts our fcntl calls in half: we don't need to
look up the previous value of a file's flags when we have just
created it.
Diffstat (limited to 'util-internal.h')
-rw-r--r-- | util-internal.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/util-internal.h b/util-internal.h index d1045e90..8880bf0f 100644 --- a/util-internal.h +++ b/util-internal.h @@ -38,6 +38,9 @@ #ifdef _EVENT_HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif +#ifdef _EVENT_HAVE_SYS_EVENTFD_H +#include <sys/eventfd.h> +#endif #include "event2/util.h" #include "ipv6-internal.h" @@ -311,6 +314,34 @@ HANDLE evutil_load_windows_system_library(const TCHAR *library_name); #endif #endif +evutil_socket_t evutil_socket(int domain, int type, int protocol); +evutil_socket_t evutil_accept4(evutil_socket_t sockfd, struct sockaddr *addr, + socklen_t *addrlen, int flags); +int evutil_make_internal_pipe(evutil_socket_t fd[2]); +evutil_socket_t evutil_eventfd(unsigned initval, int flags); + +#ifdef SOCK_NONBLOCK +#define EVUTIL_SOCK_NONBLOCK SOCK_NONBLOCK +#else +#define EVUTIL_SOCK_NONBLOCK 0x4000000 +#endif +#ifdef SOCK_CLOEXEC +#define EVUTIL_SOCK_CLOEXEC SOCK_CLOEXEC +#else +#define EVUTIL_SOCK_CLOEXEC 0x80000000 +#endif +#ifdef EFD_NONBLOCK +#define EVUTIL_EFD_NONBLOCK EFD_NONBLOCK +#else +#define EVUTIL_EFD_NONBLOCK 0x4000 +#endif +#ifdef EFD_CLOEXEC +#define EVUTIL_EFD_CLOEXEC EFD_CLOEXEC +#else +#define EVUTIL_EFD_CLOEXEC 0x8000 +#endif + + #ifdef __cplusplus } #endif |