Rizin
unix-like reverse engineering framework and cli tools
core.c File Reference
#include "uv.h"
#include "internal.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <limits.h>
#include <sys/uio.h>
#include <sys/resource.h>
#include <pwd.h>
#include <sys/utsname.h>
#include <sys/time.h>

Go to the source code of this file.

Macros

#define CHECK_ENV_VAR(name)
 

Functions

static int uv__run_pending (uv_loop_t *loop)
 
 STATIC_ASSERT (sizeof(uv_buf_t)==sizeof(struct iovec))
 
 STATIC_ASSERT (sizeof(&((uv_buf_t *) 0) ->base)==sizeof(((struct iovec *) 0) ->iov_base))
 
 STATIC_ASSERT (sizeof(&((uv_buf_t *) 0) ->len)==sizeof(((struct iovec *) 0) ->iov_len))
 
 STATIC_ASSERT (offsetof(uv_buf_t, base)==offsetof(struct iovec, iov_base))
 
 STATIC_ASSERT (offsetof(uv_buf_t, len)==offsetof(struct iovec, iov_len))
 
uint64_t uv_hrtime (void)
 
void uv_close (uv_handle_t *handle, uv_close_cb close_cb)
 
int uv__socket_sockopt (uv_handle_t *handle, int optname, int *value)
 
void uv__make_close_pending (uv_handle_t *handle)
 
int uv__getiovmax (void)
 
static void uv__finish_close (uv_handle_t *handle)
 
static void uv__run_closing_handles (uv_loop_t *loop)
 
int uv_is_closing (const uv_handle_t *handle)
 
int uv_backend_fd (const uv_loop_t *loop)
 
int uv_backend_timeout (const uv_loop_t *loop)
 
static int uv__loop_alive (const uv_loop_t *loop)
 
int uv_loop_alive (const uv_loop_t *loop)
 
int uv_run (uv_loop_t *loop, uv_run_mode mode)
 
void uv_update_time (uv_loop_t *loop)
 
int uv_is_active (const uv_handle_t *handle)
 
int uv__socket (int domain, int type, int protocol)
 
FILE * uv__open_file (const char *path)
 
int uv__accept (int sockfd)
 
int uv__close_nocancel (int fd)
 
int uv__close_nocheckstdio (int fd)
 
int uv__close (int fd)
 
int uv__nonblock_ioctl (int fd, int set)
 
int uv__cloexec_ioctl (int fd, int set)
 
int uv__nonblock_fcntl (int fd, int set)
 
int uv__cloexec_fcntl (int fd, int set)
 
ssize_t uv__recvmsg (int fd, struct msghdr *msg, int flags)
 
int uv_cwd (char *buffer, size_t *size)
 
int uv_chdir (const char *dir)
 
void uv_disable_stdio_inheritance (void)
 
int uv_fileno (const uv_handle_t *handle, uv_os_fd_t *fd)
 
static unsigned int next_power_of_two (unsigned int val)
 
static void maybe_resize (uv_loop_t *loop, unsigned int len)
 
void uv__io_init (uv__io_t *w, uv__io_cb cb, int fd)
 
void uv__io_start (uv_loop_t *loop, uv__io_t *w, unsigned int events)
 
void uv__io_stop (uv_loop_t *loop, uv__io_t *w, unsigned int events)
 
void uv__io_close (uv_loop_t *loop, uv__io_t *w)
 
void uv__io_feed (uv_loop_t *loop, uv__io_t *w)
 
int uv__io_active (const uv__io_t *w, unsigned int events)
 
int uv__fd_exists (uv_loop_t *loop, int fd)
 
int uv_getrusage (uv_rusage_t *rusage)
 
int uv__open_cloexec (const char *path, int flags)
 
int uv__dup2_cloexec (int oldfd, int newfd)
 
int uv_os_homedir (char *buffer, size_t *size)
 
int uv_os_tmpdir (char *buffer, size_t *size)
 
int uv__getpwuid_r (uv_passwd_t *pwd)
 
void uv_os_free_passwd (uv_passwd_t *pwd)
 
int uv_os_get_passwd (uv_passwd_t *pwd)
 
int uv_translate_sys_error (int sys_errno)
 
int uv_os_environ (uv_env_item_t **envitems, int *count)
 
int uv_os_getenv (const char *name, char *buffer, size_t *size)
 
int uv_os_setenv (const char *name, const char *value)
 
int uv_os_unsetenv (const char *name)
 
int uv_os_gethostname (char *buffer, size_t *size)
 
uv_os_fd_t uv_get_osfhandle (int fd)
 
int uv_open_osfhandle (uv_os_fd_t os_fd)
 
uv_pid_t uv_os_getpid (void)
 
uv_pid_t uv_os_getppid (void)
 
int uv_os_getpriority (uv_pid_t pid, int *priority)
 
int uv_os_setpriority (uv_pid_t pid, int priority)
 
int uv_os_uname (uv_utsname_t *buffer)
 
int uv__getsockpeername (const uv_handle_t *handle, uv__peersockfunc func, struct sockaddr *name, int *namelen)
 
int uv_gettimeofday (uv_timeval64_t *tv)
 
void uv_sleep (unsigned int msec)
 
int uv__search_path (const char *prog, char *buf, size_t *buflen)
 

Variables

char ** environ
 

Macro Definition Documentation

◆ CHECK_ENV_VAR

#define CHECK_ENV_VAR (   name)
Value:
do { \
buf = getenv(name); \
if (buf != NULL) \
goto return_buffer; \
} \
while (0)
#define NULL
Definition: cris-opc.c:27
voidpf void * buf
Definition: ioapi.h:138
Definition: z80asm.h:102
char * getenv()

Function Documentation

◆ maybe_resize()

static void maybe_resize ( uv_loop_t loop,
unsigned int  len 
)
static

Definition at line 830 of file core.c.

830  {
831  uv__io_t** watchers;
832  void* fake_watcher_list;
833  void* fake_watcher_count;
834  unsigned int nwatchers;
835  unsigned int i;
836 
837  if (len <= loop->nwatchers)
838  return;
839 
840  /* Preserve fake watcher list and count at the end of the watchers */
841  if (loop->watchers != NULL) {
842  fake_watcher_list = loop->watchers[loop->nwatchers];
843  fake_watcher_count = loop->watchers[loop->nwatchers + 1];
844  } else {
845  fake_watcher_list = NULL;
846  fake_watcher_count = NULL;
847  }
848 
849  nwatchers = next_power_of_two(len + 2) - 2;
850  watchers = uv__reallocf(loop->watchers,
851  (nwatchers + 2) * sizeof(loop->watchers[0]));
852 
853  if (watchers == NULL)
854  abort();
855  for (i = loop->nwatchers; i < nwatchers; i++)
856  watchers[i] = NULL;
857  watchers[nwatchers] = fake_watcher_list;
858  watchers[nwatchers + 1] = fake_watcher_count;
859 
860  loop->watchers = watchers;
861  loop->nwatchers = nwatchers;
862 }
size_t len
Definition: 6502dis.c:15
lzma_index ** i
Definition: index.h:629
Definition: unix.h:96
uv_loop_t * loop
Definition: main.c:7
static unsigned int next_power_of_two(unsigned int val)
Definition: core.c:819
void * uv__reallocf(void *ptr, size_t size)
Definition: uv-common.c:103

References i, len, loop, next_power_of_two(), NULL, and uv__reallocf().

Referenced by uv__io_start().

◆ next_power_of_two()

static unsigned int next_power_of_two ( unsigned int  val)
static

Definition at line 819 of file core.c.

819  {
820  val -= 1;
821  val |= val >> 1;
822  val |= val >> 2;
823  val |= val >> 4;
824  val |= val >> 8;
825  val |= val >> 16;
826  val += 1;
827  return val;
828 }
ut16 val
Definition: armass64_const.h:6

References val.

Referenced by maybe_resize().

◆ STATIC_ASSERT() [1/5]

STATIC_ASSERT ( offsetof(uv_buf_t, base)  = =offsetof(struct iovec, iov_base))

◆ STATIC_ASSERT() [2/5]

