[newlib-cygwin/main] Fixes compile failure if REENTRANT_SYSCALLS_PROVIDED and MISSING_SYSCALL_NAMES defined

Corinna Vinschen corinna@sourceware.org
Fri Jan 17 13:08:33 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=5ee0e96939e8784d4cbd2b2896b0ffbf88a00d86

commit 5ee0e96939e8784d4cbd2b2896b0ffbf88a00d86
Author:     Markus Eisenmann <markus.eisenmann@outlook.com>
AuthorDate: Thu Jan 16 15:13:54 2025 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Jan 17 14:07:23 2025 +0100

    Fixes compile failure if REENTRANT_SYSCALLS_PROVIDED and MISSING_SYSCALL_NAMES defined
    
    If the macros REENTRANT_SYSCALLS_PROVIDED and MISSING_SYSCALL_NAMES are defined some
    _reent_*-functions are replaced by the system-call and this leads to compile-warning
    or a runtime-failure.
    
     * newlib/libc/stdio/fopen.c _open_r is replaces by open(), declared in <fcntl.h>
     * newlib/libc/stdio64/fopen64.c ditto
     * newlib/libc/stdio/rename.c _rename_r is rename() itself; i.e, fix recursion

Diff:
---
 newlib/libc/stdio/fopen.c     | 2 --
 newlib/libc/stdio/rename.c    | 3 ++-
 newlib/libc/stdio64/fopen64.c | 2 --
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/newlib/libc/stdio/fopen.c b/newlib/libc/stdio/fopen.c
index 1ac551fed2b3..8239fd6b61c9 100644
--- a/newlib/libc/stdio/fopen.c
+++ b/newlib/libc/stdio/fopen.c
@@ -107,9 +107,7 @@ static char sccsid[] = "%W% (Berkeley) %G%";
 #include <stdio.h>
 #include <errno.h>
 #include <sys/lock.h>
-#ifdef __CYGWIN__
 #include <fcntl.h>
-#endif
 #include "local.h"
 
 FILE *
diff --git a/newlib/libc/stdio/rename.c b/newlib/libc/stdio/rename.c
index 16ef3e35134d..9abc0d39b347 100644
--- a/newlib/libc/stdio/rename.c
+++ b/newlib/libc/stdio/rename.c
@@ -51,7 +51,8 @@ Supporting OS subroutines required: <<link>>, <<unlink>>, or <<rename>>.
 #include <stdio.h>
 #include <sys/unistd.h>
 
-#ifndef _REENT_ONLY
+#if !defined(_REENT_ONLY) && !( \
+    defined(REENTRANT_SYSCALLS_PROVIDED) && defined(MISSING_SYSCALL_NAMES))
 
 int
 rename (const char *old,
diff --git a/newlib/libc/stdio64/fopen64.c b/newlib/libc/stdio64/fopen64.c
index 75d2c2c415f5..4eee1f273627 100644
--- a/newlib/libc/stdio64/fopen64.c
+++ b/newlib/libc/stdio64/fopen64.c
@@ -56,9 +56,7 @@ static char sccsid[] = "%W% (Berkeley) %G%";
 #include <stdio.h>
 #include <errno.h>
 #include "local.h"
-#ifdef __CYGWIN__
 #include <fcntl.h>
-#endif
 #include <sys/lock.h>
 
 #ifdef __LARGE64_FILES


More information about the Newlib-cvs mailing list