From: "Roger Sayle" <roger@nextmovesoftware.com>
To: <newlib@sourceware.org>
Cc: "'Jeff Law'" <jeffreyalaw@gmail.com>
Subject: [PATCH] libgloss: Resolve compilation errors for mips.
Date: Thu, 4 Jan 2024 13:59:03 -0000 [thread overview]
Message-ID: <00ac01da3f16$2e292610$8a7b7230$@nextmovesoftware.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 766 bytes --]
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 <roger@nextmovesoftware.com>
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
--
[-- Attachment #2: libgloss.patch --]
[-- Type: application/octet-stream, Size: 3829 bytes --]
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
next reply other threads:[~2024-01-04 13:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-04 13:59 Roger Sayle [this message]
2024-01-04 23:54 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='00ac01da3f16$2e292610$8a7b7230$@nextmovesoftware.com' \
--to=roger@nextmovesoftware.com \
--cc=jeffreyalaw@gmail.com \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).