STATIC_ASSERT ( offsetof(uv_buf_t, len = =offsetof(struct iovec, iov_len))

◆ STATIC_ASSERT() [3/5]

STATIC_ASSERT ( sizeof(&((uv_buf_t *) 0) ->base)  = =sizeof(((struct iovec *) 0) ->iov_base))

◆ STATIC_ASSERT() [4/5]

STATIC_ASSERT ( sizeof(&((uv_buf_t *) 0) ->len = =sizeof(((struct iovec *) 0) ->iov_len))

◆ STATIC_ASSERT() [5/5]

STATIC_ASSERT ( sizeof(uv_buf_t = =sizeof(struct iovec))

◆ uv__accept()

int uv__accept ( int  sockfd)

Definition at line 489 of file core.c.

489  {
490  int peerfd;
491  int err;
492 
493  (void) &err;
494  assert(sockfd >= 0);
495 
496  do
497 #ifdef uv__accept4
498  peerfd = uv__accept4(sockfd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
499 #else
500  peerfd = accept(sockfd, NULL, NULL);
501 #endif
502  while (peerfd == -1 && errno == EINTR);
503 
504  if (peerfd == -1)
505  return UV__ERR(errno);
506 
507 #ifndef uv__accept4
508  err = uv__cloexec(peerfd, 1);
509  if (err == 0)
510  err = uv__nonblock(peerfd, 1);
511 
512  if (err != 0) {
513  uv__close(peerfd);
514  return err;
515  }
516 #endif
517 
518  return peerfd;
519 }
static bool err
Definition: armass.c:435
#define UV__ERR(x)
Definition: errno.h:29
static const void static count static fd struct stat static buf struct pollfd unsigned static timeout void static offset void static length char static len const struct iovec static count unsigned long static filedes static sched_yield static flags static oldfd static pause unsigned static seconds static protocol accept
Definition: sflib.h:75
assert(limit<=UINT32_MAX/2)
static sockfd
Definition: sfsocketcall.h:114
#define EINTR
Definition: sftypes.h:114
int uv__close(int fd)
Definition: core.c:569
#define uv__cloexec
Definition: internal.h:169
#define uv__nonblock
Definition: internal.h:170

References accept, assert(), EINTR, err, NULL, sockfd, uv__cloexec, uv__close(), UV__ERR, and uv__nonblock.

Referenced by uv__emfile_trick(), and uv__server_io().

◆ uv__cloexec_fcntl()

int uv__cloexec_fcntl ( int  fd,
int  set 
)

Definition at line 639 of file core.c.

639  {
640  int flags;
641  int r;
642 
643  do
644  r = fcntl(fd, F_GETFD);
645  while (r == -1 && errno == EINTR);
646 
647  if (r == -1)
648  return UV__ERR(errno);
649 
650  /* Bail out now if already set/clear. */
651  if (!!(r & FD_CLOEXEC) == !!set)
652  return 0;
653 
654  if (set)
655  flags = r | FD_CLOEXEC;
656  else
657  flags = r & ~FD_CLOEXEC;
658 
659  do
660  r = fcntl(fd, F_SETFD, flags);
661  while (r == -1 && errno == EINTR);
662 
663  if (r)
664  return UV__ERR(errno);
665 
666  return 0;
667 }
#define r
Definition: crypto_rc6.c:12
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags fcntl
Definition: sflib.h:79
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123
#define FD_CLOEXEC
Definition: sftypes.h:522
#define F_GETFD
Definition: sftypes.h:504
#define F_SETFD
Definition: sftypes.h:505
static const z80_opcode fd[]
Definition: z80_tab.h:997

References EINTR, F_GETFD, F_SETFD, fcntl, fd, FD_CLOEXEC, flags, r, and UV__ERR.

Referenced by uv__process_child_init().

◆ uv__cloexec_ioctl()

int uv__cloexec_ioctl ( int  fd,
int  set 
)

Definition at line 593 of file core.c.

593  {
594  int r;
595 
596  do
597  r = ioctl(fd, set ? FIOCLEX : FIONCLEX);
598  while (r == -1 && errno == EINTR);
599 
600  if (r)
601  return UV__ERR(errno);
602 
603  return 0;
604 }
static static sync static getppid static getegid const char static filename ioctl
Definition: sflib.h:62
#define FIOCLEX
Definition: sftypes.h:749
#define FIONCLEX
Definition: sftypes.h:748

References EINTR, fd, FIOCLEX, FIONCLEX, ioctl, r, and UV__ERR.

◆ uv__close()

◆ uv__close_nocancel()

int uv__close_nocancel ( int  fd)

Definition at line 530 of file core.c.

530  {
531 #if defined(__APPLE__)
532 #pragma GCC diagnostic push
533 #pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
534 #if defined(__LP64__) || TARGET_OS_IPHONE
535  extern int close$NOCANCEL(int);
536  return close$NOCANCEL(fd);
537 #else
538  extern int close$NOCANCEL$UNIX2003(int);
539  return close$NOCANCEL$UNIX2003(fd);
540 #endif
541 #pragma GCC diagnostic pop
542 #elif defined(__linux__)
543  return syscall(SYS_close, fd);
544 #else
545  return close(fd);
546 #endif
547 }
static static fork const void static count close
Definition: sflib.h:33
const char * syscall
Definition: internal.h:270

References close, fd, and syscall.

Referenced by uv__close_nocheckstdio(), and uv__fs_close().

◆ uv__close_nocheckstdio()

int uv__close_nocheckstdio ( int  fd)

Definition at line 550 of file core.c.

550  {
551  int saved_errno;
552  int rc;
553 
554  assert(fd > -1); /* Catch uninitialized io_watcher.fd bugs. */
555 
556  saved_errno = errno;
557  rc = uv__close_nocancel(fd);
558  if (rc == -1) {
559  rc = UV__ERR(errno);
560  if (rc == UV_EINTR || rc == UV__ERR(EINPROGRESS))
561  rc = 0; /* The close is in progress, not an error. */
562  errno = saved_errno;
563  }
564 
565  return rc;
566 }
#define EINPROGRESS
Definition: sftypes.h:175
int uv__close_nocancel(int fd)
Definition: core.c:530

References assert(), EINPROGRESS, fd, uv__close_nocancel(), and UV__ERR.

Referenced by uv__close(), uv__fs_copyfile(), uv__slurp(), uv_fs_event_start(), and uv_spawn().

◆ uv__dup2_cloexec()

int uv__dup2_cloexec ( int  oldfd,
int  newfd 
)

Definition at line 1031 of file core.c.

1031  {
1032 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__linux__)
1033  int r;
1034 
1035  r = dup3(oldfd, newfd, O_CLOEXEC);
1036  if (r == -1)
1037  return UV__ERR(errno);
1038 
1039  return r;
1040 #else
1041  int err;
1042  int r;
1043 
1044  r = dup2(oldfd, newfd); /* Never retry. */
1045  if (r == -1)
1046  return UV__ERR(errno);
1047 
1048  err = uv__cloexec(newfd, 1);
1049  if (err != 0) {
1050  uv__close(newfd);
1051  return err;
1052  }
1053 
1054  return r;
1055 #endif
1056 }
#define O_CLOEXEC
Definition: compat.h:80
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname unsigned long static filedes void static end_data_segment static handler static getegid char static len static pgid const char static path dup2
Definition: sflib.h:94
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname unsigned long static filedes void static end_data_segment static handler static getegid char static len static pgid const char static path oldfd
Definition: sflib.h:94

References dup2, err, O_CLOEXEC, oldfd, r, uv__cloexec, uv__close(), and UV__ERR.

Referenced by uv_tty_init().

◆ uv__fd_exists()

int uv__fd_exists ( uv_loop_t loop,
int  fd 
)

Definition at line 965 of file core.c.

965  {
966  return (unsigned) fd < loop->nwatchers && loop->watchers[fd] != NULL;
967 }

References fd, loop, and NULL.

Referenced by uv_pipe_open(), uv_poll_init(), uv_tcp_open(), and uv_udp_open().

◆ uv__finish_close()

static void uv__finish_close ( uv_handle_t handle)
static

Definition at line 243 of file core.c.

243  {
244  uv_signal_t* sh;
245 
246  /* Note: while the handle is in the UV_HANDLE_CLOSING state now, it's still
247  * possible for it to be active in the sense that uv__is_active() returns
248  * true.
249  *
250  * A good example is when the user calls uv_shutdown(), immediately followed
251  * by uv_close(). The handle is considered active at this point because the
252  * completion of the shutdown req is still pending.
253  */
254  assert(handle->flags & UV_HANDLE_CLOSING);
255  assert(!(handle->flags & UV_HANDLE_CLOSED));
256  handle->flags |= UV_HANDLE_CLOSED;
257 
258  switch (handle->type) {
259  case UV_PREPARE:
260  case UV_CHECK:
261  case UV_IDLE:
262  case UV_ASYNC:
263  case UV_TIMER:
264  case UV_PROCESS:
265  case UV_FS_EVENT:
266  case UV_FS_POLL:
267  case UV_POLL:
268  break;
269 
270  case UV_SIGNAL:
271  /* If there are any caught signals "trapped" in the signal pipe,
272  * we can't call the close callback yet. Reinserting the handle
273  * into the closing queue makes the event loop spin but that's
274  * okay because we only need to deliver the pending events.
275  */
276  sh = (uv_signal_t*) handle;
277  if (sh->caught_signals > sh->dispatched_signals) {
278  handle->flags ^= UV_HANDLE_CLOSED;
279  uv__make_close_pending(handle); /* Back into the queue. */
280  return;
281  }
282  break;
283 
284  case UV_NAMED_PIPE:
285  case UV_TCP:
286  case UV_TTY:
288  break;
289 
290  case UV_UDP:
292  break;
293 
294  default:
295  assert(0);
296  break;
297  }
298 
300  QUEUE_REMOVE(&handle->handle_queue);
301 
302  if (handle->close_cb) {
303  handle->close_cb(handle);
304  }
305 }
static mcore_handle handle
Definition: asm_mcore.c:8
#define QUEUE_REMOVE(q)
Definition: queue.h:101
Definition: uv.h:638
void uv__make_close_pending(uv_handle_t *handle)
Definition: core.c:208
void uv__udp_finish_close(uv_udp_t *handle)
Definition: udp.c:101
void uv__stream_destroy(uv_stream_t *stream)
Definition: stream.c:458
@ UV_HANDLE_CLOSING
Definition: uv-common.h:74
@ UV_HANDLE_CLOSED
Definition: uv-common.h:75
#define uv__handle_unref(h)
Definition: uv-common.h:283

References assert(), handle, QUEUE_REMOVE, uv__handle_unref, uv__make_close_pending(), uv__stream_destroy(), uv__udp_finish_close(), UV_HANDLE_CLOSED, and UV_HANDLE_CLOSING.

Referenced by uv__run_closing_handles().

◆ uv__getiovmax()

int uv__getiovmax ( void  )

Definition at line 215 of file core.c.

215  {
216 #if defined(IOV_MAX)
217  return IOV_MAX;
218 #elif defined(_SC_IOV_MAX)
219  static int iovmax_cached = -1;
220  int iovmax;
221 
222  iovmax = uv__load_relaxed(&iovmax_cached);
223  if (iovmax != -1)
224  return iovmax;
225 
226  /* On some embedded devices (arm-linux-uclibc based ip camera),
227  * sysconf(_SC_IOV_MAX) can not get the correct value. The return
228  * value is -1 and the errno is EINPROGRESS. Degrade the value to 1.
229  */
230  iovmax = sysconf(_SC_IOV_MAX);
231  if (iovmax == -1)
232  iovmax = 1;
233 
234  uv__store_relaxed(&iovmax_cached, iovmax);
235 
236  return iovmax;
237 #else
238  return 1024;
239 #endif
240 }
#define uv__load_relaxed(p)
Definition: uv-common.h:67
#define uv__store_relaxed(p, v)
Definition: uv-common.h:68

References uv__load_relaxed, and uv__store_relaxed.

Referenced by uv__fs_read(), uv__fs_write_all(), and uv__write().

◆ uv__getpwuid_r()

int uv__getpwuid_r ( uv_passwd_t pwd)

Definition at line 1146 of file core.c.

1146  {
1147  struct passwd pw;
1148  struct passwd* result;
1149  char* buf;
1150  uid_t uid;
1151  size_t bufsize;
1152  size_t name_size;
1153  size_t homedir_size;
1154  size_t shell_size;
1155  long initsize;
1156  int r;
1157 
1158  if (pwd == NULL)
1159  return UV_EINVAL;
1160 
1161  initsize = sysconf(_SC_GETPW_R_SIZE_MAX);
1162 
1163  if (initsize <= 0)
1164  bufsize = 4096;
1165  else
1166  bufsize = (size_t) initsize;
1167 
1168  uid = geteuid();
1169  buf = NULL;
1170 
1171  for (;;) {
1172  uv__free(buf);
1173  buf = uv__malloc(bufsize);
1174 
1175  if (buf == NULL)
1176  return UV_ENOMEM;
1177 
1178  r = getpwuid_r(uid, &pw, buf, bufsize, &result);
1179 
1180  if (r != ERANGE)
1181  break;
1182 
1183  bufsize *= 2;
1184  }
1185 
1186  if (r != 0) {
1187  uv__free(buf);
1188  return -r;
1189  }
1190 
1191  if (result == NULL) {
1192  uv__free(buf);
1193  return UV_ENOENT;
1194  }
1195 
1196  /* Allocate memory for the username, shell, and home directory */
1197  name_size = strlen(pw.pw_name) + 1;
1198  homedir_size = strlen(pw.pw_dir) + 1;
1199  shell_size = strlen(pw.pw_shell) + 1;
1200  pwd->username = uv__malloc(name_size + homedir_size + shell_size);
1201 
1202  if (pwd->username == NULL) {
1203  uv__free(buf);
1204  return UV_ENOMEM;
1205  }
1206 
1207  /* Copy the username */
1208  memcpy(pwd->username, pw.pw_name, name_size);
1209 
1210  /* Copy the home directory */
1211  pwd->homedir = pwd->username + name_size;
1212  memcpy(pwd->homedir, pw.pw_dir, homedir_size);
1213 
1214  /* Copy the shell */
1215  pwd->shell = pwd->homedir + homedir_size;
1216  memcpy(pwd->shell, pw.pw_shell, shell_size);
1217 
1218  /* Copy the uid and gid */
1219  pwd->uid = pw.pw_uid;
1220  pwd->gid = pw.pw_gid;
1221 
1222  uv__free(buf);
1223 
1224  return 0;
1225 }
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
int uid_t
Definition: sftypes.h:44
int size_t
Definition: sftypes.h:40
#define ERANGE
Definition: sftypes.h:144
char * username
Definition: uv.h:1111
char * homedir
Definition: uv.h:1115
long uid
Definition: uv.h:1112
long gid
Definition: uv.h:1113
char * shell
Definition: uv.h:1114
ut8 * buf
Definition: core.c:75
void * uv__malloc(size_t size)
Definition: uv-common.c:75
void uv__free(void *ptr)
Definition: uv-common.c:81

References buf, ERANGE, uv_passwd_s::gid, uv_passwd_s::homedir, memcpy(), NULL, r, uv_passwd_s::shell, uv_passwd_s::uid, uv_passwd_s::username, uv__free(), and uv__malloc().

Referenced by uv_os_get_passwd(), and uv_os_homedir().

◆ uv__getsockpeername()

int uv__getsockpeername ( const uv_handle_t handle,
uv__peersockfunc  func,
struct sockaddr name,
int namelen 
)

Definition at line 1490 of file core.c.

1493  {
1494  socklen_t socklen;
1495  uv_os_fd_t fd;
1496  int r;
1497 
1498  r = uv_fileno(handle, &fd);
1499  if (r < 0)
1500  return r;
1501 
1502  /* sizeof(socklen_t) != sizeof(int) on some systems. */
1503  socklen = (socklen_t) *namelen;
1504 
1505  if (func(fd, name, &socklen))
1506  return UV__ERR(errno);
1507 
1508  *namelen = (int) socklen;
1509  return 0;
1510 }
static int
Definition: sfsocketcall.h:114
unsigned int socklen_t
Definition: sftypes.h:219
int uv_fileno(const uv_handle_t *handle, uv_os_fd_t *fd)
Definition: core.c:767
int uv_os_fd_t
Definition: unix.h:130

References fd, handle, int, r, UV__ERR, and uv_fileno().

Referenced by uv__pipe_getsockpeername(), uv_tcp_getpeername(), uv_tcp_getsockname(), uv_udp_getpeername(), and uv_udp_getsockname().

◆ uv__io_active()

int uv__io_active ( const uv__io_t w,
unsigned int  events 
)

Definition at line 958 of file core.c.

958  {
959  assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI)));
960  assert(0 != events);
961  return 0 != (w->pevents & events);
962 }
#define w
Definition: crypto_rc6.c:13
#define UV__POLLRDHUP
Definition: internal.h:116
#define UV__POLLPRI
Definition: internal.h:122

