summaryrefslogtreecommitdiff
path: root/libc/stdlib
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-04-06 20:28:45 +0000
committerEric Andersen <andersen@codepoet.org>2001-04-06 20:28:45 +0000
commit6278781655261a5011376b2fa2600996e32ca889 (patch)
tree11783e71b36c8c546c4dc02dff355b0f2478978b /libc/stdlib
parenta704ccaa5232184844cd67315951b39f85a6ba04 (diff)
Fix include/errno.h to not use kernel header, and instead use bits/errno.h.
This required we use _LIBC instead of __LIBC__ to be consistent with glibc. This had some sideffects in sys/syscalls.h. While fixing things, I made everything use __set_errno() for (eventual) thread support. -Erik
Diffstat (limited to 'libc/stdlib')
-rw-r--r--libc/stdlib/atexit.c2
-rw-r--r--libc/stdlib/mkstemp.c4
-rw-r--r--libc/stdlib/mktemp.c4
-rw-r--r--libc/stdlib/realpath.c8
-rw-r--r--libc/stdlib/setenv.c2
-rw-r--r--libc/stdlib/strto_l.c6
-rw-r--r--libc/stdlib/strto_ll.c6
-rw-r--r--libc/stdlib/strtod.c2
8 files changed, 17 insertions, 17 deletions
diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c
index b18e7951d..1ff8d9004 100644
--- a/libc/stdlib/atexit.c
+++ b/libc/stdlib/atexit.c
@@ -51,7 +51,7 @@ static void atexit_handler(void)
int atexit(vfuncp ptr)
{
if ((__uClibc_cleanup == 0) || (__atexit_count >= __UCLIBC_MAX_ATEXIT)) {
- errno = ENOMEM;
+ __set_errno(ENOMEM);
return -1;
}
if (ptr) {
diff --git a/libc/stdlib/mkstemp.c b/libc/stdlib/mkstemp.c
index 551f03199..241f8af8a 100644
--- a/libc/stdlib/mkstemp.c
+++ b/libc/stdlib/mkstemp.c
@@ -13,13 +13,13 @@ char *template;
int l = strlen(template);
if (l < 6) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
for (i = l - 6; i < l; i++)
if (template[i] != 'X') {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
diff --git a/libc/stdlib/mktemp.c b/libc/stdlib/mktemp.c
index 4b9f71d47..9d65d0441 100644
--- a/libc/stdlib/mktemp.c
+++ b/libc/stdlib/mktemp.c
@@ -15,13 +15,13 @@ char *template;
struct stat stbuf;
if (l < 6) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return 0;
}
for (i = l - 6; i < l; i++)
if (template[i] != 'X') {
- errno = EINVAL;
+ __set_errno(EINVAL);
return 0;
}
diff --git a/libc/stdlib/realpath.c b/libc/stdlib/realpath.c
index 73903371f..c3628b745 100644
--- a/libc/stdlib/realpath.c
+++ b/libc/stdlib/realpath.c
@@ -60,7 +60,7 @@ char resolved_path[];
/* Make a copy of the source path since we may need to modify it. */
if (strlen(path) >= PATH_MAX - 2) {
- errno = ENAMETOOLONG;
+ __set_errno(ENAMETOOLONG);
return NULL;
}
strcpy(copy_path, path);
@@ -110,7 +110,7 @@ char resolved_path[];
/* Safely copy the next pathname component. */
while (*path != '\0' && *path != '/') {
if (path > max_path) {
- errno = ENAMETOOLONG;
+ __set_errno(ENAMETOOLONG);
return NULL;
}
*new_path++ = *path++;
@@ -118,7 +118,7 @@ char resolved_path[];
#ifdef S_IFLNK
/* Protect against infinite loops. */
if (readlinks++ > MAX_READLINKS) {
- errno = ELOOP;
+ __set_errno(ELOOP);
return NULL;
}
/* See if latest pathname component is a symlink. */
@@ -143,7 +143,7 @@ char resolved_path[];
while (*(--new_path) != '/');
/* Safe sex check. */
if (strlen(path) + n >= PATH_MAX - 2) {
- errno = ENAMETOOLONG;
+ __set_errno(ENAMETOOLONG);
return NULL;
}
/* Insert symlink contents into path. */
diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c
index a027ced96..25eb641ba 100644
--- a/libc/stdlib/setenv.c
+++ b/libc/stdlib/setenv.c
@@ -83,7 +83,7 @@ int setenv(const char *name, const char *value, int replace)
if (new_environ[size] == NULL)
{
free (new_environ);
- errno = ENOMEM;
+ __set_errno(ENOMEM);
result = -1;
goto do_return;
}
diff --git a/libc/stdlib/strto_l.c b/libc/stdlib/strto_l.c
index 16b29f5d6..aed6ef346 100644
--- a/libc/stdlib/strto_l.c
+++ b/libc/stdlib/strto_l.c
@@ -137,7 +137,7 @@ unsigned long _strto_l(const char *str, char **endptr, int base, int uflag)
negative = 0; /* since unsigned returns ULONG_MAX */
}
#if _STRTO_ERRNO
- errno = ERANGE;
+ __set_errno(ERANGE);
#endif
} else {
number = number * base + digit;
@@ -155,7 +155,7 @@ unsigned long _strto_l(const char *str, char **endptr, int base, int uflag)
if (negative) {
if (!uflag && (number > ((unsigned long)(-(1+LONG_MIN)))+1)) {
#if _STRTO_ERRNO
- errno = ERANGE;
+ __set_errno(ERANGE);
#endif
return (unsigned long) LONG_MIN;
}
@@ -163,7 +163,7 @@ unsigned long _strto_l(const char *str, char **endptr, int base, int uflag)
} else {
if (!uflag && (number > (unsigned long) LONG_MAX)) {
#if _STRTO_ERRNO
- errno = ERANGE;
+ __set_errno(ERANGE);
#endif
return LONG_MAX;
}
diff --git a/libc/stdlib/strto_ll.c b/libc/stdlib/strto_ll.c
index 4b2854b8e..e127b181d 100644
--- a/libc/stdlib/strto_ll.c
+++ b/libc/stdlib/strto_ll.c
@@ -137,7 +137,7 @@ unsigned long long _strto_ll(const char *str, char **endptr, int base, int uflag
negative = 0; /* since unsigned returns ULONG_LONG_MAX */
}
#if _STRTO_ERRNO
- errno = ERANGE;
+ __set_errno(ERANGE);
#endif
} else {
number = number * base + digit;
@@ -155,7 +155,7 @@ unsigned long long _strto_ll(const char *str, char **endptr, int base, int uflag
if (negative) {
if (!uflag && (number > ((unsigned long long)(-(1+LONG_LONG_MIN)))+1)) {
#if _STRTO_ERRNO
- errno = ERANGE;
+ __set_errno(ERANGE);
#endif
return (unsigned long long) LONG_LONG_MIN;
}
@@ -163,7 +163,7 @@ unsigned long long _strto_ll(const char *str, char **endptr, int base, int uflag
} else {
if (!uflag && (number > (unsigned long long) LONG_LONG_MAX)) {
#if _STRTO_ERRNO
- errno = ERANGE;
+ __set_errno(ERANGE);
#endif
return LONG_LONG_MAX;
}
diff --git a/libc/stdlib/strtod.c b/libc/stdlib/strtod.c
index dff5aeb73..7359d5cf9 100644
--- a/libc/stdlib/strtod.c
+++ b/libc/stdlib/strtod.c
@@ -248,7 +248,7 @@ double strtod(const char *str, char **endptr)
#if _STRTOD_ERRNO
if (_zero_or_inf_check(number)) {
- errno=ERANGE;
+ __set_errno(ERANGE);
}
#endif