shithub: scc

Download patch

ref: e43e3872b43d9c1b49e9e5c015b32258c3735ad8
parent: 197533c60f4f89dbe35912d241d7295603925f29
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Aug 27 07:44:57 EDT 2021

libc: Update include to last version

This code is being updated out of the tree of scc and
it is time to synchroniza both copies now.

--- a/include/assert.h
+++ b/include/assert.h
@@ -1,8 +1,8 @@
-extern void __assert(char *exp, char *file, long line);
+extern void __assert(char *, char *, long);
 
 #undef assert
 #ifndef NDEBUG
 # define assert(exp) ((exp) ? (void) 0 : __assert(#exp, __FILE__, __LINE__))
 #else
-# define assert(exp) ((void)0)
+# define assert(exp) ((void) 0)
 #endif
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -1,30 +1,30 @@
 #ifndef _CTYPE_H
 #define _CTYPE_H
 
-extern int isalnum(int c);
-extern int isalpha(int c);
-extern int islower(int c);
-extern int isupper(int c);
-extern int isdigit(int c);
-extern int isxdigit(int c);
-extern int iscntrl(int c);
-extern int isgraph(int c);
-extern int isspace(int c);
-extern int isblank(int c);
-extern int isprint(int c);
-extern int ispunct(int c);
-extern int tolower(int c);
-extern int toupper(int c);
+extern int isalnum(int);
+extern int isalpha(int);
+extern int islower(int);
+extern int isupper(int);
+extern int isdigit(int);
+extern int isxdigit(int);
+extern int iscntrl(int);
+extern int isgraph(int);
+extern int isspace(int);
+extern int isblank(int);
+extern int isprint(int);
+extern int ispunct(int);
+extern int tolower(int);
+extern int toupper(int);
 
 
-#define _U	0x01	/* upper */
-#define _L	0x02	/* lower */
-#define _D	0x04	/* digit */
-#define _C	0x08	/* cntrl */
-#define _P	0x10	/* punct */
-#define _S	0x20	/* white space (space/lf/tab) */
-#define _X	0x40	/* hex char */
-#define _SP	0x80	/* hard space (0x20) */
+#define _U  0x01 /* upper */
+#define _L  0x02 /* lower */
+#define _D  0x04 /* digit */
+#define _C  0x08 /* cntrl */
+#define _P  0x10 /* punct */
+#define _S  0x20 /* white space (space/lf/tab) */
+#define _X  0x40 /* hex char */
+#define _SP 0x80 /* hard space (0x20) */
 
 extern const unsigned char __ctype[];
 
@@ -39,8 +39,5 @@
 #define isspace(c)  ((__ctype+1)[c] & (_S))
 #define isupper(c)  ((__ctype+1)[c] & (_U))
 #define isxdigit(c) ((__ctype+1)[c] & (_D|_X))
-
-#define isascii(c) ((unsigned)(c)<=0x7f)
-#define toascii(c) ((unsigned)(c)&0x7f)
 
 #endif
--- a/include/float.h
+++ b/include/float.h
@@ -1,4 +1,6 @@
 #ifndef _FLOAT_H
 #define _FLOAT_H
+
 #error float.h is not supported yet
+
 #endif
--- a/include/locale.h
+++ b/include/locale.h
@@ -31,9 +31,15 @@
 	char p_sign_posn;
 	char n_sign_posn;
 	char int_frac_digits;
+	char int_p_cs_precedes;
+	char int_n_cs_precedes;
+	char int_p_sep_by_space;
+	char int_n_sep_by_space;
+	char int_p_sign_posn;
+	char int_n_sign_posn;
 };
 
-extern char *setlocale(int category, const char *locale);
+extern char *setlocale(int, const char *);
 extern struct lconv *localeconv(void);
 
 #endif
--- a/include/math.h
+++ b/include/math.h
@@ -1,4 +1,6 @@
 #ifndef _MATH_H
 #define _MATH_H
+
 #error math.h is not supported yet
+
 #endif
--- a/include/setjmp.h
+++ b/include/setjmp.h
@@ -3,8 +3,8 @@
 
 #include <arch/setjmp.h>
 
-extern int setjmp(jmp_buf env);
-extern void longjmp(jmp_buf env, int val);
+extern int setjmp(jmp_buf);
+extern void longjmp(jmp_buf, int);
 
 #define setjmp setjmp
 
