File: io_nonblock.c

package info (click to toggle)
libowfat 0.34-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,288 kB
  • sloc: ansic: 20,181; makefile: 16
file content (26 lines) | stat: -rw-r--r-- 496 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "io_internal.h"

#ifdef __MINGW32__
#include <winsock2.h>
#include <windows.h>
#include "windoze.h"
#endif

#ifndef O_NDELAY
#define O_NDELAY O_NONBLOCK
#endif

void io_nonblock(int64 d) {
  io_entry* e=iarray_get(&io_fds,d);
#ifdef __MINGW32__
  unsigned long i=1;
  if (ioctlsocket( d, FIONBIO, &i)==0)
    if (e) e->nonblock=1;
#else
  if (fcntl(d,F_SETFL,fcntl(d,F_GETFL,0) | O_NDELAY)==0)
    if (e) e->nonblock=1;
#endif
}