Fix various c99/gcc-14 issues in generic libgloss code

Similar to what's been done in the ports, but this time in generic code.

Add missing #includes to pick up prototypes.  Add prototypes for various
internal functions where needed.  Fix signatures of various functions to match
what's provided by the headers (read, sbrk, write, unlink).

Nearly done with this effort ;-)

Pushed to the trunk,
This commit is contained in:
Jeff Law 2023-12-29 21:31:27 -07:00
parent 7ef32a98cd
commit 3d10b04f1e
6 changed files with 13 additions and 8 deletions

View File

@ -13,6 +13,7 @@
* they apply. * they apply.
*/ */
#include <_ansi.h> #include <_ansi.h>
#include <unistd.h>
#ifndef NULL #ifndef NULL
# define NULL 0 # define NULL 0
@ -28,4 +29,5 @@ extern char _end[]; /* _end is set in the linker command file */
/* only one prcess support, as this is OS dependant */ /* only one prcess support, as this is OS dependant */
#define __MYPID 1 #define __MYPID 1
int outbyte (char);

View File

@ -14,6 +14,8 @@
*/ */
#include "glue.h" #include "glue.h"
extern void print (char *ptr);
/* /*
* putnum -- print a 32 bit number in hex * putnum -- print a 32 bit number in hex
*/ */

View File

@ -22,10 +22,11 @@ extern char inbyte (void);
*/ */
int int
read (int fd, read (int fd,
char *buf, void *buf_,
int nbytes) size_t nbytes)
{ {
int i = 0; int i = 0;
char *buf = buf_;
for (i = 0; i < nbytes; i++) { for (i = 0; i < nbytes; i++) {
*(buf + i) = inbyte(); *(buf + i) = inbyte();

View File

@ -27,9 +27,8 @@ char *heap_ptr;
* RAM. We just increment a pointer in what's * RAM. We just increment a pointer in what's
* left of memory on the board. * left of memory on the board.
*/ */
char * void *
sbrk (nbytes) sbrk (ptrdiff_t nbytes)
int nbytes;
{ {
char *base; char *base;

View File

@ -20,7 +20,7 @@
* we just return an error. * we just return an error.
*/ */
int int
unlink (char * path) unlink (const char * path)
{ {
errno = EIO; errno = EIO;
return (-1); return (-1);

View File

@ -23,10 +23,11 @@ extern int outbyte (char x);
*/ */
int int
write (int fd, write (int fd,
char *buf, const void *buf_,
int nbytes) size_t nbytes)
{ {
int i; int i;
const char *buf = buf_;
for (i = 0; i < nbytes; i++) { for (i = 0; i < nbytes; i++) {
if (*(buf + i) == '\n') { if (*(buf + i) == '\n') {