--- a/include/signal.h
+++ b/include/signal.h
@@ -3,7 +3,7 @@
 
 #include <sys/signal.h>
 
-void ( *signal(int signum, void (*handler)(int)) ) (int);
-int raise(int sig);
+void (*signal(int, void (*handler)(int)))(int);
+int raise(int);
 
 #endif
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -2,12 +2,11 @@
 #define _STDDEF_H
 
 #define _NEED_SIZET
-#define _NEED_WCHAR_T
 #define _NEED_PTRDIFFT
 #define _NEED_NULL
 #include <sys/cdefs.h>
 #include <arch/cdefs.h>
 
-#define offsetof(st, m) ((size_t)&(((st *)0)->m))
+#define offsetof(st, m) ((size_t) &(((st *) 0)->m))
 
 #endif
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -3,115 +3,113 @@
 
 #define _NEED_NULL
 #define _NEED_SIZET
+#include <sys/stdio.h>
 #include <arch/cdefs.h>
-#include <arch/stdio.h>
 
 #ifndef FOPEN_MAX
 #define FOPEN_MAX 12
 #endif
 
-#define EOF            -1
-#define SEEK_SET        0
-#define SEEK_CUR        1
-#define SEEK_END        2
+#define EOF     -1
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
 
+#define _IOWRITE (1 << 0)
+#define _IOREAD  (1 << 1)
+#define _IORW    (1 << 2)
+#define _IOEOF   (1 << 3)
+#define _IOERR   (1 << 4)
+#define _IOSTRG  (1 << 5)
+#define _IOTXT   (1 << 6)
+#define _IOFBF   (1 << 7)
+#define _IOLBF   (1 << 8)
+#define _IONBF   (1 << 9)
+#define _IOALLOC (1 <<10)
 
-#define _IOWRITE        (1 << 0)
-#define _IOREAD         (1 << 1)
-#define _IORW           (1 << 2)
-#define _IOEOF          (1 << 3)
-#define _IOERR          (1 << 4)
-#define _IOSTRG         (1 << 5)
-#define _IOTXT          (1 << 6)
-#define _IOFBF          (1 << 7)
-#define _IOLBF          (1 << 8)
-#define _IONBF          (1 << 9)
-#define _IOALLOC        (1 <<10)
-
+/**
+ * struct FILE - opaque structure containing information about a file
+ * @fd: file descriptor
+ * @buf: pointer to i/o buffer
+ * @rp: read pointer
+ * @wp: write pointer
+ * @lp: write pointer used when line-buffering
+ * @len: actual length of buffer
+ * @flags: file open mode
+ * @unbuf: tiny buffer for unbuffered i/o
+ */
 typedef struct {
-	int fd;        	        /* file descriptor */
-	unsigned char *buf;     /* pointer to i/o buffer */
-	unsigned char *rp;      /* read pointer */
-	unsigned char *wp;      /* write pointer */
-	unsigned char *lp;      /* write pointer used when line-buffering */
-	size_t len;             /* actual length of buffer */
+	int fd;
+	unsigned char *buf;
+	unsigned char *rp;
+	unsigned char *wp;
+	unsigned char *lp;
+	size_t len;
 	unsigned short flags;
-	unsigned char unbuf[1];  /* tiny buffer for unbuffered io */
+	unsigned char unbuf[1];
 } FILE;
 
 extern FILE __iob[FOPEN_MAX];
 
-#define	stdin	(&__iob[0])
-#define	stdout	(&__iob[1])
-#define	stderr	(&__iob[2])
+#define	stdin  (&__iob[0])
+#define	stdout (&__iob[1])
+#define	stderr (&__iob[2])
 
-extern int remove(const char *filename);
-extern int rename(const char *old, const char *new);
+extern int remove(const char *);
+extern int rename(const char *, const char *);
 extern FILE *tmpfile(void);
