Rizin
unix-like reverse engineering framework and cli tools
req-inl.h File Reference
#include <assert.h>
#include "uv.h"
#include "internal.h"

Go to the source code of this file.

Macros

#define SET_REQ_STATUS(req, status)    (req)->u.io.overlapped.Internal = (ULONG_PTR) (status)
 
#define SET_REQ_ERROR(req, error)    SET_REQ_STATUS((req), NTSTATUS_FROM_WIN32((error)))
 
#define SET_REQ_SUCCESS(req)    SET_REQ_STATUS((req), STATUS_SUCCESS)
 
#define GET_REQ_STATUS(req)    ((NTSTATUS) (req)->u.io.overlapped.Internal)
 
#define REQ_SUCCESS(req)    (NT_SUCCESS(GET_REQ_STATUS((req))))
 
#define GET_REQ_ERROR(req)    (pRtlNtStatusToDosError(GET_REQ_STATUS((req))))
 
#define GET_REQ_SOCK_ERROR(req)    (uv_ntstatus_to_winsock_error(GET_REQ_STATUS((req))))
 
#define REGISTER_HANDLE_REQ(loop, handle, req)
 
#define UNREGISTER_HANDLE_REQ(loop, handle, req)
 
#define UV_SUCCEEDED_WITHOUT_IOCP(result)    ((result) && (handle->flags & UV_HANDLE_SYNC_BYPASS_IOCP))
 
#define UV_SUCCEEDED_WITH_IOCP(result)    ((result) || (GetLastError() == ERROR_IO_PENDING))
 
#define POST_COMPLETION_FOR_REQ(loop, req)
 
#define DELEGATE_STREAM_REQ(loop, req, method, handle_at)
 

Functions

static INLINE uv_req_tuv_overlapped_to_req (OVERLAPPED *overlapped)
 
static INLINE void uv_insert_pending_req (uv_loop_t *loop, uv_req_t *req)
 
static INLINE int uv_process_reqs (uv_loop_t *loop)
 

Macro Definition Documentation

◆ DELEGATE_STREAM_REQ

#define DELEGATE_STREAM_REQ (   loop,
  req,
  method,
  handle_at 
)
Value:
do { \
switch (((uv_handle_t*) (req)->handle_at)->type) { \
case UV_TCP: \
uv_process_tcp_##method##_req(loop, \
(uv_tcp_t*) ((req)->handle_at), \
req); \
break; \
\
case UV_NAMED_PIPE: \
uv_process_pipe_##method##_req(loop, \
(uv_pipe_t*) ((req)->handle_at), \
req); \
break; \
\
case UV_TTY: \
uv_process_tty_##method##_req(loop, \
(uv_tty_t*) ((req)->handle_at), \
req); \
break; \
\
default: \
assert(0); \
} \
} while (0)
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 const struct timespec req
Definition: sflib.h:128
int type
Definition: mipsasm.c:17
Definition: uv.h:767
Definition: uv.h:547
Definition: uv.h:714
uv_loop_t * loop
Definition: main.c:7

Definition at line 114 of file req-inl.h.

◆ GET_REQ_ERROR

#define GET_REQ_ERROR (   req)     (pRtlNtStatusToDosError(GET_REQ_STATUS((req))))

Definition at line 49 of file req-inl.h.

◆ GET_REQ_SOCK_ERROR

#define GET_REQ_SOCK_ERROR (   req)     (uv_ntstatus_to_winsock_error(GET_REQ_STATUS((req))))

Definition at line 52 of file req-inl.h.

◆ GET_REQ_STATUS

#define GET_REQ_STATUS (   req)     ((NTSTATUS) (req)->u.io.overlapped.Internal)

Definition at line 43 of file req-inl.h.

◆ POST_COMPLETION_FOR_REQ

