| @@ -0,0 +1,77 @@ | ||
|
|
||
| .. _signal: | ||
|
|
||
| :c:type:`uv_signal_t` --- Signal handle | ||
| ======================================= | ||
|
|
||
| Signal handles implement Unix style signal handling on a per-event loop bases. | ||
|
|
||
| Reception of some signals is emulated on Windows: | ||
|
|
||
| * SIGINT is normally delivered when the user presses CTRL+C. However, like | ||
| on Unix, it is not generated when terminal raw mode is enabled. | ||
|
|
||
| * SIGBREAK is delivered when the user pressed CTRL + BREAK. | ||
|
|
||
| * SIGHUP is generated when the user closes the console window. On SIGHUP the | ||
| program is given approximately 10 seconds to perform cleanup. After that | ||
| Windows will unconditionally terminate it. | ||
|
|
||
| * SIGWINCH is raised whenever libuv detects that the console has been | ||
| resized. SIGWINCH is emulated by libuv when the program uses a :c:type:`uv_tty_t` | ||
| handle to write to the console. SIGWINCH may not always be delivered in a | ||
| timely manner; libuv will only detect size changes when the cursor is | ||
| being moved. When a readable :c:type:`uv_tty_t` handle is used in raw mode, | ||
| resizing the console buffer will also trigger a SIGWINCH signal. | ||
|
|
||
| Watchers for other signals can be successfully created, but these signals | ||
| are never received. These signals are: `SIGILL`, `SIGABRT`, `SIGFPE`, `SIGSEGV`, | ||
| `SIGTERM` and `SIGKILL.` | ||
|
|
||
| Calls to raise() or abort() to programmatically raise a signal are | ||
| not detected by libuv; these will not trigger a signal watcher. | ||
|
|
||
| .. note:: | ||
| On Linux SIGRT0 and SIGRT1 (signals 32 and 33) are used by the NPTL pthreads library to | ||
| manage threads. Installing watchers for those signals will lead to unpredictable behavior | ||
| and is strongly discouraged. Future versions of libuv may simply reject them. | ||
|
|
||
|
|
||
| Data types | ||
| ---------- | ||
|
|
||
| .. c:type:: uv_signal_t | ||
| Signal handle type. | ||
|
|
||
| .. c:type:: void (*uv_signal_cb)(uv_signal_t* handle, int signum) | ||
| Type definition for callback passed to :c:func:`uv_signal_start`. | ||
|
|
||
|
|
||
| Public members | ||
| ^^^^^^^^^^^^^^ | ||
|
|
||
| .. c:member:: int uv_signal_t.signum | ||
| Signal being monitored by this handle. Readonly. | ||
|
|
||
| .. seealso:: The :c:type:`uv_handle_t` members also apply. | ||
|
|
||
|
|
||
| API | ||
| --- | ||
|
|
||
| .. c:function:: int uv_signal_init(uv_loop_t*, uv_signal_t* signal) | ||
| Initialize the handle. | ||
| .. c:function:: int uv_signal_start(uv_signal_t* signal, uv_signal_cb cb, int signum) | ||
| Start the handle with the given callback, watching for the given signal. | ||
| .. c:function:: int uv_signal_stop(uv_signal_t* signal) | ||
| Stop the handle, the callback will no longer be called. | ||
| .. seealso:: The :c:type:`uv_handle_t` API functions also apply. |
| @@ -0,0 +1,8 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <array> | ||
| <string>Template: White (2014-02-28 09:41)</string> | ||
| <string>M6.2.2-1878-1</string> | ||
| </array> | ||
| </plist> |
| @@ -0,0 +1 @@ | ||
| F69E9CD9-EEF1-4223-9DA4-A1EA7FE112BA |
| @@ -0,0 +1,189 @@ | ||
|
|
||
| .. _stream: | ||
|
|
||
| :c:type:`uv_stream_t` --- Stream handle | ||
| ======================================= | ||
|
|
||
| Stream handles provide an abstraction of a duplex communication channel. | ||
| :c:type:`uv_stream_t` is an abstract type, libuv provides 3 stream implementations | ||
| in the for of :c:type:`uv_tcp_t`, :c:type:`uv_pipe_t` and :c:type:`uv_tty_t`. | ||
|
|
||
|
|
||
| Data types | ||
| ---------- | ||
|
|
||
| .. c:type:: uv_stream_t | ||
| Stream handle type. | ||
|
|
||
| .. c:type:: void (*uv_read_cb)(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) | ||
| Callback called when data was read on a stream. | ||
|
|
||
| `nread` is > 0 if there is data available, 0 if libuv is done reading for | ||
| now, or < 0 on error. | ||
|
|
||
| The callee is responsible for stopping closing the stream when an error happens | ||
| by calling :c:func:`uv_read_stop` or :c:func:`uv_close`. Trying to read | ||
| from the stream again is undefined. | ||
|
|
||
| The callee is responsible for freeing the buffer, libuv does not reuse it. | ||
| The buffer may be a null buffer (where buf->base=NULL and buf->len=0) on | ||
| error. | ||
|
|
||
| .. c:type:: void (*uv_write_cb)(uv_write_t* req, int status) | ||
| Callback called after data was written on a stream. `status` will be 0 in | ||
| case of success, < 0 otherwise. | ||
|
|
||
| .. c:type:: void (*uv_connect_cb)(uv_connect_t* req, int status) | ||
| Callback called after a connection started by :c:func:`uv_connect` is done. | ||
| `status` will be 0 in case of success, < 0 otherwise. | ||
|
|
||
| .. c:type:: void (*uv_shutdown_cb)(uv_shutdown_t* req, int status) | ||
| Callback called after s shutdown request has been completed. `status` will | ||
| be 0 in case of success, < 0 otherwise. | ||
|
|
||
| .. c:type:: void (*uv_connection_cb)(uv_stream_t* server, int status) | ||
| Callback called when a stream server has received an incoming connection. | ||
| The user can accept the connection by calling :c:func:`uv_accept`. | ||
| `status` will de 0 in case of success, < 0 otherwise. | ||
|
|
||
|
|
||
| Public members | ||
| ^^^^^^^^^^^^^^ | ||
|
|
||
| .. c:member:: size_t uv_stream_t.write_queue_size | ||
| Contains the amount of queued bytes waiting to be sent. Readonly. | ||
|
|
||
| .. seealso:: The :c:type:`uv_handle_t` members also apply. | ||
|
|
||
|
|
||
| API | ||
| --- | ||
|
|
||
| .. c:function:: int uv_shutdown(uv_shutdown_t* req, uv_stream_t* handle, uv_shutdown_cb cb) | ||
| Shutdown the outgoing (write) side of a duplex stream. It waits for pending | ||
| write requests to complete. The `handle` should refer to a initialized stream. | ||
| `req` should be an uninitialized shutdown request struct. The `cb` is called | ||
| after shutdown is complete. | ||
| .. c:function:: int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) | ||
| Start listening for incoming connections. `backlog` indicates the number of | ||
| connections the kernel might queue, same as ``listen(2)``. When a new | ||
| incoming connection is received the :c:type:`uv_connection_cb` callback is | ||
| called. | ||
| .. c:function:: int uv_accept(uv_stream_t* server, uv_stream_t* client) | ||
| This call is used in conjunction with :c:func:`uv_listen` to accept incoming | ||
| connections. Call this function after receiving a :c:type:`uv_connection_cb` | ||
| to accept the connection. Before calling this function the client handle must | ||
| be initialized. < 0 return value indicates an error. | ||
| When the :c:type:`uv_connection_cb` callback is called it is guaranteed that | ||
| this function will complete successfully the first time. If you attempt to use | ||
| it more than once, it may fail. It is suggested to only call this function once | ||
| per :c:type:`uv_connection_cb` call. | ||
| .. note:: | ||
| `server` and `client` must be handles running on the same loop. | ||
| .. c:function:: int uv_read_start(uv_stream_t*, uv_alloc_cb alloc_cb, uv_read_cb read_cb) | ||
| Read data from an incoming stream. The callback will be made several | ||
| times until there is no more data to read or :c:func:`uv_read_stop` is called. | ||
| When we've reached EOF `nread` will be set to ``UV_EOF``. | ||
| When `nread` < 0, the `buf` parameter might not point to a valid buffer; | ||
| in that case `buf.len` and `buf.base` are both set to 0. | ||
| .. note:: | ||
| `nread` might also be 0, which does *not* indicate an error or EOF, it happens when | ||
| libuv requested a buffer through the alloc callback but then decided that it didn't | ||
| need that buffer. | ||
| .. c:function:: int uv_read_stop(uv_stream_t*) | ||
| Stop reading data from the stream. The :c:type:`uv_read_cb` callback will | ||
| no longer be called. | ||
| .. c:function:: int uv_write(uv_write_t* req, uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb) | ||
| Write data to stream. Buffers are written in order. Example: | ||
| :: | ||
| uv_buf_t a[] = { | ||
| { .base = "1", .len = 1 }, | ||
| { .base = "2", .len = 1 } | ||
| }; | ||
| uv_buf_t b[] = { | ||
| { .base = "3", .len = 1 }, | ||
| { .base = "4", .len = 1 } | ||
| }; | ||
| uv_write_t req1; | ||
| uv_write_t req2; | ||
| /* writes "1234" */ | ||
| uv_write(&req1, stream, a, 2); | ||
| uv_write(&req2, stream, b, 2); | ||
| .. c:function:: int uv_write2(uv_write_t* req, uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs, uv_stream_t* send_handle, uv_write_cb cb) | ||
| Extended write function for sending handles over a pipe. The pipe must be | ||
| initialized with `ipc` == 1. | ||
| .. note:: | ||
| `send_handle` must be a TCP socket or pipe, which is a server or a connection (listening | ||
| or connected state). Bound sockets or pipes will be assumed to be servers. | ||
| .. c:function:: int uv_try_write(uv_stream_t* handle, const uv_buf_t bufs[], unsigned int nbufs) | ||
| Same as :c:func:`uv_write`, but won't queue a write request if it can't be | ||
| completed immediately. | ||
| Will return either: | ||
| * > 0: number of bytes written (can be less than the supplied buffer size). | ||
| * < 0: negative error code (``UV_EAGAIN`` is returned if no data can be sent | ||
| immediately). | ||
| .. c:function:: int uv_is_readable(const uv_stream_t* handle) | ||
| Returns 1 if the stream is readable, 0 otherwise. | ||
| .. c:function:: int uv_is_writable(const uv_stream_t* handle) | ||
| Returns 1 if the stream is writable, 0 otherwise. | ||
| .. c:function:: int uv_stream_set_blocking(uv_stream_t* handle, int blocking) | ||
| Enable or disable blocking mode for a stream. | ||
| When blocking mode is enabled all writes complete synchronously. The | ||
| interface remains unchanged otherwise, e.g. completion or failure of the | ||
| operation will still be reported through a callback which is made | ||
| asychronously. | ||
| .. warning:: | ||
| Relying too much on this API is not recommended. It is likely to change | ||
| significantly in the future. | ||
| Currently this only works on Windows and only for | ||
| :c:type:`uv_pipe_t` handles. | ||
| Also libuv currently makes no ordering guarantee when the blocking mode | ||
| is changed after write requests have already been submitted. Therefore it is | ||
| recommended to set the blocking mode immediately after opening or creating | ||
| the stream. | ||
| .. seealso:: The :c:type:`uv_handle_t` API functions also apply. |
| @@ -0,0 +1,97 @@ | ||
|
|
||
| .. _tcp: | ||
|
|
||
| :c:type:`uv_tcp_t` --- TCP handle | ||
| ================================= | ||
|
|
||
| TCP handles are used to represent both TCP streams and servers. | ||
|
|
||
| :c:type:`uv_tcp_t` is a 'subclass' of :c:type:`uv_stream_t`. | ||
|
|
||
|
|
||
| Data types | ||
| ---------- | ||
|
|
||
| .. c:type:: uv_tcp_t | ||
| TCP handle type. | ||
|
|
||
|
|
||
| Public members | ||
| ^^^^^^^^^^^^^^ | ||
|
|
||
| N/A | ||
|
|
||
| .. seealso:: The :c:type:`uv_stream_t` members also apply. | ||
|
|
||
|
|
||
| API | ||
| --- | ||
|
|
||
| .. c:function:: int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle) | ||
| Initialize the handle. | ||
| .. c:function:: int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock) | ||
| Open an existing file descriptor or SOCKET as a TCP handle. | ||
| .. note:: | ||
| The user is responsible for setting the file descriptor in | ||
| non-blocking mode. | ||
| .. c:function:: int uv_tcp_nodelay(uv_tcp_t* handle, int enable) | ||
| Enable / disable Nagle's algorithm. | ||
| .. c:function:: int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) | ||
| Enable / disable TCP keep-alive. `delay` is the initial delay in seconds, | ||
| ignored when `enable` is zero. | ||
| .. c:function:: int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) | ||
| Enable / disable simultaneous asynchronous accept requests that are | ||
| queued by the operating system when listening for new TCP connections. | ||
| This setting is used to tune a TCP server for the desired performance. | ||
| Having simultaneous accepts can significantly improve the rate of accepting | ||
| connections (which is why it is enabled by default) but may lead to uneven | ||
| load distribution in multi-process setups. | ||
| .. c:function:: int uv_tcp_bind(uv_tcp_t* handle, const struct sockaddr* addr, unsigned int flags) | ||
| Bind the handle to an address and port. `addr` should point to an | ||
| initialized ``struct sockaddr_in`` or ``struct sockaddr_in6``. | ||
| When the port is already taken, you can expect to see an ``UV_EADDRINUSE`` | ||
| error from either :c:func:`uv_tcp_bind`, :c:func:`uv_listen` or | ||
| :c:func:`uv_tcp_connect`. That is, a successful call to this function does | ||
| not guarantee that the call to :c:func:`uv_listen` or :c:func:`uv_tcp_connect` | ||
| will succeed as well. | ||
| `flags` con contain ``UV_TCP_IPV6ONLY``, in which case dual-stack support | ||
| is disabled and only IPv6 is used. | ||
| .. c:function:: int uv_tcp_getsockname(const uv_tcp_t* handle, struct sockaddr* name, int* namelen) | ||
| Get the current address to which the handle is bound. `addr` must point to | ||
| a valid and big enough chunk of memory, ``struct sockaddr_storage`` is | ||
| recommended for IPv4 and IPv6 support. | ||
| .. c:function:: int uv_tcp_getpeername(const uv_tcp_t* handle, struct sockaddr* name, int* namelen) | ||
| Get the address of the peer connected to the handle. `addr` must point to | ||
| a valid and big enough chunk of memory, ``struct sockaddr_storage`` is | ||
| recommended for IPv4 and IPv6 support. | ||
| .. c:function:: int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle, const struct sockaddr* addr, uv_connect_cb cb) | ||
| Establish an IPv4 or IPv6 TCP connection. Provide an initialized TCP handle | ||
| and an uninitialized :c:type:`uv_connect_t`. `addr` should point to an | ||
| initialized ``struct sockaddr_in`` or ``struct sockaddr_in6``. | ||
| The callback is made when the connection has been established or when a | ||
| connection error happened. | ||
| .. seealso:: The :c:type:`uv_stream_t` API functions also apply. |
| @@ -0,0 +1,156 @@ | ||
|
|
||
| .. _threading: | ||
|
|
||
| Threading and synchronization utilities | ||
| ======================================= | ||
|
|
||
| libuv provides cross-platform implementations for multiple threading and | ||
| synchronization primitives. The API largely follows the pthreads API. | ||
|
|
||
|
|
||
| Data types | ||
| ---------- | ||
|
|
||
| .. c:type:: uv_thread_t | ||
| Thread data type. | ||
|
|
||
| .. c:type:: void (*uv_thread_cb)(void* arg) | ||
| Callback that is invoked to initialize thread execution. `arg` is the same | ||
| value that was passed to :c:func:`uv_thread_create`. | ||
|
|
||
| .. c:type:: uv_key_t | ||
| Thread-local key data type. | ||
|
|
||
| .. c:type:: uv_once_t | ||
| Once-only initializer data type. | ||
|
|
||
| .. c:type:: uv_mutex_t | ||
| Mutex data type. | ||
|
|
||
| .. c:type:: uv_rwlock_t | ||
| Read-write lock data type. | ||
|
|
||
| .. c:type:: uv_sem_t | ||
| Semaphore data type. | ||
|
|
||
| .. c:type:: uv_cond_t | ||
| Condition data type. | ||
|
|
||
| .. c:type:: uv_barrier_t | ||
| Barrier data type. | ||
|
|
||
|
|
||
| API | ||
| --- | ||
|
|
||
| Threads | ||
| ^^^^^^^ | ||
|
|
||
| .. c:function:: int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg) | ||
| .. c:function:: unsigned long uv_thread_self(void) | ||
| .. c:function:: int uv_thread_join(uv_thread_t *tid) | ||
| Thread-local storage | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| .. note:: | ||
| The total thread-local storage size may be limited. That is, it may not be possible to | ||
| create many TLS keys. | ||
| .. c:function:: int uv_key_create(uv_key_t* key) | ||
| .. c:function:: void uv_key_delete(uv_key_t* key) | ||
| .. c:function:: void* uv_key_get(uv_key_t* key) | ||
| .. c:function:: void uv_key_set(uv_key_t* key, void* value) | ||
| Once-only initialization | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| Runs a function once and only once. Concurrent calls to :c:func:`uv_once` with the | ||
| same guard will block all callers except one (it's unspecified which one). | ||
| The guard should be initialized statically with the UV_ONCE_INIT macro. | ||
| .. c:function:: void uv_once(uv_once_t* guard, void (*callback)(void)) | ||
| Mutex locks | ||
| ^^^^^^^^^^^ | ||
| Functions return 0 on success or an error code < 0 (unless the | ||
| return type is void, of course). | ||
| .. c:function:: int uv_mutex_init(uv_mutex_t* handle) | ||
| .. c:function:: void uv_mutex_destroy(uv_mutex_t* handle) | ||
| .. c:function:: void uv_mutex_lock(uv_mutex_t* handle) | ||
| .. c:function:: int uv_mutex_trylock(uv_mutex_t* handle) | ||
| .. c:function:: void uv_mutex_unlock(uv_mutex_t* handle) | ||
| Read-write locks | ||
| ^^^^^^^^^^^^^^^^ | ||
| Functions return 0 on success or an error code < 0 (unless the | ||
| return type is void, of course). | ||
| .. c:function:: int uv_rwlock_init(uv_rwlock_t* rwlock) | ||
| .. c:function:: void uv_rwlock_destroy(uv_rwlock_t* rwlock) | ||
| .. c:function:: void uv_rwlock_rdlock(uv_rwlock_t* rwlock) | ||
| .. c:function:: int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock) | ||
| .. c:function:: void uv_rwlock_rdunlock(uv_rwlock_t* rwlock) | ||
| .. c:function:: void uv_rwlock_wrlock(uv_rwlock_t* rwlock) | ||
| .. c:function:: int uv_rwlock_trywrlock(uv_rwlock_t* rwlock) | ||
| .. c:function:: void uv_rwlock_wrunlock(uv_rwlock_t* rwlock) | ||
| Semaphores | ||
| ^^^^^^^^^^ | ||
| Functions return 0 on success or an error code < 0 (unless the | ||
| return type is void, of course). | ||
| .. c:function:: int uv_sem_init(uv_sem_t* sem, unsigned int value) | ||
| .. c:function:: void uv_sem_destroy(uv_sem_t* sem) | ||
| .. c:function:: void uv_sem_post(uv_sem_t* sem) | ||
| .. c:function:: void uv_sem_wait(uv_sem_t* sem) | ||
| .. c:function:: int uv_sem_trywait(uv_sem_t* sem) | ||
| Conditions | ||
| ^^^^^^^^^^ | ||
| Functions return 0 on success or an error code < 0 (unless the | ||
| return type is void, of course). | ||
| .. note:: | ||
| Callers should be prepared to deal with spurious wakeups on :c:func:`uv_cond_wait` and | ||
| :c:func:`uv_cond_timedwait`. | ||
| .. c:function:: int uv_cond_init(uv_cond_t* cond) | ||
| .. c:function:: void uv_cond_destroy(uv_cond_t* cond) | ||
| .. c:function:: void uv_cond_signal(uv_cond_t* cond) | ||
| .. c:function:: void uv_cond_broadcast(uv_cond_t* cond) | ||
| .. c:function:: void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) | ||
| .. c:function:: int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) | ||
| Barriers | ||
| ^^^^^^^^ | ||
| Functions return 0 on success or an error code < 0 (unless the | ||
| return type is void, of course). | ||
| .. note:: | ||
| :c:func:`uv_barrier_wait` returns a value > 0 to an arbitrarily chosen "serializer" thread | ||
| to facilitate cleanup, i.e. | ||
| :: | ||
| if (uv_barrier_wait(&barrier) > 0) | ||
| uv_barrier_destroy(&barrier); | ||
| .. c:function:: int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) | ||
| .. c:function:: void uv_barrier_destroy(uv_barrier_t* barrier) | ||
| .. c:function:: int uv_barrier_wait(uv_barrier_t* barrier) |
| @@ -0,0 +1,59 @@ | ||
|
|
||
| .. _threadpool: | ||
|
|
||
| Thread pool work scheduling | ||
| =========================== | ||
|
|
||
| libuv provides a threadpool which can be used to run user code and get notified | ||
| in the loop thread. This thread pool is internally used to run al filesystem | ||
| operations, as well as getaddrinfo and getnameinfo requests. | ||
|
|
||
| Its default size is 4, but it can be changed at startup time by setting the | ||
| ``UV_THREADPOOL_SIZE`` environment variable to any value (the absolute maximum | ||
| is 128). | ||
|
|
||
| The threadpool is global and shared across all event loops. | ||
|
|
||
|
|
||
| Data types | ||
| ---------- | ||
|
|
||
| .. c:type:: uv_work_t | ||
| Work request type. | ||
|
|
||
| .. c:type:: void (*uv_work_cb)(uv_work_t* req) | ||
| Callback passed to :c:func:`uv_queue_work` which will be run on the thread | ||
| pool. | ||
|
|
||
| .. c:type:: void (*uv_after_work_cb)(uv_work_t* req, int status) | ||
| Callback passed to :c:func:`uv_queue_work` which will be called on the loop | ||
| thread after the work on the threadpool has been completed. If the work | ||
| was cancelled using :c:func:`uv_cancel` `status` will be ``UV_ECANCELED``. | ||
|
|
||
|
|
||
| Public members | ||
| ^^^^^^^^^^^^^^ | ||
|
|
||
| .. c:member:: uv_loop_t* uv_work_t.loop | ||
| Loop that started this request and where completion will be reported. | ||
| Readonly. | ||
|
|
||
| .. seealso:: The :c:type:`uv_req_t` members also apply. | ||
|
|
||
|
|
||
| API | ||
| --- | ||
|
|
||
| .. c:function:: int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb, uv_after_work_cb after_work_cb) | ||
| Initializes a work request which will run the given `work_cb` in a thread | ||
| from the threadpool. Once `work_cb` is completed, `after_work_cb` will be | ||
| called on the loop thread. | ||
| This request can be cancelled with :c:func:`uv_cancel`. | ||
| .. seealso:: The :c:type:`uv_req_t` API functions also apply. |
| @@ -0,0 +1,68 @@ | ||
|
|
||
| .. _timer: | ||
|
|
||
| :c:type:`uv_timer_t` --- Timer handle | ||
| ===================================== | ||
|
|
||
| Timer handles are used to schedule callbacks to be called in the future. | ||
|
|
||
|
|
||
| Data types | ||
| ---------- | ||
|
|
||
| .. c:type:: uv_timer_t | ||
| Timer handle type. | ||
|
|
||
| .. c:type:: void (*uv_timer_cb)(uv_timer_t* handle) | ||
| Type definition for callback passed to :c:func:`uv_timer_start`. | ||
|
|
||
|
|
||
| Public members | ||
| ^^^^^^^^^^^^^^ | ||
|
|
||
| N/A | ||
|
|
||
| .. seealso:: The :c:type:`uv_handle_t` members also apply. | ||
|
|
||
|
|
||
| API | ||
| --- | ||
|
|
||
| .. c:function:: int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) | ||
| Initialize the handle. | ||
| .. c:function:: int uv_timer_start(uv_timer_t* handle, uv_timer_cb cb, uint64_t timeout, uint64_t repeat) | ||
| Start the timer. `timeout` and `repeat` are in milliseconds. | ||
| If `timeout` is zero, the callback fires on the next event loop iteration. | ||
| If `repeat` is non-zero, the callback fires first after `timeout` | ||
| milliseconds and then repeatedly after `repeat` milliseconds. | ||
| .. c:function:: int uv_timer_stop(uv_timer_t* handle) | ||
| Stop the timer, the callback will not be called anymore. | ||
| .. c:function:: int uv_timer_again(uv_timer_t* handle) | ||
| Stop the timer, and if it is repeating restart it using the repeat value | ||
| as the timeout. If the timer has never been started before it returns | ||
| UV_EINVAL. | ||
| .. c:function:: void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat) | ||
| Set the repeat value in milliseconds. | ||
| .. note:: | ||
| If the repeat value is set from a timer callback it does not immediately take effect. | ||
| If the timer was non-repeating before, it will have been stopped. If it was repeating, | ||
| then the old repeat value will have been used to schedule the next timeout. | ||
| .. c:function:: uint64_t uv_timer_get_repeat(const uv_timer_t* handle) | ||
| Get the timer repeat value. | ||
| .. seealso:: The :c:type:`uv_handle_t` API functions also apply. |
| @@ -0,0 +1,63 @@ | ||
|
|
||
| .. _tty: | ||
|
|
||
| :c:type:`uv_tty_t` --- TTY handle | ||
| ================================= | ||
|
|
||
| TTY handles represent a stream for the console. | ||
|
|
||
| :c:type:`uv_tty_t` is a 'subclass' of :c:type:`uv_stream_t`. | ||
|
|
||
|
|
||
| Data types | ||
| ---------- | ||
|
|
||
| .. c:type:: uv_tty_t | ||
| TTY handle type. | ||
|
|
||
|
|
||
| Public members | ||
| ^^^^^^^^^^^^^^ | ||
|
|
||
| N/A | ||
|
|
||
| .. seealso:: The :c:type:`uv_stream_t` members also apply. | ||
|
|
||
|
|
||
| API | ||
| --- | ||
|
|
||
| .. c:function:: int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable) | ||
| Initialize a new TTY stream with the given file descriptor. Usually the | ||
| file descriptor will be: | ||
| * 0 = stdin | ||
| * 1 = stdout | ||
| * 2 = stderr | ||
| `readable`, specifies if you plan on calling :c:func:`uv_read_start` with | ||
| this stream. stdin is readable, stdout is not. | ||
| .. note:: | ||
| TTY streams which are not readable have blocking writes. | ||
| .. c:function:: int uv_tty_set_mode(uv_tty_t*, int mode) | ||
| Set the TTY mode. 0 for normal, 1 for raw. | ||
| .. c:function:: int uv_tty_reset_mode(void) | ||
| To be called when the program exits. Resets TTY settings to default | ||
| values for the next process to take over. | ||
| This function is async signal-safe on Unix platforms but can fail with error | ||
| code ``UV_EBUSY`` if you call it when execution is inside | ||
| :c:func:`uv_tty_set_mode`. | ||
| .. c:function:: int uv_tty_get_winsize(uv_tty_t*, int* width, int* height) | ||
| Gets the current Window size. On success it returns 0. | ||
| .. seealso:: The :c:type:`uv_stream_t` API functions also apply. |
| @@ -0,0 +1,280 @@ | ||
|
|
||
| .. _udp: | ||
|
|
||
| :c:type:`uv_udp_t` --- UDP handle | ||
| ================================= | ||
|
|
||
| UDP handles encapsulate UDP communication for both clients and servers. | ||
|
|
||
|
|
||
| Data types | ||
| ---------- | ||
|
|
||
| .. c:type:: uv_udp_t | ||
| UDP handle type. | ||
|
|
||
| .. c:type:: uv_udp_send_t | ||
| UDP send request type. | ||
|
|
||
| .. c:type:: uv_udp_flags | ||
| Flags used in :c:func:`uv_udp_bind` and :c:type:`uv_udp_recv_cb`.. | ||
|
|
||
| :: | ||
|
|
||
| enum uv_udp_flags { | ||
| /* Disables dual stack mode. */ | ||
| UV_UDP_IPV6ONLY = 1, | ||
| /* | ||
| * Indicates message was truncated because read buffer was too small. The | ||
| * remainder was discarded by the OS. Used in uv_udp_recv_cb. | ||
| */ | ||
| UV_UDP_PARTIAL = 2, | ||
| /* | ||
| * Indicates if SO_REUSEADDR will be set when binding the handle in | ||
| * uv_udp_bind. | ||
| * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other | ||
| * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that | ||
| * multiple threads or processes can bind to the same address without error | ||
| * (provided they all set the flag) but only the last one to bind will receive | ||
| * any traffic, in effect "stealing" the port from the previous listener. | ||
| */ | ||
| UV_UDP_REUSEADDR = 4 | ||
| }; | ||
|
|
||
| .. c:type:: void (*uv_udp_send_cb)(uv_udp_send_t* req, int status) | ||
| Type definition for callback passed to :c:func:`uv_udp_send`, which is | ||
| called after the data was sent. | ||
|
|
||
| .. c:type:: void (*uv_udp_recv_cb)(uv_udp_t* handle, ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned flags) | ||
| Type definition for callback passed to :c:func:`uv_udp_recv_start`, which | ||
| is called when the endpoint receives data. | ||
|
|
||
| * `handle`: UDP handle | ||
| * `nread`: Number of bytes that have been received. | ||
| 0 if there is no more data to read. You may discard or repurpose | ||
| the read buffer. Note that 0 may also mean that an empty datagram | ||
| was received (in this case `addr` is not NULL). < 0 if a transmission | ||
| error was detected. | ||
| * `buf`: :c:type:`uv_buf_t` with the received data. | ||
| * `addr`: ``struct sockaddr*`` containing the address of the sender. | ||
| Can be NULL. Valid for the duration of the callback only. | ||
| * `flags`: One or more or'ed UV_UDP_* constants. Right now only | ||
| ``UV_UDP_PARTIAL`` is used. | ||
|
|
||
| .. note:: | ||
| The receive callback will be called with `nread` == 0 and `addr` == NULL when there is | ||
| nothing to read, and with `nread` == 0 and `addr` != NULL when an empty UDP packet is | ||
| received. | ||
|
|
||
| .. c:type:: uv_membership | ||
| Membership type for a multicast address. | ||
|
|
||
| :: | ||
|
|
||
| typedef enum { | ||
| UV_LEAVE_GROUP = 0, | ||
| UV_JOIN_GROUP | ||
| } uv_membership; | ||
|
|
||
|
|
||
| Public members | ||
| ^^^^^^^^^^^^^^ | ||
|
|
||
| .. c:member:: size_t uv_udp_t.send_queue_size | ||
| Number of bytes queued for sending. This field strictly shows how much | ||
| information is currently queued. | ||
|
|
||
| .. c:member:: size_t uv_udp_t.send_queue_count | ||
| Number of send requests currently in the queue awaiting to be processed. | ||
|
|
||
| .. c:member:: uv_udp_t* uv_udp_send_t.handle | ||
| UDP handle where this send request is taking place. | ||
|
|
||
| .. seealso:: The :c:type:`uv_handle_t` members also apply. | ||
|
|
||
|
|
||
| API | ||
| --- | ||
|
|
||
| .. c:function:: int uv_udp_init(uv_loop_t*, uv_udp_t* handle) | ||
| Initialize a new UDP handle. The actual socket is created lazily. | ||
| Returns 0 on success. | ||
| .. c:function:: int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) | ||
| Opens an existing file descriptor or Windows SOCKET as a UDP handle. | ||
| Unix only: | ||
| The only requirement of the `sock` argument is that it follows the datagram | ||
| contract (works in unconnected mode, supports sendmsg()/recvmsg(), etc). | ||
| In other words, other datagram-type sockets like raw sockets or netlink | ||
| sockets can also be passed to this function. | ||
| .. c:function:: int uv_udp_bind(uv_udp_t* handle, const struct sockaddr* addr, unsigned int flags) | ||
| Bind the UDP handle to an IP address and port. | ||
| :param handle: UDP handle. Should have been initialized with | ||
| :c:func:`uv_udp_init`. | ||
| :param addr: `struct sockaddr_in` or `struct sockaddr_in6` | ||
| with the address and port to bind to. | ||
| :param flags: Indicate how the socket will be bound, | ||
| ``UV_UDP_IPV6ONLY`` and ``UV_UDP_REUSEADDR`` are supported. | ||
| :returns: 0 on success, or an error code < 0 on failure. | ||
| .. c:function:: int uv_udp_getsockname(const uv_udp_t* handle, struct sockaddr* name, int* namelen) | ||
| Get the local IP and port of the UDP handle. | ||
| :param handle: UDP handle. Should have been initialized with | ||
| :c:func:`uv_udp_init` and bound. | ||
| :param name: Pointer to the structure to be filled with the address data. | ||
| In order to support IPv4 and IPv6 `struct sockaddr_storage` should be | ||
| used. | ||
| :param namelen: On input it indicates the data of the `name` field. On | ||
| output it indicates how much of it was filled. | ||
| :returns: 0 on success, or an error code < 0 on failure. | ||
| .. c:function:: int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr, const char* interface_addr, uv_membership membership) | ||
| Set membership for a multicast address | ||
| :param handle: UDP handle. Should have been initialized with | ||
| :c:func:`uv_udp_init`. | ||
| :param multicast_addr: Multicast address to set membership for. | ||
| :param interface_addr: Interface address. | ||
| :param membership: Should be ``UV_JOIN_GROUP`` or ``UV_LEAVE_GROUP``. | ||
| :returns: 0 on success, or an error code < 0 on failure. | ||
| .. c:function:: int uv_udp_set_multicast_loop(uv_udp_t* handle, int on) | ||
| Set IP multicast loop flag. Makes multicast packets loop back to | ||
| local sockets. | ||
| :param handle: UDP handle. Should have been initialized with | ||
| :c:func:`uv_udp_init`. | ||
| :param on: 1 for on, 0 for off. | ||
| :returns: 0 on success, or an error code < 0 on failure. | ||
| .. c:function:: int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl) | ||
| Set the multicast ttl. | ||
| :param handle: UDP handle. Should have been initialized with | ||
| :c:func:`uv_udp_init`. | ||
| :param ttl: 1 through 255. | ||
| :returns: 0 on success, or an error code < 0 on failure. | ||
| .. c:function:: int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr) | ||
| Set the multicast interface to send or receive data on. | ||
| :param handle: UDP handle. Should have been initialized with | ||
| :c:func:`uv_udp_init`. | ||
| :param interface_addr: interface address. | ||
| :returns: 0 on success, or an error code < 0 on failure. | ||
| .. c:function:: int uv_udp_set_broadcast(uv_udp_t* handle, int on) | ||
| Set broadcast on or off. | ||
| :param handle: UDP handle. Should have been initialized with | ||
| :c:func:`uv_udp_init`. | ||
| :param on: 1 for on, 0 for off. | ||
| :returns: 0 on success, or an error code < 0 on failure. | ||
| .. c:function:: int uv_udp_set_ttl(uv_udp_t* handle, int ttl) | ||
| Set the time to live. | ||
| :param handle: UDP handle. Should have been initialized with | ||
| :c:func:`uv_udp_init`. | ||
| :param ttl: 1 through 255. | ||
| :returns: 0 on success, or an error code < 0 on failure. | ||
| .. c:function:: int uv_udp_send(uv_udp_send_t* req, uv_udp_t* handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr* addr, uv_udp_send_cb send_cb) | ||
| Send data over the UDP socket. If the socket has not previously been bound | ||
| with :c:func:`uv_udp_bind` it will be bound to 0.0.0.0 | ||
| (the "all interfaces" IPv4 address) and a random port number. | ||
| :param req: UDP request handle. Need not be initialized. | ||
| :param handle: UDP handle. Should have been initialized with | ||
| :c:func:`uv_udp_init`. | ||
| :param bufs: List of buffers to send. | ||
| :param nbufs: Number of buffers in `bufs`. | ||
| :param addr: `struct sockaddr_in` or `struct sockaddr_in6` with the | ||
| address and port of the remote peer. | ||
| :param send_cb: Callback to invoke when the data has been sent out. | ||
| :returns: 0 on success, or an error code < 0 on failure. | ||
| .. c:function:: int uv_udp_try_send(uv_udp_t* handle, const uv_buf_t bufs[], unsigned int nbufs, const struct sockaddr* addr) | ||
| Same as :c:func:`uv_udp_send`, but won't queue a send request if it can't | ||
| be completed immediately. | ||
| :returns: >= 0: number of bytes sent (it matches the given buffer size). | ||
| < 0: negative error code (``UV_EAGAIN`` is returned when the message | ||
| can't be sent immediately). | ||
| .. c:function:: int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb, uv_udp_recv_cb recv_cb) | ||
| Prepare for receiving data. If the socket has not previously been bound | ||
| with :c:func:`uv_udp_bind` it is bound to 0.0.0.0 (the "all interfaces" | ||
| IPv4 address) and a random port number. | ||
| :param handle: UDP handle. Should have been initialized with | ||
| :c:func:`uv_udp_init`. | ||
| :param alloc_cb: Callback to invoke when temporary storage is needed. | ||
| :param recv_cb: Callback to invoke with received data. | ||
| :returns: 0 on success, or an error code < 0 on failure. | ||
| .. c:function:: int uv_udp_recv_stop(uv_udp_t* handle) | ||
| Stop listening for incoming datagrams. | ||
| :param handle: UDP handle. Should have been initialized with | ||
| :c:func:`uv_udp_init`. | ||
| :returns: 0 on success, or an error code < 0 on failure. | ||
| .. seealso:: The :c:type:`uv_handle_t` API functions also apply. |
| @@ -57,12 +57,6 @@ | ||
| # define UV__EACCES (-4092) | ||
| #endif | ||
|
|
||
| #if defined(EADDRINUSE) && !defined(_WIN32) | ||
| # define UV__EADDRINUSE (-EADDRINUSE) | ||
| #else | ||
| @@ -1,2 +1,5 @@ | ||
| # Ignore libtoolize-generated files. | ||
| *.m4 | ||
| !as_case.m4 | ||
| !dtrace.m4 | ||
| !libuv-check-flags.m4 |
| @@ -0,0 +1,21 @@ | ||
| # AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT]) | ||
| # ---------------------------------------------------- | ||
| # Expand into | ||
| # | case WORD in | ||
| # | PATTERN1) IF-MATCHED1 ;; | ||
| # | ... | ||
| # | *) DEFAULT ;; | ||
| # | esac | ||
| m4_define([_AS_CASE], | ||
| [m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])], | ||
| [$#], 1, [ *) $1 ;;], | ||
| [$#], 2, [ $1) m4_default([$2], [:]) ;;], | ||
| [ $1) m4_default([$2], [:]) ;; | ||
| $0(m4_shiftn(2, $@))])dnl | ||
| ]) | ||
| m4_defun([AS_CASE], | ||
| [m4_ifval([$2$3], | ||
| [case $1 in | ||
| _AS_CASE(m4_shift($@)) | ||
| esac])]) | ||
|
|
| @@ -0,0 +1,66 @@ | ||
| dnl Copyright (C) 2009 Sun Microsystems | ||
| dnl This file is free software; Sun Microsystems | ||
| dnl gives unlimited permission to copy and/or distribute it, | ||
| dnl with or without modifications, as long as this notice is preserved. | ||
|
|
||
| dnl --------------------------------------------------------------------------- | ||
| dnl Macro: PANDORA_ENABLE_DTRACE | ||
| dnl --------------------------------------------------------------------------- | ||
| AC_DEFUN([PANDORA_ENABLE_DTRACE],[ | ||
| AC_ARG_ENABLE([dtrace], | ||
| [AS_HELP_STRING([--disable-dtrace], | ||
| [enable DTrace USDT probes. @<:@default=yes@:>@])], | ||
| [ac_cv_enable_dtrace="$enableval"], | ||
| [ac_cv_enable_dtrace="yes"]) | ||
| AS_IF([test "$ac_cv_enable_dtrace" = "yes"],[ | ||
| AC_CHECK_PROGS([DTRACE], [dtrace]) | ||
| AS_IF([test "x$ac_cv_prog_DTRACE" = "xdtrace"],[ | ||
| AC_CACHE_CHECK([if dtrace works],[ac_cv_dtrace_works],[ | ||
| cat >conftest.d <<_ACEOF | ||
| provider Example { | ||
| probe increment(int); | ||
| }; | ||
| _ACEOF | ||
| $DTRACE -h -o conftest.h -s conftest.d 2>/dev/zero | ||
| AS_IF([test $? -eq 0],[ac_cv_dtrace_works=yes], | ||
| [ac_cv_dtrace_works=no]) | ||
| rm -f conftest.h conftest.d | ||
| ]) | ||
| AS_IF([test "x$ac_cv_dtrace_works" = "xyes"],[ | ||
| AC_DEFINE([HAVE_DTRACE], [1], [Enables DTRACE Support]) | ||
| AC_CACHE_CHECK([if dtrace should instrument object files], | ||
| [ac_cv_dtrace_needs_objects],[ | ||
| dnl DTrace on MacOSX does not use -G option | ||
| cat >conftest.d <<_ACEOF | ||
| provider Example { | ||
| probe increment(int); | ||
| }; | ||
| _ACEOF | ||
| cat > conftest.c <<_ACEOF | ||
| #include "conftest.h" | ||
| void foo() { | ||
| EXAMPLE_INCREMENT(1); | ||
| } | ||
| _ACEOF | ||
| $DTRACE -h -o conftest.h -s conftest.d 2>/dev/zero | ||
| $CC -c -o conftest.o conftest.c | ||
| $DTRACE -G -o conftest.d.o -s conftest.d conftest.o 2>/dev/zero | ||
| AS_IF([test $? -eq 0],[ac_cv_dtrace_needs_objects=yes], | ||
| [ac_cv_dtrace_needs_objects=no]) | ||
| rm -f conftest.d.o conftest.d conftest.h conftest.o conftest.c | ||
| ]) | ||
| ]) | ||
| AC_SUBST(DTRACEFLAGS) dnl TODO: test for -G on OSX | ||
| ac_cv_have_dtrace=yes | ||
| ])]) | ||
| AM_CONDITIONAL([HAVE_DTRACE], [test "x$ac_cv_dtrace_works" = "xyes"]) | ||
| AM_CONDITIONAL([DTRACE_NEEDS_OBJECTS], | ||
| [test "x$ac_cv_dtrace_needs_objects" = "xyes"]) | ||
| ]) | ||
| dnl --------------------------------------------------------------------------- | ||
| dnl End Macro: PANDORA_ENABLE_DTRACE | ||
| dnl --------------------------------------------------------------------------- |
| @@ -0,0 +1,319 @@ | ||
| dnl Macros to check the presence of generic (non-typed) symbols. | ||
| dnl Copyright (c) 2006-2008 Diego Pettenà <flameeyes gmail com> | ||
| dnl Copyright (c) 2006-2008 xine project | ||
| dnl | ||
| dnl This program is free software; you can redistribute it and/or modify | ||
| dnl it under the terms of the GNU General Public License as published by | ||
| dnl the Free Software Foundation; either version 3, or (at your option) | ||
| dnl any later version. | ||
| dnl | ||
| dnl This program is distributed in the hope that it will be useful, | ||
| dnl but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| dnl GNU General Public License for more details. | ||
| dnl | ||
| dnl You should have received a copy of the GNU General Public License | ||
| dnl along with this program; if not, write to the Free Software | ||
| dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
| dnl 02110-1301, USA. | ||
| dnl | ||
| dnl As a special exception, the copyright owners of the | ||
| dnl macro gives unlimited permission to copy, distribute and modify the | ||
| dnl configure scripts that are the output of Autoconf when processing the | ||
| dnl Macro. You need not follow the terms of the GNU General Public | ||
| dnl License when using or distributing such scripts, even though portions | ||
| dnl of the text of the Macro appear in them. The GNU General Public | ||
| dnl License (GPL) does govern all other use of the material that | ||
| dnl constitutes the Autoconf Macro. | ||
| dnl | ||
| dnl This special exception to the GPL applies to versions of the | ||
| dnl Autoconf Macro released by this project. When you make and | ||
| dnl distribute a modified version of the Autoconf Macro, you may extend | ||
| dnl this special exception to the GPL to apply to your modified version as | ||
| dnl well. | ||
|
|
||
| dnl Check if the flag is supported by compiler | ||
| dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) | ||
|
|
||
| AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [ | ||
| AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]), | ||
| [ac_save_CFLAGS="$CFLAGS" | ||
| CFLAGS="$CFLAGS $1" | ||
| AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a;])], | ||
| [eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"], | ||
| [eval "AS_TR_SH([cc_cv_cflags_$1])='no'"]) | ||
| CFLAGS="$ac_save_CFLAGS" | ||
| ]) | ||
| AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], | ||
| [$2], [$3]) | ||
| ]) | ||
|
|
||
| dnl Check if the flag is supported by compiler (cacheable) | ||
| dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) | ||
|
|
||
| AC_DEFUN([CC_CHECK_CFLAGS], [ | ||
| AC_CACHE_CHECK([if $CC supports $1 flag], | ||
| AS_TR_SH([cc_cv_cflags_$1]), | ||
| CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here! | ||
| ) | ||
| AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], | ||
| [$2], [$3]) | ||
| ]) | ||
|
|
||
| dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found]) | ||
| dnl Check for CFLAG and appends them to CFLAGS if supported | ||
| AC_DEFUN([CC_CHECK_CFLAG_APPEND], [ | ||
| AC_CACHE_CHECK([if $CC supports $1 flag], | ||
| AS_TR_SH([cc_cv_cflags_$1]), | ||
| CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here! | ||
| ) | ||
| AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes], | ||
| [CFLAGS="$CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3]) | ||
| ]) | ||
|
|
||
| dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not]) | ||
| AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [ | ||
| for flag in $1; do | ||
| CC_CHECK_CFLAG_APPEND($flag, [$2], [$3]) | ||
| done | ||
| ]) | ||
|
|
||
| dnl Check if the flag is supported by linker (cacheable) | ||
| dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) | ||
|
|
||
| AC_DEFUN([CC_CHECK_LDFLAGS], [ | ||
| AC_CACHE_CHECK([if $CC supports $1 flag], | ||
| AS_TR_SH([cc_cv_ldflags_$1]), | ||
| [ac_save_LDFLAGS="$LDFLAGS" | ||
| LDFLAGS="$LDFLAGS $1" | ||
| AC_LANG_PUSH([C]) | ||
| AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 1; }])], | ||
| [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"], | ||
| [eval "AS_TR_SH([cc_cv_ldflags_$1])="]) | ||
| AC_LANG_POP([C]) | ||
| LDFLAGS="$ac_save_LDFLAGS" | ||
| ]) | ||
| AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes], | ||
| [$2], [$3]) | ||
| ]) | ||
|
|
||
| dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for | ||
| dnl the current linker to avoid undefined references in a shared object. | ||
| AC_DEFUN([CC_NOUNDEFINED], [ | ||
| dnl We check $host for which systems to enable this for. | ||
| AC_REQUIRE([AC_CANONICAL_HOST]) | ||
| case $host in | ||
| dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads | ||
| dnl are requested, as different implementations are present; to avoid problems | ||
| dnl use -Wl,-z,defs only for those platform not behaving this way. | ||
| *-freebsd* | *-openbsd*) ;; | ||
| *) | ||
| dnl First of all check for the --no-undefined variant of GNU ld. This allows | ||
| dnl for a much more readable commandline, so that people can understand what | ||
| dnl it does without going to look for what the heck -z defs does. | ||
| for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do | ||
| CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"]) | ||
| break | ||
| done | ||
| ;; | ||
| esac | ||
| AC_SUBST([LDFLAGS_NOUNDEFINED]) | ||
| ]) | ||
|
|
||
| dnl Check for a -Werror flag or equivalent. -Werror is the GCC | ||
| dnl and ICC flag that tells the compiler to treat all the warnings | ||
| dnl as fatal. We usually need this option to make sure that some | ||
| dnl constructs (like attributes) are not simply ignored. | ||
| dnl | ||
| dnl Other compilers don't support -Werror per se, but they support | ||
| dnl an equivalent flag: | ||
| dnl - Sun Studio compiler supports -errwarn=%all | ||
| AC_DEFUN([CC_CHECK_WERROR], [ | ||
| AC_CACHE_CHECK( | ||
| [for $CC way to treat warnings as errors], | ||
| [cc_cv_werror], | ||
| [CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror], | ||
| [CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])]) | ||
| ]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_CHECK_ATTRIBUTE], [ | ||
| AC_REQUIRE([CC_CHECK_WERROR]) | ||
| AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))], | ||
| AS_TR_SH([cc_cv_attribute_$1]), | ||
| [ac_save_CFLAGS="$CFLAGS" | ||
| CFLAGS="$CFLAGS $cc_cv_werror" | ||
| AC_LANG_PUSH([C]) | ||
| AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])], | ||
| [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"], | ||
| [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"]) | ||
| AC_LANG_POP([C]) | ||
| CFLAGS="$ac_save_CFLAGS" | ||
| ]) | ||
| AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes], | ||
| [AC_DEFINE( | ||
| AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1, | ||
| [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))] | ||
| ) | ||
| $4], | ||
| [$5]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [ | ||
| CC_CHECK_ATTRIBUTE( | ||
| [constructor],, | ||
| [void __attribute__((constructor)) ctor() { int a; }], | ||
| [$1], [$2]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_ATTRIBUTE_FORMAT], [ | ||
| CC_CHECK_ATTRIBUTE( | ||
| [format], [format(printf, n, n)], | ||
| [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }], | ||
| [$1], [$2]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [ | ||
| CC_CHECK_ATTRIBUTE( | ||
| [format_arg], [format_arg(printf)], | ||
| [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }], | ||
| [$1], [$2]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [ | ||
| CC_CHECK_ATTRIBUTE( | ||
| [visibility_$1], [visibility("$1")], | ||
| [void __attribute__((visibility("$1"))) $1_function() { }], | ||
| [$2], [$3]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_ATTRIBUTE_NONNULL], [ | ||
| CC_CHECK_ATTRIBUTE( | ||
| [nonnull], [nonnull()], | ||
| [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }], | ||
| [$1], [$2]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_ATTRIBUTE_UNUSED], [ | ||
| CC_CHECK_ATTRIBUTE( | ||
| [unused], , | ||
| [void some_function(void *foo, __attribute__((unused)) void *bar);], | ||
| [$1], [$2]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [ | ||
| CC_CHECK_ATTRIBUTE( | ||
| [sentinel], , | ||
| [void some_function(void *foo, ...) __attribute__((sentinel));], | ||
| [$1], [$2]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [ | ||
| CC_CHECK_ATTRIBUTE( | ||
| [deprecated], , | ||
| [void some_function(void *foo, ...) __attribute__((deprecated));], | ||
| [$1], [$2]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_ATTRIBUTE_ALIAS], [ | ||
| CC_CHECK_ATTRIBUTE( | ||
| [alias], [weak, alias], | ||
| [void other_function(void *foo) { } | ||
| void some_function(void *foo) __attribute__((weak, alias("other_function")));], | ||
| [$1], [$2]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_ATTRIBUTE_MALLOC], [ | ||
| CC_CHECK_ATTRIBUTE( | ||
| [malloc], , | ||
| [void * __attribute__((malloc)) my_alloc(int n);], | ||
| [$1], [$2]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_ATTRIBUTE_PACKED], [ | ||
| CC_CHECK_ATTRIBUTE( | ||
| [packed], , | ||
| [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));], | ||
| [$1], [$2]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_ATTRIBUTE_CONST], [ | ||
| CC_CHECK_ATTRIBUTE( | ||
| [const], , | ||
| [int __attribute__((const)) twopow(int n) { return 1 << n; } ], | ||
| [$1], [$2]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_FLAG_VISIBILITY], [ | ||
| AC_REQUIRE([CC_CHECK_WERROR]) | ||
| AC_CACHE_CHECK([if $CC supports -fvisibility=hidden], | ||
| [cc_cv_flag_visibility], | ||
| [cc_flag_visibility_save_CFLAGS="$CFLAGS" | ||
| CFLAGS="$CFLAGS $cc_cv_werror" | ||
| CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden], | ||
| cc_cv_flag_visibility='yes', | ||
| cc_cv_flag_visibility='no') | ||
| CFLAGS="$cc_flag_visibility_save_CFLAGS"]) | ||
| AS_IF([test "x$cc_cv_flag_visibility" = "xyes"], | ||
| [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1, | ||
| [Define this if the compiler supports the -fvisibility flag]) | ||
| $1], | ||
| [$2]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_FUNC_EXPECT], [ | ||
| AC_REQUIRE([CC_CHECK_WERROR]) | ||
| AC_CACHE_CHECK([if compiler has __builtin_expect function], | ||
| [cc_cv_func_expect], | ||
| [ac_save_CFLAGS="$CFLAGS" | ||
| CFLAGS="$CFLAGS $cc_cv_werror" | ||
| AC_LANG_PUSH([C]) | ||
| AC_COMPILE_IFELSE([AC_LANG_SOURCE( | ||
| [int some_function() { | ||
| int a = 3; | ||
| return (int)__builtin_expect(a, 3); | ||
| }])], | ||
| [cc_cv_func_expect=yes], | ||
| [cc_cv_func_expect=no]) | ||
| AC_LANG_POP([C]) | ||
| CFLAGS="$ac_save_CFLAGS" | ||
| ]) | ||
| AS_IF([test "x$cc_cv_func_expect" = "xyes"], | ||
| [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1, | ||
| [Define this if the compiler supports __builtin_expect() function]) | ||
| $1], | ||
| [$2]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [ | ||
| AC_REQUIRE([CC_CHECK_WERROR]) | ||
| AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported], | ||
| [cc_cv_attribute_aligned], | ||
| [ac_save_CFLAGS="$CFLAGS" | ||
| CFLAGS="$CFLAGS $cc_cv_werror" | ||
| AC_LANG_PUSH([C]) | ||
| for cc_attribute_align_try in 64 32 16 8 4 2; do | ||
| AC_COMPILE_IFELSE([AC_LANG_SOURCE([ | ||
| int main() { | ||
| static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0; | ||
| return c; | ||
| }])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break]) | ||
| done | ||
| AC_LANG_POP([C]) | ||
| CFLAGS="$ac_save_CFLAGS" | ||
| ]) | ||
| if test "x$cc_cv_attribute_aligned" != "x"; then | ||
| AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned], | ||
| [Define the highest alignment supported]) | ||
| fi | ||
| ]) |
| @@ -38,6 +38,7 @@ | ||
| #include <sys/resource.h> | ||
| #include <sys/types.h> | ||
| #include <sys/sysctl.h> | ||
| #include <uvm/uvm_extern.h> | ||
|
|
||
| #include <unistd.h> | ||
| #include <time.h> | ||
| @@ -65,6 +65,9 @@ int uv_timer_start(uv_timer_t* handle, | ||
| uint64_t repeat) { | ||
| uint64_t clamped_timeout; | ||
|
|
||
| if (cb == NULL) | ||
| return -EINVAL; | ||
|
|
||
| if (uv__is_active(handle)) | ||
| uv_timer_stop(handle); | ||
|
|
||
| @@ -340,8 +340,6 @@ static int uv__udp_maybe_deferred_bind(uv_udp_t* handle, | ||
| unsigned char taddr[sizeof(struct sockaddr_in6)]; | ||
| socklen_t addrlen; | ||
|
|
||
| if (handle->io_watcher.fd != -1) | ||
| return 0; | ||
|
|
||
| @@ -35,7 +35,7 @@ | ||
| #if UV_VERSION_IS_RELEASE | ||
| # define UV_VERSION_STRING UV_VERSION_STRING_BASE | ||
| #else | ||
| # define UV_VERSION_STRING UV_VERSION_STRING_BASE "-" UV_VERSION_SUFFIX | ||
| #endif | ||
|
|
||
|
|
||