summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-02-14 18:41:25 -0500
committerRich Felker <dalias@aerifal.cx>2011-02-14 18:41:25 -0500
commit74eea628cf43355ba2b227f0bb3c31697d637761 (patch)
tree9fe300db7b7fa7f541bdfa41176d0f6333851e74 /include
parent80695b1d1e64a026c473a33965e680444e863e34 (diff)
downloadmusl-74eea628cf43355ba2b227f0bb3c31697d637761.tar.gz
extensive header cleanup for standards conformance & correctness
thanks to Peter Mazinger (psm) for pointing many of these issues out and submitting a patch on which this commit is loosely based
Diffstat (limited to 'include')
-rwxr-xr-xinclude/bits/alltypes.h.sh5
-rw-r--r--include/bits/socket.h2
-rw-r--r--include/bits/stat.h9
-rw-r--r--include/bits/uio.h4
-rw-r--r--include/bits/wait.h2
-rw-r--r--include/ctype.h17
-rw-r--r--include/langinfo.h2
-rw-r--r--include/limits.h5
-rw-r--r--include/math.h36
-rw-r--r--include/setjmp.h18
-rw-r--r--include/strings.h7
-rw-r--r--include/sys/socket.h1
-rw-r--r--include/sys/stat.h5
-rw-r--r--include/sys/time.h2
-rw-r--r--include/sys/uio.h3
15 files changed, 63 insertions, 55 deletions
diff --git a/include/bits/alltypes.h.sh b/include/bits/alltypes.h.sh
index 595bf13e..c909d7b0 100755
--- a/include/bits/alltypes.h.sh
+++ b/include/bits/alltypes.h.sh
@@ -68,9 +68,9 @@ TYPEDEF long long intmax_t;
TYPEDEF unsigned long long uintmax_t;
TYPEDEF long time_t;
-TYPEDEF unsigned int useconds_t;
+TYPEDEF unsigned useconds_t;
TYPEDEF int suseconds_t;
-STRUCT timeval { time_t tv_sec; long tv_usec; };
+STRUCT timeval { time_t tv_sec; int tv_usec; };
STRUCT timespec { time_t tv_sec; long tv_nsec; };
TYPEDEF int pid_t;
@@ -111,5 +111,6 @@ TYPEDEF int nl_item;
TYPEDEF struct __locale * locale_t;
+STRUCT iovec { void *iov_base; size_t iov_len; };
EOF
diff --git a/include/bits/socket.h b/include/bits/socket.h
index 7a51f792..c8bac6b2 100644
--- a/include/bits/socket.h
+++ b/include/bits/socket.h
@@ -1,5 +1,3 @@
-struct iovec;
-
struct msghdr
{
void *msg_name;
diff --git a/include/bits/stat.h b/include/bits/stat.h
index 1ef34698..bb9314a5 100644
--- a/include/bits/stat.h
+++ b/include/bits/stat.h
@@ -15,11 +15,8 @@ struct stat
off_t st_size;
blksize_t st_blksize;
blkcnt_t st_blocks;
- time_t st_atime;
- unsigned long __st_atime_nsec;
- time_t st_mtime;
- unsigned long __st_mtime_nsec;
- time_t st_ctime;
- unsigned long __st_ctime_nsec;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
ino_t st_ino;
};
diff --git a/include/bits/uio.h b/include/bits/uio.h
deleted file mode 100644
index 43252653..00000000
--- a/include/bits/uio.h
+++ /dev/null
@@ -1,4 +0,0 @@
-struct iovec {
- void *iov_base;
- size_t iov_len;
-};
diff --git a/include/bits/wait.h b/include/bits/wait.h
index ca9b57e0..ae3f1012 100644
--- a/include/bits/wait.h
+++ b/include/bits/wait.h
@@ -6,6 +6,8 @@
#define WCONTINUED 8
#define WNOWAIT 0x1000000
+#if defined(__XOPEN_SOURCE) || defined(__GNU_SOURCE)
#define P_ALL 0
#define P_PID 1
#define P_PGID 2
+#endif
diff --git a/include/ctype.h b/include/ctype.h
index 02f81fa7..97b9737c 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -16,12 +16,6 @@ int isxdigit(int);
int tolower(int);
int toupper(int);
-int isascii(int);
-int toascii(int);
-
-#define _tolower(a) ((a)|0x20)
-#define _toupper(a) ((a)&0x5f)
-
#define isalpha(a) ((unsigned)(((a)|32)-'a') < 26)
#define isdigit(a) ((unsigned)((a)-'0') < 10)
#define islower(a) ((unsigned)((a)-'a') < 26)
@@ -29,7 +23,10 @@ int toascii(int);
#define isprint(a) ((unsigned)((a)-0x20) < 0x5f)
#define isgraph(a) ((unsigned)((a)-0x21) < 0x5e)
-#if 1
+
+
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
#define __NEED_locale_t
#include <bits/alltypes.h>
@@ -48,6 +45,12 @@ int isupper_l(int, locale_t);
int isxdigit_l(int, locale_t);
int tolower_l(int, locale_t);
int toupper_l(int, locale_t);
+
+int isascii(int);
+int toascii(int);
+#define _tolower(a) ((a)|0x20)
+#define _toupper(a) ((a)&0x5f)
+
#endif
#endif
diff --git a/include/langinfo.h b/include/langinfo.h
index 4d9e0997..b9c55695 100644
--- a/include/langinfo.h
+++ b/include/langinfo.h
@@ -6,6 +6,7 @@ extern "C" {
#endif
#define __NEED_nl_item
+#define __NEED_locale_t
#include <bits/alltypes.h>
@@ -77,6 +78,7 @@ extern "C" {
#define NOSTR 0x50003
char *nl_langinfo(nl_item);
+char *nl_langinfo_l(nl_item, locale_t);
#ifdef __cplusplus
}
diff --git a/include/limits.h b/include/limits.h
index 6d7dfdbb..6757012b 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -49,6 +49,8 @@
#define NL_SETMAX 255
#define NL_TEXTMAX 2048
+#endif
+
/* POSIX/SUS requirements follow. These numbers come directly
* from SUS and have nothing to do with the host system. */
@@ -56,6 +58,7 @@
#define _POSIX_AIO_MAX 1
#define _POSIX_ARG_MAX 4096
#define _POSIX_CHILD_MAX 25
+#define _POSIX_CLOCKRES_MIN 20000000
#define _POSIX_DELAYTIMER_MAX 32
#define _POSIX_HOST_NAME_MAX 255
#define _POSIX_LINK_MAX 8
@@ -104,5 +107,3 @@
#define _XOPEN_PATH_MAX 1024
#endif
-
-#endif
diff --git a/include/math.h b/include/math.h
index cc9befb7..fffdf4f7 100644
--- a/include/math.h
+++ b/include/math.h
@@ -6,20 +6,6 @@
#define __NEED___uint64_t
#include <bits/alltypes.h>
-#define M_E 2.7182818284590452354 /* e */
-#define M_LOG2E 1.4426950408889634074 /* log_2 e */
-#define M_LOG10E 0.43429448190325182765 /* log_10 e */
-#define M_LN2 0.69314718055994530942 /* log_e 2 */
-#define M_LN10 2.30258509299404568402 /* log_e 10 */
-#define M_PI 3.14159265358979323846 /* pi */
-#define M_PI_2 1.57079632679489661923 /* pi/2 */
-#define M_PI_4 0.78539816339744830962 /* pi/4 */
-#define M_1_PI 0.31830988618379067154 /* 1/pi */
-#define M_2_PI 0.63661977236758134308 /* 2/pi */
-#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
-#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
-#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
-
#define __MAKE_FLOAT(i) (((union { int __i; float __f; }){ .__i = i }).__f)
#define NAN __MAKE_FLOAT(0x7fc00000)
@@ -286,15 +272,31 @@ double trunc(double);
float truncf(float);
long double truncl(long double);
-/* XSI stuff */
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
+#define M_E 2.7182818284590452354 /* e */
+#define M_LOG2E 1.4426950408889634074 /* log_2 e */
+#define M_LOG10E 0.43429448190325182765 /* log_10 e */
+#define M_LN2 0.69314718055994530942 /* log_e 2 */
+#define M_LN10 2.30258509299404568402 /* log_e 10 */
+#define M_PI 3.14159265358979323846 /* pi */
+#define M_PI_2 1.57079632679489661923 /* pi/2 */
+#define M_PI_4 0.78539816339744830962 /* pi/4 */
+#define M_1_PI 0.31830988618379067154 /* 1/pi */
+#define M_2_PI 0.63661977236758134308 /* 2/pi */
+#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
+#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
+#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
double j0(double);
double j1(double);
double jn(int, double);
-double scalb(double, double);
double y0(double);
double y1(double);
double yn(int, double);
-
extern int signgam;
+#endif
+
+#ifdef _GNU_SOURCE
+double scalb(double, double);
+#endif
#endif
diff --git a/include/setjmp.h b/include/setjmp.h
index 6288c846..a5bb1e20 100644
--- a/include/setjmp.h
+++ b/include/setjmp.h
@@ -6,19 +6,27 @@ extern "C" {
#endif
#include <bits/setjmp.h>
-typedef unsigned long sigjmp_buf[(1024+sizeof(jmp_buf))/sizeof(long)];
+
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
+typedef unsigned long sigjmp_buf[(1024+sizeof(jmp_buf))/sizeof(long)];
#ifdef _GNU_SOURCE
#define jmp_buf sigjmp_buf
#endif
+int sigsetjmp (sigjmp_buf, int);
+void siglongjmp (sigjmp_buf, int);
+#endif
-int setjmp (jmp_buf);
+
+#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
int _setjmp (jmp_buf);
-int sigsetjmp (sigjmp_buf, int);
+void _longjmp (jmp_buf, int);
+#endif
+
+int setjmp (jmp_buf);
void longjmp (jmp_buf, int);
-void _longjmp (jmp_buf, int);
-void siglongjmp (sigjmp_buf, int);
#define setjmp setjmp
#define longjmp longjmp
diff --git a/include/strings.h b/include/strings.h
index 059e3309..aa35668c 100644
--- a/include/strings.h
+++ b/include/strings.h
@@ -5,13 +5,6 @@
extern "C" {
#endif
-#undef NULL
-#ifdef __cplusplus
-#define NULL 0
-#else
-#define NULL ((void*)0)
-#endif
-
#define __NEED_size_t
#include <bits/alltypes.h>
diff --git a/include/sys/socket.h b/include/sys/socket.h
index 78c93056..4005eb6d 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -11,6 +11,7 @@ extern "C" {
#define __NEED_uid_t
#define __NEED_pid_t
#define __NEED_gid_t
+#define __NEED_struct_iovec
#include <bits/alltypes.h>
diff --git a/include/sys/stat.h b/include/sys/stat.h
index 36575b0e..627890f4 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -14,11 +14,16 @@ extern "C" {
#define __NEED_time_t
#define __NEED_blksize_t
#define __NEED_blkcnt_t
+#define __NEED_struct_timespec
#include <bits/alltypes.h>
#include <bits/stat.h>
+#define st_atime st_atim.tv_sec
+#define st_mtime st_mtim.tv_sec
+#define st_ctime st_ctim.tv_sec
+
#define S_IFMT 0170000
#define S_IFDIR 0040000
diff --git a/include/sys/time.h b/include/sys/time.h
index 9b3bfb99..edaf6af6 100644
--- a/include/sys/time.h
+++ b/include/sys/time.h
@@ -9,7 +9,7 @@ extern "C" {
#define __NEED_time_t
#define __NEED_suseconds_t
-#define __NEED_timeval
+#define __NEED_struct_timeval
#include <bits/alltypes.h>
diff --git a/include/sys/uio.h b/include/sys/uio.h
index 7b068c0c..11b6bd27 100644
--- a/include/sys/uio.h
+++ b/include/sys/uio.h
@@ -3,11 +3,10 @@
#define __NEED_size_t
#define __NEED_ssize_t
+#define __NEED_struct_iovec
#include <bits/alltypes.h>
-#include <bits/uio.h>
-
ssize_t readv (int, const struct iovec *, int);
ssize_t writev (int, const struct iovec *, int);