summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Rules.mak2
-rw-r--r--include/errno.h9
-rw-r--r--include/features.h2
-rw-r--r--include/grp.h2
-rw-r--r--include/pwd.h2
-rw-r--r--include/utmp.h2
-rw-r--r--libc/inet/hostid.c2
-rw-r--r--libc/inet/rpc/bindresvport.c4
-rw-r--r--libc/misc/dirent/closedir.c4
-rw-r--r--libc/misc/dirent/dirfd.c2
-rw-r--r--libc/misc/dirent/opendir.c6
-rw-r--r--libc/misc/dirent/readdir.c6
-rw-r--r--libc/misc/dirent/rewinddir.c2
-rw-r--r--libc/misc/dirent/seekdir.c2
-rw-r--r--libc/misc/dirent/telldir.c4
-rw-r--r--libc/misc/internals/__uClibc_main.c2
-rw-r--r--libc/misc/lock/flock.c2
-rw-r--r--libc/misc/regex/regex.c3
-rw-r--r--libc/misc/syslog/syslog.c2
-rw-r--r--libc/misc/time/adjtime.c2
-rw-r--r--libc/pwd_grp/fgetgrent.c2
-rw-r--r--libc/pwd_grp/fgetpwent.c2
-rw-r--r--libc/pwd_grp/getgrnam.c2
-rw-r--r--libc/pwd_grp/getpw.c4
-rw-r--r--libc/pwd_grp/getpwnam.c2
-rw-r--r--libc/pwd_grp/putpwent.c2
-rw-r--r--libc/signal/sigaddset.c2
-rw-r--r--libc/signal/sigdelset.c2
-rw-r--r--libc/signal/sigemptyset.c2
-rw-r--r--libc/signal/sigfillset.c2
-rw-r--r--libc/signal/sigismem.c2
-rw-r--r--libc/stdio/getdelim.c6
-rw-r--r--libc/stdio/popen.c2
-rw-r--r--libc/stdio/remove.c2
-rw-r--r--libc/stdio/stdio.c14
-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
-rw-r--r--libc/string/config.c4
-rw-r--r--libc/sysdeps/linux/arm/bits/errno.h60
-rw-r--r--libc/sysdeps/linux/common/create_module.c2
-rw-r--r--libc/sysdeps/linux/common/errno.c1
-rw-r--r--libc/sysdeps/linux/common/getdnnm.c4
-rw-r--r--libc/sysdeps/linux/common/gethstnm.c4
-rw-r--r--libc/sysdeps/linux/common/seteuid.c2
-rw-r--r--libc/sysdeps/linux/common/syscalls.c2
-rw-r--r--libc/sysdeps/linux/i386/__init_brk.c6
-rw-r--r--libc/sysdeps/linux/i386/brk.c6
-rw-r--r--libc/sysdeps/linux/i386/sbrk.c6
-rw-r--r--libc/sysdeps/linux/m68k/ptrace.c4
-rw-r--r--libc/termios/tcgetsid.c4
-rw-r--r--libc/termios/tcsetattr.c6
-rw-r--r--libc/termios/termios.c6
-rw-r--r--libc/termios/ttyname.c6
-rw-r--r--libc/unistd/getcwd.c10
-rw-r--r--libc/unistd/sysconf.c8
61 files changed, 176 insertions, 109 deletions
diff --git a/Rules.mak b/Rules.mak
index 88911d59f..887933dd3 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -34,7 +34,7 @@ endif
ARFLAGS=r
-CCFLAGS=$(WARNINGS) $(OPTIMIZATION) -fno-builtin -nostdinc $(CPUFLAGS) -I$(TOPDIR)include -I$(GCCINCDIR) -I. -D__LIBC__
+CCFLAGS=$(WARNINGS) $(OPTIMIZATION) -fno-builtin -nostdinc $(CPUFLAGS) -I$(TOPDIR)include -I$(GCCINCDIR) -I. -D_LIBC
CFLAGS=$(ARCH_CFLAGS) $(CCFLAGS) $(DEFS) $(ARCH_CFLAGS2)
diff --git a/include/errno.h b/include/errno.h
index f96590c2e..da7f7a0e4 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -1,8 +1,8 @@
-#ifndef __ERRNO_H
-#define __ERRNO_H
+#ifndef _ERRNO_H
+#define _ERRNO_H
#include <features.h>
-#include <linux/errno.h>
+#include <bits/errno.h>
extern int sys_nerr;
extern const char *const sys_errlist[];
@@ -10,8 +10,11 @@ extern const char *const sys_errlist[];
#define _sys_nerr sys_nerr
#define _sys_errlist sys_errlist
+#ifndef errno
extern int errno;
+#endif
extern void perror __P ((__const char* __s));
extern char* strerror __P ((int __errno));
+
#endif
diff --git a/include/features.h b/include/features.h
index 93c41d7a1..475d62a85 100644
--- a/include/features.h
+++ b/include/features.h
@@ -15,7 +15,7 @@
* their developers intended. This is IMHO, pardonable, since these defines
* are not really intended to check for the presence of a particular library,
* but rather are used to define an _interface_. */
-#if !defined __LIBC__ || defined __FORCE_GLIBC__
+#if !defined _LIBC || defined __FORCE_GLIBC__
# define __GNU_LIBRARY__ 6
# define __GLIBC__ 2
# define __GLIBC_MINOR__ 1
diff --git a/include/grp.h b/include/grp.h
index 96b2b4b65..4ecef44f0 100644
--- a/include/grp.h
+++ b/include/grp.h
@@ -27,7 +27,7 @@ extern int setgroups __P ((size_t n, __const gid_t * groups));
extern int initgroups __P ((__const char * user, gid_t gid));
-#ifdef __LIBC__
+#ifdef _LIBC
extern struct group * __getgrent __P ((int grp_fd));
#endif
diff --git a/include/pwd.h b/include/pwd.h
index 6cadcf38a..64d8bc6ef 100644
--- a/include/pwd.h
+++ b/include/pwd.h
@@ -47,7 +47,7 @@ extern int fgetpwent_r __P ((FILE *__restrict __stream,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result));
-#ifdef __LIBC__
+#ifdef _LIBC
/* This is used internally to uClibc */
extern int __getpwent_r(struct passwd * passwd, char * line_buff,
size_t buflen, int pwd_fd);
diff --git a/include/utmp.h b/include/utmp.h
index 102af2f6c..c98caa5ce 100644
--- a/include/utmp.h
+++ b/include/utmp.h
@@ -45,7 +45,7 @@ extern struct utmp * getutline __P ((struct utmp *));
extern struct utmp * pututline __P ((struct utmp *));
extern void endutent __P ((void));
-#ifdef __LIBC__
+#ifdef _LIBC
struct utmp * __getutent __P ((int));
#endif
diff --git a/libc/inet/hostid.c b/libc/inet/hostid.c
index 84a441acf..0873aa4fc 100644
--- a/libc/inet/hostid.c
+++ b/libc/inet/hostid.c
@@ -17,7 +17,7 @@ int sethostid(long int new_id)
int fd;
int ret;
- if (geteuid() || getuid()) return errno=EPERM;
+ if (geteuid() || getuid()) return __set_errno(EPERM);
if ((fd=open(HOSTID,O_CREAT|O_WRONLY,0644))<0) return -1;
ret = write(fd,(void *)&new_id,sizeof(new_id)) == sizeof(new_id)
? 0 : -1;
diff --git a/libc/inet/rpc/bindresvport.c b/libc/inet/rpc/bindresvport.c
index ad8678416..e71dff7f4 100644
--- a/libc/inet/rpc/bindresvport.c
+++ b/libc/inet/rpc/bindresvport.c
@@ -62,14 +62,14 @@ struct sockaddr_in *sin;
bzero(sin, sizeof(*sin));
sin->sin_family = AF_INET;
} else if (sin->sin_family != AF_INET) {
- errno = EPFNOSUPPORT;
+ __set_errno(EPFNOSUPPORT);
return (-1);
}
if (port == 0) {
port = (getpid() % NPORTS) + STARTPORT;
}
res = -1;
- errno = EADDRINUSE;
+ __set_errno(EADDRINUSE);
for (i = 0; i < NPORTS && res < 0 && errno == EADDRINUSE; i++) {
sin->sin_port = htons(port++);
if (port > ENDPORT) {
diff --git a/libc/misc/dirent/closedir.c b/libc/misc/dirent/closedir.c
index f2ead00f2..a2ac83b17 100644
--- a/libc/misc/dirent/closedir.c
+++ b/libc/misc/dirent/closedir.c
@@ -9,13 +9,13 @@ int closedir(DIR * dir)
int fd;
if (!dir) {
- errno = EBADF;
+ __set_errno(EBADF);
return -1;
}
/* We need to check dd_fd. */
if (dir->dd_fd == -1) {
- errno = EBADF;
+ __set_errno(EBADF);
return -1;
}
fd = dir->dd_fd;
diff --git a/libc/misc/dirent/dirfd.c b/libc/misc/dirent/dirfd.c
index d401dccd2..d6c1e6647 100644
--- a/libc/misc/dirent/dirfd.c
+++ b/libc/misc/dirent/dirfd.c
@@ -4,7 +4,7 @@
int dirfd(DIR * dir)
{
if (!dir || dir->dd_fd == -1) {
- errno = EBADF;
+ __set_errno(EBADF);
return -1;
}
diff --git a/libc/misc/dirent/opendir.c b/libc/misc/dirent/opendir.c
index 329515447..0ac1637b3 100644
--- a/libc/misc/dirent/opendir.c
+++ b/libc/misc/dirent/opendir.c
@@ -21,7 +21,7 @@ DIR *opendir(const char *name)
if (stat(name, &statbuf))
return NULL;
if (!S_ISDIR(statbuf.st_mode)) {
- errno = ENOTDIR;
+ __set_errno(ENOTDIR);
return NULL;
}
if ((fd = open(name, O_RDONLY)) < 0)
@@ -33,7 +33,7 @@ DIR *opendir(const char *name)
return NULL;
if (!(ptr = malloc(sizeof(*ptr)))) {
close(fd);
- errno = ENOMEM;
+ __set_errno(ENOMEM);
return NULL;
}
@@ -44,7 +44,7 @@ DIR *opendir(const char *name)
if (!(buf = malloc(ptr->dd_max))) {
close(fd);
free(ptr);
- errno = ENOMEM;
+ __set_errno(ENOMEM);
return NULL;
}
ptr->dd_fd = fd;
diff --git a/libc/misc/dirent/readdir.c b/libc/misc/dirent/readdir.c
index a755ed24d..0bb03f4c2 100644
--- a/libc/misc/dirent/readdir.c
+++ b/libc/misc/dirent/readdir.c
@@ -14,7 +14,7 @@ struct dirent *readdir(DIR * dir)
struct dirent *de;
if (!dir) {
- errno = EBADF;
+ __set_errno(EBADF);
return NULL;
}
@@ -37,7 +37,7 @@ struct dirent *readdir(DIR * dir)
dir->dd_getdents = no_getdents;
abort();
}
- errno = result;
+ __set_errno(result);
}
return NULL;
@@ -63,7 +63,7 @@ struct dirent *readdir(DIR * dir)
if (strlen((char *) &de->d_type) > 10)
de->d_name[10] = 0;
strcpy(dir->dd_buf->d_name, (char *) &de->d_name);
- errno = 0;
+ __set_errno(0);
return dir->dd_buf;
}
diff --git a/libc/misc/dirent/rewinddir.c b/libc/misc/dirent/rewinddir.c
index 9d147fca2..2fff9101c 100644
--- a/libc/misc/dirent/rewinddir.c
+++ b/libc/misc/dirent/rewinddir.c
@@ -7,7 +7,7 @@
void rewinddir(DIR * dir)
{
if (!dir) {
- errno = EBADF;
+ __set_errno(EBADF);
return;
}
lseek(dir->dd_fd, 0, SEEK_SET);
diff --git a/libc/misc/dirent/seekdir.c b/libc/misc/dirent/seekdir.c
index 7e4f24f72..3ff9f5da9 100644
--- a/libc/misc/dirent/seekdir.c
+++ b/libc/misc/dirent/seekdir.c
@@ -6,7 +6,7 @@
void seekdir(DIR * dir, off_t offset)
{
if (!dir) {
- errno = EBADF;
+ __set_errno(EBADF);
return;
}
dir->dd_nextoff = lseek(dir->dd_fd, offset, SEEK_SET);
diff --git a/libc/misc/dirent/telldir.c b/libc/misc/dirent/telldir.c
index 33e163aba..872cddbf1 100644
--- a/libc/misc/dirent/telldir.c
+++ b/libc/misc/dirent/telldir.c
@@ -8,7 +8,7 @@ off_t telldir(DIR * dir)
off_t offset;
if (!dir) {
- errno = EBADF;
+ __set_errno(EBADF);
return -1;
}
@@ -27,7 +27,7 @@ off_t telldir(DIR * dir)
break;
default:
- errno = EBADF;
+ __set_errno(EBADF);
offset = -1;
}
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 23ca473ee..26c028015 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -64,7 +64,7 @@ void __uClibc_main(int argc, char **argv, char **envp)
* have resulted in errno being set nonzero, so set it to 0 before
* we call main.
*/
- errno = 0;
+ __set_errno(0);
/*
* Finally, invoke application's main and then exit.
diff --git a/libc/misc/lock/flock.c b/libc/misc/lock/flock.c
index 3c1264655..80d15dfd4 100644
--- a/libc/misc/lock/flock.c
+++ b/libc/misc/lock/flock.c
@@ -42,7 +42,7 @@ int flock( int fd, int operation)
lbuf.l_type = F_UNLCK;
break;
default:
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
diff --git a/libc/misc/regex/regex.c b/libc/misc/regex/regex.c
index 64e754ee0..19e3e0cbb 100644
--- a/libc/misc/regex/regex.c
+++ b/libc/misc/regex/regex.c
@@ -19,6 +19,9 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+/* To exclude some unwanted junk.... */
+#undef _LIBC
+
/* AIX requires this to be the first thing in the file. */
#if defined _AIX && !defined REGEX_MALLOC
#pragma alloca
diff --git a/libc/misc/syslog/syslog.c b/libc/misc/syslog/syslog.c
index 53a00f86d..b3c53ff7d 100644
--- a/libc/misc/syslog/syslog.c
+++ b/libc/misc/syslog/syslog.c
@@ -224,7 +224,7 @@ vsyslog( int pri, const char *fmt, va_list ap )
*/
end = tbuf + sizeof(tbuf) - 1;
- errno = saved_errno;
+ __set_errno(saved_errno);
p += vsnprintf(p, end - p, fmt, ap);
if (p >= end || p < head_end) { /* Returned -1 in case of error... */
static char truncate_msg[12] = "[truncated] ";
diff --git a/libc/misc/time/adjtime.c b/libc/misc/time/adjtime.c
index 12c1a2a40..2a9190e9b 100644
--- a/libc/misc/time/adjtime.c
+++ b/libc/misc/time/adjtime.c
@@ -24,7 +24,7 @@ adjtime(const struct timeval * itv, struct timeval * otv)
tmp.tv_usec = itv->tv_usec % 1000000L;
if (tmp.tv_sec > MAX_SEC || tmp.tv_sec < MIN_SEC)
{
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
tntx.offset = tmp.tv_usec + tmp.tv_sec * 1000000L;
diff --git a/libc/pwd_grp/fgetgrent.c b/libc/pwd_grp/fgetgrent.c
index 09701a38b..50aa01722 100644
--- a/libc/pwd_grp/fgetgrent.c
+++ b/libc/pwd_grp/fgetgrent.c
@@ -25,7 +25,7 @@
struct group *fgetgrent(FILE * file)
{
if (file == NULL) {
- errno = EINTR;
+ __set_errno(EINTR);
return NULL;
}
diff --git a/libc/pwd_grp/fgetpwent.c b/libc/pwd_grp/fgetpwent.c
index 74c59427c..aab1ec744 100644
--- a/libc/pwd_grp/fgetpwent.c
+++ b/libc/pwd_grp/fgetpwent.c
@@ -32,7 +32,7 @@ int fgetpwent_r (FILE *file, struct passwd *password,
char *buff, size_t buflen, struct passwd **crap)
{
if (file == NULL) {
- errno = EINTR;
+ __set_errno(EINTR);
return -1;
}
return(__getpwent_r(password, buff, buflen, fileno(file)));
diff --git a/libc/pwd_grp/getgrnam.c b/libc/pwd_grp/getgrnam.c
index 999404284..6f2634cee 100644
--- a/libc/pwd_grp/getgrnam.c
+++ b/libc/pwd_grp/getgrnam.c
@@ -30,7 +30,7 @@ struct group *getgrnam(const char *name)
struct group *group;
if (name == NULL) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return NULL;
}
diff --git a/libc/pwd_grp/getpw.c b/libc/pwd_grp/getpw.c
index f0663c917..83f6fe973 100644
--- a/libc/pwd_grp/getpw.c
+++ b/libc/pwd_grp/getpw.c
@@ -28,7 +28,7 @@ int getpw(uid_t uid, char *buf)
struct passwd *passwd;
if (buf == NULL) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
if ((passwd = getpwuid(uid)) == NULL)
@@ -38,7 +38,7 @@ int getpw(uid_t uid, char *buf)
(buf, "%s:%s:%u:%u:%s:%s:%s", passwd->pw_name, passwd->pw_passwd,
passwd->pw_gid, passwd->pw_uid, passwd->pw_gecos, passwd->pw_dir,
passwd->pw_shell) < 0) {
- errno = ENOBUFS;
+ __set_errno(ENOBUFS);
return -1;
}
diff --git a/libc/pwd_grp/getpwnam.c b/libc/pwd_grp/getpwnam.c
index 399e24ddc..5cb4f64f8 100644
--- a/libc/pwd_grp/getpwnam.c
+++ b/libc/pwd_grp/getpwnam.c
@@ -38,7 +38,7 @@ int getpwnam_r (const char *name, struct passwd *password,
int passwd_fd;
if (name == NULL) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
diff --git a/libc/pwd_grp/putpwent.c b/libc/pwd_grp/putpwent.c
index da8e13d67..014cefa86 100644
--- a/libc/pwd_grp/putpwent.c
+++ b/libc/pwd_grp/putpwent.c
@@ -25,7 +25,7 @@
int putpwent(const struct passwd *passwd, FILE * f)
{
if (passwd == NULL || f == NULL) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
if (fprintf
diff --git a/libc/signal/sigaddset.c b/libc/signal/sigaddset.c
index ec1c96e9b..269f7d367 100644
--- a/libc/signal/sigaddset.c
+++ b/libc/signal/sigaddset.c
@@ -25,7 +25,7 @@
int sigaddset ( sigset_t *set, int signo)
{
if (set == NULL || signo <= 0 || signo >= NSIG) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
diff --git a/libc/signal/sigdelset.c b/libc/signal/sigdelset.c
index daa545624..958f1d44a 100644
--- a/libc/signal/sigdelset.c
+++ b/libc/signal/sigdelset.c
@@ -23,7 +23,7 @@
int sigdelset ( sigset_t *set, int signo)
{
if (set == NULL || signo <= 0 || signo >= NSIG) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
diff --git a/libc/signal/sigemptyset.c b/libc/signal/sigemptyset.c
index c38cb0e5a..19d8dabdf 100644
--- a/libc/signal/sigemptyset.c
+++ b/libc/signal/sigemptyset.c
@@ -25,7 +25,7 @@ int
sigemptyset ( sigset_t *set)
{
if (set == NULL) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
diff --git a/libc/signal/sigfillset.c b/libc/signal/sigfillset.c
index 1d67f1dc5..c3ebcce4b 100644
--- a/libc/signal/sigfillset.c
+++ b/libc/signal/sigfillset.c
@@ -27,7 +27,7 @@ sigfillset (set)
{
if (set == NULL)
{
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
diff --git a/libc/signal/sigismem.c b/libc/signal/sigismem.c
index 3e9b67c6c..64b14f37e 100644
--- a/libc/signal/sigismem.c
+++ b/libc/signal/sigismem.c
@@ -25,7 +25,7 @@
int sigismember ( const sigset_t *set, int signo)
{
if (set == NULL || signo <= 0 || signo >= NSIG) {
- errno=EINVAL;
+ __set_errno(EINVAL);
return -1;
}
diff --git a/libc/stdio/getdelim.c b/libc/stdio/getdelim.c
index 6f9ebb4fb..9181f9aa0 100644
--- a/libc/stdio/getdelim.c
+++ b/libc/stdio/getdelim.c
@@ -43,14 +43,14 @@ ssize_t getdelim(char **linebuf, size_t *linebufsz, int delimiter, FILE *file)
if ((file == NULL || linebuf==NULL || *linebuf == NULL || *linebufsz == 0)
&& !(*linebuf == NULL && *linebufsz ==0 )) {
- errno=EINVAL;
+ __set_errno(EINVAL);
return -1;
}
if (*linebuf == NULL && *linebufsz == 0){
*linebuf = malloc(GROWBY);
if (!*linebuf) {
- errno=ENOMEM;
+ __set_errno(ENOMEM);
return -1;
}
*linebufsz += GROWBY;
@@ -64,7 +64,7 @@ ssize_t getdelim(char **linebuf, size_t *linebufsz, int delimiter, FILE *file)
while (idx > *linebufsz-2) {
*linebuf = realloc(*linebuf, *linebufsz += GROWBY);
if (!*linebuf) {
- errno=ENOMEM;
+ __set_errno(ENOMEM);
return -1;
}
}
diff --git a/libc/stdio/popen.c b/libc/stdio/popen.c
index bc91bb73b..0a91f0e22 100644
--- a/libc/stdio/popen.c
+++ b/libc/stdio/popen.c
@@ -21,7 +21,7 @@ FILE *popen (const char *command, const char *mode)
reading = (mode[0] == 'r');
if ((!reading && (mode[0] != 'w')) || mode[1]) {
- errno = EINVAL; /* Invalid mode arg. */
+ __set_errno(EINVAL); /* Invalid mode arg. */
} else if (pipe(pipe_fd) == 0) {
pr = pipe_fd[reading];
pnr = pipe_fd[1-reading];
diff --git a/libc/stdio/remove.c b/libc/stdio/remove.c
index 115b871bb..af256e4aa 100644
--- a/libc/stdio/remove.c
+++ b/libc/stdio/remove.c
@@ -17,7 +17,7 @@ __const char *src;
if (rv < 0 && errno == EISDIR)
rv = rmdir(src);
if (rv >= 0)
- errno = er;
+ __set_errno(er);
return rv;
}
diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c
index fe1c6a073..954318d39 100644
--- a/libc/stdio/stdio.c
+++ b/libc/stdio/stdio.c
@@ -279,7 +279,7 @@ int fflush(FILE *fp)
* ANSI says behavior in this case is undefined but also says you
* shouldn't flush a stream you were reading from.
*/
- errno = EBADF; /* Should we set stream error indicator? */
+ __set_errno(EBADF); /* Should we set stream error indicator? */
rv = -1;
}
@@ -560,7 +560,7 @@ int fseek(FILE *fp, long int offset, int ref)
#endif
if ((ref < 0) || (ref > 2)) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
@@ -610,7 +610,7 @@ FILE *fp;
--pos;
}
if (pos < 0) { /* ungetcs at start of file? */
- errno = EIO;
+ __set_errno(EIO);
pos = -1;
}
}
@@ -666,7 +666,7 @@ const char *mode;
open_mode = (O_WRONLY | O_CREAT | O_APPEND);
break;
default: /* illegal mode */
- errno = EINVAL;
+ __set_errno(EINVAL);
goto _fopen_ERROR;
}
@@ -709,7 +709,7 @@ const char *mode;
fd = -1;
} else if (!(cur_mode & O_RDWR)
&& ((cur_mode ^ open_mode) & O_ACCMODE)) {
- errno = EINVAL;
+ __set_errno(EINVAL);
fd = -1;
}
}
@@ -1037,7 +1037,7 @@ int fgetpos(FILE *fp, fpos_t *pos)
fpos_t p;
if (!pos) { /* NULL pointer. */
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
@@ -1056,7 +1056,7 @@ int fsetpos(FILE *fp, __const fpos_t *pos)
if (pos) { /* Pointer ok. */
return fseek(fp, *pos, SEEK_SET);
}
- errno = EINVAL; /* NULL pointer. */
+ __set_errno(EINVAL); /* NULL pointer. */
return EOF;
}
#endif
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
diff --git a/libc/string/config.c b/libc/string/config.c
index dad9a723e..3330ffd19 100644
--- a/libc/string/config.c
+++ b/libc/string/config.c
@@ -42,7 +42,7 @@ char **cfgread(FILE * fp)
int i;
if (!fp) {
- errno = EIO;
+ __set_errno(EIO);
return (void *) 0;
}
@@ -73,7 +73,7 @@ char **cfgfind(FILE * fp, char *var)
char search[80];
if (!fp || !var) {
- errno = EIO;
+ __set_errno(EIO);
return (void *) 0;
}
diff --git a/libc/sysdeps/linux/arm/bits/errno.h b/libc/sysdeps/linux/arm/bits/errno.h
new file mode 100644
index 000000000..6bfd44e0c
--- /dev/null
+++ b/libc/sysdeps/linux/arm/bits/errno.h
@@ -0,0 +1,60 @@
+/* Error constants. Linux specific version.
+ Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifdef _ERRNO_H
+
+# undef EDOM
+# undef EILSEQ
+# undef ERANGE
+# include <linux/errno.h>
+
+/* Linux has no ENOTSUP error code. */
+# define ENOTSUP EOPNOTSUPP
+
+/* Linux also has no ECANCELED error code. Since it is not used here
+ we define it to an invalid value. */
+# define ECANCELED 125
+
+# ifndef __ASSEMBLER__
+/* We now need a declaration of the `errno' variable. */
+extern int errno;
+
+/* Function to get address of global `errno' variable. */
+extern int *__errno_location (void) __THROW __attribute__ ((__const__));
+
+# if defined _LIBC
+/* We wouldn't need a special macro anymore but it is history. */
+# define __set_errno(val) (*__errno_location ()) = (val)
+# endif /* _LIBC */
+
+# if !defined _LIBC || defined _LIBC_REENTRANT
+/* When using threads, errno is a per-thread value. */
+# define errno (*__errno_location ())
+# endif
+# endif /* !__ASSEMBLER__ */
+#endif /* _ERRNO_H */
+
+#if !defined _ERRNO_H && defined __need_Emath
+/* This is ugly but the kernel header is not clean enough. We must
+ define only the values EDOM, EILSEQ and ERANGE in case __need_Emath is
+ defined. */
+# define EDOM 33 /* Math argument out of domain of function. */
+# define EILSEQ 84 /* Illegal byte sequence. */
+# define ERANGE 34 /* Math result not representable. */
+#endif /* !_ERRNO_H && __need_Emath */
diff --git a/libc/sysdeps/linux/common/create_module.c b/libc/sysdeps/linux/common/create_module.c
index 1cacaefaf..223b909f5 100644
--- a/libc/sysdeps/linux/common/create_module.c
+++ b/libc/sysdeps/linux/common/create_module.c
@@ -42,7 +42,7 @@ unsigned long create_module(const char *name, size_t size)
/* Jump through hoops to fixup error return codes */
if (ret == -1 && errno > 125) {
ret = -errno;
- errno = 0;
+ __set_errno(0);
}
return ret;
}
diff --git a/libc/sysdeps/linux/common/errno.c b/libc/sysdeps/linux/common/errno.c
index 418fc933b..e6a8ae875 100644
--- a/libc/sysdeps/linux/common/errno.c
+++ b/libc/sysdeps/linux/common/errno.c
@@ -6,3 +6,4 @@ int * __errno_location ( void )
{
return &errno;
}
+
diff --git a/libc/sysdeps/linux/common/getdnnm.c b/libc/sysdeps/linux/common/getdnnm.c
index fdcbb0f3a..46751b1e7 100644
--- a/libc/sysdeps/linux/common/getdnnm.c
+++ b/libc/sysdeps/linux/common/getdnnm.c
@@ -9,14 +9,14 @@ getdomainname(char *name, size_t len)
struct utsname uts;
if (name == NULL) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
if (uname(&uts) == -1) return -1;
if (strlen(uts.domainname)+1 > len) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
strcpy(name, uts.domainname);
diff --git a/libc/sysdeps/linux/common/gethstnm.c b/libc/sysdeps/linux/common/gethstnm.c
index 0728f65a4..0f7a04681 100644
--- a/libc/sysdeps/linux/common/gethstnm.c
+++ b/libc/sysdeps/linux/common/gethstnm.c
@@ -9,14 +9,14 @@ gethostname(char *name, size_t len)
struct utsname uts;
if (name == NULL) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
if (uname(&uts) == -1) return -1;
if (strlen(uts.nodename)+1 > len) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
strcpy(name, uts.nodename);
diff --git a/libc/sysdeps/linux/common/seteuid.c b/libc/sysdeps/linux/common/seteuid.c
index 179477a14..a0a63610d 100644
--- a/libc/sysdeps/linux/common/seteuid.c
+++ b/libc/sysdeps/linux/common/seteuid.c
@@ -9,7 +9,7 @@ int seteuid(uid_t uid)
case 2:
if (uid == 65535)
{
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
break;
diff --git a/libc/sysdeps/linux/common/syscalls.c b/libc/sysdeps/linux/common/syscalls.c
index ca0b3a317..8d51f1f4f 100644
--- a/libc/sysdeps/linux/common/syscalls.c
+++ b/libc/sysdeps/linux/common/syscalls.c
@@ -139,7 +139,7 @@ int _xmknod (int version, const char * path, mode_t mode, dev_t *dev)
case 1:
return mknod (path, mode, *dev);
default:
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
}
diff --git a/libc/sysdeps/linux/i386/__init_brk.c b/libc/sysdeps/linux/i386/__init_brk.c
index c2ae482dd..4d9746342 100644
--- a/libc/sysdeps/linux/i386/__init_brk.c
+++ b/libc/sysdeps/linux/i386/__init_brk.c
@@ -17,15 +17,15 @@ __init_brk ()
"int $0x80\n\t"
"popl %%ebx"
:"=a" (___brk_addr)
- :"0" (SYS_brk));
+ :"0" (__NR_brk));
#else
__asm__ volatile ("int $0x80"
:"=a" (___brk_addr)
- :"0" (SYS_brk),"b" (0));
+ :"0" (__NR_brk),"b" (0));
#endif
if (___brk_addr == 0)
{
- errno = ENOMEM;
+ __set_errno(ENOMEM);
return -1;
}
}
diff --git a/libc/sysdeps/linux/i386/brk.c b/libc/sysdeps/linux/i386/brk.c
index 2a776bac1..9e06d0acc 100644
--- a/libc/sysdeps/linux/i386/brk.c
+++ b/libc/sysdeps/linux/i386/brk.c
@@ -18,15 +18,15 @@ int brk(void * end_data_seg)
"int $0x80\n\t"
"popl %%ebx"
:"=a" (___brk_addr)
- :"0" (SYS_brk),"c" (end_data_seg));
+ :"0" (__NR_brk),"c" (end_data_seg));
#else
__asm__ volatile ("int $0x80"
:"=a" (___brk_addr)
- :"0" (SYS_brk),"b" (end_data_seg));
+ :"0" (__NR_brk),"b" (end_data_seg));
#endif
if (___brk_addr == end_data_seg)
return 0;
- errno = ENOMEM;
+ __set_errno(ENOMEM);
}
return -1;
}
diff --git a/libc/sysdeps/linux/i386/sbrk.c b/libc/sysdeps/linux/i386/sbrk.c
index f5099d7e8..ca987aa8c 100644
--- a/libc/sysdeps/linux/i386/sbrk.c
+++ b/libc/sysdeps/linux/i386/sbrk.c
@@ -20,15 +20,15 @@ sbrk(ptrdiff_t increment)
"int $0x80\n\t"
"popl %%ebx"
:"=a" (___brk_addr)
- :"0" (SYS_brk),"c" (tmp));
+ :"0" (__NR_brk),"c" (tmp));
#else
__asm__ volatile ("int $0x80"
:"=a" (___brk_addr)
- :"0" (SYS_brk),"b" (tmp));
+ :"0" (__NR_brk),"b" (tmp));
#endif
if (___brk_addr == tmp)
return tmp-increment;
- errno = ENOMEM;
+ __set_errno(ENOMEM);
return ((void *) -1);
}
return ((void *) -1);
diff --git a/libc/sysdeps/linux/m68k/ptrace.c b/libc/sysdeps/linux/m68k/ptrace.c
index 383f72615..a82adc765 100644
--- a/libc/sysdeps/linux/m68k/ptrace.c
+++ b/libc/sysdeps/linux/m68k/ptrace.c
@@ -23,11 +23,11 @@ ptrace(int request, int pid, int addr, int data)
if (res >= 0) {
if (request > 0 && request < 4) {
- errno = 0;
+ __set_errno(0);
return (ret);
}
return (int) res;
}
- errno = -res;
+ __set_errno(-res);
return -1;
}
diff --git a/libc/termios/tcgetsid.c b/libc/termios/tcgetsid.c
index 35e1c95eb..5e4addece 100644
--- a/libc/termios/tcgetsid.c
+++ b/libc/termios/tcgetsid.c
@@ -42,7 +42,7 @@ pid_t tcgetsid (int fd)
if (errno == EINVAL)
{
tiocgsid_does_not_work = 1;
- errno=serrno;
+ __set_errno(serrno);
}
else
return (pid_t) -1;
@@ -58,7 +58,7 @@ pid_t tcgetsid (int fd)
sid = getsid (pgrp);
if (sid == -1 && errno == ESRCH)
- errno=ENOTTY;
+ __set_errno(ENOTTY);
return sid;
}
diff --git a/libc/termios/tcsetattr.c b/libc/termios/tcsetattr.c
index 30ea46f4c..bb8c84d5c 100644
--- a/libc/termios/tcsetattr.c
+++ b/libc/termios/tcsetattr.c
@@ -69,7 +69,7 @@ tcsetattr (fd, optional_actions, termios_p)
cmd = TCSETSF;
break;
default:
- errno=EINVAL;
+ __set_errno(EINVAL);
return -1;
}
@@ -99,7 +99,7 @@ tcsetattr (fd, optional_actions, termios_p)
{
/* We cannot verify if the setting is ok. We don't return
an error (?). */
- errno=save;
+ __set_errno(save);
retval = 0;
}
else if ((termios_p->c_cflag & (PARENB | CREAD))
@@ -111,7 +111,7 @@ tcsetattr (fd, optional_actions, termios_p)
/* It looks like the Linux kernel silently changed the
PARENB/CREAD/CSIZE bits in c_cflag. Report it as an
error. */
- errno=EINVAL;
+ __set_errno(EINVAL);
retval = -1;
}
}
diff --git a/libc/termios/termios.c b/libc/termios/termios.c
index a180e1011..d6cd124d1 100644
--- a/libc/termios/termios.c
+++ b/libc/termios/termios.c
@@ -88,7 +88,7 @@ int tcsendbreak( int fd, int duration)
* changed to use trickery (e.g. lower speed and send a '\0') to send
* the break, but for now just return an error.
*/
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
#endif
@@ -151,7 +151,7 @@ int cfsetospeed (struct termios *termios_p, speed_t speed)
if ((speed & ~CBAUD) != 0
&& (speed < B57600 || speed > B460800))
{
- errno=EINVAL;
+ __set_errno(EINVAL);
return -1;
}
@@ -172,7 +172,7 @@ int cfsetispeed ( struct termios *termios_p, speed_t speed)
if ((speed & ~CBAUD) != 0
&& (speed < B57600 || speed > B460800))
{
- errno=EINVAL;
+ __set_errno(EINVAL);
return -1;
}
diff --git a/libc/termios/ttyname.c b/libc/termios/ttyname.c
index ee78137c0..2aa009104 100644
--- a/libc/termios/ttyname.c
+++ b/libc/termios/ttyname.c
@@ -17,7 +17,7 @@ int fd;
if (fstat(fd, &st) < 0)
return 0;
if (!isatty(fd)) {
- errno = ENOTTY;
+ __set_errno(ENOTTY);
return 0;
}
@@ -32,11 +32,11 @@ int fd;
if (stat(name, &dst) == 0
&& st.st_dev == dst.st_dev && st.st_ino == dst.st_ino) {
closedir(fp);
- errno = noerr;
+ __set_errno(noerr);
return name;
}
}
closedir(fp);
- errno = noerr;
+ __set_errno(noerr);
return 0;
}
diff --git a/libc/unistd/getcwd.c b/libc/unistd/getcwd.c
index c0be5c39e..ad68ed4a7 100644
--- a/libc/unistd/getcwd.c
+++ b/libc/unistd/getcwd.c
@@ -21,7 +21,7 @@ char *getcwd( char *buf, int size)
path_size = size;
if (size < 3) {
- errno = ERANGE;
+ __set_errno(ERANGE);
return NULL;
}
@@ -59,7 +59,7 @@ static char *recurser()
return path_buf;
}
if (strlen(path_buf) + 4 > path_size) {
- errno = ERANGE;
+ __set_errno(ERANGE);
return 0;
}
strcat(path_buf, "/..");
@@ -90,7 +90,7 @@ ino_t this_ino;
ptr = path_buf + slen - 1;
if (*ptr != '/') {
if (slen + 2 > path_size) {
- errno = ERANGE;
+ __set_errno(ERANGE);
return 0;
}
strcpy(++ptr, "/");
@@ -105,7 +105,7 @@ ino_t this_ino;
while ((d = readdir(dp)) != 0) {
if (slow_search || this_ino == d->d_ino) {
if (slen + strlen(d->d_name) > path_size) {
- errno = ERANGE;
+ __set_errno(ERANGE);
return 0;
}
strcpy(ptr + 1, d->d_name);
@@ -119,6 +119,6 @@ ino_t this_ino;
}
closedir(dp);
- errno = ENOENT;
+ __set_errno(ENOENT);
return 0;
}
diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c
index 50d8e4bb5..702046874 100644
--- a/libc/unistd/sysconf.c
+++ b/libc/unistd/sysconf.c
@@ -52,8 +52,8 @@
* a constant. The pagesize on the target arch should not vary,
* so it should be safe to set this as 0.
*/
-#define RETURN_NEG_1 errno = ENOSYS; return -1
-#define RETURN_FUNCTION(f) errno = EISNAM ; return (long int) #f
+#define RETURN_NEG_1 __set_errno(ENOSYS); return -1
+#define RETURN_FUNCTION(f) __set_errno(EISNAM); return (long int) #f
#define GETPAGESIZE_IS_DYNAMIC 0
#else
#define RETURN_NEG_1 return -1
@@ -66,7 +66,7 @@ long int sysconf(int name)
switch (name)
{
default:
- errno=EINVAL;
+ __set_errno(EINVAL);
return -1;
case _SC_ARG_MAX:
@@ -935,7 +935,7 @@ int main(void)
}
for (i=0; i<_UCLIBC_SYSCONF_NUM_VALID_ARGS ; i++) {
- errno = 0;
+ __set_errno(0);
r = ret_vals[i] = sysconf(i);
switch(errno) {
case EINVAL: /* we're missing a case! */