[hackers] [scc] [libc] Make stdlib.h portable between architectures || Roberto E. Vargas Caballero
commit 47e3a55868b27696777f41692ef3bdde1388166d
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Feb 16 16:59:22 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Feb 16 16:59:22 2017 +0100
[libc] Make stdlib.h portable between architectures
diff --git a/libc/include/amd64-sysv/arch/stdlib.h b/libc/include/amd64-sysv/arch/stdlib.h
new file mode 100644
index 0000000..c9474e6
--- /dev/null
+++ b/libc/include/amd64-sysv/arch/stdlib.h
_AT_@ -0,0 +1,14 @@
+/* See LICENSE file for copyright and license details. */
+
+#ifndef _SIZET
+typedef unsigned long size_t;
+#define _SIZET
+#endif
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
+#define RAND_MAX 32767
diff --git a/libc/include/amd64-sysv/stdlib.h b/libc/include/amd64-sysv/stdlib.h
deleted file mode 100644
index 19280b1..0000000
--- a/libc/include/amd64-sysv/stdlib.h
+++ /dev/null
_AT_@ -1,56 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef _STDLIB_H
-#define _STDLIB_H
-
-#ifndef _SIZET
-typedef unsigned long size_t;
-#define _SIZET
-#endif
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-#define RAND_MAX 32767
-
-extern double atof(const char *ptr);
-extern int atoi(const char *s);
-extern long atol(const char *s);
-extern long long atoll(const char *s);
-
-extern float strtof(const char *s, char **end);
-extern double strtod(const char *s, char **end);
-extern long double strtold(const char *s, char **end);
-
-extern long strtol(const char *s, char **end, int base);
-extern long long strtoll(const char *s, char **end, int base);
-extern unsigned long stroul(const char *s, char **end, int base);
-extern unsigned long long stroull(const char *s, char **end, int base);
-
-extern void *calloc(size_t nitems, size_t size);
-extern void free(void *ptr);
-extern void *realloc(void *ptr, size_t size);
-
-extern void abort(void);
-extern int atexit(void (*func)(void));
-extern void exit(int status);
-extern char *getenv(const char *name);
-extern int system(const char *cmd);
-
-extern void *bsearch(const void *key,
- const void *base, size_t nitems, size_t size,
- int (*cmp)(const void *, const void *));
-extern void qsort(void *base, size_t nitems, size_t size,
- int (*cmp)(const void *, const void *));
-
-extern void abs(int x);
-/* div_t div(int num, int denom); */
-extern long labs(long int x);
-/* ldiv_t ldiv(long int number, long int denom); */
-
-extern int rand(void);
-extern void srand(unsigned seed);
-
-#endif
diff --git a/libc/include/i386-sysv/arch/stdlib.h b/libc/include/i386-sysv/arch/stdlib.h
new file mode 100644
index 0000000..c9474e6
--- /dev/null
+++ b/libc/include/i386-sysv/arch/stdlib.h
_AT_@ -0,0 +1,14 @@
+/* See LICENSE file for copyright and license details. */
+
+#ifndef _SIZET
+typedef unsigned long size_t;
+#define _SIZET
+#endif
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
+#define RAND_MAX 32767
diff --git a/libc/include/i386-sysv/stdlib.h b/libc/include/i386-sysv/stdlib.h
deleted file mode 100644
index 19280b1..0000000
--- a/libc/include/i386-sysv/stdlib.h
+++ /dev/null
_AT_@ -1,56 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef _STDLIB_H
-#define _STDLIB_H
-
-#ifndef _SIZET
-typedef unsigned long size_t;
-#define _SIZET
-#endif
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-#define RAND_MAX 32767
-
-extern double atof(const char *ptr);
-extern int atoi(const char *s);
-extern long atol(const char *s);
-extern long long atoll(const char *s);
-
-extern float strtof(const char *s, char **end);
-extern double strtod(const char *s, char **end);
-extern long double strtold(const char *s, char **end);
-
-extern long strtol(const char *s, char **end, int base);
-extern long long strtoll(const char *s, char **end, int base);
-extern unsigned long stroul(const char *s, char **end, int base);
-extern unsigned long long stroull(const char *s, char **end, int base);
-
-extern void *calloc(size_t nitems, size_t size);
-extern void free(void *ptr);
-extern void *realloc(void *ptr, size_t size);
-
-extern void abort(void);
-extern int atexit(void (*func)(void));
-extern void exit(int status);
-extern char *getenv(const char *name);
-extern int system(const char *cmd);
-
-extern void *bsearch(const void *key,
- const void *base, size_t nitems, size_t size,
- int (*cmp)(const void *, const void *));
-extern void qsort(void *base, size_t nitems, size_t size,
- int (*cmp)(const void *, const void *));
-
-extern void abs(int x);
-/* div_t div(int num, int denom); */
-extern long labs(long int x);
-/* ldiv_t ldiv(long int number, long int denom); */
-
-extern int rand(void);
-extern void srand(unsigned seed);
-
-#endif
diff --git a/libc/include/qbe/arch/stdlib.h b/libc/include/qbe/arch/stdlib.h
new file mode 100644
index 0000000..c9474e6
--- /dev/null
+++ b/libc/include/qbe/arch/stdlib.h
_AT_@ -0,0 +1,14 @@
+/* See LICENSE file for copyright and license details. */
+
+#ifndef _SIZET
+typedef unsigned long size_t;
+#define _SIZET
+#endif
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
+#define RAND_MAX 32767
diff --git a/libc/include/qbe/stdlib.h b/libc/include/qbe/stdlib.h
deleted file mode 100644
index 19280b1..0000000
--- a/libc/include/qbe/stdlib.h
+++ /dev/null
_AT_@ -1,56 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef _STDLIB_H
-#define _STDLIB_H
-
-#ifndef _SIZET
-typedef unsigned long size_t;
-#define _SIZET
-#endif
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-#define RAND_MAX 32767
-
-extern double atof(const char *ptr);
-extern int atoi(const char *s);
-extern long atol(const char *s);
-extern long long atoll(const char *s);
-
-extern float strtof(const char *s, char **end);
-extern double strtod(const char *s, char **end);
-extern long double strtold(const char *s, char **end);
-
-extern long strtol(const char *s, char **end, int base);
-extern long long strtoll(const char *s, char **end, int base);
-extern unsigned long stroul(const char *s, char **end, int base);
-extern unsigned long long stroull(const char *s, char **end, int base);
-
-extern void *calloc(size_t nitems, size_t size);
-extern void free(void *ptr);
-extern void *realloc(void *ptr, size_t size);
-
-extern void abort(void);
-extern int atexit(void (*func)(void));
-extern void exit(int status);
-extern char *getenv(const char *name);
-extern int system(const char *cmd);
-
-extern void *bsearch(const void *key,
- const void *base, size_t nitems, size_t size,
- int (*cmp)(const void *, const void *));
-extern void qsort(void *base, size_t nitems, size_t size,
- int (*cmp)(const void *, const void *));
-
-extern void abs(int x);
-/* div_t div(int num, int denom); */
-extern long labs(long int x);
-/* ldiv_t ldiv(long int number, long int denom); */
-
-extern int rand(void);
-extern void srand(unsigned seed);
-
-#endif
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
new file mode 100644
index 0000000..58ad666
--- /dev/null
+++ b/libc/include/stdlib.h
_AT_@ -0,0 +1,45 @@
+/* See LICENSE file for copyright and license details. */
+#ifndef _STDLIB_H
+#define _STDLIB_H
+
+#include <arch/stdlib.h>
+
+extern double atof(const char *ptr);
+extern int atoi(const char *s);
+extern long atol(const char *s);
+extern long long atoll(const char *s);
+
+extern float strtof(const char *s, char **end);
+extern double strtod(const char *s, char **end);
+extern long double strtold(const char *s, char **end);
+
+extern long strtol(const char *s, char **end, int base);
+extern long long strtoll(const char *s, char **end, int base);
+extern unsigned long stroul(const char *s, char **end, int base);
+extern unsigned long long stroull(const char *s, char **end, int base);
+
+extern void *calloc(size_t nitems, size_t size);
+extern void free(void *ptr);
+extern void *realloc(void *ptr, size_t size);
+
+extern void abort(void);
+extern int atexit(void (*func)(void));
+extern void exit(int status);
+extern char *getenv(const char *name);
+extern int system(const char *cmd);
+
+extern void *bsearch(const void *key,
+ const void *base, size_t nitems, size_t size,
+ int (*cmp)(const void *, const void *));
+extern void qsort(void *base, size_t nitems, size_t size,
+ int (*cmp)(const void *, const void *));
+
+extern void abs(int x);
+/* div_t div(int num, int denom); */
+extern long labs(long int x);
+/* ldiv_t ldiv(long int number, long int denom); */
+
+extern int rand(void);
+extern void srand(unsigned seed);
+
+#endif
diff --git a/libc/include/z80/arch/stdlib.h b/libc/include/z80/arch/stdlib.h
new file mode 100644
index 0000000..aa817a0
--- /dev/null
+++ b/libc/include/z80/arch/stdlib.h
_AT_@ -0,0 +1,14 @@
+/* See LICENSE file for copyright and license details. */
+
+#ifndef _SIZET
+typedef unsigned size_t;
+#define _SIZET
+#endif
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
+#define RAND_MAX 32767
diff --git a/libc/include/z80/stdlib.h b/libc/include/z80/stdlib.h
deleted file mode 100644
index c05b0b7..0000000
--- a/libc/include/z80/stdlib.h
+++ /dev/null
_AT_@ -1,56 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef _STDLIB_H
-#define _STDLIB_H
-
-#ifndef _SIZET
-typedef unsigned size_t;
-#define _SIZET
-#endif
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
-#define EXIT_FAILURE 1
-#define EXIT_SUCCESS 0
-#define RAND_MAX 32767
-
-extern double atof(const char *ptr);
-extern int atoi(const char *s);
-extern long atol(const char *s);
-extern long long atoll(const char *s);
-
-extern float strtof(const char *s, char **end);
-extern double strtod(const char *s, char **end);
-extern long double strtold(const char *s, char **end);
-
-extern long strtol(const char *s, char **end, int base);
-extern long long strtoll(const char *s, char **end, int base);
-extern unsigned long stroul(const char *s, char **end, int base);
-extern unsigned long long stroull(const char *s, char **end, int base);
-
-extern void *calloc(size_t nitems, size_t size);
-extern void free(void *ptr);
-extern void *realloc(void *ptr, size_t size);
-
-extern void abort(void);
-extern int atexit(void (*func)(void));
-extern void exit(int status);
-extern char *getenv(const char *name);
-extern int system(const char *cmd);
-
-extern void *bsearch(const void *key,
- const void *base, size_t nitems, size_t size,
- int (*cmp)(const void *, const void *));
-extern void qsort(void *base, size_t nitems, size_t size,
- int (*cmp)(const void *, const void *));
-
-extern void abs(int x);
-/* div_t div(int num, int denom); */
-extern long labs(long int x);
-/* ldiv_t ldiv(long int number, long int denom); */
-
-extern int rand(void);
-extern void srand(unsigned seed);
-
-#endif
Received on Thu Feb 16 2017 - 17:00:08 CET
This archive was generated by hypermail 2.3.0
: Thu Feb 16 2017 - 17:00:27 CET