Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / reent / closer.c
blob2d72b2ab59e3332e44ee0c40acfa8da0abfbed7b
1 /* Reentrant version of close system call. */
3 #include <reent.h>
4 #include <unistd.h>
5 #include <_syslist.h>
7 /* Some targets provides their own versions of this functions. Those
8 targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
10 #ifdef _REENT_ONLY
11 #ifndef REENTRANT_SYSCALLS_PROVIDED
12 #define REENTRANT_SYSCALLS_PROVIDED
13 #endif
14 #endif
16 #ifndef REENTRANT_SYSCALLS_PROVIDED
18 /* We use the errno variable used by the system dependent layer. */
19 #undef errno
20 extern int errno;
23 FUNCTION
24 <<_close_r>>---Reentrant version of close
26 INDEX
27 _close_r
29 SYNOPSIS
30 #include <reent.h>
31 int _close_r(struct _reent *<[ptr]>, int <[fd]>);
33 DESCRIPTION
34 This is a reentrant version of <<close>>. It
35 takes a pointer to the global data block, which holds
36 <<errno>>.
39 int
40 _close_r (ptr, fd)
41 struct _reent *ptr;
42 int fd;
44 int ret;
46 errno = 0;
47 if ((ret = _close (fd)) == -1 && errno != 0)
48 _REENT_ERRNO(ptr) = errno;
49 return ret;
52 #endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */