summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libc/sysdeps/linux/alpha/bits/sem.h85
-rw-r--r--libc/sysdeps/linux/arm/__syscall_error.c2
-rw-r--r--libc/sysdeps/linux/arm/bits/kernel_stat.h4
-rw-r--r--libc/sysdeps/linux/i386/Makefile4
-rw-r--r--libc/sysdeps/linux/i386/__syscall_error.c21
-rw-r--r--libc/sysdeps/linux/powerpc/bits/sem.h93
-rw-r--r--libc/sysdeps/linux/sparc/bits/sem.h92
-rw-r--r--test/stdlib/Makefile17
-rw-r--r--test/unistd/Makefile2
-rw-r--r--test/unistd/errno.c27
10 files changed, 326 insertions, 21 deletions
diff --git a/libc/sysdeps/linux/alpha/bits/sem.h b/libc/sysdeps/linux/alpha/bits/sem.h
new file mode 100644
index 000000000..f63360b2b
--- /dev/null
+++ b/libc/sysdeps/linux/alpha/bits/sem.h
@@ -0,0 +1,85 @@
+/* Copyright (C) 1995, 1996, 1997, 1998, 2000 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_SEM_H
+# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
+#endif
+
+#include <sys/types.h>
+
+/* Flags for `semop'. */
+#define SEM_UNDO 0x1000 /* undo the operation on exit */
+
+/* Commands for `semctl'. */
+#define GETPID 11 /* get sempid */
+#define GETVAL 12 /* get semval */
+#define GETALL 13 /* get all semval's */
+#define GETNCNT 14 /* get semncnt */
+#define GETZCNT 15 /* get semzcnt */
+#define SETVAL 16 /* set semval */
+#define SETALL 17 /* set all semval's */
+
+
+/* Data structure describing a set of semaphores. */
+struct semid_ds
+{
+ struct ipc_perm sem_perm; /* operation permission struct */
+ __time_t sem_otime; /* last semop() time */
+ __time_t sem_ctime; /* last time changed by semctl() */
+ unsigned long int sem_nsems; /* number of semaphores in set */
+ unsigned long int __unused1;
+ unsigned long int __unused2;
+};
+
+/* The user should define a union like the following to use it for arguments
+ for `semctl'.
+
+ union semun
+ {
+ int val; <= value for SETVAL
+ struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET
+ unsigned short int *array; <= array for GETALL & SETALL
+ struct seminfo *__buf; <= buffer for IPC_INFO
+ };
+
+ Previous versions of this file used to define this union but this is
+ incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether
+ one must define the union or not. */
+#define _SEM_SEMUN_UNDEFINED 1
+
+#ifdef __USE_MISC
+
+/* ipcs ctl cmds */
+# define SEM_STAT 18
+# define SEM_INFO 19
+
+struct seminfo
+{
+ int semmap;
+ int semmni;
+ int semmns;
+ int semmnu;
+ int semmsl;
+ int semopm;
+ int semume;
+ int semusz;
+ int semvmx;
+ int semaem;
+};
+
+#endif /* __USE_MISC */
diff --git a/libc/sysdeps/linux/arm/__syscall_error.c b/libc/sysdeps/linux/arm/__syscall_error.c
index de65a1f39..40b6b10dc 100644
--- a/libc/sysdeps/linux/arm/__syscall_error.c
+++ b/libc/sysdeps/linux/arm/__syscall_error.c
@@ -24,6 +24,6 @@
* an error number into errno. */
int attribute_hidden __syscall_error(int err_no)
{
- __set_errno(err_no);
+ __set_errno(-err_no);
return -1;
}
diff --git a/libc/sysdeps/linux/arm/bits/kernel_stat.h b/libc/sysdeps/linux/arm/bits/kernel_stat.h
index 70d268c19..fce8a4209 100644
--- a/libc/sysdeps/linux/arm/bits/kernel_stat.h
+++ b/libc/sysdeps/linux/arm/bits/kernel_stat.h
@@ -5,6 +5,8 @@
* struct kernel_stat should look like... It turns out each arch has a
* different opinion on the subject... */
+#define STAT_HAVE_NSEC 1
+
struct kernel_stat {
#if defined(__ARMEB__)
unsigned short st_dev;
@@ -36,8 +38,6 @@ struct kernel_stat {
unsigned long __unused5;
};
-/* see the notes in common/xstatconv.c about why we have these
- * funky funk unions here ... i blame the schools */
struct kernel_stat64 {
unsigned long long st_dev;
unsigned char __pad0[4];
diff --git a/libc/sysdeps/linux/i386/Makefile b/libc/sysdeps/linux/i386/Makefile
index fc13e6f45..e7cee0c0b 100644
--- a/libc/sysdeps/linux/i386/Makefile
+++ b/libc/sysdeps/linux/i386/Makefile
@@ -82,9 +82,9 @@ $(TOPDIR)lib/crtn.o:
endif
headers:
- $(LN) -fs ../libc/sysdeps/linux/i386/fpu_control.h $(TOPDIR)/include/
+ $(LN) -fs ../libc/sysdeps/linux/i386/fpu_control.h $(TOPDIR)include/
clean:
$(RM) *.[oa] *~ core
$(RM) bits/sysnum.h
- $(RM) $(TOPDIR)/include/fpu_control.h
+ $(RM) $(TOPDIR)include/fpu_control.h
diff --git a/libc/sysdeps/linux/i386/__syscall_error.c b/libc/sysdeps/linux/i386/__syscall_error.c
index de65a1f39..133500cb6 100644
--- a/libc/sysdeps/linux/i386/__syscall_error.c
+++ b/libc/sysdeps/linux/i386/__syscall_error.c
@@ -22,8 +22,25 @@
/* This routine is jumped to by all the syscall handlers, to stash
* an error number into errno. */
-int attribute_hidden __syscall_error(int err_no)
+
+/* This version uses a lot of magic and relies heavily on x86
+ * calling convention ... The advantage is that this is the same
+ * size as the previous __syscall_error() but all the .S functions
+ * need just one instruction.
+ *
+ * Local .S files have to set %eax to the negative errno value
+ * and then jump to this function. The neglected return to caller
+ * and return value of -1 is taken care of here so we don't have to
+ * worry about it in the .S functions.
+ *
+ * We have to stash the errno from %eax in a local stack var because
+ * __set_errno will prob call a function thus clobbering %eax on us.
+ */
+int attribute_hidden __syscall_error(void)
{
- __set_errno(err_no);
+ register int edx asm("%edx");
+ asm("mov %eax, %edx");
+ asm("negl %edx");
+ __set_errno(edx);
return -1;
}
diff --git a/libc/sysdeps/linux/powerpc/bits/sem.h b/libc/sysdeps/linux/powerpc/bits/sem.h
new file mode 100644
index 000000000..6a615f154
--- /dev/null
+++ b/libc/sysdeps/linux/powerpc/bits/sem.h
@@ -0,0 +1,93 @@
+/* Copyright (C) 1995, 1996, 1997, 1998, 2000, 2002
+ 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_SEM_H
+# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
+#endif
+
+#include <sys/types.h>
+#include <bits/wordsize.h>
+
+/* Flags for `semop'. */
+#define SEM_UNDO 0x1000 /* undo the operation on exit */
+
+/* Commands for `semctl'. */
+#define GETPID 11 /* get sempid */
+#define GETVAL 12 /* get semval */
+#define GETALL 13 /* get all semval's */
+#define GETNCNT 14 /* get semncnt */
+#define GETZCNT 15 /* get semzcnt */
+#define SETVAL 16 /* set semval */
+#define SETALL 17 /* set all semval's */
+
+
+/* Data structure describing a set of semaphores. */
+struct semid_ds
+{
+ struct ipc_perm sem_perm; /* operation permission struct */
+#if __WORDSIZE == 32
+ unsigned int __unused1;
+#endif
+ __time_t sem_otime; /* last semop() time */
+#if __WORDSIZE == 32
+ unsigned int __unused2;
+#endif
+ __time_t sem_ctime; /* last time changed by semctl() */
+ unsigned long int sem_nsems; /* number of semaphores in set */
+ unsigned long __unused3;
+ unsigned long __unused4;
+};
+
+/* The user should define a union like the following to use it for arguments
+ for `semctl'.
+
+ union semun
+ {
+ int val; <= value for SETVAL
+ struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET
+ unsigned short int *array; <= array for GETALL & SETALL
+ struct seminfo *__buf; <= buffer for IPC_INFO
+ };
+
+ Previous versions of this file used to define this union but this is
+ incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether
+ one must define the union or not. */
+#define _SEM_SEMUN_UNDEFINED 1
+
+#ifdef __USE_MISC
+
+/* ipcs ctl cmds */
+# define SEM_STAT 18
+# define SEM_INFO 19
+
+struct seminfo
+{
+ int semmap;
+ int semmni;
+ int semmns;
+ int semmnu;
+ int semmsl;
+ int semopm;
+ int semume;
+ int semusz;
+ int semvmx;
+ int semaem;
+};
+
+#endif /* __USE_MISC */
diff --git a/libc/sysdeps/linux/sparc/bits/sem.h b/libc/sysdeps/linux/sparc/bits/sem.h
new file mode 100644
index 000000000..288076510
--- /dev/null
+++ b/libc/sysdeps/linux/sparc/bits/sem.h
@@ -0,0 +1,92 @@
+/* Copyright (C) 1995, 1996, 1997, 1998, 2000 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_SEM_H
+# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
+#endif
+
+#include <sys/types.h>
+#include <bits/wordsize.h>
+
+/* Flags for `semop'. */
+#define SEM_UNDO 0x1000 /* undo the operation on exit */
+
+/* Commands for `semctl'. */
+#define GETPID 11 /* get sempid */
+#define GETVAL 12 /* get semval */
+#define GETALL 13 /* get all semval's */
+#define GETNCNT 14 /* get semncnt */
+#define GETZCNT 15 /* get semzcnt */
+#define SETVAL 16 /* set semval */
+#define SETALL 17 /* set all semval's */
+
+
+/* Data structure describing a set of semaphores. */
+struct semid_ds
+{
+ struct ipc_perm sem_perm; /* operation permission struct */
+#if __WORDSIZE == 32
+ unsigned int __pad1;
+#endif
+ __time_t sem_otime; /* last semop() time */
+#if __WORDSIZE == 32
+ unsigned int __pad2;
+#endif
+ __time_t sem_ctime; /* last time changed by semctl() */
+ unsigned long int sem_nsems; /* number of semaphores in set */
+ unsigned long int __unused1;
+ unsigned long int __unused2;
+};
+
+/* The user should define a union like the following to use it for arguments
+ for `semctl'.
+
+ union semun
+ {
+ int val; <= value for SETVAL
+ struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET
+ unsigned short int *array; <= array for GETALL & SETALL
+ struct seminfo *__buf; <= buffer for IPC_INFO
+ };
+
+ Previous versions of this file used to define this union but this is
+ incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether
+ one must define the union or not. */
+#define _SEM_SEMUN_UNDEFINED 1
+
+#ifdef __USE_MISC
+
+/* ipcs ctl cmds */
+# define SEM_STAT 18
+# define SEM_INFO 19
+
+struct seminfo
+{
+ int semmap;
+ int semmni;
+ int semmns;
+ int semmnu;
+ int semmsl;
+ int semopm;
+ int semume;
+ int semusz;
+ int semvmx;
+ int semaem;
+};
+
+#endif /* __USE_MISC */
diff --git a/test/stdlib/Makefile b/test/stdlib/Makefile
index 6c485efe6..f7b03be1a 100644
--- a/test/stdlib/Makefile
+++ b/test/stdlib/Makefile
@@ -42,7 +42,6 @@ teststrtol: teststrtol.c Makefile $(TESTDIR)/Rules.mak
$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-$(LDD) $@
- ls -l $@
./$@ > $@.out
-@ echo " "
@@ -55,7 +54,6 @@ teststrtol_glibc: teststrtol.c Makefile
$(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
-$(LDD) $@
- ls -l $@
./$@ > $@.out
-@ echo " "
@@ -64,7 +62,7 @@ teststrtol_diff: teststrtol_glibc teststrtol
-@ echo " "
-@ echo "Diffing output: "
-@ echo " "
- -diff -u teststrtol_glibc.out teststrtol.out
+ diff -u teststrtol_glibc.out teststrtol.out
-@ echo " "
qsort: qsort.c Makefile $(TESTDIR)/Rules.mak
@@ -76,7 +74,6 @@ qsort: qsort.c Makefile $(TESTDIR)/Rules.mak
$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-$(LDD) $@
- ls -l $@
./$@ > $@.out
-@ echo " "
@@ -89,7 +86,6 @@ qsort_glibc: qsort.c Makefile
$(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
-$(LDD) $@
- ls -l $@
./$@ > $@.out
-@ echo " "
@@ -98,7 +94,7 @@ qsort_diff: qsort_glibc qsort
-@ echo " "
-@ echo "Diffing output: "
-@ echo " "
- -diff -u qsort_glibc.out qsort.out
+ diff -u qsort_glibc.out qsort.out
-@ echo " "
teston_exit: teston_exit.c Makefile $(TESTDIR)/Rules.mak
@@ -110,7 +106,6 @@ teston_exit: teston_exit.c Makefile $(TESTDIR)/Rules.mak
$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-$(LDD) $@
- ls -l $@
./$@ > $@.out
-@ echo " "
@@ -123,7 +118,6 @@ teston_exit_glibc: teston_exit.c Makefile
$(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
-$(LDD) $@
- ls -l $@
./$@ > $@.out
-@ echo " "
@@ -132,7 +126,7 @@ teston_exit_diff: teston_exit_glibc teston_exit
-@ echo " "
-@ echo "Diffing output: "
-@ echo " "
- -diff -u teston_exit_glibc.out teston_exit.out
+ diff -u teston_exit_glibc.out teston_exit.out
-@ echo " "
testatexit: testatexit.c Makefile $(TESTDIR)/Rules.mak
@@ -144,7 +138,6 @@ testatexit: testatexit.c Makefile $(TESTDIR)/Rules.mak
$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-$(LDD) $@
- ls -l $@
./$@ > $@.out
-@ echo " "
@@ -157,7 +150,6 @@ testatexit_glibc: testatexit.c Makefile
$(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
-$(LDD) $@
- ls -l $@
./$@ > $@.out
-@ echo " "
@@ -166,7 +158,7 @@ testatexit_diff: testatexit_glibc testatexit
-@ echo " "
-@ echo "Diffing output: "
-@ echo " "
- -diff -u testatexit_glibc.out testatexit.out
+ diff -u testatexit_glibc.out testatexit.out
-@ echo " "
ptytest: ptytest.c Makefile $(TESTDIR)/Rules.mak
@@ -178,7 +170,6 @@ ptytest: ptytest.c Makefile $(TESTDIR)/Rules.mak
$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-$(LDD) $@
- ls -l $@
./$@
-@ echo " "
diff --git a/test/unistd/Makefile b/test/unistd/Makefile
index d684f0690..4db50174d 100644
--- a/test/unistd/Makefile
+++ b/test/unistd/Makefile
@@ -1,7 +1,7 @@
# uClibc unistd tests
# Licensed under the GNU Library General Public License, see COPYING.LIB
-TESTS = clone fork getcwd getopt getopt_long preadwrite vfork
+TESTS = clone errno fork getcwd getopt getopt_long preadwrite vfork
include ../Test.mak
diff --git a/test/unistd/errno.c b/test/unistd/errno.c
new file mode 100644
index 000000000..cb082b890
--- /dev/null
+++ b/test/unistd/errno.c
@@ -0,0 +1,27 @@
+/* based originally on one the clone tests in the LTP */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sched.h>
+
+int child_fn(void *arg)
+{
+ fprintf(stderr, "in child_fn\n");
+ exit(1);
+}
+
+int main(void)
+{
+ int r_clone, ret_errno;
+
+ r_clone = clone(child_fn, NULL, (int) NULL, NULL);
+ ret_errno = errno;
+ if (ret_errno != EINVAL || r_clone != -1) {
+ fprintf(stderr, "clone: res=%d (wanted -1) errno=%d (wanted %d)\n",
+ r_clone, errno, EINVAL);
+ return 1;
+ }
+
+ return 0;
+}