Re: [PATCH] libgloss: Resolve compilation errors for mips.

Mike Frysinger <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <ZZdFQ6tIRBDPixNk@vapier>
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
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmWXRUMACgkQQWM7n+g3
9YGlCA/8CBqvot4ulTZQ0VERIfJToGkaZC0vxcJ2lLZaRuiv+YaKoXAJ/ObVKrIL
nkaX8yfKSdCoGimHPnsGZGfzNjkZ01ghT/8Zq2VGS8lf3LJ5QsH9I67C1WR/5FUv
7BbBwaiYWrxMfeg9KxEGtZaVIdJ0fxzKOtVlYYhqIrW8y2SB1viS/kLpt2c919Ey
RDE2/9mffpXUSz/27dmoQRlcuQ01seBYsoSfutMfec7XC6/vjWUcpmWqSLfvglY5
VhIGfXiaNxBxVOq4xF1JfoP4YQFBGhfORpez6D9bLVx/pjawRau0YwhjFkgajfX6
0jUgcwfT+VRFRk9VslrHL7fwaEqRl2D+qGDsHLHNuDCYzLV3scJNvusvOaZmj9FB
xn19g3X3CX60OH8O/vdFYrd/cfM/B4zWf9qk0W0KAl9F4RpyXtqJpJ75z78dfOuw
Twli8podNevRkgeqcG6AgYQx+gHG2615nEHWFKGY3ibTLVf+GJR3jA22kva/geS9
zRUBqx6rtHMEzzaOz5ajYoWaYuY58RLHVKEeDwMZtgzsThHRLW+s2yysLD2StLZa
UfgRyfNLIuV0IHo896jlX6PkNjkth1yUnzn9PAn9XtTUr/VDjr49+FOSaW2tjh//
P/6B026Sr58YnVGkYpv9iBVPuzReBdYiXa1jTCr6lGtIHRJrGuk=
=5FRF
-----END PGP SIGNATURE-----
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.