libc/uClibc: vampirise patches for 0.9.30.2 from builroot

Commit in upstream buildroot:
http://git.buildroot.org/buildroot/commit/?id=43ffd946ad569f3a1d0662de221cd4cb65bdc8e6
Everything on the 0_9_30 branch since the release (0.9.30.3 to be)
This commit is contained in:
Yann E. MORIN" 2010-02-28 11:50:15 +01:00
parent 6d53a561b2
commit ca9b06fbe6
14 changed files with 1215 additions and 0 deletions

View File

@ -0,0 +1,64 @@
From a05c4380c5aaa6e107a4c7e1e5a139ec4cc43f0c Mon Sep 17 00:00:00 2001
From: Henning Heinold <heinold@inf.fu-berlin.de>
Date: Sun, 21 Feb 2010 11:55:32 +0100
Subject: [PATCH 14/15] LT pthread_atfork: unhide
Trying to compile perl with uClibc new linuxthreads on arm.
I run into the problem that pthread_atfork is not available.
The problem was that it was synced with the glibc version, which has
compat ifdefs we do not need in uClibc. The inital checked in version
is right and works. So either revert the commit 2 years ago
or patch it with the patch attached I made for openembedded.
Signed-off-by: Henning Heinold <heinold@inf.fu-berlin.de>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libpthread/linuxthreads/Makefile.in | 2 +-
libpthread/linuxthreads/pthread_atfork.c | 13 +++----------
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/libpthread/linuxthreads/Makefile.in b/libpthread/linuxthreads/Makefile.in
index 947dea9..d53b5fa 100644
--- a/libpthread/linuxthreads/Makefile.in
+++ b/libpthread/linuxthreads/Makefile.in
@@ -45,7 +45,7 @@ pthread_sysdep_SRC := $(patsubst %,$(libpthread_DIR)/sysdeps/pthread/%.c,$(pthre
pthread_SRC := \
attr barrier cancel condvar errno events join pthread \
lockfile manager mutex pt-machine ptcleanup \
- ptclock_gettime ptclock_settime ptfork pthandles \
+ ptclock_gettime ptclock_settime ptfork pthandles pthread_atfork \
pthread_setegid pthread_seteuid pthread_setgid pthread_setregid \
pthread_setresgid pthread_setresuid pthread_setreuid pthread_setuid \
rwlock semaphore sighandler signals specific spinlock
diff --git a/libpthread/linuxthreads/pthread_atfork.c b/libpthread/linuxthreads/pthread_atfork.c
index 2464acb..4c83dd0 100644
--- a/libpthread/linuxthreads/pthread_atfork.c
+++ b/libpthread/linuxthreads/pthread_atfork.c
@@ -43,12 +43,8 @@ extern void *__dso_handle __attribute__ ((__weak__));
/* Hide the symbol so that no definition but the one locally in the
executable or DSO is used. */
-int
-#ifndef __pthread_atfork
-/* Don't mark the compatibility function as hidden. */
-attribute_hidden
-#endif
-__pthread_atfork (prepare, parent, child)
+
+int attribute_hidden __pthread_atfork (prepare, parent, child)
void (*prepare) (void);
void (*parent) (void);
void (*child) (void);
@@ -56,8 +52,5 @@ __pthread_atfork (prepare, parent, child)
return __register_atfork (prepare, parent, child,
&__dso_handle == NULL ? NULL : __dso_handle);
}
-#ifndef __pthread_atfork
-extern int pthread_atfork (void (*prepare) (void), void (*parent) (void),
- void (*child) (void)) attribute_hidden;
+
strong_alias (__pthread_atfork, pthread_atfork)
-#endif
--
1.6.6.1

View File

@ -0,0 +1,87 @@
From 2911103dd4a03bbd3aad11eddfce524a5c9ba9b3 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 22 Jan 2010 13:00:20 +0100
Subject: [PATCH 03/15] Make use of macros from sys/asm.h in crt1.S
Needed for mips nptl to boot once again.
(cherry picked from commit 9c343fd4030dcd7a52616f365893177dded50346)
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/sysdeps/linux/mips/crt1.S | 46 +++++++++++----------------------------
1 files changed, 13 insertions(+), 33 deletions(-)
diff --git a/libc/sysdeps/linux/mips/crt1.S b/libc/sysdeps/linux/mips/crt1.S
index e851d52..6a80412 100644
--- a/libc/sysdeps/linux/mips/crt1.S
+++ b/libc/sysdeps/linux/mips/crt1.S
@@ -85,29 +85,10 @@
__start:
#ifdef __PIC__
-#if _MIPS_SIM == _MIPS_SIM_ABI32
- .frame sp, 24, sp
- .set noreorder
- move $0, $31 /* Save old ra. */
- bal 10f /* Find addr of cpload. */
- nop
-10:
- .cpload $31
- move $31, $0
- .set reorder
- .cprestore 16
-#else
- move $0, $31; /* Save old ra. */
- .set noreorder
- bal 10f /* Find addr of .cpsetup. */
- nop
-10:
- .set reorder
- .cpsetup $31, $25, 10b
- move $31, $0
-#endif
+ SETUP_GPX($0)
+ SETUP_GPX64($25,$0)
#else
- la $28, _gp /* Setup GP correctly if we're non-PIC. */
+ PTR_LA $28, _gp /* Setup GP correctly if we're non-PIC. */
move $31, $0
#endif
@@ -118,18 +99,18 @@ __start:
/* Allocate space on the stack for seven arguments and
* make sure the stack is aligned to double words (8 bytes) */
+ and $29, -2 * SZREG
+
#if _MIPS_SIM == _MIPS_SIM_ABI32
- and $29, -2 * 4
- subu $29, 32
- la $7, _init /* init */
- la $8, _fini
- sw $8, 16($29) /* fini */
- sw $2, 20($29) /* rtld_fini */
- sw $29, 24($29) /* stack_end */
-#else
- and $29, -2 * PTRSIZE
+ PTR_SUBIU $29, 32
+#endif
PTR_LA $7, _init /* init */
- PTR_LA $8, _fini /* fini */
+ PTR_LA $8, _fini
+#if _MIPS_SIM == _MIPS_SIM_ABI32
+ PTR_S $8, 16($29) /* fini */
+ PTR_S $2, 20($29) /* rtld_fini */
+ PTR_S $29, 24($29) /* stack_end */
+#else
move $9, $2 /* rtld_fini */
move $10, $29 /* stack_end */
#endif
@@ -148,4 +129,3 @@ __data_start:
.weak data_start
data_start = __data_start
-
--
1.6.6.1

View File

@ -0,0 +1,30 @@
From 323453d85ed29ccba7a81d884479188869cd64b7 Mon Sep 17 00:00:00 2001
From: Henning Heinold <heinold@inf.fu-berlin.de>
Date: Sat, 23 Jan 2010 21:29:42 -0800
Subject: [PATCH 13/15] Makefile.in: Make install_dev depend on install_runtime.
* Helps in parallel build.
Signed-off-by: Henning Heinold <heinold@inf.fu-berlin.de>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
Makefile.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index ec4c28e..a889838 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -370,7 +370,7 @@ ifneq ($(UCLIBC_SUPPORT_AI_ADDRCONFIG),y)
endif
# Installs development library links.
-install_dev: install_headers all
+install_dev: install_headers install_runtime
$(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
-$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
ifeq ($(HAVE_SHARED),y)
--
1.6.6.1

View File

@ -0,0 +1,42 @@
From 7b964170536951a260f7d552db99b428d1ea5026 Mon Sep 17 00:00:00 2001
From: Austin Foxley <austinf@cetoncorp.com>
Date: Wed, 3 Feb 2010 12:12:10 -0800
Subject: [PATCH 08/15] Unbreak build for sparc on some config's
Thanks to rob@landley.net
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
---
libc/sysdeps/linux/sparc/sigaction.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/libc/sysdeps/linux/sparc/sigaction.c b/libc/sysdeps/linux/sparc/sigaction.c
index a22ac40..7140fd3 100644
--- a/libc/sysdeps/linux/sparc/sigaction.c
+++ b/libc/sysdeps/linux/sparc/sigaction.c
@@ -34,7 +34,8 @@ _syscall5(int, rt_sigaction, int, a, int, b, int, c, int, d, int, e);
static void __rt_sigreturn_stub(void);
static void __sigreturn_stub(void);
-int __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
+libc_hidden_proto(sigaction)
+int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
int ret;
struct sigaction kact, koact;
@@ -65,10 +66,8 @@ int __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oac
return ret;
}
-#ifndef LIBC_SIGACTION
-weak_alias(__libc_sigaction,sigaction)
-libc_hidden_weak(sigaction)
-#endif
+libc_hidden_def(sigaction)
+weak_alias(sigaction,__libc_sigaction)
static void
__rt_sigreturn_stub(void)
--
1.6.6.1

View File

@ -0,0 +1,74 @@
From 85bc04d5436ca6c8a30a1ad28862260a04b8b3d5 Mon Sep 17 00:00:00 2001
From: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
Date: Wed, 16 Dec 2009 13:16:08 +0100
Subject: [PATCH 02/15] avr32: add varargs handling of prctl syscall
prctl is defined to use varargs in the header file, hence it needs varargs
specific handling in the source. This patch properly handles the variodic
argument before the syscall is passed to the kernel for the AVR32 architecture.
Signed-off-by: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
---
libc/sysdeps/linux/avr32/Makefile.arch | 2 +-
libc/sysdeps/linux/avr32/prctl.c | 36 ++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletions(-)
create mode 100644 libc/sysdeps/linux/avr32/prctl.c
diff --git a/libc/sysdeps/linux/avr32/Makefile.arch b/libc/sysdeps/linux/avr32/Makefile.arch
index bc5f625..98b85a7 100644
--- a/libc/sysdeps/linux/avr32/Makefile.arch
+++ b/libc/sysdeps/linux/avr32/Makefile.arch
@@ -5,7 +5,7 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC := brk.c clone.c mmap.c sigaction.c
+CSRC := brk.c clone.c mmap.c prctl.c sigaction.c
SSRC := __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
sigrestorer.S syscall.S vfork.S
diff --git a/libc/sysdeps/linux/avr32/prctl.c b/libc/sysdeps/linux/avr32/prctl.c
new file mode 100644
index 0000000..4e146e3
--- /dev/null
+++ b/libc/sysdeps/linux/avr32/prctl.c
@@ -0,0 +1,36 @@
+/*
+ * prctl syscall for AVR32 Linux.
+ *
+ * Copyright (C) 2010 Atmel Corporation
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser General
+ * Public License. See the file "COPYING.LIB" in the main directory of this
+ * archive for more details.
+ */
+#include <sys/syscall.h>
+#include <sys/prctl.h>
+#include <stdarg.h>
+
+#ifdef __NR_prctl
+#define __NR___syscall_prctl __NR_prctl
+static inline _syscall5(int, __syscall_prctl, int, option, long, arg2,
+ long, arg3, long, arg4, long, arg5);
+
+int prctl(int __option, ...)
+{
+ long arg2;
+ long arg3;
+ long arg4;
+ long arg5;
+ va_list ap;
+
+ va_start(ap, __option);
+ arg2 = va_arg(ap, long);
+ arg3 = va_arg(ap, long);
+ arg4 = va_arg(ap, long);
+ arg5 = va_arg(ap, long);
+ va_end(ap);
+
+ return INLINE_SYSCALL(prctl, 5, __option, arg2, arg3, arg4, arg5);
+}
+#endif
--
1.6.6.1

View File

@ -0,0 +1,297 @@
From 74ca5695cd9913691192e075449b8be5794d50f0 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Thu, 8 Oct 2009 02:51:55 +0000
Subject: [PATCH 12/15] clean up O_CLOEXEC handling
Drop the "#ifndef O_CLOEXEC" cruft, enable O_CLOEXEC in most fcntl.h
headers, and import __ASSUME_O_CLOEXEC from glibc.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/pwd_grp/lckpwdf.c | 8 +++++++-
libc/sysdeps/linux/alpha/bits/fcntl.h | 2 --
libc/sysdeps/linux/arm/bits/fcntl.h | 2 --
libc/sysdeps/linux/avr32/bits/fcntl.h | 1 +
libc/sysdeps/linux/bfin/bits/fcntl.h | 2 ++
libc/sysdeps/linux/cris/bits/fcntl.h | 1 +
libc/sysdeps/linux/frv/bits/fcntl.h | 2 ++
libc/sysdeps/linux/hppa/bits/fcntl.h | 1 +
libc/sysdeps/linux/i386/bits/fcntl.h | 2 --
libc/sysdeps/linux/ia64/bits/fcntl.h | 2 --
libc/sysdeps/linux/m68k/bits/fcntl.h | 1 +
libc/sysdeps/linux/microblaze/bits/fcntl.h | 2 ++
libc/sysdeps/linux/mips/bits/fcntl.h | 1 +
libc/sysdeps/linux/powerpc/bits/fcntl.h | 2 --
libc/sysdeps/linux/sh/bits/fcntl.h | 2 --
libc/sysdeps/linux/sh64/bits/fcntl.h | 2 ++
libc/sysdeps/linux/sparc/bits/fcntl.h | 2 --
libc/sysdeps/linux/x86_64/bits/fcntl.h | 2 --
libc/sysdeps/linux/xtensa/bits/fcntl.h | 1 +
19 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/libc/pwd_grp/lckpwdf.c b/libc/pwd_grp/lckpwdf.c
index 0b0fb47..aec6283 100644
--- a/libc/pwd_grp/lckpwdf.c
+++ b/libc/pwd_grp/lckpwdf.c
@@ -75,7 +75,7 @@ lckpwdf (void)
/* Prevent problems caused by multiple threads. */
__UCLIBC_MUTEX_LOCK(mylock);
- lock_fd = open (_PATH_PASSWD, O_WRONLY);
+ lock_fd = open (_PATH_PASSWD, O_WRONLY | O_CLOEXEC);
if (lock_fd == -1) {
/* Cannot create lock file. */
goto DONE;
@@ -97,6 +97,12 @@ lckpwdf (void)
goto DONE;
}
+#ifndef __ASSUME_O_CLOEXEC
+ /* Make sure file gets correctly closed when process finished. */
+ fcntl (lock_fd, F_SETFD, FD_CLOEXEC);
+#endif
+
+
/* Now we have to get exclusive write access. Since multiple
process could try this we won't stop when it first fails.
Instead we set a timeout for the system call. Once the timer
diff --git a/libc/sysdeps/linux/alpha/bits/fcntl.h b/libc/sysdeps/linux/alpha/bits/fcntl.h
index 2a6b9ea..649c563 100644
--- a/libc/sysdeps/linux/alpha/bits/fcntl.h
+++ b/libc/sysdeps/linux/alpha/bits/fcntl.h
@@ -50,9 +50,7 @@
# define O_NOFOLLOW 0200000 /* Do not follow links. */
# define O_DIRECT 02000000 /* Direct disk access. */
# define O_NOATIME 04000000 /* Do not set atime. */
-# if 0
# define O_CLOEXEC 010000000 /* Set close_on_exec. */
-# endif
#endif
#ifdef __USE_LARGEFILE64
diff --git a/libc/sysdeps/linux/arm/bits/fcntl.h b/libc/sysdeps/linux/arm/bits/fcntl.h
index 86cea4b..7cc5a9d 100644
--- a/libc/sysdeps/linux/arm/bits/fcntl.h
+++ b/libc/sysdeps/linux/arm/bits/fcntl.h
@@ -50,9 +50,7 @@
# define O_NOFOLLOW 0100000 /* Do not follow links. */
# define O_DIRECT 0200000 /* Direct disk access. */
# define O_NOATIME 01000000 /* Do not set atime. */
-# if 0
# define O_CLOEXEC 02000000 /* Set close_on_exec. */
-# endif
#endif
/* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/avr32/bits/fcntl.h b/libc/sysdeps/linux/avr32/bits/fcntl.h
index 2301e22..767243e 100644
--- a/libc/sysdeps/linux/avr32/bits/fcntl.h
+++ b/libc/sysdeps/linux/avr32/bits/fcntl.h
@@ -30,6 +30,7 @@
# define O_DIRECTORY 00200000 /* direct disk access */
# define O_NOFOLLOW 00400000 /* don't follow links */
# define O_NOATIME 01000000 /* don't set atime */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
#endif
#ifdef __USE_LARGEFILE64
diff --git a/libc/sysdeps/linux/bfin/bits/fcntl.h b/libc/sysdeps/linux/bfin/bits/fcntl.h
index 7d0bcf9..aabf94d 100644
--- a/libc/sysdeps/linux/bfin/bits/fcntl.h
+++ b/libc/sysdeps/linux/bfin/bits/fcntl.h
@@ -48,6 +48,8 @@
# define O_DIRECTORY 040000 /* Must be a directory. */
# define O_NOFOLLOW 0100000 /* Do not follow links. */
# define O_DIRECT 0200000 /* Direct disk access. */
+# define O_NOATIME 01000000 /* don't set atime */
+# define O_CLOEXEC 02000000 /* set close_on_exec *
#endif
/* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/cris/bits/fcntl.h b/libc/sysdeps/linux/cris/bits/fcntl.h
index a2106ef..29443ba 100644
--- a/libc/sysdeps/linux/cris/bits/fcntl.h
+++ b/libc/sysdeps/linux/cris/bits/fcntl.h
@@ -50,6 +50,7 @@
# define O_DIRECTORY 0200000 /* Must be a directory. */
# define O_NOFOLLOW 0400000 /* Do not follow links. */
# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
#endif
/* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/frv/bits/fcntl.h b/libc/sysdeps/linux/frv/bits/fcntl.h
index 06e8860..5bff4d3 100644
--- a/libc/sysdeps/linux/frv/bits/fcntl.h
+++ b/libc/sysdeps/linux/frv/bits/fcntl.h
@@ -45,6 +45,8 @@
# define O_DIRECT 040000 /* Direct disk access. */
# define O_DIRECTORY 0200000 /* Must be a directory. */
# define O_NOFOLLOW 0400000 /* Do not follow links. */
+# define O_NOATIME 01000000 /* don't set atime */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
#endif
/* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/hppa/bits/fcntl.h b/libc/sysdeps/linux/hppa/bits/fcntl.h
index cc23bf8..86e3b6f 100644
--- a/libc/sysdeps/linux/hppa/bits/fcntl.h
+++ b/libc/sysdeps/linux/hppa/bits/fcntl.h
@@ -50,6 +50,7 @@
# define O_DIRECTORY 00010000 /* Must be a directory. */
# define O_NOFOLLOW 00000200 /* Do not follow links. */
# define O_NOATIME 04000000 /* Do not set atime. */
+# define O_CLOEXEC 010000000 /* set close_on_exec */
#endif
#ifdef __USE_LARGEFILE64
diff --git a/libc/sysdeps/linux/i386/bits/fcntl.h b/libc/sysdeps/linux/i386/bits/fcntl.h
index 7f0b552..22e073b 100644
--- a/libc/sysdeps/linux/i386/bits/fcntl.h
+++ b/libc/sysdeps/linux/i386/bits/fcntl.h
@@ -50,9 +50,7 @@
# define O_DIRECTORY 0200000 /* Must be a directory. */
# define O_NOFOLLOW 0400000 /* Do not follow links. */
# define O_NOATIME 01000000 /* Do not set atime. */
-# if 0
# define O_CLOEXEC 02000000 /* Set close_on_exec. */
-# endif
#endif
/* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/ia64/bits/fcntl.h b/libc/sysdeps/linux/ia64/bits/fcntl.h
index d134c4b..85a55f6 100644
--- a/libc/sysdeps/linux/ia64/bits/fcntl.h
+++ b/libc/sysdeps/linux/ia64/bits/fcntl.h
@@ -49,9 +49,7 @@
# define O_DIRECTORY 0200000 /* must be a directory */
# define O_NOFOLLOW 0400000 /* don't follow links */
# define O_NOATIME 01000000 /* Do not set atime. */
-# if 0
# define O_CLOEXEC 02000000 /* Set close_on_exec. */
-# endif
#endif
#ifdef __USE_LARGEFILE64
diff --git a/libc/sysdeps/linux/m68k/bits/fcntl.h b/libc/sysdeps/linux/m68k/bits/fcntl.h
index d36198d..e564b42 100644
--- a/libc/sysdeps/linux/m68k/bits/fcntl.h
+++ b/libc/sysdeps/linux/m68k/bits/fcntl.h
@@ -49,6 +49,7 @@
# define O_NOFOLLOW 0100000 /* Do not follow links. */
# define O_DIRECT 0200000 /* Direct disk access. */
# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
#endif
/* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/microblaze/bits/fcntl.h b/libc/sysdeps/linux/microblaze/bits/fcntl.h
index c8aeb91..da35209 100644
--- a/libc/sysdeps/linux/microblaze/bits/fcntl.h
+++ b/libc/sysdeps/linux/microblaze/bits/fcntl.h
@@ -45,6 +45,8 @@
# define O_DIRECTORY 040000 /* Must be a directory. */
# define O_NOFOLLOW 0100000 /* Do not follow links. */
# define O_DIRECT 0200000 /* Direct disk access. */
+# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
#endif
/* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/mips/bits/fcntl.h b/libc/sysdeps/linux/mips/bits/fcntl.h
index ef015a4..f0072fd 100644
--- a/libc/sysdeps/linux/mips/bits/fcntl.h
+++ b/libc/sysdeps/linux/mips/bits/fcntl.h
@@ -51,6 +51,7 @@
# define O_DIRECT 0x8000 /* Direct disk access hint. */
# define O_DIRECTORY 0x10000 /* Must be a directory. */
# define O_NOATIME 0x40000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
#endif
/* For now Linux has no synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/powerpc/bits/fcntl.h b/libc/sysdeps/linux/powerpc/bits/fcntl.h
index ceb75b4..0759c6a 100644
--- a/libc/sysdeps/linux/powerpc/bits/fcntl.h
+++ b/libc/sysdeps/linux/powerpc/bits/fcntl.h
@@ -50,9 +50,7 @@
# define O_DIRECTORY 040000 /* Must be a directory. */
# define O_NOFOLLOW 0100000 /* Do not follow links. */
# define O_NOATIME 01000000 /* Do not set atime. */
-# if 0
# define O_CLOEXEC 02000000 /* Set close_on_exec. */
-# endif
#endif
#ifdef __USE_LARGEFILE64
diff --git a/libc/sysdeps/linux/sh/bits/fcntl.h b/libc/sysdeps/linux/sh/bits/fcntl.h
index 570484c..adb7377 100644
--- a/libc/sysdeps/linux/sh/bits/fcntl.h
+++ b/libc/sysdeps/linux/sh/bits/fcntl.h
@@ -50,9 +50,7 @@
# define O_DIRECTORY 0200000 /* Must be a directory. */
# define O_NOFOLLOW 0400000 /* Do not follow links. */
# define O_NOATIME 01000000 /* Do not set atime. */
-# if 0
# define O_CLOEXEC 02000000 /* Set close_on_exec. */
-# endif
#endif
/* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/sh64/bits/fcntl.h b/libc/sysdeps/linux/sh64/bits/fcntl.h
index 06e8860..245d35a 100644
--- a/libc/sysdeps/linux/sh64/bits/fcntl.h
+++ b/libc/sysdeps/linux/sh64/bits/fcntl.h
@@ -45,6 +45,8 @@
# define O_DIRECT 040000 /* Direct disk access. */
# define O_DIRECTORY 0200000 /* Must be a directory. */
# define O_NOFOLLOW 0400000 /* Do not follow links. */
+# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
#endif
/* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/sparc/bits/fcntl.h b/libc/sysdeps/linux/sparc/bits/fcntl.h
index 29c09a9..31a6d9b 100644
--- a/libc/sysdeps/linux/sparc/bits/fcntl.h
+++ b/libc/sysdeps/linux/sparc/bits/fcntl.h
@@ -49,9 +49,7 @@
# define O_NOFOLLOW 0x20000 /* don't follow links */
# define O_DIRECT 0x100000 /* direct disk access hint */
# define O_NOATIME 0x200000 /* Do not set atime. */
-# if 0
# define O_CLOEXEC 0x400000 /* Set close_on_exit. */
-# endif
#endif
#ifdef __USE_LARGEFILE64
diff --git a/libc/sysdeps/linux/x86_64/bits/fcntl.h b/libc/sysdeps/linux/x86_64/bits/fcntl.h
index be00e4a..f1cf388 100644
--- a/libc/sysdeps/linux/x86_64/bits/fcntl.h
+++ b/libc/sysdeps/linux/x86_64/bits/fcntl.h
@@ -50,9 +50,7 @@
# define O_DIRECTORY 0200000 /* Must be a directory. */
# define O_NOFOLLOW 0400000 /* Do not follow links. */
# define O_NOATIME 01000000 /* Do not set atime. */
-# if 0
# define O_CLOEXEC 02000000 /* Set close_on_exec. */
-# endif
#endif
/* For now Linux has synchronisity options for data and read operations.
diff --git a/libc/sysdeps/linux/xtensa/bits/fcntl.h b/libc/sysdeps/linux/xtensa/bits/fcntl.h
index a89362e..921a626 100644
--- a/libc/sysdeps/linux/xtensa/bits/fcntl.h
+++ b/libc/sysdeps/linux/xtensa/bits/fcntl.h
@@ -50,6 +50,7 @@
# define O_DIRECTORY 0200000 /* Must be a directory. */
# define O_NOFOLLOW 0400000 /* Do not follow links. */
# define O_NOATIME 01000000 /* Do not set atime. */
+# define O_CLOEXEC 02000000 /* set close_on_exec */
#endif
/* For now Linux has synchronisity options for data and read operations.
--
1.6.6.1

View File

@ -0,0 +1,153 @@
From d75ad2e129b3f22296cead3db53c784527deab60 Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date: Fri, 18 Sep 2009 14:07:31 +0000
Subject: fix make {,install_}{,host}utils
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
diff --git a/extra/locale/programs/locale.c b/extra/locale/programs/locale.c
index 462a579..dfd2029 100644
--- a/extra/locale/programs/locale.c
+++ b/extra/locale/programs/locale.c
@@ -10,10 +10,9 @@
*
*/
-
+#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <langinfo.h>
#include <unistd.h>
#ifdef __UCLIBC_HAS_GETOPT_LONG__
diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c
index 290e680..3ce884d 100644
--- a/libc/misc/wchar/wchar.c
+++ b/libc/misc/wchar/wchar.c
@@ -171,7 +171,6 @@ extern size_t _wchar_utf8sntowcs(wchar_t *__restrict pwc, size_t wn,
extern size_t _wchar_wcsntoutf8s(char *__restrict s, size_t n,
const wchar_t **__restrict src, size_t wn) attribute_hidden;
-
#endif /* _LIBC */
/**********************************************************************/
#ifdef L_btowc
@@ -1201,45 +1200,6 @@ typedef struct {
int skip_invalid_input; /* To support iconv -c option. */
} _UC_iconv_t;
-
-
-#ifdef L_iconv
-
-#include <iconv.h>
-#include <string.h>
-#include <endian.h>
-#include <byteswap.h>
-
-#if (__BYTE_ORDER != __BIG_ENDIAN) && (__BYTE_ORDER != __LITTLE_ENDIAN)
-#error unsupported endianness for iconv
-#endif
-
-#ifndef __CTYPE_HAS_8_BIT_LOCALES
-#error currently iconv requires 8 bit locales
-#endif
-#ifndef __CTYPE_HAS_UTF_8_LOCALES
-#error currently iconv requires UTF-8 locales
-#endif
-
-
-enum {
- IC_WCHAR_T = 0xe0,
- IC_MULTIBYTE = 0xe0,
-#if __BYTE_ORDER == __BIG_ENDIAN
- IC_UCS_4 = 0xec,
- IC_UTF_32 = 0xe4,
- IC_UCS_2 = 0xe2,
- IC_UTF_16 = 0xea,
-#else
- IC_UCS_4 = 0xed,
- IC_UTF_32 = 0xe5,
- IC_UCS_2 = 0xe3,
- IC_UTF_16 = 0xeb,
-#endif
- IC_UTF_8 = 2,
- IC_ASCII = 1
-};
-
/* For the multibyte
* bit 0 means swap endian
* bit 1 means 2 byte
@@ -1247,8 +1207,13 @@ enum {
*
*/
+#if defined L_iconv && defined _LIBC
+/* Used externally only by iconv utility */
extern const unsigned char __iconv_codesets[];
libc_hidden_proto(__iconv_codesets)
+#endif
+
+#if defined L_iconv || defined L_iconv_main
const unsigned char __iconv_codesets[] =
"\x0a\xe0""WCHAR_T\x00" /* superset of UCS-4 but platform-endian */
#if __BYTE_ORDER == __BIG_ENDIAN
@@ -1281,7 +1246,48 @@ const unsigned char __iconv_codesets[] =
"\x08\x02""UTF-8\x00"
"\x0b\x01""US-ASCII\x00"
"\x07\x01""ASCII"; /* Must be last! (special case to save a nul) */
+#endif
+#if defined L_iconv && defined _LIBC
libc_hidden_data_def(__iconv_codesets)
+#endif
+
+
+#ifdef L_iconv
+
+#include <iconv.h>
+#include <string.h>
+#include <endian.h>
+#include <byteswap.h>
+
+#if (__BYTE_ORDER != __BIG_ENDIAN) && (__BYTE_ORDER != __LITTLE_ENDIAN)
+#error unsupported endianness for iconv
+#endif
+
+#ifndef __CTYPE_HAS_8_BIT_LOCALES
+#error currently iconv requires 8 bit locales
+#endif
+#ifndef __CTYPE_HAS_UTF_8_LOCALES
+#error currently iconv requires UTF-8 locales
+#endif
+
+
+enum {
+ IC_WCHAR_T = 0xe0,
+ IC_MULTIBYTE = 0xe0,
+#if __BYTE_ORDER == __BIG_ENDIAN
+ IC_UCS_4 = 0xec,
+ IC_UTF_32 = 0xe4,
+ IC_UCS_2 = 0xe2,
+ IC_UTF_16 = 0xea,
+#else
+ IC_UCS_4 = 0xed,
+ IC_UTF_32 = 0xe5,
+ IC_UCS_2 = 0xe3,
+ IC_UTF_16 = 0xeb,
+#endif
+ IC_UTF_8 = 2,
+ IC_ASCII = 1
+};
/* Experimentally off - libc_hidden_proto(strcasecmp) */
@@ -1575,6 +1581,4 @@ size_t weak_function iconv(iconv_t cd, char **__restrict inbuf,
}
return nrcount;
}
-
#endif
-
--
cgit v0.8.2.1

View File

@ -0,0 +1,113 @@
From d43f068e84513ed88392df4ca27d49ad01145fd2 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Sun, 6 Sep 2009 12:12:12 -0400
Subject: [PATCH 07/15] fstatat: fix up behavior on 32/64 bit hosts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The fstatat() syscall is a little funky in that it sometimes changes name
between 32 and 64 bit hosts, but it should always operate on a 64bit stat
structure. So for the fstatat() function, make sure we convert it from a
64bit kstat to a 32bit stat.
Along these lines, we need to restore the __xstat32_conv() function.
Reported-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/sysdeps/linux/common/fstatat.c | 9 +++++++--
libc/sysdeps/linux/common/fstatat64.c | 5 +++++
libc/sysdeps/linux/common/xstatconv.c | 19 +++++++++++++++++++
libc/sysdeps/linux/common/xstatconv.h | 1 +
4 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/libc/sysdeps/linux/common/fstatat.c b/libc/sysdeps/linux/common/fstatat.c
index 149c189..33daa7c 100644
--- a/libc/sysdeps/linux/common/fstatat.c
+++ b/libc/sysdeps/linux/common/fstatat.c
@@ -10,15 +10,20 @@
#include <sys/stat.h>
#include "xstatconv.h"
+/* 64bit ports tend to favor newfstatat() */
+#ifdef __NR_newfstatat
+# define __NR_fstatat64 __NR_newfstatat
+#endif
+
#ifdef __NR_fstatat64
int fstatat(int fd, const char *file, struct stat *buf, int flag)
{
int ret;
- struct kernel_stat kbuf;
+ struct kernel_stat64 kbuf;
ret = INLINE_SYSCALL(fstatat64, 4, fd, file, &kbuf, flag);
if (ret == 0)
- __xstat_conv(&kbuf, buf);
+ __xstat32_conv(&kbuf, buf);
return ret;
}
diff --git a/libc/sysdeps/linux/common/fstatat64.c b/libc/sysdeps/linux/common/fstatat64.c
index 5ae1fad..95627af 100644
--- a/libc/sysdeps/linux/common/fstatat64.c
+++ b/libc/sysdeps/linux/common/fstatat64.c
@@ -12,6 +12,11 @@
#ifdef __UCLIBC_HAS_LFS__
+/* 64bit ports tend to favor newfstatat() */
+#ifdef __NR_newfstatat
+# define __NR_fstatat64 __NR_newfstatat
+#endif
+
#ifdef __NR_fstatat64
int fstatat64(int fd, const char *file, struct stat64 *buf, int flag)
{
diff --git a/libc/sysdeps/linux/common/xstatconv.c b/libc/sysdeps/linux/common/xstatconv.c
index e575b26..50455c6 100644
--- a/libc/sysdeps/linux/common/xstatconv.c
+++ b/libc/sysdeps/linux/common/xstatconv.c
@@ -46,6 +46,25 @@ void attribute_hidden __xstat_conv(struct kernel_stat *kbuf, struct stat *buf)
buf->st_ctim = kbuf->st_ctim;
}
+void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf)
+{
+ /* Convert to current kernel version of `struct stat64'. */
+ memset(buf, 0x00, sizeof(*buf));
+ buf->st_dev = kbuf->st_dev;
+ buf->st_ino = kbuf->st_ino;
+ buf->st_mode = kbuf->st_mode;
+ buf->st_nlink = kbuf->st_nlink;
+ buf->st_uid = kbuf->st_uid;
+ buf->st_gid = kbuf->st_gid;
+ buf->st_rdev = kbuf->st_rdev;
+ buf->st_size = kbuf->st_size;
+ buf->st_blksize = kbuf->st_blksize;
+ buf->st_blocks = kbuf->st_blocks;
+ buf->st_atim = kbuf->st_atim;
+ buf->st_mtim = kbuf->st_mtim;
+ buf->st_ctim = kbuf->st_ctim;
+}
+
#ifdef __UCLIBC_HAS_LFS__
void attribute_hidden __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf)
diff --git a/libc/sysdeps/linux/common/xstatconv.h b/libc/sysdeps/linux/common/xstatconv.h
index 57c8bcb..7568da8 100644
--- a/libc/sysdeps/linux/common/xstatconv.h
+++ b/libc/sysdeps/linux/common/xstatconv.h
@@ -26,6 +26,7 @@
#include <bits/kernel_stat.h>
extern void __xstat_conv(struct kernel_stat *kbuf, struct stat *buf) attribute_hidden;
+extern void __xstat32_conv(struct kernel_stat64 *kbuf, struct stat *buf) attribute_hidden;
#if defined __UCLIBC_HAS_LFS__
extern void __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf) attribute_hidden;
#endif
--
1.6.6.1

