[PATCH] libgloss: Resolve compilation errors for mips.

"Roger Sayle" <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
This patch fixes some compilation issues in libgloss when
building a cross-compiler for mips.  This mostly requires new
function prototypes, similar to the changes recently made
by Jeff Law for other targets.

2024-01-04  Roger Sayle  <[email protected]>

libgloss/ChangeLog
	* kill.c: Prototype _exit.
	* mips/cfe_mem.c (__libcfe_meminit): Add casts to avoid compilation
	warnings/errors.
	* mips/cma101.c: Prototype __cpu_timer_poll and __cpu_flush.
	* mips/syscalls.c: Prototype get_mem_info.
	(sbrk): Add casts to avoid compilation warnings/errors.
	* mips/test.c: Prototype outbyte and print. Fix return type of main.
	* print.c: Prototype outbyte.  Make ptr argument const char*.
	* putnum.c: Update prototype of print to const char*.

Ok?
Roger
--
libgloss.patch (application/octet-stream, 3.6 KB)
diff --git a/libgloss/kill.c b/libgloss/kill.c
index a0eaee75b..a53ba331a 100644
--- a/libgloss/kill.c
+++ b/libgloss/kill.c
@@ -14,6 +14,8 @@
  */
 #include "glue.h"
 
+extern void _exit (int);
+
 /*
  * kill -- go out via exit...
  */
diff --git a/libgloss/mips/cfe_mem.c b/libgloss/mips/cfe_mem.c
index 87caabf8c..41b871eef 100644
--- a/libgloss/mips/cfe_mem.c
+++ b/libgloss/mips/cfe_mem.c
@@ -58,7 +58,7 @@ __libcfe_meminit (void)
   /* If the user has provided a memory-limit function, use it to
      determine the end of usable memory.  */
   if (&__libcfe_mem_limit != NULL)
-    memtop = __libcfe_mem_limit ();
+    memtop = (unsigned long)__libcfe_mem_limit ();
   else
     {
       uint64_t start, length, type;
@@ -80,7 +80,7 @@ __libcfe_meminit (void)
             {
               /* Did not find an available entry containing _end.
                  Assume a minimal amount of memory (1MB).  */
-              memtop = _end + (1 * 1024 * 1024);
+              memtop = (unsigned int)(_end + (1 * 1024 * 1024));
               break;
             }
 
diff --git a/libgloss/mips/cma101.c b/libgloss/mips/cma101.c
index e8f381864..ba58b1d5f 100644
--- a/libgloss/mips/cma101.c
+++ b/libgloss/mips/cma101.c
@@ -133,6 +133,7 @@ set_pclock (void)
   return;
 }
 
+extern void __cpu_timer_poll (int);
 #define PCLOCK_WAIT(x)  __cpu_timer_poll((x) * pclock)
 
 /* NOTE: On the Cogent CMA101 board the LCD controller will sometimes
@@ -178,6 +179,7 @@ lcd_display (int line, const char *msg)
 extern unsigned int __buserr_count(void);
 extern void __default_buserr_handler(void);
 extern void __restore_buserr_handler(void);
+extern void __cpu_flush(void);
 
 /* Allow the user to provide his/her own defaults.  */
 unsigned int __sizemem_default;
diff --git a/libgloss/mips/syscalls.c b/libgloss/mips/syscalls.c
index 3ab543674..4661b97be 100644
--- a/libgloss/mips/syscalls.c
+++ b/libgloss/mips/syscalls.c
@@ -5,6 +5,7 @@
 #include "regs.S"
 
 extern char _end[];
+extern void *get_mem_info (void*);
 
 /* FIXME: This is not ideal, since we do a get_mem_info() call for
    every sbrk() call. */
@@ -31,8 +32,8 @@ sbrk (nbytes)
   /* NOTE: The value returned from the get_mem_info call is the amount
      of memory, and not the address of the (last byte + 1) */
 
-  if (((size_t)heap_ptr >= heap_start) && ((size_t)heap_ptr < (heap_start + mem.size))) {
-    avail = (heap_start + mem.size) - (size_t)heap_ptr;
+  if ((heap_ptr >= heap_start) && (heap_ptr < (heap_start + mem.size))) {
+    avail = (unsigned int)((heap_start + mem.size) - heap_ptr);
     base = heap_ptr;
   } /* else will fail since "nbytes" will be greater than zeroed "avail" value */
 
diff --git a/libgloss/mips/test.c b/libgloss/mips/test.c
index a99347914..b580ea933 100644
--- a/libgloss/mips/test.c
+++ b/libgloss/mips/test.c
@@ -1,4 +1,7 @@
-main()
+extern int outbyte(unsigned char byte);
+extern void print (const char *);
+
+int main()
 {
   outbyte ('&');
   outbyte ('@');
@@ -9,5 +12,5 @@ main()
   
   print ("\r\nDone...");
 
-  return;
+  return 0;
 }
diff --git a/libgloss/print.c b/libgloss/print.c
index 76d543b67..3b7f91606 100644
--- a/libgloss/print.c
+++ b/libgloss/print.c
@@ -14,11 +14,13 @@
  */
 #include "glue.h"
 
+extern int outbyte (char x);
+
 /*
  * print -- do a raw print of a string
  */ 
 void
-print (char *ptr)
+print (const char *ptr)
 {
   while (*ptr) {
     outbyte (*ptr++);
diff --git a/libgloss/putnum.c b/libgloss/putnum.c
index 6e1051e24..1720098bd 100644
--- a/libgloss/putnum.c
+++ b/libgloss/putnum.c
@@ -14,7 +14,7 @@
  */
 #include "glue.h"
 
-extern void print (char *ptr);
+extern void print (const char *ptr);
 
 /*
  * putnum -- print a 32 bit number in hex
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.