[PATCH v2] libgloss: Resolve compilation errors for mips.
Roger Sayle
roger@nextmovesoftware.com
Mon Feb 10 21:49:58 GMT 2025
Here's an updated version of my patch from last year to restore libgloss builds
on MIPS targets, incorporating the feedback from Mike Frysinger's review.
Tested by building a combined gcc/binutils/newlib tree with --target=mips64-elf.
Ok?
2025-02-10 Roger Sayle <roger@nextmovesoftware.com>
Mike Frysinger <vapier@gentoo.org>
libgloss/ChangeLog
* glue.h (print): Provide prototype.
* kill.c: Prototype _exit with noreturn attribute.
* mips/cfe_mem.c (memtop): Change to a pointer type.
(__libcfe_meminit): Add casts to avoid compilation
warnings/errors.
* mips/cma101.c: Prototype __cpu_timer_poll and __cpu_flush.
(convertbcd): Update K&R-style function declaration.
(time): Likewise.
* mips/nullmon.c (get_mem_info): Likewise.
* mips/syscalls.c: Declare struct s_mem and prototype get_mem_info.
(sbrk): Update K&R-style function declaration. Add casts to avoid
compilation warnings/errors.
* mips/test.c: Prototype outbyte and print. Fix return type of main.
* print.c (print): Make ptr argument const char*.
* putnum.c: Remove print prototype, which is now in glue.h.
* write.c: Remove outbyte prototype, which is now in glue.h.
Thanks in advance,
Roger
--
> -----Original Message-----
> From: Mike Frysinger <vapier@gentoo.org>
> Sent: 04 January 2024 23:55
> To: Roger Sayle <roger@nextmovesoftware.com>
> Cc: newlib@sourceware.org; 'Jeff Law' <jeffreyalaw@gmail.com>
> Subject: Re: [PATCH] libgloss: Resolve compilation errors for mips.
>
> On 04 Jan 2024 13:59, Roger Sayle wrote:
> > --- a/libgloss/kill.c
> > +++ b/libgloss/kill.c
> >
> > +extern void _exit (int);
>
> missing noreturn markings. can this file include stdlib.h instead ?
>
> > --- a/libgloss/mips/cfe_mem.c
> > +++ b/libgloss/mips/cfe_mem.c
> >
> > - memtop = __libcfe_mem_limit ();
> > + memtop = (unsigned long)__libcfe_mem_limit ();
>
> if memtop is supposed to be a pointer, then it should be a pointer, not an integer.
>
> ignoring that, never use long or int to cast pointers. this is what uintptr_t is
> designed for.
>
> > --- a/libgloss/mips/syscalls.c
> > +++ b/libgloss/mips/syscalls.c
> >
> > extern char _end[];
> > +extern void *get_mem_info (void*);
>
> seems like mips should have a header for its prototypes rather than duplicating it
> across multiple files, and so it makes sure it's defined correctly both in the callers
> & definitions. seems like get_mem_info takes a struct pointer, not a void.
>
> > - 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);
>
> use ptrdiff_t to hold the difference between pointers, don't cast like this.
>
> > --- a/libgloss/print.c
> > +++ b/libgloss/print.c
> >
> > #include "glue.h"
> >
> > +extern int outbyte (char x);
>
> outbyte is already defined in glue.h which is included here
>
> > --- 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);
>
> this prob should be moved to glue.h instead -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libgloss_v2.patch
Type: application/octet-stream
Size: 6547 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/newlib/attachments/20250210/bcc74790/attachment-0001.obj>
More information about the Newlib
mailing list