References assert(), UV__POLLPRI, UV__POLLRDHUP, and w.

Referenced by uv__read(), uv__stream_close(), uv__stream_destroy(), uv__stream_eof(), uv__udp_finish_close(), uv__udp_recv_start(), uv__udp_run_completed(), uv__write(), uv_read_stop(), and uv_try_write().

◆ uv__io_close()

void uv__io_close ( uv_loop_t loop,
uv__io_t w 
)

Definition at line 942 of file core.c.

942  {
943  uv__io_stop(loop, w, POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI);
944  QUEUE_REMOVE(&w->pending_queue);
945 
946  /* Remove stale events for this file descriptor */
947  if (w->fd != -1)
949 }
void uv__platform_invalidate_fd(uv_loop_t *loop, int fd)
Definition: aix.c:1280
void uv__io_stop(uv_loop_t *loop, uv__io_t *w, unsigned int events)
Definition: core.c:910

References loop, QUEUE_REMOVE, uv__io_stop(), uv__platform_invalidate_fd(), UV__POLLPRI, UV__POLLRDHUP, and w.

Referenced by uv__stream_close(), uv__udp_close(), and uv_fs_event_stop().

◆ uv__io_feed()

void uv__io_feed ( uv_loop_t loop,
uv__io_t w 
)

Definition at line 952 of file core.c.

952  {
953  if (QUEUE_EMPTY(&w->pending_queue))
954  QUEUE_INSERT_TAIL(&loop->pending_queue, &w->pending_queue);
955 }
#define QUEUE_EMPTY(q)
Definition: queue.h:39
#define QUEUE_INSERT_TAIL(h, q)
Definition: queue.h:92

References loop, QUEUE_EMPTY, QUEUE_INSERT_TAIL, and w.

Referenced by uv__tcp_connect(), uv__udp_sendmsg(), uv__write_req_finish(), and uv_pipe_connect().

◆ uv__io_init()

void uv__io_init ( uv__io_t w,
uv__io_cb  cb,
int  fd 
)

Definition at line 865 of file core.c.

865  {
866  assert(cb != NULL);
867  assert(fd >= -1);
868  QUEUE_INIT(&w->pending_queue);
869  QUEUE_INIT(&w->watcher_queue);
870  w->cb = cb;
871  w->fd = fd;
872  w->events = 0;
873  w->pevents = 0;
874 
875 #if defined(UV_HAVE_KQUEUE)
876  w->rcount = 0;
877  w->wcount = 0;
878 #endif /* defined(UV_HAVE_KQUEUE) */
879 }
#define QUEUE_INIT(q)
Definition: queue.h:45
static const char * cb[]
Definition: z80_tab.h:176

