MCPcopy Create free account
hub / github.com/git/git / poll

Function poll

compat/poll/poll.c:306–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304#endif /* !MinGW */
305
306int
307poll (struct pollfd *pfd, nfds_t nfd, int timeout)
308{
309#ifndef WIN32_NATIVE
310 fd_set rfds, wfds, efds;
311 struct timeval tv;
312 struct timeval *ptv;
313 int maxfd, rc;
314 nfds_t i;
315
316# ifdef _SC_OPEN_MAX
317 static int sc_open_max = -1;
318
319 if (nfd < 0
320 || (nfd > sc_open_max
321 && (sc_open_max != -1
322 || nfd > (sc_open_max = sysconf (_SC_OPEN_MAX)))))
323 {
324 errno = EINVAL;
325 return -1;
326 }
327# else /* !_SC_OPEN_MAX */
328# ifdef OPEN_MAX
329 if (nfd < 0 || nfd > OPEN_MAX)
330 {
331 errno = EINVAL;
332 return -1;
333 }
334# endif /* OPEN_MAX -- else, no check is needed */
335# endif /* !_SC_OPEN_MAX */
336
337 /* EFAULT is not necessary to implement, but let's do it in the
338 simplest case. */
339 if (!pfd && nfd)
340 {
341 errno = EFAULT;
342 return -1;
343 }
344
345 /* convert timeout number into a timeval structure */
346 if (timeout == 0)
347 {
348 ptv = &tv;
349 ptv->tv_sec = 0;
350 ptv->tv_usec = 0;
351 }
352 else if (timeout > 0)
353 {
354 ptv = &tv;
355 ptv->tv_sec = timeout / 1000;
356 ptv->tv_usec = (timeout % 1000) * 1000;
357 }
358 else if (timeout == INFTIM)
359 /* wait forever */
360 ptv = NULL;
361 else
362 {
363 errno = EINVAL;

Callers 15

create_pack_fileFunction · 0.85
handle_nonblockFunction · 0.85
sleep_millisecFunction · 0.85
pump_io_roundFunction · 0.85
pp_buffer_ioFunction · 0.85
service_loopFunction · 0.85
getchar_with_timeoutFunction · 0.85
fsm_listen__loopFunction · 0.85

Calls 4

compute_reventsFunction · 0.85
IsSocketHandleFunction · 0.85
win32_compute_reventsFunction · 0.85

Tested by

no test coverage detected