-extern char *tmpnam(char *s);
-extern int fclose(FILE *fp);
-extern int fflush(FILE *fp);
-extern FILE *fopen(const char * restrict fname, const char * restrict mode);
-extern FILE *freopen(const char * restrict fname, const char * restrict mode,
-                     FILE * restrict fp);
-extern void setbuf(FILE * restrict fp, char * restrict buf);
-extern int setvbuf(FILE * restrict fp,
-                   char * restrict buf, int mode, size_t size);
-extern int fprintf(FILE * restrict fp, const char * restrict fmt, ...);
-extern int fscanf(FILE * restrict fp, const char * restrict fmt, ...);
-extern int printf(const char * restrict fmt, ...);
-extern int scanf(const char * restrict fmt, ...);
-extern int snprintf(char * restrict s,
-                    size_t n, const char * restrict fmt, ...);
-extern int sprintf(char * restrict s, const char * restrict fmt, ...);
-extern int sscanf(const char * restrict s, const char * restrict fmt, ...);
+extern char *tmpnam(char *);
+extern int fclose(FILE *);
+extern int fflush(FILE *);
+extern FILE *fopen(const char *restrict, const char *restrict);
+extern FILE *freopen(const char *restrict, const char *restrict,
+                     FILE *restrict);
+extern void setbuf(FILE *restrict, char *restrict);
+extern int setvbuf(FILE *restrict, char *restrict, int, size_t);
+extern int fprintf(FILE *restrict, const char *restrict, ...);
+extern int fscanf(FILE *restrict, const char *restrict, ...);
+extern int printf(const char *restrict, ...);
+extern int scanf(const char *restrict, ...);
+extern int snprintf(char *restrict, size_t, const char *restrict, ...);
+extern int sprintf(char *restrict, const char *restrict, ...);
+extern int sscanf(const char *restrict, const char *restrict, ...);
 
 #ifdef _STDARG_H
-extern int vfprintf(FILE * restrict fp,
-                    const char * restrict fmt, va_list arg);
-extern int vfscanf(FILE * restrict fp,
-                   const char * restrict fmt, va_list arg);
-extern int vprintf(const char * restrict fmt, va_list arg);
-extern int vscanf(const char * restrict fmt, va_list arg);
-extern int vsnprintf(char * restrict s, size_t n, const char * restrict fmt,
-                     va_list arg);
-extern int vsprintf(char * restrict s,
-                    const char * restrict fmt, va_list arg);
-extern int vsscanf(const char * restrict s,
-                   const char * restrict fmt, va_list arg);
+extern int vfprintf(FILE *restrict, const char *restrict, va_list);
+extern int vfscanf(FILE *restrict, const char *restrict, va_list);
+extern int vprintf(const char *restrict, va_list);
+extern int vscanf(const char *restrict, va_list);
+extern int vsnprintf(char *restrict, size_t, const char *restrict, va_list);
+extern int vsprintf(char *restrict, const char *restrict, va_list);
+extern int vsscanf(const char *restrict, const char *restrict, va_list);
 #endif
 
-extern int fgetc(FILE *fp);
-extern char *fgets(char * restrict s, int n, FILE * restrict fp);
-extern int fputc(int c, FILE *fp);
-extern int fputs(const char * restrict s, FILE * restrict fp);
-extern int getc(FILE *fp);
+extern int fgetc(FILE *);
+extern char *fgets(char *restrict, int, FILE *restrict);
+extern int fputc(int, FILE *);
+extern int fputs(const char *restrict, FILE *restrict);
+extern int getc(FILE *);
 extern int getchar(void);
-extern char *gets(char *s);
-extern int putc(int c, FILE *fp);
-extern int putchar(int c);
-extern int puts(const char *s);
-extern int ungetc(int c, FILE *fp);
-extern size_t fread(void * restrict ptr, size_t size, size_t nmemb,
-             FILE * restrict fp);
-extern size_t fwrite(const void * restrict ptr, size_t size, size_t nmemb,
-              FILE * restrict fp);
-extern int fgetpos(FILE * restrict fp, fpos_t * restrict pos);
-extern int fseek(FILE *fp, long int offset, int whence);
-extern int fsetpos(FILE *fp, const fpos_t *pos);
-extern long int ftell(FILE *fp);
-extern void rewind(FILE *fp);
-extern void clearerr(FILE *fp);
-extern int feof(FILE *fp);
-extern int ferror(FILE *fp);
-extern void perror(const char *s);
+extern char *gets(char *);
+extern int putc(int, FILE *);
+extern int putchar(int);
+extern int puts(const char *);
+extern int ungetc(int, FILE *);
+extern size_t fread(void *restrict, size_t, size_t, FILE *restrict);
+extern size_t fwrite(const void *restrict, size_t, size_t, FILE *restrict);
+extern int fseek(FILE *, long int, int);
+extern long int ftell(FILE *);
+extern void rewind(FILE *);
+extern void clearerr(FILE *);
+extern int feof(FILE *);
+extern int ferror(FILE *);
+extern void perror(const char *);
 
