[committed] newlib MMIX: Fix compilation warnings that recent gcc treats as errors

Hans-Peter Nilsson <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
Without this, when building with recent gcc, we'll see errors when
compiling for --target mmix the first being:
  CC       libc/sys/mmixware/libc_a-chmod.o
In file included from /x/newlib/libc/sys/mmixware/chmod.c:17:
/x/newlib/libc/sys/mmixware/chmod.c: In function 'chmod':
/x/newlib/libc/sys/mmixware/sys/syscall.h:139:6: error: implicit declaration \
of function 'sprintf' [-Wimplicit-function-declaration]
  139 |      sprintf (buf, "UNIMPLEMENTED %s in %s\n", __FUNCTION__,
 __FILE__); \

Other warnings also quelled.

	* libc/sys/mmixware/sys/syscall.h: Include stdio.h, string.h
	and unistd.h.
	* libc/sys/mmixware/_exit.c: Call __unreachable after simulator exit.
	* libc/sys/mmixware/chown.c (chown): Match declaration in unistd.h.
	* libc/sys/mmixware/getpid.c (_getpid): Ditto.
	* libc/sys/mmixware/kill.c (_kill): Ditto.
	* libc/sys/mmixware/link.c (_link): Ditto.
	* libc/sys/mmixware/read.c (_read): Ditto.
	* libc/sys/mmixware/sbrk.c (_sbrk): Ditto.
	* libc/sys/mmixware/unlink.c (_unlink): Ditto.
	* libc/sys/mmixware/write.c (_write): Ditto.
---
 newlib/libc/sys/mmixware/_exit.c       |  3 ++-
 newlib/libc/sys/mmixware/chown.c       |  4 ++--
 newlib/libc/sys/mmixware/getpid.c      |  5 +++--
 newlib/libc/sys/mmixware/kill.c        |  5 +++--
 newlib/libc/sys/mmixware/link.c        |  4 ++--
 newlib/libc/sys/mmixware/read.c        |  4 ++--
 newlib/libc/sys/mmixware/sbrk.c        | 10 +++++-----
 newlib/libc/sys/mmixware/sys/syscall.h |  8 +++++++-
 newlib/libc/sys/mmixware/unlink.c      |  4 ++--
 newlib/libc/sys/mmixware/write.c       |  4 ++--
 10 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/newlib/libc/sys/mmixware/_exit.c b/newlib/libc/sys/mmixware/_exit.c
index 2f70154f2961..9ac62c743a7d 100644
--- a/newlib/libc/sys/mmixware/_exit.c
+++ b/newlib/libc/sys/mmixware/_exit.c
@@ -1,6 +1,6 @@
 /* _exit for MMIXware.
 
-   Copyright (C) 2001 Hans-Peter Nilsson
+   Copyright (C) 2001, 2023 Hans-Peter Nilsson
 
    Permission to use, copy, modify, and distribute this software is
    freely granted, provided that the above copyright notice, this notice
@@ -27,4 +27,5 @@ void _exit (int n)
 	   : /* No outputs.  */
 	   : "r" (n)
 	   : "memory");
+  __unreachable ();
 }
diff --git a/newlib/libc/sys/mmixware/chown.c b/newlib/libc/sys/mmixware/chown.c
index f4fc49cac9a1..646504b32a8d 100644
--- a/newlib/libc/sys/mmixware/chown.c
+++ b/newlib/libc/sys/mmixware/chown.c
@@ -1,6 +1,6 @@
 /* chown stub for MMIXware.
 
-   Copyright (C) 2001 Hans-Peter Nilsson
+   Copyright (C) 2001, 2023 Hans-Peter Nilsson
 
    Permission to use, copy, modify, and distribute this software is
    freely granted, provided that the above copyright notice, this notice
@@ -18,7 +18,7 @@
 #include <errno.h>
 
 int
-chown (const char *path, short owner, short group)
+chown (const char *path, uid_t owner, gid_t group)
 {
   UNIMPLEMENTED (("path: %s, owner: %d, group: %d", path, owner, group));
   errno = ENOSYS;
diff --git a/newlib/libc/sys/mmixware/getpid.c b/newlib/libc/sys/mmixware/getpid.c
index 5190726bf5aa..723317f17d2f 100644
--- a/newlib/libc/sys/mmixware/getpid.c
+++ b/newlib/libc/sys/mmixware/getpid.c
@@ -1,6 +1,6 @@
 /* getpid stub for MMIXware.
 
-   Copyright (C) 2001 Hans-Peter Nilsson
+   Copyright (C) 2001, 2023 Hans-Peter Nilsson
 
    Permission to use, copy, modify, and distribute this software is
    freely granted, provided that the above copyright notice, this notice
@@ -16,7 +16,8 @@
 #include <sys/stat.h>
 #include "sys/syscall.h"
 
-_getpid (n)
+pid_t
+_getpid (void)
 {
   return 1;
 }
diff --git a/newlib/libc/sys/mmixware/kill.c b/newlib/libc/sys/mmixware/kill.c
index c01f53c81a73..ed9d92bb1053 100644
--- a/newlib/libc/sys/mmixware/kill.c
+++ b/newlib/libc/sys/mmixware/kill.c
@@ -1,6 +1,6 @@
 /* kill for MMIXware.
 
-   Copyright (C) 2001 Hans-Peter Nilsson
+   Copyright (C) 2001, 2023 Hans-Peter Nilsson
 
    Permission to use, copy, modify, and distribute this software is
    freely granted, provided that the above copyright notice, this notice
@@ -17,7 +17,8 @@
 #include "sys/syscall.h"
 #include <errno.h>
 
-_kill (n, m)
+int
+_kill (pid_t n, int m __unused)
 {
   if (n == 1)
     return TRAP1i (SYS_halt, 0);
diff --git a/newlib/libc/sys/mmixware/link.c b/newlib/libc/sys/mmixware/link.c
index 0629163b381c..cbcf7ee44807 100644
--- a/newlib/libc/sys/mmixware/link.c
+++ b/newlib/libc/sys/mmixware/link.c
@@ -1,6 +1,6 @@
 /* link stub for MMIXware.
 
-   Copyright (C) 2002 Hans-Peter Nilsson
+   Copyright (C) 2002, 2023 Hans-Peter Nilsson
 
    Permission to use, copy, modify, and distribute this software is
    freely granted, provided that the above copyright notice, this notice
@@ -18,7 +18,7 @@
 #include <errno.h>
 
 int
-_link ()
+_link (const char *p1 __unused, const char *p2 __unused)
 {
   errno = EMLINK;
   return -1;
diff --git a/newlib/libc/sys/mmixware/read.c b/newlib/libc/sys/mmixware/read.c
index f0f5e22f975f..3f34ca4876e6 100644
--- a/newlib/libc/sys/mmixware/read.c
+++ b/newlib/libc/sys/mmixware/read.c
@@ -1,6 +1,6 @@
 /* read for MMIXware.
 
-   Copyright (C) 2001 Hans-Peter Nilsson
+   Copyright (C) 2001, 2023 Hans-Peter Nilsson
 
    Permission to use, copy, modify, and distribute this software is
    freely granted, provided that the above copyright notice, this notice
@@ -19,7 +19,7 @@
 
 int
 _read (int file,
-       char *ptr,
+       void *ptr,
        size_t len)
 {
   long ret;
diff --git a/newlib/libc/sys/mmixware/sbrk.c b/newlib/libc/sys/mmixware/sbrk.c
index f50886df86cc..621169fc8a04 100644
--- a/newlib/libc/sys/mmixware/sbrk.c
+++ b/newlib/libc/sys/mmixware/sbrk.c
@@ -1,6 +1,6 @@
 /* sbrk for MMIXware.
 
-   Copyright (C) 2001, 2012 Hans-Peter Nilsson
+   Copyright (C) 2001, 2012, 2023 Hans-Peter Nilsson
 
    Permission to use, copy, modify, and distribute this software is
    freely granted, provided that the above copyright notice, this notice
@@ -31,10 +31,10 @@ __asm__ (" .global _Sbrk_high\n"
 	 "_Sbrk_high	IS	Pool_Segment\n"
 	 "Pool_Segment	IS	0x40<<56");
 
-caddr_t
-_sbrk (size_t incr)
+void *
+_sbrk (ptrdiff_t incr)
 {
-  char *prev_heap_end;
+  void *prev_heap_end;
 
   prev_heap_end = _Sbrk_high;
 
@@ -55,5 +55,5 @@ _sbrk (size_t incr)
     }
 
   _Sbrk_high += incr;
-  return (caddr_t) prev_heap_end;
+  return prev_heap_end;
 }
diff --git a/newlib/libc/sys/mmixware/sys/syscall.h b/newlib/libc/sys/mmixware/sys/syscall.h
index 4b4419cc0e1a..b5e40cc12ba3 100644
--- a/newlib/libc/sys/mmixware/sys/syscall.h
+++ b/newlib/libc/sys/mmixware/sys/syscall.h
@@ -1,6 +1,6 @@
 /* syscall defines for MMIXware.
 
-   Copyright (C) 2001, 2002, 2007 Hans-Peter Nilsson
+   Copyright (C) 2001, 2002, 2007, 2023 Hans-Peter Nilsson
 
    Permission to use, copy, modify, and distribute this software is
    freely granted, provided that the above copyright notice, this notice
@@ -11,6 +11,12 @@
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    PURPOSE.  */
 
+/* The standard-library calls in UNIMPLEMENTED, defined below, need to
+   be declared.  Don't push the #include requirements to the caller.  */
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
 /* These are the mmixware simulator calls that are of use in newlib.  */
 
 #define SYS_halt	0
diff --git a/newlib/libc/sys/mmixware/unlink.c b/newlib/libc/sys/mmixware/unlink.c
index b70df2dc3f9d..dfc92c6223f5 100644
--- a/newlib/libc/sys/mmixware/unlink.c
+++ b/newlib/libc/sys/mmixware/unlink.c
@@ -1,6 +1,6 @@
 /* unlink stub for MMIXware.
 
-   Copyright (C) 2001 Hans-Peter Nilsson
+   Copyright (C) 2001, 2023 Hans-Peter Nilsson
 
    Permission to use, copy, modify, and distribute this software is
    freely granted, provided that the above copyright notice, this notice
@@ -17,7 +17,7 @@
 #include "sys/syscall.h"
 
 int
-_unlink ()
+_unlink (const char *p __unused)
 {
   return -1;
 }
diff --git a/newlib/libc/sys/mmixware/write.c b/newlib/libc/sys/mmixware/write.c
index 74d5fcaa7105..89247895ea0b 100644
--- a/newlib/libc/sys/mmixware/write.c
+++ b/newlib/libc/sys/mmixware/write.c
@@ -1,6 +1,6 @@
 /* write for MMIXware.
 
-   Copyright (C) 2001 Hans-Peter Nilsson
+   Copyright (C) 2001, 2023 Hans-Peter Nilsson
 
    Permission to use, copy, modify, and distribute this software is
    freely granted, provided that the above copyright notice, this notice
@@ -19,7 +19,7 @@
 
 int
 _write ( int file,
-	 char *ptr,
+	 const void *ptr,
 	 size_t len)
 {
   long ret;
-- 
2.30.2

brgds, H-P
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.