References assert(), cb, fd, NULL, QUEUE_INIT, and w.

Referenced by init_inotify(), uv__async_start(), uv__signal_loop_once_init(), uv__stream_init(), uv__udp_init_ex(), uv_fs_event_start(), and uv_poll_init().

◆ uv__io_start()

void uv__io_start ( uv_loop_t loop,
uv__io_t w,
unsigned int  events 
)

Definition at line 882 of file core.c.

882  {
883  assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI)));
884  assert(0 != events);
885  assert(w->fd >= 0);
886  assert(w->fd < INT_MAX);
887 
888  w->pevents |= events;
889  maybe_resize(loop, w->fd + 1);
890 
891 #if !defined(__sun)
892  /* The event ports backend needs to rearm all file descriptors on each and
893  * every tick of the event loop but the other backends allow us to
894  * short-circuit here if the event mask is unchanged.
895  */
896  if (w->events == w->pevents)
897  return;
898 #endif
899 
900  if (QUEUE_EMPTY(&w->watcher_queue))
901  QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue);
902 
903  if (loop->watchers[w->fd] == NULL) {
904  loop->watchers[w->fd] = w;
905  loop->nfds++;
906  }
907 }
#define INT_MAX
Definition: cp-demangle.c:131
static void maybe_resize(uv_loop_t *loop, unsigned int len)
Definition: core.c:830

References assert(), INT_MAX, loop, maybe_resize(), NULL, QUEUE_EMPTY, QUEUE_INSERT_TAIL, UV__POLLPRI, UV__POLLRDHUP, and w.

Referenced by init_inotify(), uv__async_start(), uv__read(), uv__server_io(), uv__signal_loop_once_init(), uv__tcp_connect(), uv__udp_recv_start(), uv__udp_send(), uv__write(), uv_accept(), uv_fs_event_start(), uv_pipe_connect(), uv_pipe_listen(), uv_poll_start(), uv_read_start(), uv_shutdown(), uv_tcp_listen(), and uv_write2().

◆ uv__io_stop()

void uv__io_stop ( uv_loop_t loop,
uv__io_t w,
unsigned int  events 
)

Definition at line 910 of file core.c.

910  {
911  assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI)));
912  assert(0 != events);
913 
914  if (w->fd == -1)
915  return;
916 
917  assert(w->fd >= 0);
918 
919  /* Happens when uv__io_stop() is called on a handle that was never started. */
920  if ((unsigned) w->fd >= loop->nwatchers)
921  return;
922 
923  w->pevents &= ~events;
924 
925  if (w->pevents == 0) {
926  QUEUE_REMOVE(&w->watcher_queue);
927  QUEUE_INIT(&w->watcher_queue);
928 
929  if (loop->watchers[w->fd] != NULL) {
930  assert(loop->watchers[w->fd] == w);
931  assert(loop->nfds > 0);
932  loop->watchers[w->fd] = NULL;
933  loop->nfds--;
934  w->events = 0;
935  }
936  }
937  else if (QUEUE_EMPTY(&w->watcher_queue))
938  QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue);
939 }

References assert(), loop, NULL, QUEUE_EMPTY, QUEUE_INIT, QUEUE_INSERT_TAIL, QUEUE_REMOVE, UV__POLLPRI, UV__POLLRDHUP, and w.

Referenced by uv__async_stop(), uv__drain(), uv__io_close(), uv__io_fork(), uv__platform_loop_delete(), uv__poll_io(), uv__poll_stop(), uv__read(), uv__server_io(), uv__signal_loop_fork(), uv__stream_connect(), uv__stream_eof(), uv__udp_run_completed(), uv__write(), uv_read_stop(), and uv_try_write().

◆ uv__loop_alive()

static int uv__loop_alive ( const uv_loop_t loop)
static

Definition at line 353 of file core.c.

353  {
354  return uv__has_active_handles(loop) ||
356  loop->closing_handles != NULL;
357 }
#define uv__has_active_handles(loop)
Definition: uv-common.h:237
#define uv__has_active_reqs(loop)
Definition: uv-common.h:221

References loop, NULL, uv__has_active_handles, and uv__has_active_reqs.

Referenced by uv_loop_alive(), and uv_run().

◆ uv__make_close_pending()

void uv__make_close_pending ( uv_handle_t handle)

Definition at line 208 of file core.c.

208  {
209  assert(handle->flags & UV_HANDLE_CLOSING);
210  assert(!(handle->flags & UV_HANDLE_CLOSED));
211  handle->next_closing = handle->loop->closing_handles;
212  handle->loop->closing_handles = handle;
213 }

References assert(), handle, UV_HANDLE_CLOSED, and UV_HANDLE_CLOSING.

Referenced by timer_close_cb(), uv__finish_close(), uv__fs_poll_close(), and uv_close().

◆ uv__nonblock_fcntl()

int uv__nonblock_fcntl ( int  fd,
int  set 
)

Definition at line 608 of file core.c.

608  {
609  int flags;
610  int r;
611 
612  do
613  r = fcntl(fd, F_GETFL);
614  while (r == -1 && errno == EINTR);
615 
616  if (r == -1)
617  return UV__ERR(errno);
618 
619  /* Bail out now if already set/clear. */
620  if (!!(r & O_NONBLOCK) == !!set)
621  return 0;
622 
623  if (set)
624  flags = r | O_NONBLOCK;
625  else
626  flags = r & ~O_NONBLOCK;
627 
628  do
629  r = fcntl(fd, F_SETFL, flags);
630  while (r == -1 && errno == EINTR);
631 
632  if (r)
633  return UV__ERR(errno);
634 
635  return 0;
636 }
#define F_GETFL
Definition: sftypes.h:506
#define O_NONBLOCK
Definition: sftypes.h:494
#define F_SETFL
Definition: sftypes.h:507

References EINTR, F_GETFL, F_SETFL, fcntl, fd, flags, O_NONBLOCK, r, and UV__ERR.

Referenced by uv__process_child_init(), and uv_poll_init().

◆ uv__nonblock_ioctl()

int uv__nonblock_ioctl ( int  fd,
int  set 
)

Definition at line 578 of file core.c.

578  {
579  int r;
580 
581  do
582  r = ioctl(fd, FIONBIO, &set);
583  while (r == -1 && errno == EINTR);
584 
585  if (r)
586  return UV__ERR(errno);
587 
588  return 0;
589 }
#define FIONBIO
Definition: sftypes.h:736

References EINTR, fd, FIONBIO, ioctl, r, and UV__ERR.

Referenced by uv_poll_init().

◆ uv__open_cloexec()

int uv__open_cloexec ( const char *  path,
int  flags 
)

Definition at line 1003 of file core.c.

1003  {
1004 #if defined(O_CLOEXEC)
1005  int fd;
1006 
1007  fd = open(path, flags | O_CLOEXEC);
1008  if (fd == -1)
1009  return UV__ERR(errno);
1010 
1011  return fd;
1012 #else /* O_CLOEXEC */
1013  int err;
1014  int fd;
1015 
1016  fd = open(path, flags);
1017  if (fd == -1)
1018  return UV__ERR(errno);
1019 
1020  err = uv__cloexec(fd, 1);
1021  if (err) {
1022  uv__close(fd);
1023  return err;
1024  }
1025 
1026  return fd;
1027 #endif /* O_CLOEXEC */
1028 }
static static fork const void static count static fd const char const char static newpath const char static path const char path
Definition: sflib.h:35

References err, fd, flags, O_CLOEXEC, path, uv__cloexec, uv__close(), and UV__ERR.

Referenced by uv__emfile_trick(), uv__open_file(), uv__random_readpath(), uv__slurp(), uv__stream_init(), uv_resident_set_memory(), and uv_tty_init().

◆ uv__open_file()

FILE* uv__open_file ( const char *  path)

Definition at line 473 of file core.c.

473  {
474  int fd;
475  FILE* fp;
476 
478  if (fd < 0)
479  return NULL;
480 
481  fp = fdopen(fd, "r");
482  if (fp == NULL)
483  uv__close(fd);
484 
485  return fp;
486 }
string FILE
Definition: benchmark.py:21
#define O_RDONLY
Definition: sftypes.h:486
int uv__open_cloexec(const char *path, int flags)
Definition: core.c:1003

References fd, benchmark::FILE, NULL, O_RDONLY, path, uv__close(), and uv__open_cloexec().

Referenced by read_cpufreq(), read_models(), and uv_cpu_info().

◆ uv__recvmsg()

ssize_t uv__recvmsg ( int  fd,
struct msghdr msg,
int  flags 
)

Definition at line 670 of file core.c.