-extern int __getc(FILE *fp);
-extern int __putc(int, FILE *fp);
+extern int __getc(FILE *);
+extern int __putc(int, FILE *);
 
 #define getc(fp)            ((fp)->rp >= (fp)->wp ? __getc(fp) : *(fp)->rp++)
 #define putc(c, fp)         ((fp)->wp >= (fp)->rp ? __putc(c,fp) : (*(fp)->wp++ = c))
-
 #define ferror(fp)          ((fp)->flags & _IOERR)
 #define feof(fp)            ((fp)->flags & _IOEOF)
 #define clearerr(fp)        (void) ((fp)->flags &= ~(_IOERR|_IOEOF))
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -5,6 +5,7 @@
 #define _NEED_SIZET
 #define _NEED_WCHART
 #include <sys/cdefs.h>
+#include <sys/stdlib.h>
 #include <arch/cdefs.h>
 #include <arch/stdlib.h>
 
@@ -25,46 +26,44 @@
 	long long quot, rem;
 } lldiv_t;
 
-extern double atof(const char *nptr);
-extern int atoi(const char *nptr);
-extern long int atol(const char *nptr);
-extern long long int atoll(const char *nptr);
-extern double strtod(const char * restrict nptr, char ** restrict endptr);
-extern float strtof(const char * restrict nptr, char ** restrict endptr);
-extern long double strtold(const char * restrict nptr, char ** restrict endptr);
-extern long int strtol(const char * restrict nptr, char ** restrict endptr, int base);
-extern long long int strtoll(const char * restrict nptr, char ** restrict endptr,
-                             int base);
-extern unsigned long int strtoul(const char * restrict nptr, char ** restrict endptr,
-                                 int base);
-extern unsigned long long int strtoull(const char * restrict nptr,
-                                       char ** restrict endptr, int base);
+extern double atof(const char *);
+extern int atoi(const char *);
+extern long int atol(const char *);
+extern long long int atoll(const char *);
+extern double strtod(const char *restrict, char **restrict);
+extern float strtof(const char *restrict, char **restrict);
+extern long double strtold(const char *restrict, char **restrict);
+extern long int strtol(const char *restrict, char **restrict, int);
+extern long long int strtoll(const char *restrict, char **restrict, int);
+extern unsigned long int strtoul(const char *restrict, char **restrict, int);
+extern unsigned long long int strtoull(const char *restrict, char **restrict,
+                                       int);
 extern int rand(void);
-extern void srand(unsigned int seed);
-extern void *calloc(size_t nmemb, size_t size);
-extern void free(void *ptr);
-extern void *malloc(size_t size);
-extern void *realloc(void *ptr, size_t size);
+extern void srand(unsigned int);
+extern void *calloc(size_t, size_t);
+extern void free(void *);
+extern void *malloc(size_t);
+extern void *realloc(void *, size_t);
 extern void abort(void);
-extern int atexit(void (*func)(void));
-extern void exit(int status);
-extern void _Exit(int status);
-extern char *getenv(const char *name);
-extern int system(const char *string);
-extern void *bsearch(const void *key, const void *base, size_t nmemb, size_t size,
-                     int (*compar)(const void *, const void *));
-extern void qsort(void *base, size_t nmemb, size_t size,
-                  int (*compar)(const void *, const void *));
-extern int abs(int j);
-extern long int labs(long int j);
-extern long long int llabs(long long int j);
-extern div_t div(int numer, int denom);
-extern ldiv_t ldiv(long int numer, long int denom);
-extern lldiv_t lldiv(long long int numer, long long int denom);
-extern int mblen(const char *s, size_t n);
-extern int mbtowc(wchar_t * restrict pwc, const char * restrict s, size_t n);
-extern int wctomb(char *s, wchar_t wchar);
-extern size_t mbstowcs(wchar_t * restrict pwcs, const char * restrict s, size_t n);
-extern size_t wcstombs(char * restrict s, const wchar_t * restrict pwcs, size_t n);
+extern int atexit(void (*)(void));
+extern void exit(int);
+extern void _Exit(int);
+extern char *getenv(const char *);
+extern int system(const char *);
+extern void *bsearch(const void *, const void *, size_t, size_t,
+                     int (*)(const void *, const void *));
+extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
+extern int abs(int);
+extern long int labs(long int);
+extern long long int llabs(long long int);
+extern div_t div(int, int);
+extern ldiv_t ldiv(long int, long int);
+extern lldiv_t lldiv(long long int, long long int);
+
+extern int mblen(const char *, size_t);
+extern int mbtowc(wchar_t *restrict, const char *restrict, size_t);
+extern int wctomb(char *, wchar_t);
+extern size_t mbstowcs(wchar_t *restrict, const char *restrict, size_t);
+extern size_t wcstombs(char *restrict, const wchar_t *restrict, size_t);
 
 #endif
