Commit f9f7dad5 authored by Natanael Copa's avatar Natanael Copa

main/libc0.9.32: remove

we havent supported this for years
parent d89594d9
From d0d708fffcc475973736aea3759f4d7944a4629a Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Fri, 23 Dec 2011 14:06:09 +0100
Subject: [PATCH 1/8] Compatible stack protector for non Thread Local storage
Before we had thread local storage the __stack_chk_guard was a global
variable that was referenced to by the older binaries.
We since then have changed ABI so this patch can probably go away.
---
ldso/ldso/ldso.c | 7 +------
libc/misc/internals/__uClibc_main.c | 8 +-------
2 files changed, 2 insertions(+), 13 deletions(-)
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 014bbf5..7690036 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -121,11 +121,7 @@ extern void _start(void);
#ifdef __UCLIBC_HAS_SSP__
# include <dl-osinfo.h>
static uintptr_t stack_chk_guard;
-# ifndef THREAD_SET_STACK_GUARD
-/* Only exported for architectures that don't store the stack guard canary
- * in local thread area. */
uintptr_t __stack_chk_guard attribute_relro;
-# endif
# ifdef __UCLIBC_HAS_SSP_COMPAT__
uintptr_t __guard attribute_relro;
# endif
@@ -1189,9 +1185,8 @@ of this helper program; chances are you did not intend to run this program.\n\
stack_chk_guard = _dl_setup_stack_chk_guard ();
# ifdef THREAD_SET_STACK_GUARD
THREAD_SET_STACK_GUARD (stack_chk_guard);
-# else
- __stack_chk_guard = stack_chk_guard;
# endif
+ __stack_chk_guard = stack_chk_guard;
# ifdef __UCLIBC_HAS_SSP_COMPAT__
__guard = stack_chk_guard;
# endif
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 71fdbd8..3a24acd 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -46,12 +46,7 @@ void *__libc_stack_end = NULL;
# ifdef __UCLIBC_HAS_SSP__
# include <dl-osinfo.h>
static uintptr_t stack_chk_guard;
-# ifndef THREAD_SET_STACK_GUARD
-/* Only exported for architectures that don't store the stack guard canary
- * in thread local area. */
-/* for gcc-4.1 non-TLS */
uintptr_t __stack_chk_guard attribute_relro;
-# endif
/* for gcc-3.x + Etoh ssp */
# ifdef __UCLIBC_HAS_SSP_COMPAT__
uintptr_t __guard attribute_relro;
@@ -251,9 +246,8 @@ void __uClibc_init(void)
stack_chk_guard = _dl_setup_stack_chk_guard();
# ifdef THREAD_SET_STACK_GUARD
THREAD_SET_STACK_GUARD (stack_chk_guard);
-# else
- __stack_chk_guard = stack_chk_guard;
# endif
+ __stack_chk_guard = stack_chk_guard;
# ifdef __UCLIBC_HAS_SSP_COMPAT__
__guard = stack_chk_guard;
# endif
--
1.7.8.4
From 9d101732ad0609f2f19ef20062a00cd26b01d859 Mon Sep 17 00:00:00 2001
From: "Peter S. Mazinger" <ps.m@gmx.net>
Date: Tue, 26 Apr 2011 23:03:44 +0200
Subject: [PATCH] add posix_madvise.c
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
libc/sysdeps/linux/common/Makefile.in | 2 +-
libc/sysdeps/linux/common/posix_madvise.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
create mode 100644 libc/sysdeps/linux/common/posix_madvise.c
diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
index cf9f25a..b40bb78 100644
--- a/libc/sysdeps/linux/common/Makefile.in
+++ b/libc/sysdeps/linux/common/Makefile.in
@@ -81,7 +81,7 @@ CSRC-$(UCLIBC_HAS_REALTIME) += clock_getres.c clock_gettime.c clock_settime.c \
sched_get_priority_max.c sched_get_priority_min.c sched_getscheduler.c \
sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c sigqueue.c
# clock_getcpuclockid|clock_nanosleep|mq_timedreceive|mq_timedsend|posix_fadvise|posix_fallocate|posix_madvise|posix_memalign|posix_mem_offset|posix_spawnattr_destroy|posix_spawnattr_init|posix_spawnattr_getflags|posix_spawnattr_setflags|posix_spawnattr_getpgroup|posix_spawnattr_setpgroup|posix_spawnattr_getschedparam|posix_spawnattr_setschedparam|posix_spawnattr_getschedpolicy|posix_spawnattr_setschedpolicy|posix_spawnattr_getsigdefault|posix_spawnattr_setsigdefault|posix_spawnattr_getsigmask|posix_spawnattr_setsigmask|posix_spawnattr_init|posix_spawnattr_setflags|posix_spawnattr_setpgroup|posix_spawnattr_setschedparam|posix_spawnattr_setschedpolicy|posix_spawnattr_setsigdefault|posix_spawnattr_setsigmask|posix_spawn_file_actions_addclose|posix_spawn_file_actions_addopen|posix_spawn_file_actions_adddup2|posix_spawn_file_actions_addopen|posix_spawn_file_actions_destroy|posix_spawn_file_actions_init|posix_spawn_file_actions_init|posix_spawn|posix_spawnp|posix_spawnp|posix_typed_mem_get_info|pthread_mutex_timedlock|sem_timedwait
-CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c
+CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_fadvise64.c posix_fadvise.c posix_madvise.c
CSRC-$(UCLIBC_SUSV4_LEGACY) += utime.c
CSRC-$(UCLIBC_HAS_EPOLL) += epoll.c
CSRC-$(UCLIBC_HAS_XATTR) += xattr.c
diff --git a/libc/sysdeps/linux/common/posix_madvise.c b/libc/sysdeps/linux/common/posix_madvise.c
new file mode 100644
index 0000000..2f95bcb
--- /dev/null
+++ b/libc/sysdeps/linux/common/posix_madvise.c
@@ -0,0 +1,25 @@
+/* vi: set sw=4 ts=4: */
+/* Licensed under the LGPL v2.1, see the file LICENSE in this tarball. */
+
+#include <sys/mman.h>
+#include <sys/syscall.h>
+
+#if defined __NR_madvise && defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
+int posix_madvise(void *addr, size_t len, int advice)
+{
+ int result;
+ /* We have one problem: the kernel's MADV_DONTNEED does not
+ * correspond to POSIX's POSIX_MADV_DONTNEED. The former simply
+ * discards changes made to the memory without writing it back to
+ * disk, if this would be necessary. The POSIX behaviour does not
+ * allow this. There is no functionality mapping for the POSIX
+ * behaviour so far so we ignore that advice for now. */
+ if (advice == POSIX_MADV_DONTNEED)
+ return 0;
+
+ /* this part might use madvise function */
+ INTERNAL_SYSCALL_DECL (err);
+ result = INTERNAL_SYSCALL (madvise, err, 3, addr, len, advice);
+ return INTERNAL_SYSCALL_ERRNO (result, err);
+}
+#endif
--
1.7.11.1
From b26db0813ca2aab8882535caa9d0a6c8671e9bbc Mon Sep 17 00:00:00 2001
From: "Peter S. Mazinger" <ps.m@gmx.net>
Date: Thu, 21 Apr 2011 21:19:39 +0200
Subject: [PATCH 1/6] cancel.h: add generic file to ease cancellation support
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
(cherry picked from commit 9f68f0cbf8c8eea6a7f9e195e4617bbaa808d7c6)
Conflicts:
Makefile.in
---
Makefile.in | 1 +
include/cancel.h | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 102 insertions(+)
create mode 100644 include/cancel.h
diff --git a/Makefile.in b/Makefile.in
index 9ba590d..e81926d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -210,6 +210,7 @@ $(top_builddir)extra/scripts/unifdef: $(top_srcdir)extra/scripts/unifdef.c
# a "y" here means the feature is enabled and so we should *not* rm it.
# if the option expands to nothing though, we can punt the headers.
HEADERS_RM- := \
+ cancel.h \
dl-osinfo.h \
hp-timing.h \
_lfs_64.h \
diff --git a/include/cancel.h b/include/cancel.h
new file mode 100644
index 0000000..ac6f6b6
--- /dev/null
+++ b/include/cancel.h
@@ -0,0 +1,101 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2000-2011 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _CANCEL_H
+#define _CANCEL_H
+
+/*
+ * Usage of this header:
+ * 1. define a static or hidden function __NC(NAME) - expands to __NAME_nocancel
+ * 2. if it is hidden, add the prototype to the appropiate header where NAME has
+ * it's prototype (guarded by _LIBC)
+ * 3. add a CANCELLABLE_SYSCALL(...) line at the end, this will create the function
+ * NAME (as weak) with enabled cancellation for NPTL (and later for new LT), for
+ * LT_OLD it will also create a strong_alias to __libc_NAME to be used in libpthread
+ * 4. if you need libc_hidden_(weak|def) line, use instead lt_libc_hidden, this will
+ * take care of the correct type, weak or strong depending on the THREADS type
+ * 5. If the implementation can't be done using CANCELLABLE_SYSCALL (like for fcntl)
+ * you need to manually add lt_strong_alias() line too, to optionally create the
+ * __libc_NAME alias
+ * 6. if functions are needed to implement __NC(NAME), that themselves are cancellable,
+ * decide how the cancellation should be solved, two variants are possible:
+ * a. use the other function as __NC(FUNC), this way you access the non-cancellable
+ * variant and provide by CANCELLABLE_SYSCALL(...) the dedicated cancellation for NAME.
+ * be aware, that for this case __NC(FUNC) has to be hidden (not static)
+ * b. use the other function with it's name (FUNC) and add LIBC_CANCEL_HANDLED(); at
+ * the end of file with a comment telling us which function took care of the cancellation
+ * Note: LIBC_CANCEL_HANDLED() is noop on uClibc, glibc uses it only for tests, we use
+ * it only for "documentation".
+ *
+ * For now the use of this file is limited to libc, will expand later to support libpthread
+ * and librt as well.
+ */
+
+#include <features.h>
+
+#ifndef NOT_IN_libc
+
+#define __NC(name) _NC(name)
+#define _NC(name) __##name##_nocancel
+
+#define __NC_OLD(name) _NC_OLD(name)
+#define _NC_OLD(name) __libc_##name
+
+#define __NC_PROTO(name) extern __typeof(name) __NC(name) attribute_hidden;
+#define __NC_OLD_PROTO(name) extern __typeof(name) __NC_OLD(name);
+
+#if defined __UCLIBC_HAS_THREADS__ && !defined __LINUXTHREADS_OLD__
+# define __NEW_THREADS 1
+#else
+# define SINGLE_THREAD_P 1
+#endif
+
+#ifdef __NEW_THREADS
+# include <sysdep-cancel.h>
+
+# define CANCELLABLE_SYSCALL(res_type, name, param_list, params) \
+res_type weak_function name param_list \
+{ \
+ if (SINGLE_THREAD_P) \
+ return __NC(name) params; \
+ int oldtype = LIBC_CANCEL_ASYNC(); \
+ res_type result = __NC(name) params; \
+ LIBC_CANCEL_RESET(oldtype); \
+ return result; \
+}
+
+# define lt_strong_alias(name)
+# define lt_libc_hidden(name) libc_hidden_def(name)
+
+#elif defined __LINUXTHREADS_OLD__
+
+# define CANCELLABLE_SYSCALL(res_type, name, param_list, params) \
+weak_alias(__NC(name),name) \
+lt_strong_alias(name)
+
+# define lt_strong_alias(name) \
+__NC_OLD_PROTO(name) \
+strong_alias(name,__NC_OLD(name))
+# define lt_libc_hidden(name) libc_hidden_weak(name)
+
+#else
+
+# define CANCELLABLE_SYSCALL(res_type, name, param_list, params) \
+strong_alias(__NC(name),name)
+
+# define lt_strong_alias(name)
+# define lt_libc_hidden(name) libc_hidden_def(name)
+
+#endif
+
+/* disable it, useless, glibc uses it only for tests */
+# undef LIBC_CANCEL_HANDLED
+# define LIBC_CANCEL_HANDLED()
+
+#endif /* NOT_IN_libc */
+
+#endif
--
1.7.11.1
--- uClibc-0.9.33.2.orig/utils/ldd.c
+++ uClibc-0.9.33.2/utils/ldd.c
@@ -827,7 +827,7 @@
for (cur = lib_list; cur; cur = cur->next) {
if (cur->resolved == 0 && cur->path) {
got_em_all = 1;
- printf("checking sub-depends for '%s'\n", cur->path);
+ fprintf(stderr, "checking sub-depends for '%s'\n", cur->path);
find_dependencies(cur->path);
cur->resolved = 1;
}
From a8dc90eaaa5e6474beac828558d969b1aafee4af Mon Sep 17 00:00:00 2001
From: Florian Fainelli <florian@openwrt.org>
Date: Wed, 9 Jan 2013 16:17:21 +0100
Subject: [PATCH] libc: add {get,set,swap,make}context user context
manipulation functions
Add the obsolescent SUSv3 family of user context manipulating functions
for arm, i386, mips, x86_64.
Signed-off-by: Timon ter Braak <timonterbraak@gmail.com>
Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
Rules.mak | 2 +
extra/Configs/Config.arm | 1 +
extra/Configs/Config.i386 | 1 +
extra/Configs/Config.in | 16 ++
extra/Configs/Config.mips | 1 +
extra/Configs/Config.x86_64 | 1 +
include/ucontext.h | 32 +++-
libc/.gitignore | 1 +
libc/sysdeps/linux/Makefile.commonarch | 20 +-
libc/sysdeps/linux/arm/Makefile.arch | 5 +
libc/sysdeps/linux/arm/getcontext.S | 80 ++++++++
libc/sysdeps/linux/arm/makecontext.c | 73 +++++++
libc/sysdeps/linux/arm/setcontext.S | 76 ++++++++
libc/sysdeps/linux/arm/swapcontext.S | 63 ++++++
libc/sysdeps/linux/arm/ucontext_i.sym | 30 +++
libc/sysdeps/linux/i386/Makefile.arch | 4 +
libc/sysdeps/linux/i386/getcontext.S | 84 ++++++++
libc/sysdeps/linux/i386/makecontext.S | 123 ++++++++++++
libc/sysdeps/linux/i386/setcontext.S | 96 ++++++++++
libc/sysdeps/linux/i386/swapcontext.S | 110 +++++++++++
libc/sysdeps/linux/i386/ucontext_i.sym | 30 +++
libc/sysdeps/linux/mips/Makefile.arch | 4 +
libc/sysdeps/linux/mips/getcontext.S | 148 +++++++++++++++
libc/sysdeps/linux/mips/kernel_rt_sigframe.h | 10 +
libc/sysdeps/linux/mips/makecontext.S | 188 ++++++++++++++++++
libc/sysdeps/linux/mips/setcontext.S | 191 +++++++++++++++++++
libc/sysdeps/linux/mips/swapcontext.S | 211 +++++++++++++++++++++
libc/sysdeps/linux/mips/ucontext_i.sym | 52 +++++
libc/sysdeps/linux/x86_64/Makefile.arch | 5 +
libc/sysdeps/linux/x86_64/__start_context.S | 49 +++++
libc/sysdeps/linux/x86_64/getcontext.S | 88 +++++++++
libc/sysdeps/linux/x86_64/makecontext.c | 121 ++++++++++++
libc/sysdeps/linux/x86_64/setcontext.S | 103 ++++++++++
libc/sysdeps/linux/x86_64/swapcontext.S | 121 ++++++++++++
libc/sysdeps/linux/x86_64/ucontext_i.sym | 37 ++++
libpthread/nptl/sysdeps/Makefile.commonarch | 3 +-
.../sysdeps/unix/sysv/linux/Makefile.commonarch | 2 -
37 files changed, 2174 insertions(+), 8 deletions(-)
create mode 100644 libc/.gitignore
create mode 100644 libc/sysdeps/linux/arm/getcontext.S
create mode 100644 libc/sysdeps/linux/arm/makecontext.c
create mode 100644 libc/sysdeps/linux/arm/setcontext.S
create mode 100644 libc/sysdeps/linux/arm/swapcontext.S
create mode 100644 libc/sysdeps/linux/arm/ucontext_i.sym
create mode 100644 libc/sysdeps/linux/i386/getcontext.S
create mode 100644 libc/sysdeps/linux/i386/makecontext.S
create mode 100644 libc/sysdeps/linux/i386/setcontext.S
create mode 100644 libc/sysdeps/linux/i386/swapcontext.S
create mode 100644 libc/sysdeps/linux/i386/ucontext_i.sym
create mode 100644 libc/sysdeps/linux/mips/getcontext.S
create mode 100644 libc/sysdeps/linux/mips/kernel_rt_sigframe.h
create mode 100644 libc/sysdeps/linux/mips/makecontext.S
create mode 100644 libc/sysdeps/linux/mips/setcontext.S
create mode 100644 libc/sysdeps/linux/mips/swapcontext.S
create mode 100644 libc/sysdeps/linux/mips/ucontext_i.sym
create mode 100644 libc/sysdeps/linux/x86_64/__start_context.S
create mode 100644 libc/sysdeps/linux/x86_64/getcontext.S
create mode 100644 libc/sysdeps/linux/x86_64/makecontext.c
create mode 100644 libc/sysdeps/linux/x86_64/setcontext.S
create mode 100644 libc/sysdeps/linux/x86_64/swapcontext.S
create mode 100644 libc/sysdeps/linux/x86_64/ucontext_i.sym
diff --git a/Rules.mak b/Rules.mak
index 96871e1..8943fbf 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -813,3 +813,5 @@ SHARED_END_FILES:=$(LIBGCC_DIR)crtendS.o $(top_builddir)lib/crtn.o
endif
LOCAL_INSTALL_PATH := install_dir
+
+PTHREAD_GENERATE_MANGLE ?= -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*\$$/\#define \1 \2/p"
diff --git a/extra/Configs/Config.arm b/extra/Configs/Config.arm
index 0bb2971..dc53643 100644
--- a/extra/Configs/Config.arm
+++ b/extra/Configs/Config.arm
@@ -11,6 +11,7 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_ANY_ENDIAN
+ select ARCH_HAS_UCONTEXT
config CONFIG_ARM_EABI
bool "Build for EABI"
diff --git a/extra/Configs/Config.i386 b/extra/Configs/Config.i386
index 288aa5e..92cee3b 100644
--- a/extra/Configs/Config.i386
+++ b/extra/Configs/Config.i386
@@ -12,6 +12,7 @@ config FORCE_OPTIONS_FOR_ARCH
default y
select ARCH_LITTLE_ENDIAN
select ARCH_HAS_MMU
+ select ARCH_HAS_UCONTEXT
choice
prompt "Target x86 Processor Family"
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index 4bb6812..62bcd9b 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -261,6 +261,9 @@ config ARCH_HAS_NO_LDSO
bool
select ARCH_HAS_NO_SHARED
+config ARCH_HAS_UCONTEXT
+ bool
+
config HAVE_SHARED
bool "Enable shared libraries"
depends on !ARCH_HAS_NO_SHARED
@@ -678,6 +681,19 @@ config UCLIBC_SUSV3_LEGACY
WARNING! ABI incompatibility.
+config UCLIBC_HAS_CONTEXT_FUNCS
+ bool "Use obsolescent context control functions"
+ depends on UCLIBC_SUSV3_LEGACY && ARCH_HAS_UCONTEXT
+ help
+ Add into library the SuSv3 obsolescent functions used for context
+ control. The setcontext family allows the implementation in C of
+ advanced control flow patterns such as iterators, fibers, and
+ coroutines. They may be viewed as an advanced version of
+ setjmp/longjmp; whereas the latter allows only a single non-local jump
+ up the stack, setcontext allows the creation of multiple cooperative
+ threads of control, each with its own stack.
+ These functions are: setcontext, getcontext, makecontext, swapcontext.
+
config UCLIBC_SUSV3_LEGACY_MACROS
bool "Enable SuSv3 LEGACY macros"
help
diff --git a/extra/Configs/Config.mips b/extra/Configs/Config.mips
index 063b07c..48e0b64 100644
--- a/extra/Configs/Config.mips
+++ b/extra/Configs/Config.mips
@@ -11,6 +11,7 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_ANY_ENDIAN
+ select ARCH_HAS_UCONTEXT
choice
prompt "Target ABI"
diff --git a/extra/Configs/Config.x86_64 b/extra/Configs/Config.x86_64
index 1b28088..4c8c3a9 100644
--- a/extra/Configs/Config.x86_64
+++ b/extra/Configs/Config.x86_64
@@ -12,3 +12,4 @@ config FORCE_OPTIONS_FOR_ARCH
default y
select ARCH_LITTLE_ENDIAN
select ARCH_HAS_MMU
+ select ARCH_HAS_UCONTEXT
diff --git a/include/ucontext.h b/include/ucontext.h
index 14a1270..f11db77 100644
--- a/include/ucontext.h
+++ b/include/ucontext.h
@@ -15,17 +15,43 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+/* The System V ABI user-level context switching support functions
+ are marked obsolescent by SuSv3. */
+
#ifndef _UCONTEXT_H
#define _UCONTEXT_H 1
#include <features.h>
+#ifdef __UCLIBC_HAS_CONTEXT_FUNCS__
+
/* Get machine dependent definition of data structures. */
#include <sys/ucontext.h>
-/* The System V ABI user-level context switching support functions
- * are marked obsolescent by SuSv3, and are not implemented by
- * uClibc. This header is therefore empty. */
+__BEGIN_DECLS
+
+/* Get user context and store it in variable pointed to by UCP. */
+extern int getcontext (ucontext_t *__ucp) __THROW;
+
+/* Set user context from information of variable pointed to by UCP. */
+extern int setcontext (const ucontext_t *__ucp) __THROW;
+
+/* Save current context in context variable pointed to by OUCP and set
+ context from variable pointed to by UCP. */
+extern int swapcontext (ucontext_t *__restrict __oucp,
+ const ucontext_t *__restrict __ucp) __THROW;
+
+/* Manipulate user context UCP to continue with calling functions FUNC
+ and the ARGC-1 parameters following ARGC when the context is used
+ the next time in `setcontext' or `swapcontext'.
+
+ We cannot say anything about the parameters FUNC takes; `void'
+ is as good as any other choice. */
+extern void makecontext (ucontext_t *__ucp, void (*__func) (void),
+ int __argc, ...) __THROW;
+
+__END_DECLS
+#endif
#endif /* ucontext.h */
diff --git a/libc/.gitignore b/libc/.gitignore
new file mode 100644
index 0000000..f4c0305
--- /dev/null
+++ b/libc/.gitignore
@@ -0,0 +1 @@
+ucontext_i.[chs]
diff --git a/libc/sysdeps/linux/Makefile.commonarch b/libc/sysdeps/linux/Makefile.commonarch
index c1bc5df..ac89e72 100644
--- a/libc/sysdeps/linux/Makefile.commonarch
+++ b/libc/sysdeps/linux/Makefile.commonarch
@@ -37,5 +37,23 @@ headers-y += $(ARCH_HEADERS_OUT)
headers_clean-y += HEADERCLEAN_$(subst $(top_builddir),,$(ARCH_OUT))
HEADERCLEAN_$(subst $(top_builddir),,$(ARCH_OUT)):
$(do_rm) $(ARCH_HEADERS_OUT)
-
endif
+
+CFLAGS-ucontext_i.c = -S
+
+$(ARCH_OUT)/ucontext_i.c: $(ARCH_DIR)/ucontext_i.sym
+ $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
+
+$(ARCH_OUT)/ucontext_i.s: $(ARCH_OUT)/ucontext_i.c
+ $(compile.c)
+
+$(ARCH_OUT)/ucontext_i.h: $(ARCH_OUT)/ucontext_i.s
+ $(do_sed) $(PTHREAD_GENERATE_MANGLE) $< > $@
+
+pregen-headers-$(UCLIBC_HAS_CONTEXT_FUNCS) += $(ARCH_OUT)/ucontext_i.h
+
+headers_clean-$(UCLIBC_HAS_CONTEXT_FUNCS) += \
+ HEADERCLEAN_$(subst $(top_builddir),,$(ARCH_OUT)/ucontext_i)
+
+HEADERCLEAN_$(subst $(top_builddir),,$(ARCH_OUT)/ucontext_i):
+ $(do_rm) $(addprefix $(ARCH_OUT)/ucontext_i., c h s)
diff --git a/libc/sysdeps/linux/arm/Makefile.arch b/libc/sysdeps/linux/arm/Makefile.arch
index 5fc3e54..36d988b 100644
--- a/libc/sysdeps/linux/arm/Makefile.arch
+++ b/libc/sysdeps/linux/arm/Makefile.arch
@@ -43,3 +43,8 @@ libc-static-y += $(ARCH_OUT)/aeabi_lcsts.o $(ARCH_OUT)/aeabi_math.o \
libc-nonshared-y += $(ARCH_OUT)/aeabi_lcsts.os $(ARCH_OUT)/aeabi_math.os \
$(ARCH_OUT)/aeabi_sighandlers.os $(ARCH_OUT)/aeabi_unwind_cpp_pr1.o
endif
+
+ifeq ($(UCLIBC_HAS_CONTEXT_FUNCS),y)
+CSRC += makecontext.c
+SSRC += getcontext.S setcontext.S swapcontext.S
+endif
diff --git a/libc/sysdeps/linux/arm/getcontext.S b/libc/sysdeps/linux/arm/getcontext.S
new file mode 100644
index 0000000..a987c52
--- /dev/null
+++ b/libc/sysdeps/linux/arm/getcontext.S
@@ -0,0 +1,80 @@
+/* Copyright (C) 2012 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+#include "ucontext_i.h"
+
+ .syntax unified
+ .text
+
+/* int getcontext (ucontext_t *ucp) */
+
+ENTRY(__getcontext)
+ /* No need to save r0-r3, d0-d7, or d16-d31. */
+ add r1, r0, #MCONTEXT_ARM_R4
+ stmia r1, {r4-r11}
+
+ /* Save R13 separately as Thumb can't STM it. */
+ str r13, [r0, #MCONTEXT_ARM_SP]
+ str r14, [r0, #MCONTEXT_ARM_LR]
+ /* Return to LR */
+ str r14, [r0, #MCONTEXT_ARM_PC]
+ /* Return zero */
+ mov r2, #0
+ str r2, [r0, #MCONTEXT_ARM_R0]
+
+ /* Save ucontext_t * across the next call. */
+ mov r4, r0
+
+ /* __sigprocmask(SIG_BLOCK, NULL, &(ucontext->uc_sigmask)) */
+ mov r0, #SIG_BLOCK
+ mov r1, #0
+ add r2, r4, #UCONTEXT_SIGMASK
+ bl PLTJMP(sigprocmask)
+
+#if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
+# ifdef __VFP_FP__
+ /* Store the VFP registers. */
+ /* Following instruction is fstmiax ip!, {d8-d15}. */
+ stc p11, cr8, [r0], #64
+ /* Store the floating-point status register. */
+ /* Following instruction is fmrx r2, fpscr. */
+ mrc p10, 7, r1, cr1, cr0, 0
+ str r1, [r0], #4
+# endif
+#endif
+#ifdef __IWMMXT__
+ /* Save the call-preserved iWMMXt registers. */
+ /* Following instructions are wstrd wr10, [r0], #8 (etc.) */
+ stcl p1, cr10, [r0], #8
+ stcl p1, cr11, [r0], #8
+ stcl p1, cr12, [r0], #8
+ stcl p1, cr13, [r0], #8
+ stcl p1, cr14, [r0], #8
+ stcl p1, cr15, [r0], #8
+#endif
+
+ /* Restore the clobbered R4 and LR. */
+ ldr r14, [r4, #MCONTEXT_ARM_LR]
+ ldr r4, [r4, #MCONTEXT_ARM_R4]
+
+ mov r0, #0
+ DO_RET(r14)
+
+END(__getcontext)
+weak_alias(__getcontext, getcontext)
diff --git a/libc/sysdeps/linux/arm/makecontext.c b/libc/sysdeps/linux/arm/makecontext.c
new file mode 100644
index 0000000..d6ae6f0
--- /dev/null
+++ b/libc/sysdeps/linux/arm/makecontext.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 2012 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.