Add forward declarations

Christophe Lyon <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CAKdteOYC8t+K9iyDrTQw9PhXRTKSkEOM933W6c2rnFZwG8kHFA@mail.gmail.com>
Hi,

While building newlib for Aarch64, I noticed several warnings because
of missing prototypes. I am not familiar enough to know why the same
warnings do not appear when building for Arm.

This patch adds the missing prototypes, tested by rebuilding for
Aarch64 and Arm, it removed the warnings and didn't generate any
error.

OK?

Christophe
newlib-7.txt (text/plain, 7.6 KB)
commit 91b75af446b712f7f1a84d0afdf5d3f03a2377ed
Author: Christophe Lyon <[email protected]>
Date:   Mon Oct 1 21:16:40 2018 +0000

    Add forward declarations.
    
    2018-10-01  Christophe Lyon  <[email protected]>
    
    	* newlib/libc/reent/closer.c: Add _close prototype.
    	* newlib/libc/reent/execr.c: Add _execve and fork prototypes.
    	* newlib/libc/reent/fcntlr.c: Add _fcntl prototype.
    	* newlib/libc/reent/fstatr.c: Add _fstat prototype.
    	* newlib/libc/reent/gettimeofdayr.c: Add _gettimeofday prototype.
    	* newlib/libc/reent/isattyr.c: Add _isatty prototype.
    	* newlib/libc/reent/linkr.c: Add _link prototype.
    	* newlib/libc/reent/lseekr.c: Add _lseek prototype.
    	* newlib/libc/reent/mkdirr.c: Add _mkdir prototype.
    	* newlib/libc/reent/openr.c: Add _open prototype.
    	* newlib/libc/reent/readr.c: Add _read prototype.
    	* newlib/libc/reent/signalr.c: Add _kill and _getpid prototypes.
    	* newlib/libc/reent/statr.c: Add _stat prototype.
    	* newlib/libc/reent/timesr.c: Add _times prototype.
    	* newlib/libc/reent/unlinkr.c: Add _unlink prototype.
    	* newlib/libc/reent/writer.c: Add _write prototype.
    	* newlib/libc/stdlib/strtorx: Add nanl prototype.
    	* newlib/libc/syscalls/sysisatty.c: Add _isatty prototype.