#define POST_COMPLETION_FOR_REQ (   loop,
  req 
)
Value:
if (!PostQueuedCompletionStatus((loop)->iocp, \
0, \
0, \
&((req)->u.io.overlapped))) { \
uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus"); \
}

Definition at line 76 of file req-inl.h.

◆ REGISTER_HANDLE_REQ

#define REGISTER_HANDLE_REQ (   loop,
  handle,
  req 
)
Value:
do { \
INCREASE_ACTIVE_COUNT((loop), (handle)); \
uv__req_register((loop), (req)); \
} while (0)
static mcore_handle handle
Definition: asm_mcore.c:8

Definition at line 56 of file req-inl.h.

◆ REQ_SUCCESS

#define REQ_SUCCESS (   req)     (NT_SUCCESS(GET_REQ_STATUS((req))))

Definition at line 46 of file req-inl.h.

◆ SET_REQ_ERROR

#define SET_REQ_ERROR (   req,
  error 
)     SET_REQ_STATUS((req), NTSTATUS_FROM_WIN32((error)))

Definition at line 34 of file req-inl.h.

◆ SET_REQ_STATUS

#define SET_REQ_STATUS (   req,
  status 
)     (req)->u.io.overlapped.Internal = (ULONG_PTR) (status)

Definition at line 31 of file req-inl.h.

◆ SET_REQ_SUCCESS

#define SET_REQ_SUCCESS (   req)     SET_REQ_STATUS((req), STATUS_SUCCESS)

Definition at line 40 of file req-inl.h.

◆ UNREGISTER_HANDLE_REQ

#define UNREGISTER_HANDLE_REQ (   loop,
  handle,
  req 
)
Value:
do { \
DECREASE_ACTIVE_COUNT((loop), (handle)); \
uv__req_unregister((loop), (req)); \
} while (0)

Definition at line 62 of file req-inl.h.

◆ UV_SUCCEEDED_WITH_IOCP

#define UV_SUCCEEDED_WITH_IOCP (   result)     ((result) || (GetLastError() == ERROR_IO_PENDING))

Definition at line 72 of file req-inl.h.

◆ UV_SUCCEEDED_WITHOUT_IOCP

#define UV_SUCCEEDED_WITHOUT_IOCP (   result)     ((result) && (handle->flags & UV_HANDLE_SYNC_BYPASS_IOCP))

Definition at line 69 of file req-inl.h.

Function Documentation

◆ uv_insert_pending_req()

static INLINE void uv_insert_pending_req ( uv_loop_t loop,
uv_req_t req 
)
static

Definition at line 90 of file req-inl.h.

90  {
91  req->next_req = NULL;
92  if (loop->pending_reqs_tail) {
93 #ifdef _DEBUG
94  /* Ensure the request is not already in the queue, or the queue
95  * will get corrupted.
96  */
97  uv_req_t* current = loop->pending_reqs_tail;
98  do {
99  assert(req != current);
100  current = current->next_req;
101  } while(current != loop->pending_reqs_tail);
102 #endif
103 
104  req->next_req = loop->pending_reqs_tail->next_req;
105  loop->pending_reqs_tail->next_req = req;
106  loop->pending_reqs_tail = req;
107  } else {
108  req->next_req = req;
109  loop->pending_reqs_tail = req;
110  }
111 }
#define NULL
Definition: cris-opc.c:27
assert(limit<=UINT32_MAX/2)
Definition: uv.h:407

References assert(), loop, NULL, and req.

Referenced by uv__fast_poll_submit_poll_req(), uv__poll(), uv__poll_wine(), uv__send(), uv__slow_poll_submit_poll_req(), uv_fs_event_queue_readdirchanges(), uv_pipe_connect(), uv_pipe_endgame(), uv_pipe_queue_accept(), uv_pipe_queue_read(), uv_tcp_queue_accept(), uv_tcp_queue_read(), uv_tcp_try_connect(), uv_tcp_write(), uv_tty_queue_read_line(), uv_tty_queue_read_raw(), uv_tty_read_start(), uv_tty_write(), and uv_udp_queue_recv().

◆ uv_overlapped_to_req()

