Fix missing declarations in libgloss m68k

Jean-Paul Mari <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <BN6PR16MB3139202289FAB70CA85FE95CA720A@BN6PR16MB3139.namprd16.prod.outlook.com>
This patch avoids compilation errors.
0000-cover-letter.patch (application/octet-stream, 842 B)
From 607d7d9a06cbd53144fee62983bb3b4c338f37de Mon Sep 17 00:00:00 2001
From: Jean-Paul Mari <[email protected]>
Date: Fri, 27 Jun 2025 06:57:26 -0400
Subject: [PATCH 0/1] Fix missing declarations in libgloss m68k

This patch adds missing function declarations in several m68k-specific libgloss source files.
This helps avoid implicit declaration compiler warnings / errors and ensures better portability.

Tested by building newlib for m68k-elf with GCC.

Jean-Paul Mari (1):
  Fix missing declarations in libgloss m68k

 libgloss/m68k/leds.c       | 2 ++
 libgloss/m68k/mc68ec.c     | 2 +-
 libgloss/m68k/sim-abort.c  | 3 +++
 libgloss/m68k/sim-funcs.c  | 1 +
 libgloss/m68k/sim-inbyte.c | 2 ++
 libgloss/m68k/sim-print.c  | 2 ++
 libgloss/m68k/sim-sbrk.c   | 2 ++
 7 files changed, 13 insertions(+), 1 deletion(-)

-- 
2.45.2.windows.1
0001-Fix-missing-declarations-in-libgloss-m68k.patch (application/octet-stream, 2.7 KB)
From 607d7d9a06cbd53144fee62983bb3b4c338f37de Mon Sep 17 00:00:00 2001
From: Jean-Paul Mari <[email protected]>
Date: Fri, 27 Jun 2025 06:57:15 -0400
Subject: [PATCH 1/1] Fix missing declarations in libgloss m68k

Fix missing declarations in libgloss m68k
---
 libgloss/m68k/leds.c       | 2 ++
 libgloss/m68k/mc68ec.c     | 2 +-
 libgloss/m68k/sim-abort.c  | 3 +++
 libgloss/m68k/sim-funcs.c  | 1 +
 libgloss/m68k/sim-inbyte.c | 2 ++
 libgloss/m68k/sim-print.c  | 2 ++
 libgloss/m68k/sim-sbrk.c   | 2 ++
 7 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/libgloss/m68k/leds.c b/libgloss/m68k/leds.c
index b9112376d..96904762b 100644
--- a/libgloss/m68k/leds.c
+++ b/libgloss/m68k/leds.c
@@ -15,6 +15,8 @@
  */
 #include "leds.h"
 
+extern void delay(int);
+
 /*
  * led_putnum -- print a hex number on the LED. the value of num must be a char with
  *              the ascii value. ie... number 0 is '0', a is 'a', ' ' (null) clears
diff --git a/libgloss/m68k/mc68ec.c b/libgloss/m68k/mc68ec.c
index 76e737fe7..5543defb3 100644
--- a/libgloss/m68k/mc68ec.c
+++ b/libgloss/m68k/mc68ec.c
@@ -25,7 +25,7 @@
  *          prompt. It can be restarted from there.
  */
 void
-_exit (int_status)
+_exit (int status)
 {
   /* Use `i' constraint to get proper immediate-operand syntax for
      target assembler configuration.  */
diff --git a/libgloss/m68k/sim-abort.c b/libgloss/m68k/sim-abort.c
index 4960de8f8..affc2c672 100644
--- a/libgloss/m68k/sim-abort.c
+++ b/libgloss/m68k/sim-abort.c
@@ -14,6 +14,9 @@
  * they apply.
  */
 
+#include <stdlib.h>
+#include <unistd.h>
+
 void abort(void)
 {
   write (2, "Abort called.\n", sizeof("Abort called.\n")-1);
diff --git a/libgloss/m68k/sim-funcs.c b/libgloss/m68k/sim-funcs.c
index 712c566b2..865e752f4 100644
--- a/libgloss/m68k/sim-funcs.c
+++ b/libgloss/m68k/sim-funcs.c
@@ -15,6 +15,7 @@
 
 #define _XOPEN_SOURCE
 #include <unistd.h>
+#include <stdlib.h>
 
 int
 kill(int pid, int sig)
diff --git a/libgloss/m68k/sim-inbyte.c b/libgloss/m68k/sim-inbyte.c
index 3fa3f2474..7d2c97254 100644
--- a/libgloss/m68k/sim-inbyte.c
+++ b/libgloss/m68k/sim-inbyte.c
@@ -14,6 +14,8 @@
  * they apply.
  */
 
+#include <unistd.h>
+
 int
 inbyte ()
 {
diff --git a/libgloss/m68k/sim-print.c b/libgloss/m68k/sim-print.c
index 18ca02261..907c54144 100644
--- a/libgloss/m68k/sim-print.c
+++ b/libgloss/m68k/sim-print.c
@@ -13,6 +13,8 @@
  * they apply.
  */
 
+#include <unistd.h>
+
 /*
  * print -- do a raw print of a string
  */ 
diff --git a/libgloss/m68k/sim-sbrk.c b/libgloss/m68k/sim-sbrk.c
index 83e5287eb..771eecf06 100644
--- a/libgloss/m68k/sim-sbrk.c
+++ b/libgloss/m68k/sim-sbrk.c
@@ -14,6 +14,8 @@
  * they apply.
  */
 
+extern int brk(void *addr);
+
 extern char _end[];
 static char *curbrk = _end;
 
-- 
2.45.2.windows.1
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.