670  {
671  struct cmsghdr* cmsg;
672  ssize_t rc;
673  int* pfd;
674  int* end;
675 #if defined(__linux__)
676  static int no_msg_cmsg_cloexec;
677  if (0 == uv__load_relaxed(&no_msg_cmsg_cloexec)) {
678  rc = recvmsg(fd, msg, flags | 0x40000000); /* MSG_CMSG_CLOEXEC */
679  if (rc != -1)
680  return rc;
681  if (errno != EINVAL)
682  return UV__ERR(errno);
683  rc = recvmsg(fd, msg, flags);
684  if (rc == -1)
685  return UV__ERR(errno);
686  uv__store_relaxed(&no_msg_cmsg_cloexec, 1);
687  } else {
688  rc = recvmsg(fd, msg, flags);
689  }
690 #else
691  rc = recvmsg(fd, msg, flags);
692 #endif
693  if (rc == -1)
694  return UV__ERR(errno);
695  if (msg->msg_controllen == 0)
696  return rc;
697  for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg))
698  if (cmsg->cmsg_type == SCM_RIGHTS)
699  for (pfd = (int*) CMSG_DATA(cmsg),
700  end = (int*) ((char*) cmsg + cmsg->cmsg_len);
701  pfd < end;
702  pfd += 1)
703  uv__cloexec(*pfd, 1);
704  return rc;
705 }
static struct sockaddr static addrlen static backlog const void msg
Definition: sfsocketcall.h:119
@ SCM_RIGHTS
Definition: sftypes.h:383
#define EINVAL
Definition: sftypes.h:132
#define CMSG_FIRSTHDR(mhdr)
Definition: sftypes.h:418
#define CMSG_NXTHDR(mhdr, cmsg)
Definition: sftypes.h:417
#define CMSG_DATA(cmsg)
Definition: sftypes.h:416
int ssize_t
Definition: sftypes.h:39
int cmsg_type
Definition: sftypes.h:412
size_t cmsg_len
Definition: sftypes.h:409

References CMSG_DATA, CMSG_FIRSTHDR, cmsghdr::cmsg_len, CMSG_NXTHDR, cmsghdr::cmsg_type, EINVAL, test_evm::end, fd, flags, msg, NULL, SCM_RIGHTS, uv__cloexec, UV__ERR, uv__load_relaxed, and uv__store_relaxed.

Referenced by uv__read().

◆ uv__run_closing_handles()

static void uv__run_closing_handles ( uv_loop_t loop)
static

Definition at line 308 of file core.c.

308  {
309  uv_handle_t* p;
310  uv_handle_t* q;
311 
312  p = loop->closing_handles;
313  loop->closing_handles = NULL;
314 
315  while (p) {
316  q = p->next_closing;
318  p = q;
319  }
320 }
void * p
Definition: libc.cpp:67
static void uv__finish_close(uv_handle_t *handle)
Definition: core.c:243

References loop, NULL, p, and uv__finish_close().

Referenced by uv_run().

◆ uv__run_pending()

static int uv__run_pending ( uv_loop_t loop)
static

Definition at line 797 of file core.c.

797  {
798  QUEUE* q;
799  QUEUE pq;
800  uv__io_t* w;
801 
802  if (QUEUE_EMPTY(&loop->pending_queue))
803  return 0;
804 
805  QUEUE_MOVE(&loop->pending_queue, &pq);
806 
807  while (!QUEUE_EMPTY(&pq)) {
808  q = QUEUE_HEAD(&pq);
809  QUEUE_REMOVE(q);
810  QUEUE_INIT(q);
811  w = QUEUE_DATA(q, uv__io_t, pending_queue);
812  w->cb(loop, w, POLLOUT);
813  }
814 
815  return 1;
816 }
#define QUEUE_DATA(ptr, type, field)
Definition: queue.h:30
#define QUEUE_HEAD(q)
Definition: queue.h:42
#define QUEUE_MOVE(h, n)
Definition: queue.h:72
void * QUEUE[2]
Definition: queue.h:21

References loop, QUEUE_DATA, QUEUE_EMPTY, QUEUE_HEAD, QUEUE_INIT, QUEUE_MOVE, QUEUE_REMOVE, and w.

Referenced by uv_run().

◆ uv__search_path()

int uv__search_path ( const char *  prog,
char *  buf,
size_t buflen 
)

Definition at line 1540 of file core.c.

1540  {
1541  char abspath[UV__PATH_MAX];
1542  size_t abspath_size;
1543  char trypath[UV__PATH_MAX];
1544  char* cloned_path;
1545  char* path_env;
1546  char* token;
1547 
1548  if (buf == NULL || buflen == NULL || *buflen == 0)
1549  return UV_EINVAL;
1550 
1551  /*
1552  * Possibilities for prog:
1553  * i) an absolute path such as: /home/user/myprojects/nodejs/node
1554  * ii) a relative path such as: ./node or ../myprojects/nodejs/node
1555  * iii) a bare filename such as "node", after exporting PATH variable
1556  * to its location.
1557  */
1558 
1559  /* Case i) and ii) absolute or relative paths */
1560  if (strchr(prog, '/') != NULL) {
1561  if (realpath(prog, abspath) != abspath)
1562  return UV__ERR(errno);
1563 
1564  abspath_size = strlen(abspath);
1565 
1566  *buflen -= 1;
1567  if (*buflen > abspath_size)
1568  *buflen = abspath_size;
1569 
1570  memcpy(buf, abspath, *buflen);
1571  buf[*buflen] = '\0';
1572 
1573  return 0;
1574  }
1575 
1576  /* Case iii). Search PATH environment variable */
1577  cloned_path = NULL;
1578  token = NULL;
1579  path_env = getenv("PATH");
1580 
1581  if (path_env == NULL)
1582  return UV_EINVAL;
1583 
1584  cloned_path = uv__strdup(path_env);
1585  if (cloned_path == NULL)
1586  return UV_ENOMEM;
1587 
1588  token = strtok(cloned_path, ":");
1589  while (token != NULL) {
1590  snprintf(trypath, sizeof(trypath) - 1, "%s/%s", token, prog);
1591  if (realpath(trypath, abspath) == abspath) {
1592  /* Check the match is executable */
1593  if (access(abspath, X_OK) == 0) {
1594  abspath_size = strlen(abspath);
1595 
1596  *buflen -= 1;
1597  if (*buflen > abspath_size)
1598  *buflen = abspath_size;
1599 
1600  memcpy(buf, abspath, *buflen);
1601  buf[*buflen] = '\0';
1602 
1603  uv__free(cloned_path);
1604  return 0;
1605  }
1606  }
1607  token = strtok(NULL, ":");
1608  }
1609  uv__free(cloned_path);
1610 
1611  /* Out of tokens (path entries), and no match found */
1612  return UV_EINVAL;
1613 }
snprintf
Definition: kernel.h:364
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause access
Definition: sflib.h:64
#define UV__PATH_MAX
Definition: internal.h:68
ut64 buflen
Definition: core.c:76
char * prog
Definition: untgz.c:125
char * uv__strdup(const char *s)
Definition: uv-common.c:55
#define X_OK
Definition: win.h:664

References access, buflen, getenv(), memcpy(), NULL, prog, snprintf, UV__ERR, uv__free(), UV__PATH_MAX, uv__strdup(), and X_OK.

Referenced by uv_exepath(), and uv_setup_args().

◆ uv__socket()

int uv__socket ( int  domain,
int  type,
int  protocol 
)

Definition at line 436 of file core.c.