static INLINE uv_req_t* uv_overlapped_to_req ( OVERLAPPED *  overlapped)
static

Definition at line 85 of file req-inl.h.

85  {
86  return CONTAINING_RECORD(overlapped, uv_req_t, u.io.overlapped);
87 }

Referenced by uv__poll(), and uv__poll_wine().

◆ uv_process_reqs()

static INLINE int uv_process_reqs ( uv_loop_t loop)
static

Definition at line 141 of file req-inl.h.

141  {
142  uv_req_t* req;
143  uv_req_t* first;
144  uv_req_t* next;
145 
146  if (loop->pending_reqs_tail == NULL)
147  return 0;
148 
149  first = loop->pending_reqs_tail->next_req;
150  next = first;
151  loop->pending_reqs_tail = NULL;
152 
153  while (next != NULL) {
154  req = next;
155  next = req->next_req != first ? req->next_req : NULL;
156 
157  switch (req->type) {
158  case UV_READ:
159  DELEGATE_STREAM_REQ(loop, req, read, data);
160  break;
161 
162  case UV_WRITE:
164  break;
165 
166  case UV_ACCEPT:
168  break;
169 
170  case UV_CONNECT:
172  break;
173 
174  case UV_SHUTDOWN:
175  /* Tcp shutdown requests don't come here. */
176  assert(((uv_shutdown_t*) req)->handle->type == UV_NAMED_PIPE);
178  loop,
180  (uv_shutdown_t*) req);
181  break;
182 
183  case UV_UDP_RECV:
185  break;
186 
187  case UV_UDP_SEND:
189  ((uv_udp_send_t*) req)->handle,
190  (uv_udp_send_t*) req);
191  break;
192 
193  case UV_WAKEUP:
195  break;
196 
197  case UV_SIGNAL_REQ:
199  break;
200 
201  case UV_POLL_REQ:
203  break;
204 
205  case UV_PROCESS_EXIT:
207  break;
208 
209  case UV_FS_EVENT_REQ:
211  break;
212 
213  default:
214  assert(0);
215  }
216  }
217 
218  return 1;
219 }
static static fork write
Definition: sflib.h:33
void uv_process_fs_event_req(uv_loop_t *loop, uv_req_t *req, uv_fs_event_t *handle)
Definition: fs-event.c:426
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
#define DELEGATE_STREAM_REQ(loop, req, method, handle_at)
Definition: req-inl.h:114
Definition: uv.h:844
Definition: uv.h:793
Definition: uv.h:638
Definition: uv.h:525
void uv_process_poll_req(uv_loop_t *loop, uv_poll_t *handle, uv_req_t *req)
Definition: poll.c:526
void uv_process_pipe_shutdown_req(uv_loop_t *loop, uv_pipe_t *handle, uv_shutdown_t *req)
Definition: pipe.c:1967
void uv_process_udp_recv_req(uv_loop_t *loop, uv_udp_t *handle, uv_req_t *req)
Definition: udp.c:453
void uv_process_proc_exit(uv_loop_t *loop, uv_process_t *handle)
Definition: process.c:865
void uv_process_udp_send_req(uv_loop_t *loop, uv_udp_t *handle, uv_udp_send_t *req)
Definition: udp.c:564
void uv_process_signal_req(uv_loop_t *loop, uv_signal_t *handle, uv_req_t *req)
Definition: signal.c:234
void uv_process_async_wakeup_req(uv_loop_t *loop, uv_async_t *handle, uv_req_t *req)
Definition: async.c:86
int read(izstream &zs, T *x, Items items)
Definition: zstream.h:115

References accept, assert(), DELEGATE_STREAM_REQ, handle, loop, NULL, read(), req, uv_process_async_wakeup_req(), uv_process_fs_event_req(), uv_process_pipe_shutdown_req(), uv_process_poll_req(), uv_process_proc_exit(), uv_process_signal_req(), uv_process_udp_recv_req(), uv_process_udp_send_req(), and write.

Referenced by uv_run().