View File

@ -0,0 +1,72 @@
From 13545bce877b33e30155fc412ad44cc118d83f77 Mon Sep 17 00:00:00 2001
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Sat, 30 Jan 2010 00:24:37 +0900
Subject: [PATCH 15/15] getdents: Fix mips64 build
On Wed, 27 Jan 2010 07:14:08 +0100, Carmelo AMOROSO <carmelo.amoroso@st.com> wrote:
> I would re-write your patch in a simpler way.
>
> We already have the following
>
> 136 #if defined __UCLIBC_HAS_LFS__ && ! defined __NR_getdents64
> 137 attribute_hidden strong_alias(__getdents,__getdents64)
> 138 #endif
>
> I think that it's simpler to move in the proper place this statement.
Thanks, indeed. If we came into "#elif WORDSIZE == 32" block, above
condition never be true. So we can just move this statement out of
"#if...#elif...#elif...#endif" block. Here is a revised patch.
------------------------------------------------------
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Subject: [PATCH] getdents: Fix mips64 build
Some archs (such as mips64) do not have getdents64 syscall but have
getdents syscall. Define alias for it.
This fixes regression from 0.9.30.1.
Backgrounds:
This is once done by commit e8b1c674. But after the commit 33bcf733
("Use getdents syscall if kernel provide supports for this instead of
relying upon getdents64."), if __ASSUME_GETDENTS32_D_TYPE was defined
the alias for getdents64 is not defined. The macro
__ASSUME_GETDENTS32_D_TYPE had been effectively ignored until 0.9.30.1
but the commit 0f0f20ab ("Move kernel-features.h header from the
linuxthread directory to a common one...") really enables it.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/sysdeps/linux/common/getdents.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libc/sysdeps/linux/common/getdents.c b/libc/sysdeps/linux/common/getdents.c
index b518cc0..66a03b3 100644
--- a/libc/sysdeps/linux/common/getdents.c
+++ b/libc/sysdeps/linux/common/getdents.c
@@ -136,10 +136,6 @@ ssize_t __getdents (int fd, char *buf, size_t nbytes)
return (char *) dp - buf;
}
-#if defined __UCLIBC_HAS_LFS__ && ! defined __NR_getdents64
-attribute_hidden strong_alias(__getdents,__getdents64)
-#endif
-
#elif __WORDSIZE == 32
/* Experimentally off - libc_hidden_proto(memmove) */
@@ -171,4 +167,8 @@ ssize_t __getdents (int fd, char *buf, size_t nbytes)
}
#endif
+#if defined __UCLIBC_HAS_LFS__ && ! defined __NR_getdents64
+attribute_hidden strong_alias(__getdents,__getdents64)
+#endif
+
#endif
--
1.6.6.1

