From 50428619e12d8eeebe5eda9814a0d3ecc37d00b7 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 13 Jan 2015 21:57:49 +0000 Subject: [PATCH] libc: Make the libc code with cc65. Clean all the header bugs it found cc65 is quite pedantic about consts, sdcc is rather slack. Clean up all the errors cc65 found. That should also make it rather easier to do the gcc builds. This isn't yet a complete cc65 libc. It doesn't handle some of the calls due to arg ordering funnies and it doesn't have a syscalls lib. A pure runtime library for a cc65 'fuzix' target and crt0.s are also needed. --- Library/include/6502/stdint.h | 19 ++++++++ Library/include/grp.h | 2 +- Library/include/pwd.h | 4 +- Library/include/syscalls.h | 1 + Library/include/unistd.h | 20 ++++---- Library/include/utime.h | 2 +- Library/include/utmp.h | 8 ++-- Library/libs/Makefile.6502 | 87 +++++++++++++++++++++++++++++++++++ Library/libs/execl.c | 14 ++++-- Library/libs/execv.c | 4 +- Library/libs/execvp.c | 4 +- Library/libs/fopen.c | 2 +- Library/libs/fprintf.c | 2 +- Library/libs/fputs.c | 2 +- Library/libs/free.c | 3 +- Library/libs/fuzix/Makefile | 1 + Library/libs/fwrite.c | 2 +- Library/libs/gets.c | 2 +- Library/libs/lstat.c | 2 +- Library/libs/pathconf.c | 4 +- Library/libs/perror.c | 6 +-- Library/libs/printf.c | 4 +- Library/libs/readlink.c | 2 +- Library/libs/setjmp.c | 2 + Library/libs/sprintf.c | 4 +- Library/libs/stdio0.c | 2 +- Library/libs/strcasestr.c | 2 +- Library/libs/strdup.c | 6 +-- Library/libs/stricmp.c | 4 +- Library/libs/strnicmp.c | 4 +- Library/libs/strsep.c | 7 +-- Library/libs/utent.c | 2 +- Library/libs/vfprintf.c | 2 +- Library/libs/vfscanf.c | 2 +- Library/libs/vprintf.c | 2 +- 35 files changed, 176 insertions(+), 60 deletions(-) create mode 100644 Library/include/6502/stdint.h create mode 100644 Library/libs/Makefile.6502 diff --git a/Library/include/6502/stdint.h b/Library/include/6502/stdint.h new file mode 100644 index 00000000..cd86d211 --- /dev/null +++ b/Library/include/6502/stdint.h @@ -0,0 +1,19 @@ +#ifndef __STDINT_H +#define __STDINT_H + +/* C types */ +typedef unsigned long uint32_t; +typedef signed long int32_t; +typedef unsigned short uint16_t; +typedef signed short int16_t; +typedef unsigned char uint8_t; +typedef signed char int8_t; + +/* C99 */ +typedef int16_t intptr_t; +typedef uint16_t uintptr_t; + +#define __SIZE_T_DEFINED +#define NO_64BIT + +#endif diff --git a/Library/include/grp.h b/Library/include/grp.h index 1b19518d..0c6dd415 100644 --- a/Library/include/grp.h +++ b/Library/include/grp.h @@ -21,7 +21,7 @@ extern void endgrent __P((void)); extern struct group *getgrent __P((void)); extern struct group *getgrgid __P((const gid_t gid)); -extern struct group *getgrnam __P((char * name)); +extern struct group *getgrnam __P((const char * name)); extern struct group * fgetgrent __P((FILE * file)); diff --git a/Library/include/pwd.h b/Library/include/pwd.h index 5187518b..2f662263 100644 --- a/Library/include/pwd.h +++ b/Library/include/pwd.h @@ -20,13 +20,13 @@ extern void setpwent __P((void)); extern void endpwent __P((void)); extern struct passwd *getpwent __P((void)); -extern int putpwent __P((struct passwd * __p, FILE * __f)); +extern int putpwent __P((const struct passwd * __p, FILE * __f)); extern int getpw __P((uid_t uid, char *buf)); extern struct passwd *fgetpwent __P((FILE * file)); extern struct passwd *getpwuid __P((uid_t __uid)); -extern struct passwd *getpwnam __P((char *)); +extern struct passwd *getpwnam __P((const char *)); extern struct passwd * __getpwent __P((int passwd_fd)); diff --git a/Library/include/syscalls.h b/Library/include/syscalls.h index acebd1f9..d5a7577f 100644 --- a/Library/include/syscalls.h +++ b/Library/include/syscalls.h @@ -123,6 +123,7 @@ extern int uadmin(int cmd, int ctrl, void *ptr); extern int nice(int prio); extern int rename(const char *path, const char *newpath); extern int flock(int fd, int op); +extern pid_t getpgrp(void); /* asm syscall hooks with C wrappers */ extern int _getdirent(int fd, void *buf, int len); diff --git a/Library/include/unistd.h b/Library/include/unistd.h index 7d018b03..7ab84fcf 100644 --- a/Library/include/unistd.h +++ b/Library/include/unistd.h @@ -27,18 +27,18 @@ extern unsigned int sleep __P((unsigned int seconds)); extern char **environ; -extern char * _findPath __P((char *pathname)); -extern int execl __P((char *pathname, char *arg0, ...)); -extern int execle __P((char *pathname, char *arg0, ...)); -extern int execlp __P((char *pathname, char *arg0, ...)); -extern int execlpe __P((char *pathname, char *arg0, ...)); -extern int execv __P((char *pathname, char *argv[])); -extern int exect __P((char *pathname, char *argv[], char *envp[])); -extern int execvp __P((char *pathname, char *argv[])); -extern int execvpe __P((char *pathname, char *argv[], char *envp[])); +extern const char * _findPath __P((const char *pathname)); +extern int execl __P((const char *pathname, const char *arg0, ...)); +extern int execle __P((const char *pathname, const char *arg0, ...)); +extern int execlp __P((const char *pathname, const char *arg0, ...)); +extern int execlpe __P((const char *pathname, const char *arg0, ...)); +extern int execv __P((const char *pathname, const char *argv[])); +extern int execve __P((const char *pathname, const char *argv[], const char *envp[])); +extern int execvp __P((const char *pathname, const char *argv[])); +extern int execvpe __P((const char *pathname, const char *argv[], const char *envp[])); extern char *ttyname __P((int)); -extern int system __P((char *)); +extern int system __P((const char *)); extern int pause __P((void)); extern pid_t fork __P((void)); extern char *getcwd __P((char *, int)); diff --git a/Library/include/utime.h b/Library/include/utime.h index 0ebbfd38..772134c9 100644 --- a/Library/include/utime.h +++ b/Library/include/utime.h @@ -9,6 +9,6 @@ struct utimbuf { time_t modtime; /* modification time */ }; -extern int utime __P ((char *__filename, struct utimbuf *__utimebuf)); +extern int utime __P ((const char *__filename, const struct utimbuf *__utimebuf)); #endif diff --git a/Library/include/utmp.h b/Library/include/utmp.h index c4f19017..6eefc372 100644 --- a/Library/include/utmp.h +++ b/Library/include/utmp.h @@ -33,11 +33,11 @@ struct utmp { }; extern void setutent __P((void)); -extern void utmpname __P((char *)); +extern void utmpname __P((const char *)); extern struct utmp * getutent __P((void)); -extern struct utmp * getutid __P((struct utmp *)); -extern struct utmp * getutline __P((struct utmp *)); -extern struct utmp * pututline __P((struct utmp *)); +extern struct utmp * getutid __P((const struct utmp *)); +extern struct utmp * getutline __P((const struct utmp *)); +extern struct utmp * pututline __P((const struct utmp *)); extern void endutent __P((void)); struct utmp * __getutent __P((int)); diff --git a/Library/libs/Makefile.6502 b/Library/libs/Makefile.6502 new file mode 100644 index 00000000..21ff019e --- /dev/null +++ b/Library/libs/Makefile.6502 @@ -0,0 +1,87 @@ +CC = cl65 +ASM = ca65 +AR = sar65 +LINKER = ld65 +CC_OPT = -O -D__STDC__ --all-fastcall -c -O -I../include/ -I../include/6502/ +ASM_OPT = -l -o -s +LINKER_OPT = -m -i -o +SRC_CRT0 = crt0.s +OBJ_CRT0 = $(SRC_CRT0:.s=.o) +SRC_ASM = +OBJ_ASM = $(SRC_ASM:.s=.o) +SRC_C = __argv.c abort.c asctime.c assert.c atexit.c +SRC_C += bcmp.c bcopy.c bsearch.c bzero.c calloc.c cfree.c clock.c closedir.c +SRC_C += clock_gettime.c clock_getres.c clock_settime.c +SRC_C += creat.c crypt.c ctime.c ctype.c difftime.c err.c errno.c error.c +SRC_C += execl.c execv.c execvp.c exit.c +SRC_C += fclose.c fflush.c fgetc.c fgetgrent.c fgetpwent.c +SRC_C += fgetpos.c fgets.c fopen.c fprintf.c fputc.c fputs.c fread.c free.c +SRC_C += fsetpos.c ftell.c fwrite.c getcwd.c +SRC_C += getenv.c __getgrent.c getgrgid.c getgrnam.c getopt.c +SRC_C += getpw.c __getpwent.c getpwnam.c getpwuid.c gets.c gettimeofday.c +SRC_C += gmtime.c gmtime_r.c grent.c index.c isatty.c itoa.c killpg.c +SRC_C += localtim.c localtim_r.c lseek.c lsearch.c lstat.c ltoa.c ltostr.c +SRC_C += malloc.c mkfifo.c nanosleep.c opendir.c pause.c perror.c +SRC_C += popen.c printf.c putenv.c putgetch.c putpwent.c pwent.c qsort.c +SRC_C += raise.c rand.c readdir.c readlink.c realloc.c regerror.c +SRC_C += regsub.c remove.c rewind.c rindex.c setbuffer.c setenv.c setjmp.c +SRC_C += setvbuf.c settimeofday.c sleep.c sprintf.c stat.c stdio0.c +SRC_C += strcasecmp.c strcasestr.c strdup.c stricmp.c strlcpy.c strncasecmp.c +SRC_C += strnicmp.c strsep.c +SRC_C += strtol.c system.c time.c tmpnam.c ttyname.c +SRC_C += tzset.c ungetc.c utent.c utimes.c utsname.c +SRC_C += vfprintf.c vprintf.c wait.c xitoa.c pathconf.c +SRC_C += gethostname.c sysconf.c confstr.c memccpy.c getpass.c +# tty layer +SRC_C += tcgetattr.c tcsetattr.c tcdrain.c tcflow.c tcflush.c +SRC_C += cfmakeraw.c cfspeed.c revoke.c +# scanf +SRC_C += fscanf.c scanf.c sscanf.c vfscanf.c vscanf.c vsscanf.c +# Seems to give the compiler a hard time +SRC_HARD += regexp.c +# Not supported yet +#SRC_C += initgroups.c +# Pieces we inherit in this case from the compiler library instead +#SRC_C += strcpy.c strlen.c abs.c atof.c atoi.c atol.c labs.c +#SRC_C += strcat.c strchr.c strcmp.c strcspn.c strncat.c strncmp.c +#SRC_C += strncpy.c strpbrk.c strrchr.c strspn.c strstr.c strtok.c +#SRC_C += memchr.c memcmp.c memcpy.c memset.c + +OBJ_C = $(SRC_C:.c=.o) +OBJ_ALL = $(OBJ_ASM) $(OBJ_C) + +all: syslib.lib crt0.rel + +libc.l:%.l:$(OBJ_ALL) + ls $(OBJ_ALL) > libc.l + +syscall.l: fuzix/syslib.l +# ../tools/syscall-6502 +# (cd fuzix; make) +# cat fuzix/syslib.l | tr " " "\\n" | sed -e "s/^/fuzix\//" >syscall.l + +syslib.lib: syscall.l libc.l + cat libc.l syscall.l >syslib.l + $(AR) rc syslib.lib @syslib.l + $(AR) s syslib.lib + ln -sf syslib.lib c.lib + +fuzix/syslib.l: +# ../tools/syscall-6502 +# make -C fuzix-6502 + +$(OBJ_ASM):%.o: %.s + $(ASM) $(ASM_OPT) $@ $(@:.o=.s) + +$(OBJ_CRT0):%.o: %.s + $(ASM) $(ASM_OPT) $@ $(@:.o=.s) + +$(OBJ_C):%.o: %.c + $(CC) $(CC_OPT) $(@:.o=.c) + +$(OBJ_HARD):%.o: %.c + $(CC) $(CC_NOOPT) $(@:.o=.c) + +clean: + rm -rf *.rel *.asm *.sym *.lst *.lib *~ syscall.l libc.l syslib.l + (cd fuzix-6502; make clean) diff --git a/Library/libs/execl.c b/Library/libs/execl.c index 3bd1e6a9..b3e74434 100644 --- a/Library/libs/execl.c +++ b/Library/libs/execl.c @@ -17,7 +17,7 @@ * 3. else search in current directory * 4. else return NULL (execve() interpretes NULL as non existent file!) */ -char *_findPath(char *path) +const char *_findPath(const char *path) { char *p; const char *envp; @@ -49,14 +49,18 @@ char *_findPath(char *path) if (access(path, 0) == 0) /* file exist in current dir */ return name; return NULL; -} - -int execl(char *pathP, char *arg0) +} + +#ifndef __CC65__ + +/* FIXME: The 6502 calling sequence means these need a different implementation */ +int execl(const char *pathP, const char *arg0, ...) { return execve(pathP, &arg0, environ); } -int execlp(char *pathP, char *arg0) +int execlp(const char *pathP, const char *arg0, ...) { return execve(_findPath(pathP), &arg0, environ); } +#endif \ No newline at end of file diff --git a/Library/libs/execv.c b/Library/libs/execv.c index ec9c20b5..c9185de5 100644 --- a/Library/libs/execv.c +++ b/Library/libs/execv.c @@ -7,9 +7,9 @@ #include #include -int execv(char *pathP, char *argv[]) +int execv(const char *pathP, const char *argv[]) { - return execve(pathP, argv, environ); + return execve(pathP, argv, (void *)environ); } diff --git a/Library/libs/execvp.c b/Library/libs/execvp.c index 85adcb85..2925f9cf 100644 --- a/Library/libs/execvp.c +++ b/Library/libs/execvp.c @@ -7,7 +7,7 @@ #include #include -int execvp(char *pathP, char *argv[]) +int execvp(const char *pathP, const char *argv[]) { - return execve(_findPath(pathP), argv, environ); + return execve(_findPath(pathP), argv, (void *)environ); } diff --git a/Library/libs/fopen.c b/Library/libs/fopen.c index a8ee10b6..11079c04 100644 --- a/Library/libs/fopen.c +++ b/Library/libs/fopen.c @@ -13,7 +13,7 @@ * stdio.h show the other names. */ -FILE * __fopen(char *fname, int fd, FILE * fp, char *mode) +FILE * __fopen(const char *fname, int fd, FILE * fp, const char *mode) { uint open_mode = 0; diff --git a/Library/libs/fprintf.c b/Library/libs/fprintf.c index fbde805c..d8b0a173 100644 --- a/Library/libs/fprintf.c +++ b/Library/libs/fprintf.c @@ -14,7 +14,7 @@ #include "printf.h" -int fprintf(FILE * fp, char *fmt, ...) +int fprintf(FILE * fp, const char *fmt, ...) { va_list ptr; int rv; diff --git a/Library/libs/fputs.c b/Library/libs/fputs.c index 4f4bd294..6e3f2a24 100644 --- a/Library/libs/fputs.c +++ b/Library/libs/fputs.c @@ -1,6 +1,6 @@ #include "stdio-l.h" -int fputs(void *str, FILE * fp) +int fputs(const void *str, FILE * fp) { register int n = 0; char *s = str; diff --git a/Library/libs/free.c b/Library/libs/free.c index b8b27347..1fd24485 100644 --- a/Library/libs/free.c +++ b/Library/libs/free.c @@ -66,7 +66,8 @@ void free(void *ptr) * tho. */ #ifdef __MINI_MALLOC__ - if (__alloca_alloc == __mini_malloc && __freed_list) { + /* FIXME: void * cast appears to be a cc65 bug */ + if (__alloca_alloc == (void *)__mini_malloc && __freed_list) { chk = __freed_list; __freed_list = m_next(__freed_list); goto try_this; diff --git a/Library/libs/fuzix/Makefile b/Library/libs/fuzix/Makefile index f38e10a6..4424cf6b 100644 --- a/Library/libs/fuzix/Makefile +++ b/Library/libs/fuzix/Makefile @@ -65,6 +65,7 @@ ASRCS += syscall__profil.s ASRCS += syscall_uadmin.s ASRCS += syscall_nice.s ASRCS += syscall__sigdisp.s +ASRCS += syscall_flock.s ASRCALL = $(ASRCS) $(ASYS) diff --git a/Library/libs/fwrite.c b/Library/libs/fwrite.c index c89b540a..4dc5e434 100644 --- a/Library/libs/fwrite.c +++ b/Library/libs/fwrite.c @@ -14,7 +14,7 @@ * * But first we check to see if there's space in the buffer. */ -int fwrite(void *buf, size_t size, size_t nelm, FILE * fp) +int fwrite(const void *buf, size_t size, size_t nelm, FILE * fp) { int len; register int v; diff --git a/Library/libs/gets.c b/Library/libs/gets.c index 4f2e77e8..eb118f76 100644 --- a/Library/libs/gets.c +++ b/Library/libs/gets.c @@ -21,7 +21,7 @@ char *gets(char *str) /* BAD function; DON'T use it! */ return (((c == EOF) && (p == str)) ? NULL : str);/* NULL == EOF */ } -int puts(void *str) +int puts(const void *str) { register int n; if (((n = fputs(str, stdout)) == EOF) diff --git a/Library/libs/lstat.c b/Library/libs/lstat.c index a488bfc4..b9f22faf 100644 --- a/Library/libs/lstat.c +++ b/Library/libs/lstat.c @@ -2,7 +2,7 @@ #include #include -int lstat(char *name, struct stat *buf) +int lstat(const char *name, struct stat *buf) { int sts, fd = open(name, O_SYMLINK|O_RDONLY); diff --git a/Library/libs/pathconf.c b/Library/libs/pathconf.c index 74701dbb..f04135c7 100644 --- a/Library/libs/pathconf.c +++ b/Library/libs/pathconf.c @@ -5,7 +5,7 @@ long _pathconf(int name) { switch(name) { case _PC_LINK_MAX: - return 65535; + return 65535L; case _PC_MAX_CANON: case _PC_MAX_INPUT: return 132; /* In theory must be 256+ .. */ @@ -26,7 +26,7 @@ long _pathconf(int name) return -1; } -long pathconf(char *p, int name) +long pathconf(const char *p, int name) { p; return _pathconf(name); diff --git a/Library/libs/perror.c b/Library/libs/perror.c index 5e6d6383..8ec91eba 100644 --- a/Library/libs/perror.c +++ b/Library/libs/perror.c @@ -5,16 +5,16 @@ #include #include -static void wr2(char *str) +static void wr2(const char *str) { - char *p = str; + const char *p = str; while (*p) ++p; write(2, str, (unsigned int) (p - str)); } -void perror(char *str) +void perror(const char *str) { if (!str) str = "error"; diff --git a/Library/libs/printf.c b/Library/libs/printf.c index b0e8b5ce..911d461d 100644 --- a/Library/libs/printf.c +++ b/Library/libs/printf.c @@ -13,9 +13,9 @@ */ #include "printf.h" -#include "stdarg.h" +#include -int printf(char *fmt, ...) +int printf(const char *fmt, ...) { va_list ptr; int rv; diff --git a/Library/libs/readlink.c b/Library/libs/readlink.c index e4931458..6dd877d2 100644 --- a/Library/libs/readlink.c +++ b/Library/libs/readlink.c @@ -4,7 +4,7 @@ #include #include -int readlink(char *name, char *buf, int size) +int readlink(const char *name, char *buf, int size) { int sts, fd = open(name, O_SYMLINK|O_RDONLY); diff --git a/Library/libs/setjmp.c b/Library/libs/setjmp.c index 2ead9457..5180ae3a 100644 --- a/Library/libs/setjmp.c +++ b/Library/libs/setjmp.c @@ -6,6 +6,7 @@ */ #include +#if defined(__SDCC_z80) || defined(__SDCC_z180) static int _lngjmprv = 1; int setjmp (jmp_buf env) __naked /* int jmp_buf[7] */ @@ -145,3 +146,4 @@ __asm __endasm; } +#endif diff --git a/Library/libs/sprintf.c b/Library/libs/sprintf.c index 09ad93d3..8c28f198 100644 --- a/Library/libs/sprintf.c +++ b/Library/libs/sprintf.c @@ -17,13 +17,13 @@ /* Moved out of struct to keep SDCC generating what we want */ static FILE string[1] = { - {0, 0, /* TODO sdcc bug (unsigned char *)-1 */ 0xffff, + {0, 0, (unsigned char *) -1, 0, (unsigned char *) -1, -1, _IOFBF | __MODE_WRITE} }; -int sprintf(char *sp, char *fmt, ...) +int sprintf(char *sp, const char *fmt, ...) { va_list ptr; int rv; diff --git a/Library/libs/stdio0.c b/Library/libs/stdio0.c index 69c96eac..cf4222c5 100644 --- a/Library/libs/stdio0.c +++ b/Library/libs/stdio0.c @@ -42,7 +42,7 @@ STATIC void __stdio_close_all(VOID) } } -STATIC void __stdio_init_vars() +STATIC void __stdio_init_vars(void) { if (isatty(1)) stdout->mode |= _IOLBF; diff --git a/Library/libs/strcasestr.c b/Library/libs/strcasestr.c index 67cd83da..594fcfda 100644 --- a/Library/libs/strcasestr.c +++ b/Library/libs/strcasestr.c @@ -12,7 +12,7 @@ char *strcasestr(const char *needle, const char *haystack) /* check the lead byte here for speed */ if (tolower(*haystack) == c) { if (strncasecmp(needle, haystack, s) == 0) - return haystack; + return (char *)haystack; } haystack++; } diff --git a/Library/libs/strdup.c b/Library/libs/strdup.c index 18e4f8ea..0adda8ef 100644 --- a/Library/libs/strdup.c +++ b/Library/libs/strdup.c @@ -8,10 +8,10 @@ #include "string.h" /********************** Function strdup ************************************/ -char *strdup(char *s) +char *strdup(const char *s) { - register size_t len = strlen(s) + 1; - register char *p = (char *) malloc(len); + size_t len = strlen(s) + 1; + char *p = (char *) malloc(len); if (p) memcpy(p, s, len); /* Faster than strcpy */ diff --git a/Library/libs/stricmp.c b/Library/libs/stricmp.c index b664926f..67d8d0b3 100644 --- a/Library/libs/stricmp.c +++ b/Library/libs/stricmp.c @@ -8,10 +8,10 @@ #include /********************** Function stricmp ************************************/ -int stricmp(char *s, char *d) +int stricmp(const char *s, const char *d) { for (;;) { - unsigned char sc = *(uchar *) s++, dc = *(uchar *) d++; + unsigned char sc = *(const uchar *) s++, dc = *(const uchar *) d++; if (sc != dc) { if (_tolower(sc) != _tolower(dc)) diff --git a/Library/libs/strnicmp.c b/Library/libs/strnicmp.c index d32a9382..1ea68c95 100644 --- a/Library/libs/strnicmp.c +++ b/Library/libs/strnicmp.c @@ -9,10 +9,10 @@ /********************** Function strnicmp ************************************/ -int strnicmp(char *s, char *d, size_t l) +int strnicmp(const char *s, const char *d, size_t l) { while (l-- != 0) { - unsigned char sc = *(uchar *) s++, dc = *(uchar *) d++; + unsigned char sc = *(const uchar *) s++, dc = *(const uchar *) d++; if (sc != dc) { if (_tolower(sc) != _tolower(dc)) diff --git a/Library/libs/strsep.c b/Library/libs/strsep.c index fe93128c..4cede185 100644 --- a/Library/libs/strsep.c +++ b/Library/libs/strsep.c @@ -18,9 +18,10 @@ Cambridge, MA 02139, USA. */ #include -char *strsep(char **pp, char *delim) +char *strsep(char **pp, const char *delim) { - char *p, *q; + const char *p; + char *q; if (!(p = *pp)) return 0; @@ -31,5 +32,5 @@ char *strsep(char **pp, char *delim) } else *pp = 0; - return p; + return (char *)p; } diff --git a/Library/libs/utent.c b/Library/libs/utent.c index f4c2ebc0..f271c993 100644 --- a/Library/libs/utent.c +++ b/Library/libs/utent.c @@ -137,7 +137,7 @@ pututline(const struct utmp * utmp_entry) /* Ignoring untrapped errors */ errno=xerrno; - return utmp_entry; + return (struct utmp *)utmp_entry; } void diff --git a/Library/libs/vfprintf.c b/Library/libs/vfprintf.c index 138abc41..7cdcba8b 100644 --- a/Library/libs/vfprintf.c +++ b/Library/libs/vfprintf.c @@ -66,7 +66,7 @@ static int prtfld(FILE * op, unsigned char *buf, int ljustf, char sign, return (cnt); } -int vfprintf(FILE * op, char *fmt, va_list ap) +int vfprintf(FILE * op, const char *fmt, va_list ap) { register int i, ljustf, lval, preci, dpoint, width, radix, cnt = 0; char pad, sign, hash; diff --git a/Library/libs/vfscanf.c b/Library/libs/vfscanf.c index d52dfb08..0ee07e96 100644 --- a/Library/libs/vfscanf.c +++ b/Library/libs/vfscanf.c @@ -108,7 +108,7 @@ double fp_scan(int neg, int eneg, int n, int frac, int expo, int fraclen) #endif -int vfscanf(FILE *fp, char *fmt, va_list ap) +int vfscanf(FILE *fp, const char *fmt, va_list ap) { long n; int c, width, lval, cnt = 0; diff --git a/Library/libs/vprintf.c b/Library/libs/vprintf.c index 2c3b896d..c3dd7f64 100644 --- a/Library/libs/vprintf.c +++ b/Library/libs/vprintf.c @@ -14,7 +14,7 @@ #include "printf.h" -int vprintf(char *fmt, va_list ap) +int vprintf(const char *fmt, va_list ap) { return vfprintf(stdout, fmt, ap); } -- 2.34.1