11cb0ef41Sopenharmony_ci/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
21cb0ef41Sopenharmony_ci *
31cb0ef41Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
41cb0ef41Sopenharmony_ci * of this software and associated documentation files (the "Software"), to
51cb0ef41Sopenharmony_ci * deal in the Software without restriction, including without limitation the
61cb0ef41Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
71cb0ef41Sopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is
81cb0ef41Sopenharmony_ci * furnished to do so, subject to the following conditions:
91cb0ef41Sopenharmony_ci *
101cb0ef41Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
111cb0ef41Sopenharmony_ci * all copies or substantial portions of the Software.
121cb0ef41Sopenharmony_ci *
131cb0ef41Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
141cb0ef41Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
151cb0ef41Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
161cb0ef41Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
171cb0ef41Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
181cb0ef41Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
191cb0ef41Sopenharmony_ci * IN THE SOFTWARE.
201cb0ef41Sopenharmony_ci */
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci#ifndef UV_UNIX_INTERNAL_H_
231cb0ef41Sopenharmony_ci#define UV_UNIX_INTERNAL_H_
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci#include "uv-common.h"
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci#include <assert.h>
281cb0ef41Sopenharmony_ci#include <limits.h> /* _POSIX_PATH_MAX, PATH_MAX */
291cb0ef41Sopenharmony_ci#include <stdlib.h> /* abort */
301cb0ef41Sopenharmony_ci#include <string.h> /* strrchr */
311cb0ef41Sopenharmony_ci#include <fcntl.h>  /* O_CLOEXEC and O_NONBLOCK, if supported. */
321cb0ef41Sopenharmony_ci#include <stdio.h>
331cb0ef41Sopenharmony_ci#include <errno.h>
341cb0ef41Sopenharmony_ci#include <sys/socket.h>
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci#if defined(__STRICT_ANSI__)
371cb0ef41Sopenharmony_ci# define inline __inline
381cb0ef41Sopenharmony_ci#endif
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ci#if defined(__linux__)
411cb0ef41Sopenharmony_ci# include "linux-syscalls.h"
421cb0ef41Sopenharmony_ci#endif /* __linux__ */
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ci#if defined(__MVS__)
451cb0ef41Sopenharmony_ci# include "os390-syscalls.h"
461cb0ef41Sopenharmony_ci#endif /* __MVS__ */
471cb0ef41Sopenharmony_ci
481cb0ef41Sopenharmony_ci#if defined(__sun)
491cb0ef41Sopenharmony_ci# include <sys/port.h>
501cb0ef41Sopenharmony_ci# include <port.h>
511cb0ef41Sopenharmony_ci#endif /* __sun */
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ci#if defined(_AIX)
541cb0ef41Sopenharmony_ci# define reqevents events
551cb0ef41Sopenharmony_ci# define rtnevents revents
561cb0ef41Sopenharmony_ci# include <sys/poll.h>
571cb0ef41Sopenharmony_ci#else
581cb0ef41Sopenharmony_ci# include <poll.h>
591cb0ef41Sopenharmony_ci#endif /* _AIX */
601cb0ef41Sopenharmony_ci
611cb0ef41Sopenharmony_ci#if defined(__APPLE__) && !TARGET_OS_IPHONE
621cb0ef41Sopenharmony_ci# include <AvailabilityMacros.h>
631cb0ef41Sopenharmony_ci#endif
641cb0ef41Sopenharmony_ci
651cb0ef41Sopenharmony_ci/*
661cb0ef41Sopenharmony_ci * Define common detection for active Thread Sanitizer
671cb0ef41Sopenharmony_ci * - clang uses __has_feature(thread_sanitizer)
681cb0ef41Sopenharmony_ci * - gcc-7+ uses __SANITIZE_THREAD__
691cb0ef41Sopenharmony_ci */
701cb0ef41Sopenharmony_ci#if defined(__has_feature)
711cb0ef41Sopenharmony_ci# if __has_feature(thread_sanitizer)
721cb0ef41Sopenharmony_ci#  define __SANITIZE_THREAD__ 1
731cb0ef41Sopenharmony_ci# endif
741cb0ef41Sopenharmony_ci#endif
751cb0ef41Sopenharmony_ci
761cb0ef41Sopenharmony_ci#if defined(PATH_MAX)
771cb0ef41Sopenharmony_ci# define UV__PATH_MAX PATH_MAX
781cb0ef41Sopenharmony_ci#else
791cb0ef41Sopenharmony_ci# define UV__PATH_MAX 8192
801cb0ef41Sopenharmony_ci#endif
811cb0ef41Sopenharmony_ci
821cb0ef41Sopenharmony_ci#if defined(__ANDROID__)
831cb0ef41Sopenharmony_ciint uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset);
841cb0ef41Sopenharmony_ci# ifdef pthread_sigmask
851cb0ef41Sopenharmony_ci# undef pthread_sigmask
861cb0ef41Sopenharmony_ci# endif
871cb0ef41Sopenharmony_ci# define pthread_sigmask(how, set, oldset) uv__pthread_sigmask(how, set, oldset)
881cb0ef41Sopenharmony_ci#endif
891cb0ef41Sopenharmony_ci
901cb0ef41Sopenharmony_ci#define ACCESS_ONCE(type, var)                                                \
911cb0ef41Sopenharmony_ci  (*(volatile type*) &(var))
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ci#define ROUND_UP(a, b)                                                        \
941cb0ef41Sopenharmony_ci  ((a) % (b) ? ((a) + (b)) - ((a) % (b)) : (a))
951cb0ef41Sopenharmony_ci
961cb0ef41Sopenharmony_ci#define UNREACHABLE()                                                         \
971cb0ef41Sopenharmony_ci  do {                                                                        \
981cb0ef41Sopenharmony_ci    assert(0 && "unreachable code");                                          \
991cb0ef41Sopenharmony_ci    abort();                                                                  \
1001cb0ef41Sopenharmony_ci  }                                                                           \
1011cb0ef41Sopenharmony_ci  while (0)
1021cb0ef41Sopenharmony_ci
1031cb0ef41Sopenharmony_ci#define SAVE_ERRNO(block)                                                     \
1041cb0ef41Sopenharmony_ci  do {                                                                        \
1051cb0ef41Sopenharmony_ci    int _saved_errno = errno;                                                 \
1061cb0ef41Sopenharmony_ci    do { block; } while (0);                                                  \
1071cb0ef41Sopenharmony_ci    errno = _saved_errno;                                                     \
1081cb0ef41Sopenharmony_ci  }                                                                           \
1091cb0ef41Sopenharmony_ci  while (0)
1101cb0ef41Sopenharmony_ci
1111cb0ef41Sopenharmony_ci/* The __clang__ and __INTEL_COMPILER checks are superfluous because they
1121cb0ef41Sopenharmony_ci * define __GNUC__. They are here to convey to you, dear reader, that these
1131cb0ef41Sopenharmony_ci * macros are enabled when compiling with clang or icc.
1141cb0ef41Sopenharmony_ci */
1151cb0ef41Sopenharmony_ci#if defined(__clang__) ||                                                     \
1161cb0ef41Sopenharmony_ci    defined(__GNUC__) ||                                                      \
1171cb0ef41Sopenharmony_ci    defined(__INTEL_COMPILER)
1181cb0ef41Sopenharmony_ci# define UV_UNUSED(declaration)     __attribute__((unused)) declaration
1191cb0ef41Sopenharmony_ci#else
1201cb0ef41Sopenharmony_ci# define UV_UNUSED(declaration)     declaration
1211cb0ef41Sopenharmony_ci#endif
1221cb0ef41Sopenharmony_ci
1231cb0ef41Sopenharmony_ci/* Leans on the fact that, on Linux, POLLRDHUP == EPOLLRDHUP. */
1241cb0ef41Sopenharmony_ci#ifdef POLLRDHUP
1251cb0ef41Sopenharmony_ci# define UV__POLLRDHUP POLLRDHUP
1261cb0ef41Sopenharmony_ci#else
1271cb0ef41Sopenharmony_ci# define UV__POLLRDHUP 0x2000
1281cb0ef41Sopenharmony_ci#endif
1291cb0ef41Sopenharmony_ci
1301cb0ef41Sopenharmony_ci#ifdef POLLPRI
1311cb0ef41Sopenharmony_ci# define UV__POLLPRI POLLPRI
1321cb0ef41Sopenharmony_ci#else
1331cb0ef41Sopenharmony_ci# define UV__POLLPRI 0
1341cb0ef41Sopenharmony_ci#endif
1351cb0ef41Sopenharmony_ci
1361cb0ef41Sopenharmony_ci#if !defined(O_CLOEXEC) && defined(__FreeBSD__)
1371cb0ef41Sopenharmony_ci/*
1381cb0ef41Sopenharmony_ci * It may be that we are just missing `__POSIX_VISIBLE >= 200809`.
1391cb0ef41Sopenharmony_ci * Try using fixed value const and give up, if it doesn't work
1401cb0ef41Sopenharmony_ci */
1411cb0ef41Sopenharmony_ci# define O_CLOEXEC 0x00100000
1421cb0ef41Sopenharmony_ci#endif
1431cb0ef41Sopenharmony_ci
1441cb0ef41Sopenharmony_citypedef struct uv__stream_queued_fds_s uv__stream_queued_fds_t;
1451cb0ef41Sopenharmony_ci
1461cb0ef41Sopenharmony_ci/* loop flags */
1471cb0ef41Sopenharmony_cienum {
1481cb0ef41Sopenharmony_ci  UV_LOOP_BLOCK_SIGPROF = 0x1,
1491cb0ef41Sopenharmony_ci  UV_LOOP_REAP_CHILDREN = 0x2
1501cb0ef41Sopenharmony_ci};
1511cb0ef41Sopenharmony_ci
1521cb0ef41Sopenharmony_ci/* flags of excluding ifaddr */
1531cb0ef41Sopenharmony_cienum {
1541cb0ef41Sopenharmony_ci  UV__EXCLUDE_IFPHYS,
1551cb0ef41Sopenharmony_ci  UV__EXCLUDE_IFADDR
1561cb0ef41Sopenharmony_ci};
1571cb0ef41Sopenharmony_ci
1581cb0ef41Sopenharmony_citypedef enum {
1591cb0ef41Sopenharmony_ci  UV_CLOCK_PRECISE = 0,  /* Use the highest resolution clock available. */
1601cb0ef41Sopenharmony_ci  UV_CLOCK_FAST = 1      /* Use the fastest clock with <= 1ms granularity. */
1611cb0ef41Sopenharmony_ci} uv_clocktype_t;
1621cb0ef41Sopenharmony_ci
1631cb0ef41Sopenharmony_cistruct uv__stream_queued_fds_s {
1641cb0ef41Sopenharmony_ci  unsigned int size;
1651cb0ef41Sopenharmony_ci  unsigned int offset;
1661cb0ef41Sopenharmony_ci  int fds[1];
1671cb0ef41Sopenharmony_ci};
1681cb0ef41Sopenharmony_ci
1691cb0ef41Sopenharmony_ci
1701cb0ef41Sopenharmony_ci#if defined(_AIX) || \
1711cb0ef41Sopenharmony_ci    defined(__APPLE__) || \
1721cb0ef41Sopenharmony_ci    defined(__DragonFly__) || \
1731cb0ef41Sopenharmony_ci    defined(__FreeBSD__) || \
1741cb0ef41Sopenharmony_ci    defined(__FreeBSD_kernel__) || \
1751cb0ef41Sopenharmony_ci    defined(__linux__) || \
1761cb0ef41Sopenharmony_ci    defined(__OpenBSD__) || \
1771cb0ef41Sopenharmony_ci    defined(__NetBSD__)
1781cb0ef41Sopenharmony_ci#define uv__nonblock uv__nonblock_ioctl
1791cb0ef41Sopenharmony_ci#define UV__NONBLOCK_IS_IOCTL 1
1801cb0ef41Sopenharmony_ci#else
1811cb0ef41Sopenharmony_ci#define uv__nonblock uv__nonblock_fcntl
1821cb0ef41Sopenharmony_ci#define UV__NONBLOCK_IS_IOCTL 0
1831cb0ef41Sopenharmony_ci#endif
1841cb0ef41Sopenharmony_ci
1851cb0ef41Sopenharmony_ci/* On Linux, uv__nonblock_fcntl() and uv__nonblock_ioctl() do not commute
1861cb0ef41Sopenharmony_ci * when O_NDELAY is not equal to O_NONBLOCK.  Case in point: linux/sparc32
1871cb0ef41Sopenharmony_ci * and linux/sparc64, where O_NDELAY is O_NONBLOCK + another bit.
1881cb0ef41Sopenharmony_ci *
1891cb0ef41Sopenharmony_ci * Libuv uses uv__nonblock_fcntl() directly sometimes so ensure that it
1901cb0ef41Sopenharmony_ci * commutes with uv__nonblock().
1911cb0ef41Sopenharmony_ci */
1921cb0ef41Sopenharmony_ci#if defined(__linux__) && O_NDELAY != O_NONBLOCK
1931cb0ef41Sopenharmony_ci#undef uv__nonblock
1941cb0ef41Sopenharmony_ci#define uv__nonblock uv__nonblock_fcntl
1951cb0ef41Sopenharmony_ci#endif
1961cb0ef41Sopenharmony_ci
1971cb0ef41Sopenharmony_ci/* core */
1981cb0ef41Sopenharmony_ciint uv__cloexec(int fd, int set);
1991cb0ef41Sopenharmony_ciint uv__nonblock_ioctl(int fd, int set);
2001cb0ef41Sopenharmony_ciint uv__nonblock_fcntl(int fd, int set);
2011cb0ef41Sopenharmony_ciint uv__close(int fd); /* preserves errno */
2021cb0ef41Sopenharmony_ciint uv__close_nocheckstdio(int fd);
2031cb0ef41Sopenharmony_ciint uv__close_nocancel(int fd);
2041cb0ef41Sopenharmony_ciint uv__socket(int domain, int type, int protocol);
2051cb0ef41Sopenharmony_cissize_t uv__recvmsg(int fd, struct msghdr *msg, int flags);
2061cb0ef41Sopenharmony_civoid uv__make_close_pending(uv_handle_t* handle);
2071cb0ef41Sopenharmony_ciint uv__getiovmax(void);
2081cb0ef41Sopenharmony_ci
2091cb0ef41Sopenharmony_civoid uv__io_init(uv__io_t* w, uv__io_cb cb, int fd);
2101cb0ef41Sopenharmony_civoid uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events);
2111cb0ef41Sopenharmony_civoid uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events);
2121cb0ef41Sopenharmony_civoid uv__io_close(uv_loop_t* loop, uv__io_t* w);
2131cb0ef41Sopenharmony_civoid uv__io_feed(uv_loop_t* loop, uv__io_t* w);
2141cb0ef41Sopenharmony_ciint uv__io_active(const uv__io_t* w, unsigned int events);
2151cb0ef41Sopenharmony_ciint uv__io_check_fd(uv_loop_t* loop, int fd);
2161cb0ef41Sopenharmony_civoid uv__io_poll(uv_loop_t* loop, int timeout); /* in milliseconds or -1 */
2171cb0ef41Sopenharmony_ciint uv__io_fork(uv_loop_t* loop);
2181cb0ef41Sopenharmony_ciint uv__fd_exists(uv_loop_t* loop, int fd);
2191cb0ef41Sopenharmony_ci
2201cb0ef41Sopenharmony_ci/* async */
2211cb0ef41Sopenharmony_civoid uv__async_stop(uv_loop_t* loop);
2221cb0ef41Sopenharmony_ciint uv__async_fork(uv_loop_t* loop);
2231cb0ef41Sopenharmony_ci
2241cb0ef41Sopenharmony_ci
2251cb0ef41Sopenharmony_ci/* loop */
2261cb0ef41Sopenharmony_civoid uv__run_idle(uv_loop_t* loop);
2271cb0ef41Sopenharmony_civoid uv__run_check(uv_loop_t* loop);
2281cb0ef41Sopenharmony_civoid uv__run_prepare(uv_loop_t* loop);
2291cb0ef41Sopenharmony_ci
2301cb0ef41Sopenharmony_ci/* stream */
2311cb0ef41Sopenharmony_civoid uv__stream_init(uv_loop_t* loop, uv_stream_t* stream,
2321cb0ef41Sopenharmony_ci    uv_handle_type type);
2331cb0ef41Sopenharmony_ciint uv__stream_open(uv_stream_t*, int fd, int flags);
2341cb0ef41Sopenharmony_civoid uv__stream_destroy(uv_stream_t* stream);
2351cb0ef41Sopenharmony_ci#if defined(__APPLE__)
2361cb0ef41Sopenharmony_ciint uv__stream_try_select(uv_stream_t* stream, int* fd);
2371cb0ef41Sopenharmony_ci#endif /* defined(__APPLE__) */
2381cb0ef41Sopenharmony_civoid uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events);
2391cb0ef41Sopenharmony_ciint uv__accept(int sockfd);
2401cb0ef41Sopenharmony_ciint uv__dup2_cloexec(int oldfd, int newfd);
2411cb0ef41Sopenharmony_ciint uv__open_cloexec(const char* path, int flags);
2421cb0ef41Sopenharmony_ciint uv__slurp(const char* filename, char* buf, size_t len);
2431cb0ef41Sopenharmony_ci
2441cb0ef41Sopenharmony_ci/* tcp */
2451cb0ef41Sopenharmony_ciint uv__tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb);
2461cb0ef41Sopenharmony_ciint uv__tcp_nodelay(int fd, int on);
2471cb0ef41Sopenharmony_ciint uv__tcp_keepalive(int fd, int on, unsigned int delay);
2481cb0ef41Sopenharmony_ci
2491cb0ef41Sopenharmony_ci/* pipe */
2501cb0ef41Sopenharmony_ciint uv__pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb);
2511cb0ef41Sopenharmony_ci
2521cb0ef41Sopenharmony_ci/* signal */
2531cb0ef41Sopenharmony_civoid uv__signal_close(uv_signal_t* handle);
2541cb0ef41Sopenharmony_civoid uv__signal_global_once_init(void);
2551cb0ef41Sopenharmony_civoid uv__signal_loop_cleanup(uv_loop_t* loop);
2561cb0ef41Sopenharmony_ciint uv__signal_loop_fork(uv_loop_t* loop);
2571cb0ef41Sopenharmony_ci
2581cb0ef41Sopenharmony_ci/* platform specific */
2591cb0ef41Sopenharmony_ciuint64_t uv__hrtime(uv_clocktype_t type);
2601cb0ef41Sopenharmony_ciint uv__kqueue_init(uv_loop_t* loop);
2611cb0ef41Sopenharmony_ciint uv__epoll_init(uv_loop_t* loop);
2621cb0ef41Sopenharmony_ciint uv__platform_loop_init(uv_loop_t* loop);
2631cb0ef41Sopenharmony_civoid uv__platform_loop_delete(uv_loop_t* loop);
2641cb0ef41Sopenharmony_civoid uv__platform_invalidate_fd(uv_loop_t* loop, int fd);
2651cb0ef41Sopenharmony_ci
2661cb0ef41Sopenharmony_ci/* various */
2671cb0ef41Sopenharmony_civoid uv__async_close(uv_async_t* handle);
2681cb0ef41Sopenharmony_civoid uv__check_close(uv_check_t* handle);
2691cb0ef41Sopenharmony_civoid uv__fs_event_close(uv_fs_event_t* handle);
2701cb0ef41Sopenharmony_civoid uv__idle_close(uv_idle_t* handle);
2711cb0ef41Sopenharmony_civoid uv__pipe_close(uv_pipe_t* handle);
2721cb0ef41Sopenharmony_civoid uv__poll_close(uv_poll_t* handle);
2731cb0ef41Sopenharmony_civoid uv__prepare_close(uv_prepare_t* handle);
2741cb0ef41Sopenharmony_civoid uv__process_close(uv_process_t* handle);
2751cb0ef41Sopenharmony_civoid uv__stream_close(uv_stream_t* handle);
2761cb0ef41Sopenharmony_civoid uv__tcp_close(uv_tcp_t* handle);
2771cb0ef41Sopenharmony_cisize_t uv__thread_stack_size(void);
2781cb0ef41Sopenharmony_civoid uv__udp_close(uv_udp_t* handle);
2791cb0ef41Sopenharmony_civoid uv__udp_finish_close(uv_udp_t* handle);
2801cb0ef41Sopenharmony_ciFILE* uv__open_file(const char* path);
2811cb0ef41Sopenharmony_ciint uv__getpwuid_r(uv_passwd_t* pwd);
2821cb0ef41Sopenharmony_ciint uv__search_path(const char* prog, char* buf, size_t* buflen);
2831cb0ef41Sopenharmony_civoid uv__wait_children(uv_loop_t* loop);
2841cb0ef41Sopenharmony_ci
2851cb0ef41Sopenharmony_ci/* random */
2861cb0ef41Sopenharmony_ciint uv__random_devurandom(void* buf, size_t buflen);
2871cb0ef41Sopenharmony_ciint uv__random_getrandom(void* buf, size_t buflen);
2881cb0ef41Sopenharmony_ciint uv__random_getentropy(void* buf, size_t buflen);
2891cb0ef41Sopenharmony_ciint uv__random_readpath(const char* path, void* buf, size_t buflen);
2901cb0ef41Sopenharmony_ciint uv__random_sysctl(void* buf, size_t buflen);
2911cb0ef41Sopenharmony_ci
2921cb0ef41Sopenharmony_ci#if defined(__APPLE__)
2931cb0ef41Sopenharmony_ciint uv___stream_fd(const uv_stream_t* handle);
2941cb0ef41Sopenharmony_ci#define uv__stream_fd(handle) (uv___stream_fd((const uv_stream_t*) (handle)))
2951cb0ef41Sopenharmony_ci#else
2961cb0ef41Sopenharmony_ci#define uv__stream_fd(handle) ((handle)->io_watcher.fd)
2971cb0ef41Sopenharmony_ci#endif /* defined(__APPLE__) */
2981cb0ef41Sopenharmony_ci
2991cb0ef41Sopenharmony_ciint uv__make_pipe(int fds[2], int flags);
3001cb0ef41Sopenharmony_ci
3011cb0ef41Sopenharmony_ci#if defined(__APPLE__)
3021cb0ef41Sopenharmony_ci
3031cb0ef41Sopenharmony_ciint uv__fsevents_init(uv_fs_event_t* handle);
3041cb0ef41Sopenharmony_ciint uv__fsevents_close(uv_fs_event_t* handle);
3051cb0ef41Sopenharmony_civoid uv__fsevents_loop_delete(uv_loop_t* loop);
3061cb0ef41Sopenharmony_ci
3071cb0ef41Sopenharmony_ci#endif /* defined(__APPLE__) */
3081cb0ef41Sopenharmony_ci
3091cb0ef41Sopenharmony_ciUV_UNUSED(static void uv__update_time(uv_loop_t* loop)) {
3101cb0ef41Sopenharmony_ci  /* Use a fast time source if available.  We only need millisecond precision.
3111cb0ef41Sopenharmony_ci   */
3121cb0ef41Sopenharmony_ci  loop->time = uv__hrtime(UV_CLOCK_FAST) / 1000000;
3131cb0ef41Sopenharmony_ci}
3141cb0ef41Sopenharmony_ci
3151cb0ef41Sopenharmony_ciUV_UNUSED(static char* uv__basename_r(const char* path)) {
3161cb0ef41Sopenharmony_ci  char* s;
3171cb0ef41Sopenharmony_ci
3181cb0ef41Sopenharmony_ci  s = strrchr(path, '/');
3191cb0ef41Sopenharmony_ci  if (s == NULL)
3201cb0ef41Sopenharmony_ci    return (char*) path;
3211cb0ef41Sopenharmony_ci
3221cb0ef41Sopenharmony_ci  return s + 1;
3231cb0ef41Sopenharmony_ci}
3241cb0ef41Sopenharmony_ci
3251cb0ef41Sopenharmony_ci#if defined(__linux__)
3261cb0ef41Sopenharmony_ciint uv__inotify_fork(uv_loop_t* loop, void* old_watchers);
3271cb0ef41Sopenharmony_ci#endif
3281cb0ef41Sopenharmony_ci
3291cb0ef41Sopenharmony_citypedef int (*uv__peersockfunc)(int, struct sockaddr*, socklen_t*);
3301cb0ef41Sopenharmony_ci
3311cb0ef41Sopenharmony_ciint uv__getsockpeername(const uv_handle_t* handle,
3321cb0ef41Sopenharmony_ci                        uv__peersockfunc func,
3331cb0ef41Sopenharmony_ci                        struct sockaddr* name,
3341cb0ef41Sopenharmony_ci                        int* namelen);
3351cb0ef41Sopenharmony_ci
3361cb0ef41Sopenharmony_ci#if defined(__linux__)            ||                                      \
3371cb0ef41Sopenharmony_ci    defined(__FreeBSD__)          ||                                      \
3381cb0ef41Sopenharmony_ci    defined(__FreeBSD_kernel__)   ||                                       \
3391cb0ef41Sopenharmony_ci    defined(__DragonFly__)
3401cb0ef41Sopenharmony_ci#define HAVE_MMSG 1
3411cb0ef41Sopenharmony_cistruct uv__mmsghdr {
3421cb0ef41Sopenharmony_ci  struct msghdr msg_hdr;
3431cb0ef41Sopenharmony_ci  unsigned int msg_len;
3441cb0ef41Sopenharmony_ci};
3451cb0ef41Sopenharmony_ci
3461cb0ef41Sopenharmony_ciint uv__recvmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen);
3471cb0ef41Sopenharmony_ciint uv__sendmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen);
3481cb0ef41Sopenharmony_ci#else
3491cb0ef41Sopenharmony_ci#define HAVE_MMSG 0
3501cb0ef41Sopenharmony_ci#endif
3511cb0ef41Sopenharmony_ci
3521cb0ef41Sopenharmony_ci#if defined(__sun)
3531cb0ef41Sopenharmony_ci#if !defined(_POSIX_VERSION) || _POSIX_VERSION < 200809L
3541cb0ef41Sopenharmony_cisize_t strnlen(const char* s, size_t maxlen);
3551cb0ef41Sopenharmony_ci#endif
3561cb0ef41Sopenharmony_ci#endif
3571cb0ef41Sopenharmony_ci
3581cb0ef41Sopenharmony_ci#if defined(__FreeBSD__)
3591cb0ef41Sopenharmony_cissize_t
3601cb0ef41Sopenharmony_ciuv__fs_copy_file_range(int fd_in,
3611cb0ef41Sopenharmony_ci                       off_t* off_in,
3621cb0ef41Sopenharmony_ci                       int fd_out,
3631cb0ef41Sopenharmony_ci                       off_t* off_out,
3641cb0ef41Sopenharmony_ci                       size_t len,
3651cb0ef41Sopenharmony_ci                       unsigned int flags);
3661cb0ef41Sopenharmony_ci#endif
3671cb0ef41Sopenharmony_ci
3681cb0ef41Sopenharmony_ci
3691cb0ef41Sopenharmony_ci#endif /* UV_UNIX_INTERNAL_H_ */
370