--- a/include/string.h
+++ b/include/string.h
@@ -7,27 +7,27 @@
 #include <arch/cdefs.h>
 #include <arch/string.h>
 
-extern void *memcpy(void * restrict s1, const void * restrict s2, size_t n);
-extern void *memmove(void *s1, const void *s2, size_t n);
-extern char *strcpy(char * restrict s1, const char * restrict s2);
-extern char *strncpy(char * restrict s1, const char * restrict s2, size_t n);
-extern char *strcat(char * restrict s1, const char * restrict s2);
-extern char *strncat(char * restrict s1, const char * restrict s2, size_t n);
-extern int memcmp(const void *s1, const void *s2, size_t n);
-extern int strcmp(const char *s1, const char *s2);
-extern int strcoll(const char *s1, const char *s2);
-extern int strncmp(const char *s1, const char *s2, size_t n);
-extern size_t strxfrm(char * restrict s1, const char * restrict s2, size_t n);
-extern void *memchr(const void *s, int c, size_t n);
-extern char *strchr(const char *s, int c);
-extern size_t strcspn(const char *s1, const char *s2);
-extern char *strpbrk(const char *s1, const char *s2);
-extern char *strrchr(const char *s, int c);
-extern size_t strspn(const char *s1, const char *s2);
-extern char *strstr(const char *s1, const char *s2);
-extern char *strtok(char * restrict s1, const char * restrict s2);
-extern void *memset(void *s, int c, size_t n);
-extern char *strerror(int errnum);
-extern size_t strlen(const char *s);
+extern void *memcpy(void *restrict, const void *restrict, size_t);
+extern void *memmove(void *, const void *, size_t);
+extern char *strcpy(char *restrict, const char *restrict);
+extern char *strncpy(char *restrict, const char *restrict, size_t);
+extern char *strcat(char *restrict, const char *restrict);
+extern char *strncat(char *restrict, const char *restrict, size_t);
+extern int memcmp(const void *, const void *, size_t);
+extern int strcmp(const char *, const char *);
+extern int strcoll(const char *, const char *);
+extern int strncmp(const char *, const char *, size_t);
+extern size_t strxfrm(char *restrict, const char *restrict, size_t);
+extern void *memchr(const void *, int, size_t);
+extern char *strchr(const char *, int);
+extern size_t strcspn(const char *, const char *);
+extern char *strpbrk(const char *, const char *);
+extern char *strrchr(const char *, int);
+extern size_t strspn(const char *, const char *);
+extern char *strstr(const char *, const char *);
+extern char *strtok(char *restrict, const char *restrict);
+extern void *memset(void *, int, size_t);
+extern char *strerror(int);
+extern size_t strlen(const char *);
 
 #endif
--- a/include/time.h
+++ b/include/time.h
@@ -27,15 +27,14 @@
 };
 
 extern clock_t clock(void);
-extern double difftime(time_t time1, time_t time0);
-extern time_t mktime(struct tm *timeptr);
-extern time_t time(time_t *timer);
-extern char *asctime(const struct tm *timeptr);
-extern char *ctime(const time_t *timer);
-extern struct tm *gmtime(const time_t *timer);
-extern struct tm *localtime(const time_t *timer);
-extern size_t strftime(char * restrict s, size_t maxsize,
-                       const char * restrict format,
-                       const struct tm * restrict timeptr);
+extern double difftime(time_t, time_t);
+extern time_t mktime(struct tm *);
+extern time_t time(time_t *);
+extern char *asctime(const struct tm *);
+extern char *ctime(const time_t *);
+extern struct tm *gmtime(const time_t *);
+extern struct tm *localtime(const time_t *);
+extern size_t strftime(char *restrict, size_t, const char *restrict,
+                       const struct tm *restrict);
 
 #endif