aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2024-01-23 13:41:14 +0100
committerCorinna Vinschen <corinna@vinschen.de>2024-01-31 20:11:57 +0100
commitd72be712aa1e88f20a2cc0606c6d7b0928923848 (patch)
tree0fd1c5cf95296d29a524c163ffaff06205cc9094
parent7e40e0169a75ebdf3f3861dab47abdfeb0ad9c58 (diff)
downloadnewlib-d72be712aa1e88f20a2cc0606c6d7b0928923848.zip
newlib-d72be712aa1e88f20a2cc0606c6d7b0928923848.tar.gz
newlib-d72be712aa1e88f20a2cc0606c6d7b0928923848.tar.bz2
Cygwin: implement fdclosedir
fdclosedir is BSD-only but already present in dirent.h for a couple of years. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/cygwin.din1
-rw-r--r--winsup/cygwin/dir.cc34
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
-rw-r--r--winsup/cygwin/release/3.6.02
4 files changed, 33 insertions, 7 deletions
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index 4539496..049be4c 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -520,6 +520,7 @@ fcvt SIGFE
fcvtbuf SIGFE
fcvtf SIGFE
fdatasync SIGFE
+fdclosedir SIGFE
fdim NOSIGFE
fdimf NOSIGFE
fdiml NOSIGFE
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index 2e0f03b..82797a4 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -267,9 +267,8 @@ rewinddir (DIR *dir)
__endtry
}
-/* closedir: POSIX 5.1.2.1 */
-extern "C" int
-closedir (DIR *dir)
+static int
+closedir_worker (DIR *dir, int *fdret)
{
__try
{
@@ -280,21 +279,44 @@ closedir (DIR *dir)
int res = ((fhandler_base *) dir->__fh)->closedir (dir);
- close (dir->__d_fd);
+ if (fdret)
+ *fdret = dir->__d_fd;
+ else
+ close (dir->__d_fd);
+
free (dir->__d_dirname);
free (dir->__d_dirent);
free (dir);
- syscall_printf ("%R = closedir(%p)", res, dir);
return res;
}
set_errno (EBADF);
}
__except (EFAULT) {}
__endtry
- syscall_printf ("%R = closedir(%p)", -1, dir);
return -1;
}
+/* closedir: POSIX 5.1.2.1 */
+extern "C" int
+closedir (DIR *dir)
+{
+ int res;
+
+ res = closedir_worker (dir, NULL);
+ syscall_printf ("%R = closedir(%p)", res, dir);
+ return res;
+}
+
+extern "C" int
+fdclosedir (DIR *dir)
+{
+ int fd = -1;
+
+ closedir_worker (dir, &fd);
+ syscall_printf ("%d = fdclosedir(%p)", fd, dir);
+ return fd;
+}
+
/* mkdir: POSIX 5.4.1.1 */
extern "C" int
mkdir (const char *dir, mode_t mode)
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index ceff101..e21e04a 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -487,12 +487,13 @@ details. */
350: Add close_range.
351: Add getlocalename_l.
352: Implement dirent.d_reclen.
+ 353: Implement fdclosedir.
Note that we forgot to bump the api for ualarm, strtoll, strtoull,
sigaltstack, sethostname. */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 352
+#define CYGWIN_VERSION_API_MINOR 353
/* There is also a compatibity version number associated with the shared memory
regions. It is incremented when incompatible changes are made to the shared
diff --git a/winsup/cygwin/release/3.6.0 b/winsup/cygwin/release/3.6.0
index 6b0ec5d..fe933d8 100644
--- a/winsup/cygwin/release/3.6.0
+++ b/winsup/cygwin/release/3.6.0
@@ -3,6 +3,8 @@ What's new:
- New API call: getlocalename_l.
+- New API call: fdclosedir.
+
What changed:
-------------