View File

@ -0,0 +1,35 @@
From 47e88c04e01299f975ff23f33035d0f34a8f6787 Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date: Fri, 22 Jan 2010 13:32:44 +0100
Subject: [PATCH 06/15] {,host}utils depend on headers
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
Makefile.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 4c5aecb..ec4c28e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -436,7 +436,7 @@ ifeq ($(HAVE_SHARED),y)
fi
endif
-utils:
+utils: headers
$(Q)$(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils $@
# Installs helper applications, such as 'ldd' and 'ldconfig'
@@ -445,7 +445,7 @@ install_utils: utils
endif # ifeq ($(HAVE_DOT_CONFIG),y)
-hostutils:
+hostutils: headers
$(Q)$(MAKE) CROSS="$(CROSS)" CC="$(CC)" HOSTCC="$(HOSTCC)" DOTHOST=.host -C utils $@
install_hostutils: hostutils
--
1.6.6.1

View File

@ -0,0 +1,63 @@
From b4d6a6e94d87ff2b4ae687a21048833f19b9dd48 Mon Sep 17 00:00:00 2001
From: Carmelo Amoroso <carmelo.amoroso@st.com>
Date: Mon, 8 Feb 2010 16:24:06 +0100
Subject: [PATCH 11/15] libc: Fix typo in include/rpc
s/GNU_SOUCE/GNU_SOURCE/ in include/rcp/
Signed-off-by: Jason Woodward <jason.woodward@timesys.com>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
---
include/rpc/auth.h | 4 ++--
include/rpc/rpc.h | 4 ++--
include/rpc/types.h | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/rpc/auth.h b/include/rpc/auth.h
index 17eb59f..12297e6 100644
--- a/include/rpc/auth.h
+++ b/include/rpc/auth.h
@@ -47,8 +47,8 @@
#ifndef __FORCE_GLIBC
#define __FORCE_GLIBC
#endif
-#ifndef _GNU_SOUCE
-#define _GNU_SOUCE
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
#endif
#define _(X) X
#endif
diff --git a/include/rpc/rpc.h b/include/rpc/rpc.h
index 8194ffe..219910e 100644
--- a/include/rpc/rpc.h
+++ b/include/rpc/rpc.h
@@ -44,8 +44,8 @@
#ifndef __FORCE_GLIBC
#define __FORCE_GLIBC
#endif
-#ifndef _GNU_SOUCE
-#define _GNU_SOUCE
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
#endif
#define _(X) X
#include <features.h>
diff --git a/include/rpc/types.h b/include/rpc/types.h
index 469576e..05f49c3 100644
--- a/include/rpc/types.h
+++ b/include/rpc/types.h
@@ -39,8 +39,8 @@
#ifndef __FORCE_GLIBC
#define __FORCE_GLIBC
#endif
-#ifndef _GNU_SOUCE
-#define _GNU_SOUCE
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
#endif
#define _(X) X
#endif
--
1.6.6.1

View File

@ -0,0 +1,70 @@
From 956a0087e282e53ba9c085dbbc469391f7234944 Mon Sep 17 00:00:00 2001
From: Aurelien Jacobs <aurel@gnuage.org>
Date: Thu, 4 Feb 2010 09:31:40 -0800
Subject: [PATCH 10/15] libm: enable log2f and exp2f
Signed-off-by: Aurelien Jacobs <aurel@gnuage.org>
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
---
libm/float_wrappers.c | 4 ++--
test/math/compile_test.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libm/float_wrappers.c b/libm/float_wrappers.c
index dc315e7..b7317a1 100644
--- a/libm/float_wrappers.c
+++ b/libm/float_wrappers.c
@@ -15,12 +15,10 @@
/* For the time being, do _NOT_ implement these functions
* that are defined by SuSv3 */
-#undef L_exp2f /*float exp2f(float);*/
#undef L_fdimf /*float fdimf(float, float);*/
#undef L_fmaf /*float fmaf(float, float, float);*/
#undef L_fmaxf /*float fmaxf(float, float);*/
#undef L_fminf /*float fminf(float, float);*/
-#undef L_log2f /*float log2f(float);*/
#undef L_nearbyintf /*float nearbyintf(float);*/
#undef L_nexttowardf /*float nexttowardf(float, long double);*/
#undef L_remquof /*float remquof(float, float, int *);*/
@@ -43,6 +41,7 @@ float cosf(float);
float coshf(float);
float erfcf(float);
float erff(float);
+float exp2f(float);
float expf(float);
float expm1f(float);
float fabsf(float);
@@ -56,6 +55,7 @@ float lgammaf(float);
long long llroundf(float);
float log10f(float);
float log1pf(float);
+float log2f(float);
float logbf(float);
float logf(float);
long lroundf(float);
diff --git a/test/math/compile_test.c b/test/math/compile_test.c
index 9990520..ee5e2e3 100644
--- a/test/math/compile_test.c
+++ b/test/math/compile_test.c
@@ -18,7 +18,7 @@ r += cosf(float_x);
r += coshf(float_x);
r += erfcf(float_x);
r += erff(float_x);
-/*r += exp2f(float_x); - uclibc does not have it (yet?) */
+r += exp2f(float_x);
r += expf(float_x);
r += expm1f(float_x);
r += fabsf(float_x);
@@ -38,7 +38,7 @@ r += llrintf(float_x);
r += llroundf(float_x);
r += log10f(float_x);
r += log1pf(float_x);
-/*r += log2f(float_x); - uclibc does not have it (yet?) */
+r += log2f(float_x);
r += logbf(float_x);
r += logf(float_x);
r += lrintf(float_x);
--
1.6.6.1

View File

@ -0,0 +1,89 @@
From fa476d01f1c1990a92ee49d1f1c557b83805d0e9 Mon Sep 17 00:00:00 2001
From: Freeman Wang <xwang@ubicom.com>
Date: Sat, 19 Dec 2009 13:43:00 -0800
Subject: [PATCH 09/15] malloc: fix race condition and other bugs in the no-mmu malloc
Fixes multiple race conditions on mmb list. This was done by
making the mmb_heap_lock into a recursive lock and making the
regular heap_lock extend to cover the mmb heap handling.
Also move the new_mmb allocation up to before the mmb list is
iterated through to find the insertion point. When the mmb_heap
also runs out and needs to be extended when the regular heap is
just extended, the mmb list could be messed up.
Signed-off-by: Freeman Wang <xwang@ubicom.com>
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
---
libc/stdlib/malloc/free.c | 6 +++---
libc/stdlib/malloc/malloc.c | 7 ++++---
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/libc/stdlib/malloc/free.c b/libc/stdlib/malloc/free.c
index 90e18f4..741248a 100644
--- a/libc/stdlib/malloc/free.c
+++ b/libc/stdlib/malloc/free.c
@@ -179,14 +179,14 @@ __free_to_heap (void *mem, struct heap_free_area **heap
/* Start searching again from the end of this block. */
start = mmb_end;
+ /* Release the descriptor block we used. */
+ free_to_heap (mmb, &__malloc_mmb_heap, &__malloc_mmb_heap_lock);
+
/* We have to unlock the heap before we recurse to free the mmb
descriptor, because we might be unmapping from the mmb
heap. */
__heap_unlock (heap_lock);
- /* Release the descriptor block we used. */
- free_to_heap (mmb, &__malloc_mmb_heap, &__malloc_mmb_heap_lock);
-
/* Do the actual munmap. */
munmap ((void *)mmb_start, mmb_end - mmb_start);
diff --git a/libc/stdlib/malloc/malloc.c b/libc/stdlib/malloc/malloc.c
index 71f9e58..84a6acd 100644
--- a/libc/stdlib/malloc/malloc.c
+++ b/libc/stdlib/malloc/malloc.c
@@ -48,7 +48,7 @@ struct malloc_mmb *__malloc_mmapped_blocks = 0;
HEAP_DECLARE_STATIC_FREE_AREA (initial_mmb_fa, 48); /* enough for 3 mmbs */
struct heap_free_area *__malloc_mmb_heap = HEAP_INIT_WITH_FA (initial_mmb_fa);
#ifdef HEAP_USE_LOCKING
-pthread_mutex_t __malloc_mmb_heap_lock = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t __malloc_mmb_heap_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
#endif
#endif /* __UCLIBC_UCLINUX_BROKEN_MUNMAP__ */
@@ -151,19 +151,19 @@ __malloc_from_heap (size_t size, struct heap_free_area **heap
/* Try again to allocate. */
mem = __heap_alloc (heap, &size);
- __heap_unlock (heap_lock);
#if !defined(MALLOC_USE_SBRK) && defined(__UCLIBC_UCLINUX_BROKEN_MUNMAP__)
/* Insert a record of BLOCK in sorted order into the
__malloc_mmapped_blocks list. */
+ new_mmb = malloc_from_heap (sizeof *new_mmb, &__malloc_mmb_heap, &__malloc_mmb_heap_lock);
+
for (prev_mmb = 0, mmb = __malloc_mmapped_blocks;
mmb;
prev_mmb = mmb, mmb = mmb->next)
if (block < mmb->mem)
break;
- new_mmb = malloc_from_heap (sizeof *new_mmb, &__malloc_mmb_heap, &__malloc_mmb_heap_lock);
new_mmb->next = mmb;
new_mmb->mem = block;
new_mmb->size = block_size;
@@ -177,6 +177,7 @@ __malloc_from_heap (size_t size, struct heap_free_area **heap
(unsigned)new_mmb,
(unsigned)new_mmb->mem, block_size);
#endif /* !MALLOC_USE_SBRK && __UCLIBC_UCLINUX_BROKEN_MUNMAP__ */
+ __heap_unlock (heap_lock);
}
}
--
1.6.6.1

View File

@ -0,0 +1,26 @@
From 83a09cd5c9ed9afd87a7d1d17319c2fd2203ad0f Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Date: Thu, 21 Jan 2010 10:36:13 +0100
Subject: [PATCH 04/15] rpc: fix typo in version mismatch msg
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/inet/rpc/rpc_prot.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libc/inet/rpc/rpc_prot.c b/libc/inet/rpc/rpc_prot.c
index 74658e6..229f988 100644
--- a/libc/inet/rpc/rpc_prot.c
+++ b/libc/inet/rpc/rpc_prot.c
@@ -229,7 +229,7 @@ rejected (enum reject_stat rjct_stat,
{
switch (rjct_stat)
{
- case RPC_VERSMISMATCH:
+ case RPC_MISMATCH:
error->re_status = RPC_VERSMISMATCH;
return;
case AUTH_ERROR:
--
1.6.6.1