436  {
437  int sockfd;
438  int err;
439 
440 #if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC)
441  sockfd = socket(domain, type | SOCK_NONBLOCK | SOCK_CLOEXEC, protocol);
442  if (sockfd != -1)
443  return sockfd;
444 
445  if (errno != EINVAL)
446  return UV__ERR(errno);
447 #endif
448 
449  sockfd = socket(domain, type, protocol);
450  if (sockfd == -1)
451  return UV__ERR(errno);
452 
453  err = uv__nonblock(sockfd, 1);
454  if (err == 0)
455  err = uv__cloexec(sockfd, 1);
456 
457  if (err) {
458  uv__close(sockfd);
459  return err;
460  }
461 
462 #if defined(SO_NOSIGPIPE)
463  {
464  int on = 1;
465  setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
466  }
467 #endif
468 
469  return sockfd;
470 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd domain
Definition: sflib.h:79
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd socket
Definition: sflib.h:79
int type
Definition: mipsasm.c:17
#define SOL_SOCKET
Definition: sftypes.h:427

References domain, EINVAL, err, socket, sockfd, SOL_SOCKET, type, uv__cloexec, uv__close(), UV__ERR, and uv__nonblock.

Referenced by new_socket(), uv__udp_bind(), uv__udp_init_ex(), uv_pipe_bind(), and uv_pipe_connect().

◆ uv__socket_sockopt()

int uv__socket_sockopt ( uv_handle_t handle,
int  optname,
int value 
)

Definition at line 180 of file core.c.

180  {
181  int r;
182  int fd;
183  socklen_t len;
184 
185  if (handle == NULL || value == NULL)
186  return UV_EINVAL;
187 
188  if (handle->type == UV_TCP || handle->type == UV_NAMED_PIPE)
190  else if (handle->type == UV_UDP)
191  fd = ((uv_udp_t *) handle)->io_watcher.fd;
192  else
193  return UV_ENOTSUP;
194 
195  len = sizeof(*value);
196 
197  if (*value == 0)
198  r = getsockopt(fd, SOL_SOCKET, optname, value, &len);
199  else
200  r = setsockopt(fd, SOL_SOCKET, optname, (const void*) value, len);
201 
202  if (r < 0)
203  return UV__ERR(errno);
204 
205  return 0;
206 }
static int value
Definition: cmd_api.c:93
#define uv__stream_fd(handle)
Definition: internal.h:282

References fd, handle, len, NULL, r, SOL_SOCKET, UV__ERR, uv__stream_fd, and value.

Referenced by uv_recv_buffer_size(), and uv_send_buffer_size().

◆ uv_backend_fd()

int uv_backend_fd ( const uv_loop_t loop)

Definition at line 328 of file core.c.

328  {
329  return loop->backend_fd;
330 }

◆ uv_backend_timeout()

int uv_backend_timeout ( const uv_loop_t loop)

Definition at line 333 of file core.c.

333  {
334  if (loop->stop_flag != 0)
335  return 0;
336 
338  return 0;
339 
340  if (!QUEUE_EMPTY(&loop->idle_handles))
341  return 0;
342 
343  if (!QUEUE_EMPTY(&loop->pending_queue))
344  return 0;
345 
346  if (loop->closing_handles)
347  return 0;
348 
349  return uv__next_timeout(loop);
350 }
unsigned int stop_flag
Definition: uv.h:1793
int uv__next_timeout(const uv_loop_t *loop)
Definition: timer.c:141

Referenced by uv_run().

◆ uv_chdir()

int uv_chdir ( const char *  dir)

Definition at line 747 of file core.c.

747  {
748  if (chdir(dir))
749  return UV__ERR(errno);
750 
751  return 0;
752 }
static static fork const void static count static fd const char const char static newpath chdir
Definition: sflib.h:33

◆ uv_close()

void uv_close ( uv_handle_t handle,
uv_close_cb  close_cb 
)

Definition at line 108 of file core.c.

108  {
110 
111  handle->flags |= UV_HANDLE_CLOSING;
112  handle->close_cb = close_cb;
113 
114  switch (handle->type) {
115  case UV_NAMED_PIPE:
117  break;
118 
119  case UV_TTY:
121  break;
122 
123  case UV_TCP:
125  break;
126 
127  case UV_UDP:
129  break;
130 
131  case UV_PREPARE:
133  break;
134 
135  case UV_CHECK:
137  break;
138 
139  case UV_IDLE:
141  break;
142 
143  case UV_ASYNC:
145  break;
146 
147  case UV_TIMER:
149  break;
150 
151  case UV_PROCESS:
153  break;
154 
155  case UV_FS_EVENT:
157  break;
158 
159  case UV_POLL:
161  break;
162 
163  case UV_FS_POLL:
165  /* Poll handles use file system requests, and one of them may still be
166  * running. The poll code will call uv__make_close_pending() for us. */
167  return;
168 
169  case UV_SIGNAL:
171  break;
172 
173  default:
174  assert(0);
175  }
176 
178 }
void uv__fs_event_close(uv_fs_event_t *handle)
Definition: aix.c:863
void uv__fs_poll_close(uv_fs_poll_t *handle)
Definition: fs-poll.c:164
Definition: uv.h:844
Definition: uv.h:824
Definition: uv.h:834
Definition: uv.h:767
Definition: uv.h:793
Definition: uv.h:547
Definition: uv.h:860
void uv__prepare_close(uv_prepare_t *handle)
void uv__udp_close(uv_udp_t *handle)
Definition: udp.c:90
void uv__poll_close(uv_poll_t *handle)
Definition: poll.c:148
void uv__idle_close(uv_idle_t *handle)
void uv__signal_close(uv_signal_t *handle)
Definition: signal.c:335
void uv__check_close(uv_check_t *handle)
void uv__pipe_close(uv_pipe_t *handle)
Definition: pipe.c:120
void uv__process_close(uv_process_t *handle)
Definition: process.c:590
void uv__stream_close(uv_stream_t *handle)
Definition: stream.c:1633
void uv__tcp_close(uv_tcp_t *handle)
Definition: tcp.c:459
void uv__timer_close(uv_timer_t *handle)
Definition: timer.c:182
void uv__async_close(uv_async_t *handle)
Definition: async.c:115
#define uv__is_closing(h)
Definition: uv-common.h:255

◆ uv_cwd()

int uv_cwd ( char *  buffer,
size_t size 
)

Definition at line 708 of file core.c.

708  {
709  char scratch[1 + UV__PATH_MAX];
710 
711  if (buffer == NULL || size == NULL)
712  return UV_EINVAL;
713 
714  /* Try to read directly into the user's buffer first... */
715  if (getcwd(buffer, *size) != NULL)
716  goto fixup;
717 
718  if (errno != ERANGE)
719  return UV__ERR(errno);
720 
721  /* ...or into scratch space if the user's buffer is too small
722  * so we can report how much space to provide on the next try.
723  */
724  if (getcwd(scratch, sizeof(scratch)) == NULL)
725  return UV__ERR(errno);
726 
727  buffer = scratch;
728 
729 fixup:
730 
731  *size = strlen(buffer);
732 
733  if (*size > 1 && buffer[*size - 1] == '/') {
734  *size -= 1;
735  buffer[*size] = '\0';
736  }
737 
738  if (buffer == scratch) {
739  *size += 1;
740  return UV_ENOBUFS;
741  }
742 
743  return 0;
744 }
voidpf void uLong size
Definition: ioapi.h:138
Definition: buffer.h:15

◆ uv_disable_stdio_inheritance()

void uv_disable_stdio_inheritance ( void  )

Definition at line 755 of file core.c.

755  {
756  int fd;
757 
758  /* Set the CLOEXEC flag on all open descriptors. Unconditionally try the
759  * first 16 file descriptors. After that, bail out after the first error.
760  */
761  for (fd = 0; ; fd++)
762  if (uv__cloexec(fd, 1) && fd > 15)
763  break;
764 }

◆ uv_fileno()

int uv_fileno ( const uv_handle_t handle,
uv_os_fd_t fd 
)

Definition at line 767 of file core.c.

767  {
768  int fd_out;
769 
770  switch (handle->type) {
771  case UV_TCP:
772  case UV_NAMED_PIPE:
773  case UV_TTY:
774  fd_out = uv__stream_fd((uv_stream_t*) handle);
775  break;
776 
777  case UV_UDP:
778  fd_out = ((uv_udp_t *) handle)->io_watcher.fd;
779  break;
780 
781  case UV_POLL:
782  fd_out = ((uv_poll_t *) handle)->io_watcher.fd;
783  break;
784 
785  default:
786  return UV_EINVAL;
787  }
788 
789  if (uv__is_closing(handle) || fd_out == -1)
790  return UV_EBADF;
791 
792  *fd = fd_out;
793  return 0;
794 }

Referenced by uv__getsockpeername().

◆ uv_get_osfhandle()

uv_os_fd_t uv_get_osfhandle ( int  fd)

Definition at line 1389 of file core.c.

1389  {
1390  return fd;
1391 }

◆ uv_getrusage()

int uv_getrusage ( uv_rusage_t rusage)

Definition at line 970 of file core.c.

970  {
971  struct rusage usage;
972 
973  if (getrusage(RUSAGE_SELF, &usage))
974  return UV__ERR(errno);
975 
976  rusage->ru_utime.tv_sec = usage.ru_utime.tv_sec;
977  rusage->ru_utime.tv_usec = usage.ru_utime.tv_usec;
978 
979  rusage->ru_stime.tv_sec = usage.ru_stime.tv_sec;
980  rusage->ru_stime.tv_usec = usage.ru_stime.tv_usec;
981 
982 #if !defined(__MVS__) && !defined(__HAIKU__)
983  rusage->ru_maxrss = usage.ru_maxrss;
984  rusage->ru_ixrss = usage.ru_ixrss;
985  rusage->ru_idrss = usage.ru_idrss;
986  rusage->ru_isrss = usage.ru_isrss;
987  rusage->ru_minflt = usage.ru_minflt;
988  rusage->ru_majflt = usage.ru_majflt;
989  rusage->ru_nswap = usage.ru_nswap;
990  rusage->ru_inblock = usage.ru_inblock;
991  rusage->ru_oublock = usage.ru_oublock;
992  rusage->ru_msgsnd = usage.ru_msgsnd;
993  rusage->ru_msgrcv = usage.ru_msgrcv;
994  rusage->ru_nsignals = usage.ru_nsignals;
995  rusage->ru_nvcsw = usage.ru_nvcsw;
996  rusage->ru_nivcsw = usage.ru_nivcsw;
997 #endif
998 
999  return 0;
1000 }
void usage(const char *message)
long ru_nvcsw
Definition: sftypes.h:3485
long ru_nswap
Definition: sftypes.h:3479
struct timeval ru_utime
Definition: sftypes.h:3471
long ru_minflt
Definition: sftypes.h:3477
long ru_nivcsw
Definition: sftypes.h:3486
struct timeval ru_stime
Definition: sftypes.h:3472
long ru_isrss
Definition: sftypes.h:3476
long ru_majflt
Definition: sftypes.h:3478
long ru_idrss
Definition: sftypes.h:3475
long ru_nsignals
Definition: sftypes.h:3484
long ru_msgsnd
Definition: sftypes.h:3482
long ru_ixrss
Definition: sftypes.h:3474
long ru_inblock
Definition: sftypes.h:3480
long ru_msgrcv
Definition: sftypes.h:3483
long ru_maxrss
Definition: sftypes.h:3473
long ru_oublock
Definition: sftypes.h:3481
long tv_sec
Definition: sftypes.h:84
long tv_usec
Definition: sftypes.h:85

◆ uv_gettimeofday()

int uv_gettimeofday ( uv_timeval64_t tv)

Definition at line 1512 of file core.c.

1512  {
1513  struct timeval time;
1514 
1515  if (tv == NULL)
1516  return UV_EINVAL;
1517 
1518  if (gettimeofday(&time, NULL) != 0)
1519  return UV__ERR(errno);
1520 
1521  tv->tv_sec = (int64_t) time.tv_sec;
1522  tv->tv_usec = (int32_t) time.tv_usec;
1523  return 0;
1524 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval tv
Definition: sflib.h:79
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog gettimeofday
Definition: sflib.h:79
static static fork const void static count static fd const char const char static newpath char char char static envp time
Definition: sflib.h:42
long int64_t
Definition: sftypes.h:32
int int32_t
Definition: sftypes.h:33

◆ uv_hrtime()

uint64_t uv_hrtime ( void  )

Definition at line 103 of file core.c.

103  {
105 }
uint64_t uv__hrtime(uv_clocktype_t type)
Definition: aix-common.c:43
@ UV_CLOCK_PRECISE
Definition: internal.h:147

◆ uv_is_active()

int uv_is_active ( const uv_handle_t handle)

Definition at line 430 of file core.c.

430  {
431  return uv__is_active(handle);
432 }
#define uv__is_active(h)
Definition: uv-common.h:252

◆ uv_is_closing()

int uv_is_closing ( const uv_handle_t handle)

Definition at line 323 of file core.c.

323  {
324  return uv__is_closing(handle);
325 }

Referenced by uv_fileno().

◆ uv_loop_alive()

int uv_loop_alive ( const uv_loop_t loop)

Definition at line 360 of file core.c.

360  {
361  return uv__loop_alive(loop);
362 }
static int uv__loop_alive(const uv_loop_t *loop)
Definition: core.c:353

◆ uv_open_osfhandle()

int uv_open_osfhandle ( uv_os_fd_t  os_fd)

Definition at line 1393 of file core.c.

1393  {
1394  return os_fd;
1395 }

◆ uv_os_environ()

int uv_os_environ ( uv_env_item_t **  envitems,
int count 
)

Definition at line 1255 of file core.c.

1255  {
1256  int i, j, cnt;
1257  uv_env_item_t* envitem;
1258 
1259  *envitems = NULL;
1260  *count = 0;
1261 
1262  for (i = 0; environ[i] != NULL; i++);
1263 
1264  *envitems = uv__calloc(i, sizeof(**envitems));
1265 
1266  if (*envitems == NULL)
1267  return UV_ENOMEM;
1268 
1269  for (j = 0, cnt = 0; j < i; j++) {
1270  char* buf;
1271  char* ptr;
1272 
1273  if (environ[j] == NULL)
1274  break;
1275 
1276  buf = uv__strdup(environ[j]);
1277  if (buf == NULL)
1278  goto fail;
1279 
1280  ptr = strchr(buf, '=');
1281  if (ptr == NULL) {
1282  uv__free(buf);
1283  continue;
1284  }
1285 
1286  *ptr = '\0';
1287 
1288  envitem = &(*envitems)[cnt];
1289  envitem->name = buf;
1290  envitem->value = ptr + 1;
1291 
1292  cnt++;
1293  }
1294 
1295  *count = cnt;
1296  return 0;
1297 
1298 fail:
1299  for (i = 0; i < cnt; i++) {
1300  envitem = &(*envitems)[cnt];
1301  uv__free(envitem->name);
1302  }
1303  uv__free(*envitems);
1304 
1305  *envitems = NULL;
1306  *count = 0;
1307  return UV_ENOMEM;
1308 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
char * value
Definition: uv.h:1231
char * name
Definition: uv.h:1230
char ** environ
#define fail(test)
Definition: tests.h:29
void * uv__calloc(size_t count, size_t size)
Definition: uv-common.c:92

◆ uv_os_free_passwd()

void uv_os_free_passwd ( uv_passwd_t pwd)

Definition at line 1228 of file core.c.

1228  {
1229  if (pwd == NULL)
1230  return;
1231 
1232  /*
1233  The memory for name, shell, and homedir are allocated in a single
1234  uv__malloc() call. The base of the pointer is stored in pwd->username, so
1235  that is the field that needs to be freed.
1236  */
1237  uv__free(pwd->username);
1238  pwd->username = NULL;
1239  pwd->shell = NULL;
1240  pwd->homedir = NULL;
1241 }

Referenced by uv_os_homedir().

◆ uv_os_get_passwd()

int uv_os_get_passwd ( uv_passwd_t pwd)

Definition at line 1244 of file core.c.

1244  {
1245  return uv__getpwuid_r(pwd);
1246 }
int uv__getpwuid_r(uv_passwd_t *pwd)
Definition: core.c:1146

◆ uv_os_getenv()

int uv_os_getenv ( const char *  name,
char *  buffer,
size_t size 
)

Definition at line 1311 of file core.c.

1311  {
1312  char* var;
1313  size_t len;
1314 
1315  if (name == NULL || buffer == NULL || size == NULL || *size == 0)
1316  return UV_EINVAL;
1317 
1318  var = getenv(name);
1319 
1320  if (var == NULL)
1321  return UV_ENOENT;
1322 
1323  len = strlen(var);
1324 
1325  if (len >= *size) {
1326  *size = len + 1;
1327  return UV_ENOBUFS;
1328  }
1329 
1330  memcpy(buffer, var, len + 1);
1331  *size = len;
1332 
1333  return 0;
1334 }

Referenced by uv_os_homedir().

◆ uv_os_gethostname()

int uv_os_gethostname ( char *  buffer,
size_t size 
)

Definition at line 1359 of file core.c.

1359  {
1360  /*
1361  On some platforms, if the input buffer is not large enough, gethostname()
1362  succeeds, but truncates the result. libuv can detect this and return ENOBUFS
1363  instead by creating a large enough buffer and comparing the hostname length
1364  to the size input.
1365  */
1366  char buf[UV_MAXHOSTNAMESIZE];
1367  size_t len;
1368 
1369  if (buffer == NULL || size == NULL || *size == 0)
1370  return UV_EINVAL;
1371 
1372  if (gethostname(buf, sizeof(buf)) != 0)
1373  return UV__ERR(errno);
1374 
1375  buf[sizeof(buf) - 1] = '\0'; /* Null terminate, just to be safe. */
1376  len = strlen(buf);
1377 
1378  if (len >= *size) {
1379  *size = len + 1;
1380  return UV_ENOBUFS;
1381  }
1382 
1383  memcpy(buffer, buf, len + 1);
1384  *size = len;
1385  return 0;
1386 }
#define UV_MAXHOSTNAMESIZE
Definition: uv.h:1248

◆ uv_os_getpid()

uv_pid_t uv_os_getpid ( void  )

Definition at line 1397 of file core.c.

1397  {
1398  return getpid();
1399 }

◆ uv_os_getppid()

uv_pid_t uv_os_getppid ( void  )

Definition at line 1402 of file core.c.

1402  {
1403  return getppid();
1404 }

◆ uv_os_getpriority()

int uv_os_getpriority ( uv_pid_t  pid,
int priority 
)

Definition at line 1407 of file core.c.

1407  {
1408  int r;
1409 
1410  if (priority == NULL)
1411  return UV_EINVAL;
1412 
1413  errno = 0;
1414  r = getpriority(PRIO_PROCESS, (int) pid);
1415 
1416  if (r == -1 && errno != 0)
1417  return UV__ERR(errno);
1418 
1419  *priority = r;
1420  return 0;
1421 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol getpriority
Definition: sflib.h:79
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc pid
Definition: sflib.h:64

◆ uv_os_homedir()

int uv_os_homedir ( char *  buffer,
size_t size 
)

Definition at line 1059 of file core.c.

1059  {
1060  uv_passwd_t pwd;
1061  size_t len;
1062  int r;
1063 
1064  /* Check if the HOME environment variable is set first. The task of
1065  performing input validation on buffer and size is taken care of by
1066  uv_os_getenv(). */
1067  r = uv_os_getenv("HOME", buffer, size);
1068 
1069  if (r != UV_ENOENT)
1070  return r;
1071 
1072  /* HOME is not set, so call uv__getpwuid_r() */
1073  r = uv__getpwuid_r(&pwd);
1074 
1075  if (r != 0) {
1076  return r;
1077  }
1078 
1079  len = strlen(pwd.homedir);
1080 
1081  if (len >= *size) {
1082  *size = len + 1;
1083  uv_os_free_passwd(&pwd);
1084  return UV_ENOBUFS;
1085  }
1086 
1087  memcpy(buffer, pwd.homedir, len + 1);
1088  *size = len;
1089  uv_os_free_passwd(&pwd);
1090 
1091  return 0;
1092 }
void uv_os_free_passwd(uv_passwd_t *pwd)
Definition: core.c:1228
int uv_os_getenv(const char *name, char *buffer, size_t *size)
Definition: core.c:1311

◆ uv_os_setenv()

int uv_os_setenv ( const char *  name,
const char *  value 
)

Definition at line 1337 of file core.c.

1337  {
1338  if (name == NULL || value == NULL)
1339  return UV_EINVAL;
1340 
1341  if (setenv(name, value, 1) != 0)
1342  return UV__ERR(errno);
1343 
1344  return 0;
1345 }

◆ uv_os_setpriority()

int uv_os_setpriority ( uv_pid_t  pid,
int  priority 
)

Definition at line 1424 of file core.c.

1424  {
1425  if (priority < UV_PRIORITY_HIGHEST || priority > UV_PRIORITY_LOW)
1426  return UV_EINVAL;
1427 
1428  if (setpriority(PRIO_PROCESS, (int) pid, priority) != 0)
1429  return UV__ERR(errno);
1430 
1431  return 0;
1432 }
static void struct sockaddr socklen_t static fromlen static backlog static fork char char char static envp int struct rusage static rusage struct utsname static buf struct sembuf static nsops static fd const char static length unsigned struct dirent unsigned static count const char const char static newpath const char static pathname const char const char static newpath const char const char static newpath const char static mode const char static group const char static group struct timeval struct timezone static tz struct tms static buf static getuid static getgid static getegid static getppid static setsid static egid static suid static pid static fsgid static data const char static dev unsigned static persona const char struct statfs static buf unsigned char static buf setpriority
Definition: sflib.h:173
#define UV_PRIORITY_LOW
Definition: uv.h:1210

◆ uv_os_tmpdir()

int uv_os_tmpdir ( char *  buffer,
size_t size 
)

Definition at line 1095 of file core.c.

1095  {
1096  const char* buf;
1097  size_t len;
1098 
1099  if (buffer == NULL || size == NULL || *size == 0)
1100  return UV_EINVAL;
1101 
1102 #define CHECK_ENV_VAR(name) \
1103  do { \
1104  buf = getenv(name); \
1105  if (buf != NULL) \
1106  goto return_buffer; \
1107  } \
1108  while (0)
1109 
1110  /* Check the TMPDIR, TMP, TEMP, and TEMPDIR environment variables in order */
1111  CHECK_ENV_VAR("TMPDIR");
1112  CHECK_ENV_VAR("TMP");
1113  CHECK_ENV_VAR("TEMP");
1114  CHECK_ENV_VAR("TEMPDIR");
1115 
1116 #undef CHECK_ENV_VAR
1117 
1118  /* No temp environment variables defined */
1119  #if defined(__ANDROID__)
1120  buf = "/data/local/tmp";
1121  #else
1122  buf = "/tmp";
1123  #endif
1124 
1125 return_buffer:
1126  len = strlen(buf);
1127 
1128  if (len >= *size) {
1129  *size = len + 1;
1130  return UV_ENOBUFS;
1131  }
1132 
1133  /* The returned directory should not have a trailing slash. */
1134  if (len > 1 && buf[len - 1] == '/') {
1135  len--;
1136  }
1137 
1138  memcpy(buffer, buf, len + 1);
1139  buffer[len] = '\0';
1140  *size = len;
1141 
1142  return 0;
1143 }
#define CHECK_ENV_VAR(name)

◆ uv_os_uname()

int uv_os_uname ( uv_utsname_t buffer)

Definition at line 1435 of file core.c.

1435  {
1436  struct utsname buf;
1437  int r;
1438 
1439  if (buffer == NULL)
1440  return UV_EINVAL;
1441 
1442  if (uname(&buf) == -1) {
1443  r = UV__ERR(errno);
1444  goto error;
1445  }
1446 
1447  r = uv__strscpy(buffer->sysname, buf.sysname, sizeof(buffer->sysname));
1448  if (r == UV_E2BIG)
1449  goto error;
1450 
1451 #ifdef _AIX
1452  r = snprintf(buffer->release,
1453  sizeof(buffer->release),
1454  "%s.%s",
1455  buf.version,
1456  buf.release);
1457  if (r >= sizeof(buffer->release)) {
1458  r = UV_E2BIG;
1459  goto error;
1460  }
1461 #else
1462  r = uv__strscpy(buffer->release, buf.release, sizeof(buffer->release));
1463  if (r == UV_E2BIG)
1464  goto error;
1465 #endif
1466 
1467  r = uv__strscpy(buffer->version, buf.version, sizeof(buffer->version));
1468  if (r == UV_E2BIG)
1469  goto error;
1470 
1471 #if defined(_AIX) || defined(__PASE__)
1472  r = uv__strscpy(buffer->machine, "ppc64", sizeof(buffer->machine));
1473 #else
1474  r = uv__strscpy(buffer->machine, buf.machine, sizeof(buffer->machine));
1475 #endif
1476 
1477  if (r == UV_E2BIG)
1478  goto error;
1479 
1480  return 0;
1481 
1482 error:
1483  buffer->sysname[0] = '\0';
1484  buffer->release[0] = '\0';
1485  buffer->version[0] = '\0';
1486  buffer->machine[0] = '\0';
1487  return r;
1488 }
static const char struct stat static buf struct stat static buf static vhangup int struct rusage static rusage struct sysinfo static info unsigned static __unused uname
Definition: sflib.h:153
ssize_t uv__strscpy(char *d, const char *s, size_t n)
Definition: strscpy.c:25
void error(const char *msg)
Definition: untgz.c:593

◆ uv_os_unsetenv()

int uv_os_unsetenv ( const char *  name)

Definition at line 1348 of file core.c.

1348  {
1349  if (name == NULL)
1350  return UV_EINVAL;
1351 
1352  if (unsetenv(name) != 0)
1353  return UV__ERR(errno);
1354 
1355  return 0;
1356 }

◆ uv_run()

int uv_run ( uv_loop_t loop,
uv_run_mode  mode 
)

Definition at line 365 of file core.c.

365  {
366  int timeout;
367  int r;
368  int ran_pending;
369 
370  r = uv__loop_alive(loop);
371  if (!r)
372  uv__update_time(loop);
373 
374  while (r != 0 && loop->stop_flag == 0) {
375  uv__update_time(loop);
377  ran_pending = uv__run_pending(loop);
380 
381  timeout = 0;
382  if ((mode == UV_RUN_ONCE && !ran_pending) || mode == UV_RUN_DEFAULT)
384 
386 
387  /* Run one final update on the provider_idle_time in case uv__io_poll
388  * returned because the timeout expired, but no events were received. This
389  * call will be ignored if the provider_entry_time was either never set (if
390  * the timeout == 0) or was already updated b/c an event was received.
391  */
393 
396 
397  if (mode == UV_RUN_ONCE) {
398  /* UV_RUN_ONCE implies forward progress: at least one callback must have
399  * been invoked when it returns. uv__io_poll() can return without doing
400  * I/O (meaning: no callbacks) when its timeout expires - which means we
401  * have pending timers that satisfy the forward progress constraint.
402  *
403  * UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from
404  * the check.
405  */
406  uv__update_time(loop);
408  }
409 
410  r = uv__loop_alive(loop);
411  if (mode == UV_RUN_ONCE || mode == UV_RUN_NOWAIT)
412  break;
413  }
414 
415  /* The if statement lets gcc compile it to a conditional store. Avoids
416  * dirtying a cache line.
417  */
418  if (loop->stop_flag != 0)
419  loop->stop_flag = 0;
420 
421  return r;
422 }
void uv__io_poll(uv_loop_t *loop, int timeout)
Definition: aix.c:133
const char int mode
Definition: ioapi.h:137
uv_timer_t timeout
Definition: main.c:9
static int uv__run_pending(uv_loop_t *loop)
Definition: core.c:797
int uv_backend_timeout(const uv_loop_t *loop)
Definition: core.c:333
static void uv__run_closing_handles(uv_loop_t *loop)
Definition: core.c:308
void uv__run_prepare(uv_loop_t *loop)
void uv__run_check(uv_loop_t *loop)
void uv__run_idle(uv_loop_t *loop)
void uv__run_timers(uv_loop_t *loop)
Definition: timer.c:162
void uv__metrics_update_idle_time(uv_loop_t *loop)
Definition: uv-common.c:872
@ UV_RUN_NOWAIT
Definition: uv.h:257
@ UV_RUN_ONCE
Definition: uv.h:256
@ UV_RUN_DEFAULT
Definition: uv.h:255

◆ uv_sleep()

void uv_sleep ( unsigned int  msec)

Definition at line 1526 of file core.c.

1526  {
1527  struct timespec timeout;
1528  int rc;
1529 
1530  timeout.tv_sec = msec / 1000;
1531  timeout.tv_nsec = (msec % 1000) * 1000 * 1000;
1532 
1533  do
1534  rc = nanosleep(&timeout, &timeout);
1535  while (rc == -1 && errno == EINTR);
1536 
1537  assert(rc == 0);
1538 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg nanosleep
Definition: sflib.h:128

◆ uv_translate_sys_error()

int uv_translate_sys_error ( int  sys_errno)

Definition at line 1249 of file core.c.

1249  {
1250  /* If < 0 then it's already a libuv error. */
1251  return sys_errno <= 0 ? sys_errno : -sys_errno;
1252 }

Referenced by uv__getsockpeername(), uv__socket_sockopt(), and uv_loop_init().

◆ uv_update_time()

void uv_update_time ( uv_loop_t loop)

Definition at line 425 of file core.c.

425  {
426  uv__update_time(loop);
427 }

Referenced by uv__poll(), uv__poll_wine(), uv_loop_init(), and uv_run().

Variable Documentation

◆ environ