Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / reent / fcntlr.c
blobf60aa091c7a3b9eb9bad63098c46733e586f6f91
1 /* Reentrant versions of fcntl system call. This implementation just
2 calls the fcntl system call. */
4 #include <reent.h>
5 #include <fcntl.h>
6 #include <sys/stat.h>
7 #include <_syslist.h>
9 /* Some targets provides their own versions of these functions. Those
10 targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
12 #ifdef _REENT_ONLY
13 #ifndef REENTRANT_SYSCALLS_PROVIDED
14 #define REENTRANT_SYSCALLS_PROVIDED
15 #endif
16 #endif
18 #ifndef REENTRANT_SYSCALLS_PROVIDED
20 /* We use the errno variable used by the system dependent layer. */
21 #undef errno
22 extern int errno;
25 FUNCTION
26 <<_fcntl_r>>---Reentrant version of fcntl
28 INDEX
29 _fcntl_r
31 SYNOPSIS
32 #include <reent.h>
33 int _fcntl_r(struct _reent *<[ptr]>,
34 int <[fd]>, int <[cmd]>, <[arg]>);
36 DESCRIPTION
37 This is a reentrant version of <<fcntl>>. It
38 takes a pointer to the global data block, which holds
39 <<errno>>.
42 int
43 _fcntl_r (struct _reent *ptr,
44 int fd,
45 int cmd,
46 int arg)
48 int ret;
50 errno = 0;
51 if ((ret = _fcntl (fd, cmd, arg)) == -1 && errno != 0)
52 _REENT_ERRNO(ptr) = errno;
53 return ret;
56 #endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */