From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2152) id 442A23858D33; Fri, 29 Dec 2023 18:29:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 442A23858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1703874585; bh=AEWcADJuoJzL8hY3WJbEmgarg4dNEkSjfIfnGq484sI=; h=From:To:Subject:Date:From; b=XmdASRn05W8S1vHZ6qmHPFY/UEdNed9j1am9sjF5OUhRXOHE3EyI+jqxofz0Fkhja ZTi9dt6AtYsAS1xH//XwJ/+QBf4XaA4+CyD/6X6giHY1l3zTS6u1tJi23j9JQM7wHw nVRfP8YJ2S9xTlWCqJz16Bxp7DSzfpgKLI0Qm3g8= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Hans-Peter Nilsson To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] newlib MMIX: Fix compilation warnings that recent gcc treats as errors X-Act-Checkin: newlib-cygwin X-Git-Author: Hans-Peter Nilsson X-Git-Refname: refs/heads/master X-Git-Oldrev: 1a177610d8e181d09206a5a8ce2d873822751657 X-Git-Newrev: ddb614993a78bf2cdf2ed269617f7f552490e76f Message-Id: <20231229182945.442A23858D33@sourceware.org> Date: Fri, 29 Dec 2023 18:29:45 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dddb614993a7= 8bf2cdf2ed269617f7f552490e76f commit ddb614993a78bf2cdf2ed269617f7f552490e76f Author: Hans-Peter Nilsson Date: Thu Dec 28 04:31:19 2023 +0100 newlib MMIX: Fix compilation warnings that recent gcc treats as errors =20 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 declar= ation \ of function 'sprintf' [-Wimplicit-function-declaration] 139 | sprintf (buf, "UNIMPLEMENTED %s in %s\n", __FUNCTION__, __FILE__); \ =20 Other warnings also quelled. =20 * 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 unist= d.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. Diff: --- 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/_e= xit.c index 2f70154f2..9ac62c743 100644 --- a/newlib/libc/sys/mmixware/_exit.c +++ b/newlib/libc/sys/mmixware/_exit.c @@ -1,6 +1,6 @@ /* _exit for MMIXware. =20 - Copyright (C) 2001 Hans-Peter Nilsson + Copyright (C) 2001, 2023 Hans-Peter Nilsson =20 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/ch= own.c index f4fc49cac..646504b32 100644 --- a/newlib/libc/sys/mmixware/chown.c +++ b/newlib/libc/sys/mmixware/chown.c @@ -1,6 +1,6 @@ /* chown stub for MMIXware. =20 - Copyright (C) 2001 Hans-Peter Nilsson + Copyright (C) 2001, 2023 Hans-Peter Nilsson =20 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 =20 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 =3D ENOSYS; diff --git a/newlib/libc/sys/mmixware/getpid.c b/newlib/libc/sys/mmixware/g= etpid.c index 5190726bf..723317f17 100644 --- a/newlib/libc/sys/mmixware/getpid.c +++ b/newlib/libc/sys/mmixware/getpid.c @@ -1,6 +1,6 @@ /* getpid stub for MMIXware. =20 - Copyright (C) 2001 Hans-Peter Nilsson + Copyright (C) 2001, 2023 Hans-Peter Nilsson =20 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 #include "sys/syscall.h" =20 -_getpid (n) +pid_t +_getpid (void) { return 1; } diff --git a/newlib/libc/sys/mmixware/kill.c b/newlib/libc/sys/mmixware/kil= l.c index c01f53c81..ed9d92bb1 100644 --- a/newlib/libc/sys/mmixware/kill.c +++ b/newlib/libc/sys/mmixware/kill.c @@ -1,6 +1,6 @@ /* kill for MMIXware. =20 - Copyright (C) 2001 Hans-Peter Nilsson + Copyright (C) 2001, 2023 Hans-Peter Nilsson =20 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 =20 -_kill (n, m) +int +_kill (pid_t n, int m __unused) { if (n =3D=3D 1) return TRAP1i (SYS_halt, 0); diff --git a/newlib/libc/sys/mmixware/link.c b/newlib/libc/sys/mmixware/lin= k.c index 0629163b3..cbcf7ee44 100644 --- a/newlib/libc/sys/mmixware/link.c +++ b/newlib/libc/sys/mmixware/link.c @@ -1,6 +1,6 @@ /* link stub for MMIXware. =20 - Copyright (C) 2002 Hans-Peter Nilsson + Copyright (C) 2002, 2023 Hans-Peter Nilsson =20 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 =20 int -_link () +_link (const char *p1 __unused, const char *p2 __unused) { errno =3D EMLINK; return -1; diff --git a/newlib/libc/sys/mmixware/read.c b/newlib/libc/sys/mmixware/rea= d.c index f0f5e22f9..3f34ca487 100644 --- a/newlib/libc/sys/mmixware/read.c +++ b/newlib/libc/sys/mmixware/read.c @@ -1,6 +1,6 @@ /* read for MMIXware. =20 - Copyright (C) 2001 Hans-Peter Nilsson + Copyright (C) 2001, 2023 Hans-Peter Nilsson =20 Permission to use, copy, modify, and distribute this software is freely granted, provided that the above copyright notice, this notice @@ -19,7 +19,7 @@ =20 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/sbr= k.c index f50886df8..621169fc8 100644 --- a/newlib/libc/sys/mmixware/sbrk.c +++ b/newlib/libc/sys/mmixware/sbrk.c @@ -1,6 +1,6 @@ /* sbrk for MMIXware. =20 - Copyright (C) 2001, 2012 Hans-Peter Nilsson + Copyright (C) 2001, 2012, 2023 Hans-Peter Nilsson =20 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"); =20 -caddr_t -_sbrk (size_t incr) +void * +_sbrk (ptrdiff_t incr) { - char *prev_heap_end; + void *prev_heap_end; =20 prev_heap_end =3D _Sbrk_high; =20 @@ -55,5 +55,5 @@ _sbrk (size_t incr) } =20 _Sbrk_high +=3D 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/mmixw= are/sys/syscall.h index 4b4419cc0..b5e40cc12 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. =20 - Copyright (C) 2001, 2002, 2007 Hans-Peter Nilsson + Copyright (C) 2001, 2002, 2007, 2023 Hans-Peter Nilsson =20 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. */ =20 +/* The standard-library calls in UNIMPLEMENTED, defined below, need to + be declared. Don't push the #include requirements to the caller. */ +#include +#include +#include + /* These are the mmixware simulator calls that are of use in newlib. */ =20 #define SYS_halt 0 diff --git a/newlib/libc/sys/mmixware/unlink.c b/newlib/libc/sys/mmixware/u= nlink.c index b70df2dc3..dfc92c622 100644 --- a/newlib/libc/sys/mmixware/unlink.c +++ b/newlib/libc/sys/mmixware/unlink.c @@ -1,6 +1,6 @@ /* unlink stub for MMIXware. =20 - Copyright (C) 2001 Hans-Peter Nilsson + Copyright (C) 2001, 2023 Hans-Peter Nilsson =20 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" =20 int -_unlink () +_unlink (const char *p __unused) { return -1; } diff --git a/newlib/libc/sys/mmixware/write.c b/newlib/libc/sys/mmixware/wr= ite.c index 74d5fcaa7..89247895e 100644 --- a/newlib/libc/sys/mmixware/write.c +++ b/newlib/libc/sys/mmixware/write.c @@ -1,6 +1,6 @@ /* write for MMIXware. =20 - Copyright (C) 2001 Hans-Peter Nilsson + Copyright (C) 2001, 2023 Hans-Peter Nilsson =20 Permission to use, copy, modify, and distribute this software is freely granted, provided that the above copyright notice, this notice @@ -19,7 +19,7 @@ =20 int _write ( int file, - char *ptr, + const void *ptr, size_t len) { long ret;