diff --git a/newlib/libc/reent/closer.c b/newlib/libc/reent/closer.c
index deb34b0..1bef515 100644
--- a/newlib/libc/reent/closer.c
+++ b/newlib/libc/reent/closer.c
@@ -19,6 +19,9 @@
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+int _close (int);
+
 /*
 FUNCTION
 	<<_close_r>>---Reentrant version of close
diff --git a/newlib/libc/reent/execr.c b/newlib/libc/reent/execr.c
index 59b6122..90201b7 100644
--- a/newlib/libc/reent/execr.c
+++ b/newlib/libc/reent/execr.c
@@ -27,6 +27,10 @@ int _dummy_exec_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* Forward declarations.  */
+int _execve(const char *filename, char *const argv[], char *const envp[]);
+int _fork();
+
 /*
 FUNCTION
 	<<_execve_r>>---Reentrant version of execve	
diff --git a/newlib/libc/reent/fcntlr.c b/newlib/libc/reent/fcntlr.c
index cd19d22..27ab74c 100644
--- a/newlib/libc/reent/fcntlr.c
+++ b/newlib/libc/reent/fcntlr.c
@@ -21,6 +21,9 @@
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+int _fcntl (int, int, ...);
+
 /*
 FUNCTION
 	<<_fcntl_r>>---Reentrant version of fcntl
diff --git a/newlib/libc/reent/fstatr.c b/newlib/libc/reent/fstatr.c
index ec906c9..dcbaaee 100644
--- a/newlib/libc/reent/fstatr.c
+++ b/newlib/libc/reent/fstatr.c
@@ -25,6 +25,9 @@ int _dummy_fstat_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+int _fstat(int, struct stat *);
+
 /*
 FUNCTION
 	<<_fstat_r>>---Reentrant version of fstat
diff --git a/newlib/libc/reent/gettimeofdayr.c b/newlib/libc/reent/gettimeofdayr.c
index 9b982a9..361ee4f 100644
--- a/newlib/libc/reent/gettimeofdayr.c
+++ b/newlib/libc/reent/gettimeofdayr.c
@@ -28,6 +28,9 @@ int _dummy_gettimeofday_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+int _gettimeofday (struct timeval *, void *);
+
 /*
 FUNCTION
 	<<_gettimeofday_r>>---Reentrant version of gettimeofday
diff --git a/newlib/libc/reent/isattyr.c b/newlib/libc/reent/isattyr.c
index f21bf25..dcd609d 100644
--- a/newlib/libc/reent/isattyr.c
+++ b/newlib/libc/reent/isattyr.c
@@ -23,6 +23,9 @@ int _dummy_isatty_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+int _isatty (int);
+
 /*
 FUNCTION
 	<<_isatty_r>>---Reentrant version of isatty
diff --git a/newlib/libc/reent/linkr.c b/newlib/libc/reent/linkr.c
index b22da5f..701b8f3 100644
--- a/newlib/libc/reent/linkr.c
+++ b/newlib/libc/reent/linkr.c
@@ -24,6 +24,9 @@ int _dummy_link_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+int _link (const char *, const char *);
+
 /*
 FUNCTION
 	<<_link_r>>---Reentrant version of link
diff --git a/newlib/libc/reent/lseekr.c b/newlib/libc/reent/lseekr.c
index ac2daaa..d39f942 100644
--- a/newlib/libc/reent/lseekr.c
+++ b/newlib/libc/reent/lseekr.c
@@ -19,6 +19,9 @@
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+_off_t _lseek (int, _off_t, int);
+
 /*
 FUNCTION
 	<<_lseek_r>>---Reentrant version of lseek
diff --git a/newlib/libc/reent/mkdirr.c b/newlib/libc/reent/mkdirr.c
index fd72df6..f0bf749 100644
--- a/newlib/libc/reent/mkdirr.c
+++ b/newlib/libc/reent/mkdirr.c
@@ -19,6 +19,9 @@
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+int _mkdir (const char *, mode_t);
+
 /*
 FUNCTION
 	<<_mkdir_r>>---Reentrant version of mkdir
diff --git a/newlib/libc/reent/openr.c b/newlib/libc/reent/openr.c
index c6a7db5..a63de62 100644
--- a/newlib/libc/reent/openr.c
+++ b/newlib/libc/reent/openr.c
@@ -20,6 +20,9 @@
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+int _open (const char *, int, ...);
+
 /*
 FUNCTION
 	<<_open_r>>---Reentrant version of open
diff --git a/newlib/libc/reent/readr.c b/newlib/libc/reent/readr.c
index 7fccefd..09462ef 100644
--- a/newlib/libc/reent/readr.c
+++ b/newlib/libc/reent/readr.c
@@ -19,6 +19,9 @@
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+int _read (int, void *, size_t);
+
 /*
 FUNCTION
 	<<_read_r>>---Reentrant version of read
diff --git a/newlib/libc/reent/signalr.c b/newlib/libc/reent/signalr.c
index 345910e..217c368 100644
--- a/newlib/libc/reent/signalr.c
+++ b/newlib/libc/reent/signalr.c
@@ -25,6 +25,10 @@ int _dummy_link_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* Forward declarations.  */
+int _kill (int, int);
+int _getpid ();
+
 /*
 FUNCTION
 	<<_kill_r>>---Reentrant version of kill
diff --git a/newlib/libc/reent/statr.c b/newlib/libc/reent/statr.c
index 9388e02..f338940 100644
--- a/newlib/libc/reent/statr.c
+++ b/newlib/libc/reent/statr.c
@@ -26,6 +26,9 @@ int _dummy_stat_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+int _stat (const char *, struct stat *);
+
 /*
 FUNCTION
 	<<_stat_r>>---Reentrant version of stat
diff --git a/newlib/libc/reent/timesr.c b/newlib/libc/reent/timesr.c
index bb89003..ab80176 100644
--- a/newlib/libc/reent/timesr.c
+++ b/newlib/libc/reent/timesr.c
@@ -25,6 +25,9 @@ int _dummy_times_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+clock_t _times (struct tms *);
+
 /*
 FUNCTION
 	<<_times_r>>---Reentrant version of times
diff --git a/newlib/libc/reent/unlinkr.c b/newlib/libc/reent/unlinkr.c
index 41bac01..d6fd460 100644
--- a/newlib/libc/reent/unlinkr.c
+++ b/newlib/libc/reent/unlinkr.c
@@ -20,6 +20,9 @@
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+int _unlink (const char *);
+
 /*
 FUNCTION
 	<<_unlink_r>>---Reentrant version of unlink
diff --git a/newlib/libc/reent/writer.c b/newlib/libc/reent/writer.c
index 704aba1..ffb468d 100644
--- a/newlib/libc/reent/writer.c
+++ b/newlib/libc/reent/writer.c
@@ -19,6 +19,9 @@
 #undef errno
 extern int errno;
 
+/* Forward declaration.  */
+int _write (int, const void *, size_t);
+
 /*
 FUNCTION
 	<<_write_r>>---Reentrant version of write
diff --git a/newlib/libc/stdlib/strtorx.c b/newlib/libc/stdlib/strtorx.c
index a35dabe..fcea9f2 100644
--- a/newlib/libc/stdlib/strtorx.c
+++ b/newlib/libc/stdlib/strtorx.c
@@ -55,6 +55,9 @@ THIS SOFTWARE.
 #define _4 0
 #endif
 
+/* Forward declaration.  */
+long double nanl(const char *tagp);
+
  void
 #ifdef KR_headers
 ULtox(L, bits, exp, k) __UShort *L; __ULong *bits; Long exp; int k;
diff --git a/newlib/libc/syscalls/sysisatty.c b/newlib/libc/syscalls/sysisatty.c
index 697c54b..2672ae1 100644
--- a/newlib/libc/syscalls/sysisatty.c
+++ b/newlib/libc/syscalls/sysisatty.c
@@ -3,6 +3,9 @@
 #include <reent.h>
 #include <unistd.h>
 
+/* Forward declaration.  */
+int _isatty (int);
+
 int
 isatty (int fd)
 {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.