diff --git a/include/signal.h b/include/signal.h index 90cb4acd..4491e914 100644 --- a/include/signal.h +++ b/include/signal.h @@ -24,31 +24,12 @@ #undef __MES_SIGNAL_H #include_next #else //! WITH_GLIBC -typedef int sigset_t; + +typedef int sigset_t; typedef int stack_t; -#ifndef __MES_PID_T -#define __MES_PID_T -typedef int pid_t; -#endif - -#ifndef __MES_UID_T -#define __MES_UID_T -typedef int uid_t; -#endif - -#ifndef __MES_CLOCK_T -#define __MES_CLOCK_T -#undef clock_t -typedef long clock_t; -#endif - -#ifndef __MES_SIGVAL_T -#define __MES_SIGVAL_T -#undef clock_t -typedef int sigval_t; -#endif +#include #define NSIG 30 #define SIGHUP 1 diff --git a/include/stdarg.h b/include/stdarg.h index 03487a56..65e3a61a 100644 --- a/include/stdarg.h +++ b/include/stdarg.h @@ -25,11 +25,7 @@ #include_next #else // ! WITH_GLIBC -#ifndef __MES_SIZE_T -#define __MES_SIZE_T -#undef size_t -typedef unsigned long size_t; -#endif +#include #if __GNUC__ typedef char* va_list; @@ -43,6 +39,7 @@ typedef int va_list; #define va_end(ap) (void)((ap) = 0) #define va_copy(dest, src) dest = src +int vfprintf (FILE *stream, char const *template, va_list ap); int vprintf (char const* format, va_list ap); int vsprintf (char *str, char const *format, va_list ap); int vsnprintf (char *str, size_t size, char const *format, va_list ap); diff --git a/include/stdio.h b/include/stdio.h index 174b86ac..0d2fd469 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -45,18 +45,6 @@ int g_stdout; #else // ! WITH_GLIBC -#ifndef __MESCCLIB__ -#define __MESCCLIB__ 15 -#endif - -#ifndef EOF -#define EOF -1 -#endif - -#ifndef NULL -#define NULL 0 -#endif - #ifndef BUFSIZ #define BUFSIZ 256 #endif @@ -65,11 +53,7 @@ int g_stdout; #define L_tmpnam 100 #endif -#if !defined (__MES_FILE_T) && ! defined (_FILE_T) -#define __MES_FILE_T -#define _FILE_T -typedef int FILE; -#endif +#include #define stdin (FILE*)0 #define stdout (FILE*)1 @@ -79,12 +63,6 @@ typedef int FILE; #define SEEK_CUR 1 #define SEEK_END 2 -#ifndef __MES_SIZE_T -#define __MES_SIZE_T -#undef size_t -typedef unsigned long size_t; -#endif - FILE *fdopen (int fd, char const *mode); FILE *fopen (char const *file_name, char const *mode); int eputc (int c); @@ -101,7 +79,7 @@ int fputc (int c, FILE *stream); int fputs (char const* s, FILE *stream); int fseek (FILE *stream, long offset, int whence); int getc (FILE *stream); -int getchar (); +int getchar (void); int printf (char const* format, ...); int putc (int c, FILE* stream); int putchar (int c); diff --git a/include/stdlib.h b/include/stdlib.h index 46cbd286..5c5beda2 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -28,11 +28,7 @@ #include_next #else // ! WITH_GLIBC -#ifndef __MES_SIZE_T -#define __MES_SIZE_T -#undef size_t -typedef unsigned long size_t; -#endif +#include #if _ALLOCA_UNSIGNED void * alloca (unsigned size); @@ -62,20 +58,13 @@ unsigned long long strtoull (char const *string, char **tailptr, int base); #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 -#ifndef NULL -#define NULL 0 -#endif - -#if __MESC__ +#ifndef __MES_COMPARISON_FN_T +#define __MES_COMPARISON_FN_T typedef int (*comparison_fn_t) (void const *, void const *); -#else -typedef void (*comparison_fn_t) (); #endif void * bsearch (void const *key, void const *array, size_t count, size_t size, comparison_fn_t compare); -#include - #endif // ! WITH_GLIBC #endif // __MES_STDLIB_H diff --git a/include/string.h b/include/string.h index eec1a440..51e226dd 100644 --- a/include/string.h +++ b/include/string.h @@ -48,14 +48,17 @@ typedef long ssize_t; void *memcpy (void *dest, void const *src, size_t n); void *memmove (void *dest, void const *src, size_t n); void *memset (void *s, int c, size_t n); +void * memchr (void const *block, int c, size_t size); int memcmp (void const *s1, void const *s2, size_t n); char *strcat (char *dest, char const *src); char *strchr (char const *s, int c); +int strcasecmp (char const *s1, char const *s2); int strcmp (char const*, char const*); char *strcpy (char *dest, char const *src); size_t strlen (char const*); char *strncpy (char *to, char const *from, size_t size); +int strncasecmp (char const *s1, char const *s2, size_t size); int strncmp (char const*, char const*, size_t); char *strrchr (char const *s, int c); char *strstr (char const *haystack, char const *needle); diff --git a/include/sys/stat.h b/include/sys/stat.h index 38e13d5f..4ccd5a7e 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -26,6 +26,7 @@ #else // ! WITH_GLIBC +#include #include #ifndef __MES_MODE_T @@ -45,11 +46,11 @@ struct stat long st_size; unsigned int st_blksize; unsigned int st_blocks; - long st_atime; + time_t st_atime; unsigned long st_atime_usec; - long st_mtime; + time_t st_mtime; unsigned long st_mtime_usec; - long st_ctime; + time_t st_ctime; unsigned long st_ctime_usec; unsigned int __foo0; unsigned int __foo1; diff --git a/include/sys/types.h b/include/sys/types.h index 1e7c310b..0b275b19 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -24,14 +24,39 @@ #undef __MES_SYS_TYPES_H #include_next #else // ! WITH_GLIBC + #include +#ifndef __MESCCLIB__ +#define __MESCCLIB__ 15 +#endif + +#ifndef EOF +#define EOF -1 +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef __MES_CLOCK_T +#define __MES_CLOCK_T +#undef clock_t +typedef long clock_t; +#endif + #ifndef __MES_DEV_T #define __MES_DEV_T #undef dev_t typedef int dev_t; #endif +#if !defined (__MES_FILE_T) && ! defined (_FILE_T) +#define __MES_FILE_T +#define _FILE_T +typedef int FILE; +#endif + #ifndef __MES_GID_T #define __MES_GID_T #undef gid_t @@ -44,18 +69,48 @@ typedef int gid_t; typedef unsigned ino_t; #endif +#ifndef __MES_INTPTR_T +#define __MES_INTPTR_T +#undef intptr_t +typedef long intptr_t; +#endif + +#ifndef __MES_OFF_T +#define __MES_OFF_T +#undef off_t +typedef unsigned long off_t; +#endif + #ifndef __MES_PID_T #define __MES_PID_T #undef pid_t typedef int pid_t; #endif +#ifndef __MES_PTRDIFF_T +#define __MES_PTRDIFF_T +#undef ptrdiff_t +typedef long ptrdiff_t; +#endif + +#ifndef __MES_SIGVAL_T +#define __MES_SIGVAL_T +#undef clock_t +typedef int sigval_t; +#endif + #ifndef __MES_SIZE_T #define __MES_SIZE_T #undef size_t typedef unsigned long size_t; #endif +#ifndef __MES_SSIZE_T +#define __MES_SSIZE_T +#undef ssize_t +typedef long ssize_t; +#endif + #ifndef __MES_UID_T #define __MES_UID_T #undef uid_t diff --git a/include/unistd.h b/include/unistd.h index 3db8dde9..cda0dd14 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -29,6 +29,7 @@ #else // ! WITH_GLIBC +#include #ifndef NULL #define NULL 0 #endif @@ -45,42 +46,6 @@ #define STDERR_FILE_NO 2 #endif // STDIN_FILE_NO -#ifndef __MES_OFF_T -#define __MES_OFF_T -#undef off_t -typedef unsigned long off_t; -#endif - -#ifndef __MES_SIZE_T -#define __MES_SIZE_T -#undef size_t -typedef unsigned long size_t; -#endif - -#ifndef __MES_SSIZE_T -#define __MES_SSIZE_T -#undef ssize_t -typedef long ssize_t; -#endif - -#ifndef __MES_INTPTR_T -#define __MES_INTPTR_T -#undef intptr_t -typedef long intptr_t; -#endif - -#ifndef __MES_PTRDIFF_T -#define __MES_PTRDIFF_T -#undef ptrdiff_t -typedef long ptrdiff_t; -#endif - -#ifndef __MES_PID_T -#define __MES_PID_T -#undef pid_t -typedef int pid_t; -#endif - #ifndef R_OK #define F_OK 0 #define X_OK 1 @@ -94,8 +59,10 @@ int close (int fd); int execv (char const *file_name, char *const argv[]); int execve (char const *file, char *const argv[], char *const env[]); int execvp (char const *file, char *const argv[]); -int fork (); +int fork (void); char *getcwd (char *buf, size_t size); +uid_t getgid (void); +uid_t getuid (void); int isatty (int fd); int link (char const *oldname, char const *newname); off_t lseek (int fd, off_t offset, int whence);