This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "uClibc-ng - small C library for embedded systems".
The branch, upstream has been updated
via 24946289317ea23bb0d1814cca0a499a905f7d6f (commit)
via d3c60fc490d714d7610a91555cec67952409b189 (commit)
via 70bafe7e4d52f6dafbb5888009c9b601cdbc3743 (commit)
via 8fde02feb2f8a36934308012d89fa6614967b2dc (commit)
via cc8d7d062e2db0a1ed3973e6af38cd1938ba74d7 (commit)
via 560f416794403be952e850756d7e8b23e8fa92ac (commit)
via cf80a7fc2db30364ac98be40483e599c2c243e87 (commit)
via 8836d184d4da65e8959210bc7b768e628b0273fb (commit)
via fc673e14203e1c9aea353d99ff89a17d46b2ad93 (commit)
via 2c8a7766681b704e710f51c0817534e3f9a952d1 (commit)
via 9e552e6a2d836698834d2bf887dbf1806172729f (commit)
via 6f363f69221a6b40ef0f88631cd8d675465eb63d (commit)
via 6ff9c31abc14f207265ab214370982ecb3bfe428 (commit)
via 2b33716c08cc506e57115e34b5fe11d8d5477398 (commit)
from 40effcf4c1e9a2fb9169d9189bdc9b1c888f9345 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 24946289317ea23bb0d1814cca0a499a905f7d6f
Author: Alexey Brodkin <abrodkin(a)synopsys.com>
Date: Thu Mar 26 14:25:37 2015 +0530
ARC: don't hard-code ELF_NGREG
Signed-off-by: Alexey Brodkin <abrodkin(a)synopsys.com>
Signed-off-by: Vineet Gupta <vgupta(a)synopsys.com>
[updated changelog]
Signed-off-by: Vineet Gupta <vgupta(a)synopsys.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
commit d3c60fc490d714d7610a91555cec67952409b189
Author: Vineet Gupta <vgupta(a)synopsys.com>
Date: Thu Mar 26 18:07:04 2015 +0530
ARC/signal: shield sa_restorer from compiler toggle side-effects
when building uClibc with -O0 (DODEBUG build) the default sigrestorer
had some extra glue code generated for stack manipulation which was
messing up resume from signal path.
So annotate the function with -Os so that gcc would only generate the
bare min 2 instruction TRAP sequence
Reported-and-Debugged-by: Alexey Brodkin <abrodkin(a)synopsys.com>
Signed-off-by: Vineet Gupta <vgupta(a)synopsys.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
commit 70bafe7e4d52f6dafbb5888009c9b601cdbc3743
Author: Vineet Gupta <vgupta(a)synopsys.com>
Date: Thu Mar 26 14:25:35 2015 +0530
ARC: switch to NPTL
Signed-off-by: Vineet Gupta <vgupta(a)synopsys.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
commit 8fde02feb2f8a36934308012d89fa6614967b2dc
Author: Andrew Burgess <andrew.burgess(a)embecosm.com>
Date: Thu Mar 26 14:25:34 2015 +0530
Add support for R_ARC_NONE relocations.
The R_ARC_NONE relocation is generated when --gc-sections, used by the
compile time linker, removes some sections. This is completely normal,
and we can see that all other targets (based on random sampling) have
support for R_*_NONE relocations (named for each target).
Handling R_ARC_NONE involves doing nothing with it, which is nice and
easy.
Signed-off-by: Andrew Burgess <andrew.burgess(a)embecosm.com>
Signed-off-by: Vineet Gupta <vgupta(a)synopsys.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
commit cc8d7d062e2db0a1ed3973e6af38cd1938ba74d7
Author: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
Date: Thu Mar 26 23:12:38 2015 +0100
include: update atomic.h from glibc
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
commit 560f416794403be952e850756d7e8b23e8fa92ac
Author: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
Date: Thu Mar 26 22:51:16 2015 +0100
test: Add SIMULATOR_uclibc and SIMULATOR_glibc
where SIMULATOR_glibc is an optional simulator to run host binaries and
SIMULATOR_uclibc is an optional simulator to run target (uClibc)
binaries.
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
commit cf80a7fc2db30364ac98be40483e599c2c243e87
Author: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
Date: Thu Mar 26 00:50:17 2015 +0100
utmp: always have at least utmpx
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
commit 8836d184d4da65e8959210bc7b768e628b0273fb
Author: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
Date: Thu Mar 26 00:03:09 2015 +0100
NPTL: SH: silence warning
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
commit fc673e14203e1c9aea353d99ff89a17d46b2ad93
Author: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
Date: Thu Mar 26 00:03:05 2015 +0100
SH: add 't' to syscall clobber list
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
commit 2c8a7766681b704e710f51c0817534e3f9a952d1
Author: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
Date: Thu Mar 26 00:02:58 2015 +0100
ldso: mark _dl_exit as noreturn
Otherwise gcc might not understand that oom() ended control-flow and
might emit an (untaken) reference to abort() in _dl_update_slotinfo()
on e.g. SH4 which breaks linking ld-uClibc.so.
Arguably -ffreestanding should prevent GCC from emitting this
'.global abort' but alas, it does not, which is another bug..
Also mark the function cold to further lower the incoming frequency and
branch probability.
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
commit 9e552e6a2d836698834d2bf887dbf1806172729f
Author: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
Date: Wed Mar 25 23:59:52 2015 +0100
test: tweaks
Fix arc4random exclusion for real.
Silence warning about missing prototype for external helper-function in
tst-scandir
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
commit 6f363f69221a6b40ef0f88631cd8d675465eb63d
Author: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
Date: Wed Mar 25 23:59:49 2015 +0100
include: Expand malloc-family comments
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
commit 6ff9c31abc14f207265ab214370982ecb3bfe428
Author: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
Date: Wed Mar 25 23:59:45 2015 +0100
utmp: favour POSIX utmpx over SVID utmp
Note: _PATH_UTMPX == _PATH_UTMP and the utmp struct is identical to the
utmpx struct so this only changes the external API entrypoints and NOT
the underlying data source.
This saves about 500b (~1300b from previously ~1950) while at it.
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
commit 2b33716c08cc506e57115e34b5fe11d8d5477398
Author: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
Date: Wed Mar 25 23:59:37 2015 +0100
utmp: Remove unneeded alias
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop(a)gmail.com>
-----------------------------------------------------------------------
Summary of changes:
extra/Configs/Config.in | 24 +-
extra/Configs/defconfigs/arc/arcv2_defconfig | 2 +-
extra/Configs/defconfigs/arc/defconfig | 2 +-
include/atomic.h | 235 +++++++-
include/internal/utmp.h | 92 ++++
include/pty.h | 1 +
include/stdlib.h | 6 +-
include/utmp.h | 10 +-
ldso/include/dl-syscall.h | 10 +-
ldso/ldso/arc/elfinterp.c | 4 +
libc/misc/utmp/Makefile.in | 4 +-
libc/misc/utmp/utent.c | 122 +++--
libc/misc/utmp/utxent.c | 108 ----
libc/misc/utmp/wtent.c | 50 --
libc/sysdeps/linux/arc/sigaction.c | 3 +-
libc/sysdeps/linux/arc/sys/procfs.h | 7 +-
libc/sysdeps/linux/sh/bits/atomic.h | 12 +-
libc/sysdeps/linux/sh/bits/syscalls.h | 2 +-
.../nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h | 2 +-
libutil/forkpty.c | 3 -
libutil/login.c | 6 +-
libutil/login_tty.c | 1 -
libutil/logout.c | 6 +-
libutil/logwtmp.c | 21 +-
libutil/openpty.c | 1 -
test/.gitignore | 2 +
test/README | 3 +
test/Test.mak | 5 +-
test/misc/Makefile.in | 4 +
test/misc/tst-scandir.c | 2 +-
test/silly/Makefile.in | 3 +
test/silly/hello.c | 2 +-
.../silly/tst-atomic-long.c | 16 +-
test/silly/tst-atomic.c | 573 ++++++++++++++++++++
test/stdlib/Makefile.in | 3 +-
35 files changed, 1052 insertions(+), 295 deletions(-)
create mode 100644 include/internal/utmp.h
delete mode 100644 libc/misc/utmp/utxent.c
delete mode 100644 libc/misc/utmp/wtent.c
copy libc/sysdeps/linux/sparc/jmpbuf-offsets.h => test/silly/tst-atomic-long.c (75%)
create mode 100644 test/silly/tst-atomic.c
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index 7546e96..1fd6860 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -701,23 +701,23 @@ config COMPAT_ATEXIT
else you will be missing atexit() until you rebuild all apps.
config UCLIBC_HAS_UTMPX
- bool "utmpx based support for tracking login/logouts to/from the
system"
- depends on UCLIBC_HAS_UTMP # TODO, remove this, it's backward
- help
- Answer y to enable support for accessing user accounting database.
- It can be used to track all login/logout to the system.
+ bool "utmpx based support for tracking login/logouts to/from the system"
+ help
+ Answer y to enable support for accessing user accounting database.
+ It can be used to track all login/logout to the system.
config UCLIBC_HAS_UTMP
- bool "utmp support (XPG2, SVr4 compat)"
- help
- Answer y to enable legacy SVID support for accessing
- user accounting database:
+ bool "utmp support (XPG2 compat, SVr4 compat)"
+ depends on UCLIBC_HAS_UTMPX
+ help
+ Answer y to enable legacy SVID support for accessing
+ user accounting database:
getutent(), getutid(), getutline(), pututline(),
setutent(), endutent(), utmpname() in utmp.h
- It can be used to track all login/logout to the system.
+ It can be used to track all login/logout to the system.
- If unsure, just answer N and use utmpx.h and corresponding
- POSIX functions.
+ If unsure, answer N and use corresponding POSIX functions
+ from utmpx.h
config UCLIBC_SUSV2_LEGACY
bool "Enable SuSv2 LEGACY functions"
diff --git a/extra/Configs/defconfigs/arc/arcv2_defconfig
b/extra/Configs/defconfigs/arc/arcv2_defconfig
index d3a7dc7..7c4694e 100644
--- a/extra/Configs/defconfigs/arc/arcv2_defconfig
+++ b/extra/Configs/defconfigs/arc/arcv2_defconfig
@@ -7,7 +7,7 @@ KERNEL_HEADERS="%KERNEL_HEADERS%"
# LDSO_CACHE_SUPPORT is not set
LDSO_RUNPATH=y
# LDSO_SAFE_RUNPATH is not set
-LINUXTHREADS_OLD=y
+UCLIBC_HAS_THREADS_NATIVE=y
PTHREADS_DEBUG_SUPPORT=y
UCLIBC_HAS_OBSTACK=y
UCLIBC_SUSV2_LEGACY=y
diff --git a/extra/Configs/defconfigs/arc/defconfig
b/extra/Configs/defconfigs/arc/defconfig
index 490bc22..eebb115 100644
--- a/extra/Configs/defconfigs/arc/defconfig
+++ b/extra/Configs/defconfigs/arc/defconfig
@@ -6,7 +6,7 @@ KERNEL_HEADERS="%KERNEL_HEADERS%"
# LDSO_CACHE_SUPPORT is not set
LDSO_RUNPATH=y
# LDSO_SAFE_RUNPATH is not set
-LINUXTHREADS_OLD=y
+UCLIBC_HAS_THREADS_NATIVE=y
PTHREADS_DEBUG_SUPPORT=y
UCLIBC_HAS_OBSTACK=y
UCLIBC_SUSV2_LEGACY=y
diff --git a/include/atomic.h b/include/atomic.h
index 307704c..3680d87 100644
--- a/include/atomic.h
+++ b/include/atomic.h
@@ -1,5 +1,5 @@
/* Internal macros for atomic operations for GNU C Library.
- Copyright (C) 2002-2006, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2002-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper(a)redhat.com>om>, 2002.
@@ -32,7 +32,7 @@
the multi-thread case. The interfaces have the prefix
"catomic_".
- - support functions like barriers. They also have the preifx
+ - support functions like barriers. They also have the prefix
"atomic_".
Architectures must provide a few lowlevel macros (the compare
@@ -198,8 +198,12 @@
/* Add VALUE to *MEM and return the old value of *MEM. */
-#ifndef atomic_exchange_and_add
-# define atomic_exchange_and_add(mem, value) \
+#ifndef atomic_exchange_and_add_acq
+# ifdef atomic_exchange_and_add
+# define atomic_exchange_and_add_acq(mem, value) \
+ atomic_exchange_and_add (mem, value)
+# else
+# define atomic_exchange_and_add_acq(mem, value) \
({ __typeof (*(mem)) __atg6_oldval; \
__typeof (mem) __atg6_memp = (mem); \
__typeof (*(mem)) __atg6_value = (value); \
@@ -213,8 +217,18 @@
__atg6_oldval), 0)); \
\
__atg6_oldval; })
+# endif
#endif
+#ifndef atomic_exchange_and_add_rel
+# define atomic_exchange_and_add_rel(mem, value) \
+ atomic_exchange_and_add_acq(mem, value)
+#endif
+
+#ifndef atomic_exchange_and_add
+# define atomic_exchange_and_add(mem, value) \
+ atomic_exchange_and_add_acq(mem, value)
+#endif
#ifndef catomic_exchange_and_add
# define catomic_exchange_and_add(mem, value) \
@@ -528,6 +542,219 @@
({ __typeof (x) __x; __asm__ ("" : "=r" (__x) : "0" (x));
__x; })
#endif
+/* This is equal to 1 iff the architecture supports 64b atomic operations. */
+#define __HAVE_64B_ATOMICS 0 /* TODO: not yet used - Add these to arch bits! */
+#ifndef __HAVE_64B_ATOMICS
+#error Unable to determine if 64-bit atomics are present.
+#endif
+
+/* The following functions are a subset of the atomic operations provided by
+ C11. Usually, a function named atomic_OP_MO(args) is equivalent to C11's
+ atomic_OP_explicit(args, memory_order_MO); exceptions noted below. */
+
+/* Each arch can request to use compiler built-ins for C11 atomics. If it
+ does, all atomics will be based on these. */
+#if 0 /* not yet used USE_ATOMIC_COMPILER_BUILTINS */
+
+/* We require 32b atomic operations; some archs also support 64b atomic
+ operations. */
+void __atomic_link_error (void);
+# if __HAVE_64B_ATOMICS == 1
+# define __atomic_check_size(mem) \
+ if ((sizeof (*mem) != 4) && (sizeof (*mem) != 8)) \
+ __atomic_link_error ();
+# else
+# define __atomic_check_size(mem) \
+ if (sizeof (*mem) != 4) \
+ __atomic_link_error ();
+# endif
+
+# define atomic_thread_fence_acquire() \
+ __atomic_thread_fence (__ATOMIC_ACQUIRE)
+# define atomic_thread_fence_release() \
+ __atomic_thread_fence (__ATOMIC_RELEASE)
+# define atomic_thread_fence_seq_cst() \
+ __atomic_thread_fence (__ATOMIC_SEQ_CST)
+
+# define atomic_load_relaxed(mem) \
+ ({ __atomic_check_size((mem)); __atomic_load_n ((mem), __ATOMIC_RELAXED); })
+# define atomic_load_acquire(mem) \
+ ({ __atomic_check_size((mem)); __atomic_load_n ((mem), __ATOMIC_ACQUIRE); })
+
+# define atomic_store_relaxed(mem, val) \
+ do { \
+ __atomic_check_size((mem)); \
+ __atomic_store_n ((mem), (val), __ATOMIC_RELAXED); \
+ } while (0)
+# define atomic_store_release(mem, val) \
+ do { \
+ __atomic_check_size((mem)); \
+ __atomic_store_n ((mem), (val), __ATOMIC_RELEASE); \
+ } while (0)
+
+/* On failure, this CAS has memory_order_relaxed semantics. */
+# define atomic_compare_exchange_weak_relaxed(mem, expected, desired) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_compare_exchange_n ((mem), (expected), (desired), 1, \
+ __ATOMIC_RELAXED, __ATOMIC_RELAXED); })
+# define atomic_compare_exchange_weak_acquire(mem, expected, desired) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_compare_exchange_n ((mem), (expected), (desired), 1, \
+ __ATOMIC_ACQUIRE, __ATOMIC_RELAXED); })
+# define atomic_compare_exchange_weak_release(mem, expected, desired) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_compare_exchange_n ((mem), (expected), (desired), 1, \
+ __ATOMIC_RELEASE, __ATOMIC_RELAXED); })
+
+# define atomic_exchange_acquire(mem, desired) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_exchange_n ((mem), (desired), __ATOMIC_ACQUIRE); })
+# define atomic_exchange_release(mem, desired) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_exchange_n ((mem), (desired), __ATOMIC_RELEASE); })
+
+# define atomic_fetch_add_relaxed(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_add ((mem), (operand), __ATOMIC_RELAXED); })
+# define atomic_fetch_add_acquire(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_add ((mem), (operand), __ATOMIC_ACQUIRE); })
+# define atomic_fetch_add_release(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_add ((mem), (operand), __ATOMIC_RELEASE); })
+# define atomic_fetch_add_acq_rel(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_add ((mem), (operand), __ATOMIC_ACQ_REL); })
+
+# define atomic_fetch_and_acquire(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_and ((mem), (operand), __ATOMIC_ACQUIRE); })
+
+# define atomic_fetch_or_relaxed(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_or ((mem), (operand), __ATOMIC_RELAXED); })
+# define atomic_fetch_or_acquire(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_or ((mem), (operand), __ATOMIC_ACQUIRE); })
+
+#else /* !USE_ATOMIC_COMPILER_BUILTINS */
+
+/* By default, we assume that read, write, and full barriers are equivalent
+ to acquire, release, and seq_cst barriers. Archs for which this does not
+ hold have to provide custom definitions of the fences. */
+# ifndef atomic_thread_fence_acquire
+# define atomic_thread_fence_acquire() atomic_read_barrier ()
+# endif
+# ifndef atomic_thread_fence_release
+# define atomic_thread_fence_release() atomic_write_barrier ()
+# endif
+# ifndef atomic_thread_fence_seq_cst
+# define atomic_thread_fence_seq_cst() atomic_full_barrier ()
+# endif
+
+# ifndef atomic_load_relaxed
+# define atomic_load_relaxed(mem) \
+ ({ __typeof (*(mem)) __atg100_val; \
+ __asm__ ("" : "=r" (__atg100_val) : "0" (*(mem)));
\
+ __atg100_val; })
+# endif
+# ifndef atomic_load_acquire
+# define atomic_load_acquire(mem) \
+ ({ __typeof (*(mem)) __atg101_val = atomic_load_relaxed (mem); \
+ atomic_thread_fence_acquire (); \
+ __atg101_val; })
+# endif
+
+# ifndef atomic_store_relaxed
+/* XXX Use inline asm here? */
+# define atomic_store_relaxed(mem, val) do { *(mem) = (val); } while (0)
+# endif
+# ifndef atomic_store_release
+# define atomic_store_release(mem, val) \
+ do { \
+ atomic_thread_fence_release (); \
+ atomic_store_relaxed ((mem), (val)); \
+ } while (0)
+# endif
+
+/* On failure, this CAS has memory_order_relaxed semantics. */
+/* XXX This potentially has one branch more than necessary, but archs
+ currently do not define a CAS that returns both the previous value and
+ the success flag. */
+# ifndef atomic_compare_exchange_weak_acquire
+# define atomic_compare_exchange_weak_acquire(mem, expected, desired) \
+ ({ __typeof (*(expected)) __atg102_expected = *(expected); \
+ *(expected) = \
+ atomic_compare_and_exchange_val_acq ((mem), (desired), *(expected)); \
+ *(expected) == __atg102_expected; })
+# endif
+# ifndef atomic_compare_exchange_weak_relaxed
+/* XXX Fall back to CAS with acquire MO because archs do not define a weaker
+ CAS. */
+# define atomic_compare_exchange_weak_relaxed(mem, expected, desired) \
+ atomic_compare_exchange_weak_acquire ((mem), (expected), (desired))
+# endif
+# ifndef atomic_compare_exchange_weak_release
+# define atomic_compare_exchange_weak_release(mem, expected, desired) \
+ ({ __typeof (*(expected)) __atg103_expected = *(expected); \
+ *(expected) = \
+ atomic_compare_and_exchange_val_rel ((mem), (desired), *(expected)); \
+ *(expected) == __atg103_expected; })
+# endif
+
+# ifndef atomic_exchange_acquire
+# define atomic_exchange_acquire(mem, val) \
+ atomic_exchange_acq ((mem), (val))
+# endif
+# ifndef atomic_exchange_release
+# define atomic_exchange_release(mem, val) \
+ atomic_exchange_rel ((mem), (val))
+# endif
+
+# ifndef atomic_fetch_add_acquire
+# define atomic_fetch_add_acquire(mem, operand) \
+ atomic_exchange_and_add_acq ((mem), (operand))
+# endif
+# ifndef atomic_fetch_add_relaxed
+/* XXX Fall back to acquire MO because the MO semantics of
+ atomic_exchange_and_add are not documented; the generic version falls back
+ to atomic_exchange_and_add_acq if atomic_exchange_and_add is not defined,
+ and vice versa. */
+# define atomic_fetch_add_relaxed(mem, operand) \
+ atomic_fetch_add_acquire ((mem), (operand))
+# endif
+# ifndef atomic_fetch_add_release
+# define atomic_fetch_add_release(mem, operand) \
+ atomic_exchange_and_add_rel ((mem), (operand))
+# endif
+# ifndef atomic_fetch_add_acq_rel
+# define atomic_fetch_add_acq_rel(mem, operand) \
+ ({ atomic_thread_fence_release (); \
+ atomic_exchange_and_add_acq ((mem), (operand)); })
+# endif
+
+/* XXX The default for atomic_and_val has acquire semantics, but this is not
+ documented. */
+# ifndef atomic_fetch_and_acquire
+# define atomic_fetch_and_acquire(mem, operand) \
+ atomic_and_val ((mem), (operand))
+# endif
+
+/* XXX The default for atomic_or_val has acquire semantics, but this is not
+ documented. */
+# ifndef atomic_fetch_or_acquire
+# define atomic_fetch_or_acquire(mem, operand) \
+ atomic_or_val ((mem), (operand))
+# endif
+/* XXX Fall back to acquire MO because archs do not define a weaker
+ atomic_or_val. */
+# ifndef atomic_fetch_or_relaxed
+# define atomic_fetch_or_relaxed(mem, operand) \
+ atomic_fetch_or_acquire ((mem), (operand))
+# endif
+
+#endif /* !USE_ATOMIC_COMPILER_BUILTINS */
+
#ifndef atomic_delay
# define atomic_delay() do { /* nothing */ } while (0)
diff --git a/include/internal/utmp.h b/include/internal/utmp.h
new file mode 100644
index 0000000..49f96b4
--- /dev/null
+++ b/include/internal/utmp.h
@@ -0,0 +1,92 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * internal helper for utmp and utmpx handling
+ *
+ * Copyright (C) 2015 by Bernhard Reutner-Fischer
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ */
+#ifndef __INTERNAL_UTMP_H
+#define __INTERNAL_UTMP_H
+
+#include <utmpx.h>
+#include <utmp.h>
+
+/* Note: _PATH_UTMPX == _PATH_UTMP */
+
+#if (defined __UCLIBC_HAS_UTMPX__ && defined __UCLIBC_HAS_UTMP__) \
+ || !defined __UCLIBC_HAS_UTMP__
+/* implement the X and alias the non-X */
+# define __set_unlocked __setutxent_unlocked
+# define set setutxent
+# define __get_unlocked __getutxent_unlocked
+# define get getutxent
+# define end endutxent
+# define __getid_unlocked __getutxid_unlocked
+# define getid getutxid
+# define getline getutxline
+# define putline pututxline
+# define name utmpxname
+# define updw updwtmpx
+# define UT utmpx
+# ifndef __DEFAULT_PATH_UTMP
+# define __DEFAULT_PATH_UTMP _PATH_UTMPX
+# endif
+# if defined __UCLIBC_HAS_UTMP__
+# define other(n,a) strong_alias_untyped(n,a)
+# else
+# define other(n,a) /* nothing */
+# endif
+#elif defined __UCLIBC_HAS_UTMP__
+# define __set_unlocked __setutent_unlocked
+# define set setutent
+# define __get_unlocked __getutent_unlocked
+# define get getutent
+# define end endutent
+# define __getid_unlocked __getutid_unlocked
+# define getid getutid
+# define getline getutline
+# define putline pututline
+# define name utmpname
+# define updw updwtmp
+# define UT utmp
+# ifndef __DEFAULT_PATH_UTMP
+# define __DEFAULT_PATH_UTMP _PATH_UTMP
+# endif
+# define other(n,a) /* nothing */
+#else
+#error You are supposed to either have UTMP or UTMPX or both here
+#endif
+
+/* not used in libc_hidden_proto(setutxent) */
+/* not used in libc_hidden_proto(endutxent) */
+/* not used in libc_hidden_proto(getutxent) */
+/* not used in libc_hidden_proto(getutxid) */
+/* not used in libc_hidden_proto(getutxline) */
+/* not used in libc_hidden_proto(pututxline) */
+/* not used in libc_hidden_proto(utmpxname) */
+/* not used in libc_hidden_proto(updwtmpx) */
+
+/* not used in libc_hidden_proto(setutent) */
+/* not used in libc_hidden_proto(endutent) */
+/* not used in libc_hidden_proto(getutent) */
+/* not used in libc_hidden_proto(getutid) */
+/* not used in libc_hidden_proto(getutline) */
+/* not used in libc_hidden_proto(pututline) */
+/* not used in libc_hidden_proto(utmpname) */
+/* not used in libc_hidden_proto(updwtmp) */
+
+#ifdef IS_IN_libutil
+# if (defined __UCLIBC_HAS_UTMPX__ && defined __UCLIBC_HAS_UTMP__) \
+ || !defined __UCLIBC_HAS_UTMP__
+ /* monkey-patch to use the POSIX interface */
+# define setutent setutxent
+# define getutline getutxline
+# define pututline pututxline
+# define endutent endutxent
+# define updwtmp updwtmpx
+# endif
+#endif /* IS_IN_libutil */
+
+#endif /* __INTERNAL_UTMP_H */
+
diff --git a/include/pty.h b/include/pty.h
index 26c3011..f23a260 100644
--- a/include/pty.h
+++ b/include/pty.h
@@ -32,6 +32,7 @@ __BEGIN_DECLS
ends in AMASTER and ASLAVE. */
extern int openpty (int *__amaster, int *__aslave, char *__name,
struct termios *__termp, struct winsize *__winp) __THROW;
+libutil_hidden_proto(openpty)
/* Create child process and establish the slave pseudo terminal as the
child's controlling terminal. */
diff --git a/include/stdlib.h b/include/stdlib.h
index 2065dfa..809256d 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -486,11 +486,11 @@ extern int lcong48_r (unsigned short int __param[7],
__BEGIN_NAMESPACE_STD
/* Allocate SIZE bytes of memory. */
extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
-/* We want the malloc symbols overridable at runtime
- * libc_hidden_proto(malloc) */
+/* We want the malloc symbol overridable at runtime, do not hide it! */
/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
extern void *calloc (size_t __nmemb, size_t __size)
__THROW __attribute_malloc__ __wur;
+/* We want the calloc symbol overridable at runtime, do not hide it! */
__END_NAMESPACE_STD
#endif
@@ -503,8 +503,10 @@ __BEGIN_NAMESPACE_STD
between objects pointed by the old and new pointers. */
extern void *realloc (void *__ptr, size_t __size)
__THROW __wur;
+/* We want the realloc symbol overridable at runtime, do not hide it! */
/* Free a block allocated by `malloc', `realloc' or `calloc'. */
extern void free (void *__ptr) __THROW;
+/* We want the free symbol overridable at runtime, do not hide it! */
__END_NAMESPACE_STD
#if 0 /*def __USE_MISC*/
diff --git a/include/utmp.h b/include/utmp.h
index 754f767..8ecbb54 100644
--- a/include/utmp.h
+++ b/include/utmp.h
@@ -40,7 +40,7 @@ __BEGIN_DECLS
/* Make FD be the controlling terminal, stdin, stdout, and stderr;
then close FD. Returns 0 on success, nonzero on error. */
extern int login_tty (int __fd) __THROW;
-
+libutil_hidden_proto(login_tty)
/* Write the given entry into utmp and wtmp. */
extern void login (const struct utmp *__entry) __THROW;
@@ -56,37 +56,29 @@ extern void logwtmp (const char *__ut_line, const char *__ut_name,
/* Append entry UTMP to the wtmp-like file WTMP_FILE. */
extern void updwtmp (const char *__wtmp_file, const struct utmp *__utmp)
__THROW;
-libc_hidden_proto(updwtmp)
/* Change name of the utmp file to be examined. */
extern int utmpname (const char *__file) __THROW;
-libc_hidden_proto(utmpname)
/* Read next entry from a utmp-like file. */
extern struct utmp *getutent (void) __THROW;
-libc_hidden_proto(getutent)
/* Reset the input stream to the beginning of the file. */
extern void setutent (void) __THROW;
-libc_hidden_proto(setutent)
/* Close the current open file. */
extern void endutent (void) __THROW;
-libc_hidden_proto(endutent)
/* Search forward from the current point in the utmp file until the
next entry with a ut_type matching ID->ut_type. */
extern struct utmp *getutid (const struct utmp *__id) __THROW;
-libc_hidden_proto(getutid)
/* Search forward from the current point in the utmp file until the
next entry with a ut_line matching LINE->ut_line. */
extern struct utmp *getutline (const struct utmp *__line) __THROW;
-libc_hidden_proto(getutline)
/* Write out entry pointed to by UTMP_PTR into the utmp file. */
extern struct utmp *pututline (const struct utmp *__utmp_ptr) __THROW;
-libc_hidden_proto(pututline)
#if 0 /* def __USE_MISC */
diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
index 675b93a..e556f7b 100644
--- a/ldso/include/dl-syscall.h
+++ b/ldso/include/dl-syscall.h
@@ -52,7 +52,15 @@ extern int _dl_errno;
dynamic linking at all, so we cannot return any error codes.
We just punt if there is an error. */
#define __NR__dl_exit __NR_exit
-static __always_inline _syscall1(void, _dl_exit, int, status)
+static __always_inline attribute_noreturn __cold void _dl_exit(int status)
+{
+ INLINE_SYSCALL(_dl_exit, 1, status);
+#if defined __GNUC__
+ __builtin_unreachable(); /* shut up warning: 'noreturn' function does return*/
+#else
+ while (1);
+#endif
+}
#define __NR__dl_close __NR_close
static __always_inline _syscall1(int, _dl_close, int, fd)
diff --git a/ldso/ldso/arc/elfinterp.c b/ldso/ldso/arc/elfinterp.c
index 7c31d3a..2f0cf7f 100644
--- a/ldso/ldso/arc/elfinterp.c
+++ b/ldso/ldso/arc/elfinterp.c
@@ -144,6 +144,8 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
#endif
switch (reloc_type) {
+ case R_ARC_NONE:
+ break;
case R_ARC_32:
*reloc_addr += symbol_addr + rpnt->r_addend;
break;
@@ -202,6 +204,8 @@ _dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem
*scope,
#endif
switch (reloc_type) {
+ case R_ARC_NONE:
+ break;
case R_ARC_JMP_SLOT:
*reloc_addr += tpnt->loadaddr;
break;
diff --git a/libc/misc/utmp/Makefile.in b/libc/misc/utmp/Makefile.in
index 715341c..6c54ade 100644
--- a/libc/misc/utmp/Makefile.in
+++ b/libc/misc/utmp/Makefile.in
@@ -8,9 +8,7 @@
subdirs += libc/misc/utmp
CSRC-y :=
-CSRC-$(if $(findstring y,$(UCLIBC_HAS_UTMP)$(UCLIBC_HAS_UTMPX)),y) += wtent.c
-CSRC-$(UCLIBC_HAS_UTMP) += utent.c
-CSRC-$(UCLIBC_HAS_UTMPX) += utxent.c
+CSRC-$(if $(findstring y,$(UCLIBC_HAS_UTMP)$(UCLIBC_HAS_UTMPX)),y) += utent.c
MISC_UTMP_DIR := $(top_srcdir)libc/misc/utmp
MISC_UTMP_OUT := $(top_builddir)libc/misc/utmp
diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c
index 4d71f5e..3671bb0 100644
--- a/libc/misc/utmp/utent.c
+++ b/libc/misc/utmp/utent.c
@@ -19,7 +19,7 @@
#include <paths.h>
#include <errno.h>
#include <string.h>
-#include <utmp.h>
+#include "internal/utmp.h"
#include <not-cancel.h>
#include <bits/uClibc_mutex.h>
@@ -27,17 +27,17 @@ __UCLIBC_MUTEX_STATIC(utmplock, PTHREAD_MUTEX_INITIALIZER);
/* Some global crap */
static int static_fd = -1;
-static struct utmp static_utmp;
-static const char default_file_name[] = _PATH_UTMP;
-static const char *static_ut_name = default_file_name;
+static struct UT static_utmp;
+static const char default_file[] = __DEFAULT_PATH_UTMP;
+static const char *current_file = default_file;
/* This function must be called with the LOCK held */
-static void __setutent_unlocked(void)
+static void __set_unlocked(void)
{
if (static_fd < 0) {
- static_fd = open_not_cancel_2(static_ut_name, O_RDWR | O_CLOEXEC);
+ static_fd = open_not_cancel_2(current_file, O_RDWR | O_CLOEXEC);
if (static_fd < 0) {
- static_fd = open_not_cancel_2(static_ut_name, O_RDONLY | O_CLOEXEC);
+ static_fd = open_not_cancel_2(current_file, O_RDONLY | O_CLOEXEC);
if (static_fd < 0) {
return; /* static_fd remains < 0 */
}
@@ -51,22 +51,23 @@ static void __setutent_unlocked(void)
lseek(static_fd, 0, SEEK_SET);
}
#if defined __UCLIBC_HAS_THREADS__
-void setutent(void)
+void set(void)
{
__UCLIBC_MUTEX_LOCK(utmplock);
- __setutent_unlocked();
+ __set_unlocked();
__UCLIBC_MUTEX_UNLOCK(utmplock);
}
#else
-strong_alias(__setutent_unlocked,setutent)
+strong_alias(__set_unlocked,set)
#endif
-libc_hidden_def(setutent)
+/* not used in libc_hidden_def(set) */
+other(setutxent,setutent)
/* This function must be called with the LOCK held */
-static struct utmp *__getutent_unlocked(void)
+static struct UT *__get_unlocked(void)
{
if (static_fd < 0) {
- __setutent_unlocked();
+ __set_unlocked();
if (static_fd < 0)
return NULL;
}
@@ -79,21 +80,22 @@ static struct utmp *__getutent_unlocked(void)
return NULL;
}
#if defined __UCLIBC_HAS_THREADS__
-struct utmp *getutent(void)
+struct UT *get(void)
{
- struct utmp *ret;
+ struct UT *ret;
__UCLIBC_MUTEX_LOCK(utmplock);
- ret = __getutent_unlocked();
+ ret = __get_unlocked();
__UCLIBC_MUTEX_UNLOCK(utmplock);
return ret;
}
#else
-strong_alias(__getutent_unlocked,getutent)
+strong_alias(__get_unlocked,get)
#endif
-libc_hidden_def(getutent)
+/* not used in libc_hidden_def(get) */
+other(getutxent,getutent)
-static void __endutent(void)
+void end(void)
{
__UCLIBC_MUTEX_LOCK(utmplock);
if (static_fd >= 0)
@@ -101,13 +103,13 @@ static void __endutent(void)
static_fd = -1;
__UCLIBC_MUTEX_UNLOCK(utmplock);
}
-strong_alias(__endutent,endutent)
-libc_hidden_def(endutent)
+/* not used in libc_hidden_def(end) */
+other(endutxent,endutent)
/* This function must be called with the LOCK held */
-static struct utmp *__getutid_unlocked(const struct utmp *utmp_entry)
+static struct UT *__getid_unlocked(const struct UT *utmp_entry)
{
- struct utmp *lutmp;
+ struct UT *lutmp;
unsigned type;
/* We use the fact that constants we are interested in are: */
@@ -115,7 +117,7 @@ static struct utmp *__getutid_unlocked(const struct utmp *utmp_entry)
type = utmp_entry->ut_type - 1;
type /= 4;
- while ((lutmp = __getutent_unlocked()) != NULL) {
+ while ((lutmp = __get_unlocked()) != NULL) {
if (type == 0 && lutmp->ut_type == utmp_entry->ut_type) {
/* one of RUN_LVL, BOOT_TIME, NEW_TIME, OLD_TIME */
return lutmp;
@@ -131,26 +133,27 @@ static struct utmp *__getutid_unlocked(const struct utmp
*utmp_entry)
return NULL;
}
#if defined __UCLIBC_HAS_THREADS__
-struct utmp *getutid(const struct utmp *utmp_entry)
+struct UT *getid(const struct UT *utmp_entry)
{
- struct utmp *ret;
+ struct UT *ret;
__UCLIBC_MUTEX_LOCK(utmplock);
- ret = __getutid_unlocked(utmp_entry);
+ ret = __getid_unlocked(utmp_entry);
__UCLIBC_MUTEX_UNLOCK(utmplock);
return ret;
}
#else
-strong_alias(__getutid_unlocked,getutid)
+strong_alias(__getid_unlocked,getid)
#endif
-libc_hidden_def(getutid)
+/* not used in libc_hidden_def(getid) */
+other(getutxid,getutid)
-struct utmp *getutline(const struct utmp *utmp_entry)
+struct UT *getline(const struct UT *utmp_entry)
{
- struct utmp *lutmp;
+ struct UT *lutmp;
__UCLIBC_MUTEX_LOCK(utmplock);
- while ((lutmp = __getutent_unlocked()) != NULL) {
+ while ((lutmp = __get_unlocked()) != NULL) {
if (lutmp->ut_type == USER_PROCESS || lutmp->ut_type == LOGIN_PROCESS) {
if (strncmp(lutmp->ut_line, utmp_entry->ut_line,
sizeof(lutmp->ut_line)) == 0) {
@@ -161,39 +164,41 @@ struct utmp *getutline(const struct utmp *utmp_entry)
__UCLIBC_MUTEX_UNLOCK(utmplock);
return lutmp;
}
-libc_hidden_def(getutline)
+/* libc_hidden_def(getline) */
+other(getutxline,getutline)
-struct utmp *pututline(const struct utmp *utmp_entry)
+struct UT *putline(const struct UT *utmp_entry)
{
__UCLIBC_MUTEX_LOCK(utmplock);
/* Ignore the return value. That way, if they've already positioned
the file pointer where they want it, everything will work out. */
- lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
+ lseek(static_fd, (off_t) - sizeof(struct UT), SEEK_CUR);
- if (__getutid_unlocked(utmp_entry) != NULL)
- lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
+ if (__getid_unlocked(utmp_entry) != NULL)
+ lseek(static_fd, (off_t) - sizeof(struct UT), SEEK_CUR);
else
lseek(static_fd, (off_t) 0, SEEK_END);
- if (write(static_fd, utmp_entry, sizeof(struct utmp))
- != sizeof(struct utmp))
+ if (write(static_fd, utmp_entry, sizeof(struct UT))
+ != sizeof(struct UT))
utmp_entry = NULL;
__UCLIBC_MUTEX_UNLOCK(utmplock);
- return (struct utmp *)utmp_entry;
+ return (struct UT *)utmp_entry;
}
-libc_hidden_def(pututline)
+/* not used in libc_hidden_def(putline) */
+other(pututxline,pututline)
-int utmpname(const char *new_ut_name)
+int name(const char *new_file)
{
__UCLIBC_MUTEX_LOCK(utmplock);
- if (new_ut_name != NULL) {
- if (static_ut_name != default_file_name)
- free((char *)static_ut_name);
- static_ut_name = strdup(new_ut_name);
- if (static_ut_name == NULL) {
+ if (new_file != NULL) {
+ if (current_file != default_file)
+ free((char *)current_file);
+ current_file = strdup(new_file);
+ if (current_file == NULL) {
/* We should probably whine about out-of-memory
* errors here... Instead just reset to the default */
- static_ut_name = default_file_name;
+ current_file = default_file;
}
}
@@ -202,6 +207,23 @@ int utmpname(const char *new_ut_name)
static_fd = -1;
}
__UCLIBC_MUTEX_UNLOCK(utmplock);
- return 0; /* or maybe return -(static_ut_name != new_ut_name)? */
+ return 0; /* or maybe return -(current_file != new_file)? */
}
-libc_hidden_def(utmpname)
+/* not used in libc_hidden_def(name) */
+other(utmpxname,utmpname)
+
+void updw(const char *wtmp_file, const struct UT *lutmp)
+{
+ int fd;
+
+ fd = open_not_cancel_2(wtmp_file, O_APPEND | O_WRONLY);
+ if (fd >= 0) {
+ if (lockf(fd, F_LOCK, 0) == 0) {
+ write_not_cancel(fd, lutmp, sizeof(struct UT));
+ lockf(fd, F_ULOCK, 0);
+ close_not_cancel_no_status(fd);
+ }
+ }
+}
+/* not used in libc_hidden_def(updw) */
+other(updwtmpx,updwtmp)
diff --git a/libc/misc/utmp/utxent.c b/libc/misc/utmp/utxent.c
deleted file mode 100644
index c32e4da..0000000
--- a/libc/misc/utmp/utxent.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * utexent.c : Support for accessing user accounting database.
- * Copyright (C) 2010 STMicroelectronics Ltd.
- *
- * Author: Salvatore Cro <salvatore.cro(a)st.com>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- *
- */
-
-#include <features.h>
-#include <string.h>
-#include <utmpx.h>
-#include <utmp.h>
-
-void setutxent(void)
-{
- setutent ();
-}
-
-void endutxent(void)
-{
- endutent ();
-}
-
-struct utmpx *getutxent(void)
-{
- return (struct utmpx *) getutent ();
-}
-
-struct utmpx *getutxid(const struct utmpx *utmp_entry)
-{
- return (struct utmpx *) getutid ((const struct utmp *) utmp_entry);
-}
-
-struct utmpx *getutxline(const struct utmpx *utmp_entry)
-{
- return (struct utmpx *) getutline ((const struct utmp *) utmp_entry);
-}
-
-struct utmpx *pututxline (const struct utmpx *utmp_entry)
-{
- return (struct utmpx *) pututline ((const struct utmp *) utmp_entry);
-}
-
-int utmpxname (const char *new_ut_name)
-{
- return utmpname (new_ut_name);
-}
-
-void updwtmpx (const char *wtmpx_file, const struct utmpx *utmpx)
-{
- updwtmp (wtmpx_file, (const struct utmp *) utmpx);
-}
-
-/* Copy the information in UTMPX to UTMP. */
-void getutmp (const struct utmpx *utmpx, struct utmp *utmp)
-{
-#if _HAVE_UT_TYPE - 0
- utmp->ut_type = utmpx->ut_type;
-#endif
-#if _HAVE_UT_PID - 0
- utmp->ut_pid = utmpx->ut_pid;
-#endif
- memcpy (utmp->ut_line, utmpx->ut_line, sizeof (utmp->ut_line));
- memcpy (utmp->ut_user, utmpx->ut_user, sizeof (utmp->ut_user));
-#if _HAVE_UT_ID - 0
- memcpy (utmp->ut_id, utmpx->ut_id, sizeof (utmp->ut_id));
-#endif
-#if _HAVE_UT_HOST - 0
- memcpy (utmp->ut_host, utmpx->ut_host, sizeof (utmp->ut_host));
-#endif
-#if _HAVE_UT_TV - 0
- utmp->ut_tv.tv_sec = utmpx->ut_tv.tv_sec;
- utmp->ut_tv.tv_usec = utmpx->ut_tv.tv_usec;
-#else
- utmp->ut_time = utmpx->ut_time;
-#endif
-}
-
-/* Copy the information in UTMP to UTMPX. */
-void getutmpx (const struct utmp *utmp, struct utmpx *utmpx)
-{
- memset (utmpx, 0, sizeof (struct utmpx));
-
-#if _HAVE_UT_TYPE - 0
- utmpx->ut_type = utmp->ut_type;
-#endif
-#if _HAVE_UT_PID - 0
- utmpx->ut_pid = utmp->ut_pid;
-#endif
- memcpy (utmpx->ut_line, utmp->ut_line, sizeof (utmp->ut_line));
- memcpy (utmpx->ut_user, utmp->ut_user, sizeof (utmp->ut_user));
-#if _HAVE_UT_ID - 0
- memcpy (utmpx->ut_id, utmp->ut_id, sizeof (utmp->ut_id));
-#endif
-#if _HAVE_UT_HOST - 0
- memcpy (utmpx->ut_host, utmp->ut_host, sizeof (utmp->ut_host));
-#endif
-#if _HAVE_UT_TV - 0
- utmpx->ut_tv.tv_sec = utmp->ut_tv.tv_sec;
- utmpx->ut_tv.tv_usec = utmp->ut_tv.tv_usec;
-#else
- utmpx->ut_time = utmp->ut_time;
-#endif
-}
-
diff --git a/libc/misc/utmp/wtent.c b/libc/misc/utmp/wtent.c
deleted file mode 100644
index 30939ea..0000000
--- a/libc/misc/utmp/wtent.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen(a)uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-/* wtmp support rubbish (i.e. complete crap) */
-
-#include <string.h>
-#include <sys/time.h>
-#include <time.h>
-#include <unistd.h>
-#include <utmp.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include <not-cancel.h>
-
-#if 0
-/* This is enabled in uClibc/libutil/logwtmp.c */
-void logwtmp (const char *line, const char *name, const char *host)
-{
- struct utmp lutmp;
- memset(&lutmp, 0, sizeof(lutmp));
-
- lutmp.ut_type = (name && *name) ? USER_PROCESS : DEAD_PROCESS;
- lutmp.ut_pid = getpid();
- strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1);
- strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1);
- strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1);
- gettimeofday(&(lutmp.ut_tv), NULL);
-
- updwtmp(_PATH_WTMP, &lutmp);
-}
-#endif
-
-void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
-{
- int fd;
-
- fd = open_not_cancel_2(wtmp_file, O_APPEND | O_WRONLY);
- if (fd >= 0) {
- if (lockf(fd, F_LOCK, 0) == 0) {
- write_not_cancel(fd, lutmp, sizeof(struct utmp));
- lockf(fd, F_ULOCK, 0);
- close_not_cancel_no_status(fd);
- }
- }
-}
-libc_hidden_def(updwtmp)
diff --git a/libc/sysdeps/linux/arc/sigaction.c b/libc/sysdeps/linux/arc/sigaction.c
index 4a4c9e2..67ca38a 100644
--- a/libc/sysdeps/linux/arc/sigaction.c
+++ b/libc/sysdeps/linux/arc/sigaction.c
@@ -13,7 +13,8 @@
/*
* Default sigretrun stub if user doesn't specify SA_RESTORER
*/
-static void __default_rt_sa_restorer(void)
+static void attribute_optimize("Os") __attribute_noinline__
+__default_rt_sa_restorer(void)
{
INTERNAL_SYSCALL_NCS(__NR_rt_sigreturn, , 0);
}
diff --git a/libc/sysdeps/linux/arc/sys/procfs.h b/libc/sysdeps/linux/arc/sys/procfs.h
index a9e375b..a474303 100755
--- a/libc/sysdeps/linux/arc/sys/procfs.h
+++ b/libc/sysdeps/linux/arc/sys/procfs.h
@@ -20,17 +20,14 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/user.h>
+#include <asm/ptrace.h>
__BEGIN_DECLS
/* Type for a general-purpose register. */
typedef unsigned long elf_greg_t;
-/* And the whole bunch of them. We could have used `struct
- user_regs' directly in the typedef, but tradition says that
- the register set is an array, which does have some peculiar
- semantics, so leave it that way. */
-#define ELF_NGREG 40
+#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
typedef elf_greg_t elf_gregset_t[ELF_NGREG];
typedef struct { } elf_fpregset_t;
diff --git a/libc/sysdeps/linux/sh/bits/atomic.h b/libc/sysdeps/linux/sh/bits/atomic.h
index 745c85c..18ae9ea 100644
--- a/libc/sysdeps/linux/sh/bits/atomic.h
+++ b/libc/sysdeps/linux/sh/bits/atomic.h
@@ -68,6 +68,12 @@ typedef uintmax_t uatomic_max_t;
r1: saved stack pointer
*/
+#if __GNUC_PREREQ (4, 7)
+# define rNOSP "u"
+#else
+# define rNOSP "r"
+#endif
+
/* Avoid having lots of different versions of compare and exchange,
by having this one complicated version. Parameters:
bwl: b, w or l for 8, 16 and 32 bit versions.
@@ -94,7 +100,7 @@ typedef uintmax_t uatomic_max_t;
movt %0\n\
.endif\n" \
: "=&r" (__arch_result) \
- : "r" (mem), "r" (newval), "r" (oldval) \
+ : rNOSP (mem), rNOSP (newval), rNOSP (oldval) \
: "r0", "r1", "t", "memory"); \
__arch_result; })
@@ -150,7 +156,7 @@ typedef uintmax_t uatomic_max_t;
mov." #bwl " %1,@%2\n\
1: mov r1,r15" \
: "=&r" (old), "=&r"(new) \
- : "r" (mem), "r" (value) \
+ : rNOSP (mem), rNOSP (value) \
: "r0", "r1", "memory"); \
})
@@ -194,7 +200,7 @@ typedef uintmax_t uatomic_max_t;
mov." #bwl " %0,@%1\n\
1: mov r1,r15" \
: "=&r" (__new) \
- : "r" (mem), "r" (__value) \
+ : rNOSP (mem), rNOSP (__value) \
: "r0", "r1", "memory"); \
__new; \
})
diff --git a/libc/sysdeps/linux/sh/bits/syscalls.h
b/libc/sysdeps/linux/sh/bits/syscalls.h
index b308276..efd423e 100644
--- a/libc/sysdeps/linux/sh/bits/syscalls.h
+++ b/libc/sysdeps/linux/sh/bits/syscalls.h
@@ -122,7 +122,7 @@
__asm__ __volatile__ (SYSCALL_INST_STR##nr SYSCALL_INST_PAD \
: "=z" (resultvar) \
: "r" (r3) ASMFMT_##nr \
- : "memory" \
+ : "memory", "t" \
); \
(int) resultvar; \
}) \
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h
b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h
index 0b635d3..a9652bb 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h
@@ -358,7 +358,7 @@ extern int __lll_unlock_wake (int *__futex, int private)
attribute_hidden;
register unsigned long __r5 __asm__ ("r5") \
= __lll_private_flag (FUTEX_WAIT, private); \
register unsigned long __r6 __asm__ ("r6") = (unsigned long) (val);
\
- register unsigned long __r7 __asm__ ("r7") = (timeout); \
+ register unsigned long __r7 __asm__ ("r7") = (unsigned long) (timeout);
\
__asm__ __volatile__ (SYSCALL_WITH_INST_PAD \
: "=z" (__status) \
: "r" (__r3), "r" (__r4), "r" (__r5), \
diff --git a/libutil/forkpty.c b/libutil/forkpty.c
index ec490f0..2464333 100644
--- a/libutil/forkpty.c
+++ b/libutil/forkpty.c
@@ -22,9 +22,6 @@
#include <utmp.h>
#include <pty.h>
-libutil_hidden_proto(openpty)
-libutil_hidden_proto(login_tty)
-
int
forkpty (int *amaster, char *name, struct termios *termp, struct winsize *winp)
{
diff --git a/libutil/login.c b/libutil/login.c
index 4007e4c..971997d 100644
--- a/libutil/login.c
+++ b/libutil/login.c
@@ -3,7 +3,7 @@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
-#include <utmp.h>
+#include "internal/utmp.h"
/* Write the given entry into utmp and wtmp.
* Note: the match in utmp is done against ut_id field,
@@ -11,7 +11,7 @@
*/
void login(const struct utmp *entry)
{
- struct utmp copy;
+ struct UT copy;
char tty_name[sizeof(copy.ut_line) + 6];
int fd;
@@ -20,7 +20,7 @@ void login(const struct utmp *entry)
// (if there is such a field) with the value USER_PROCESS,
// and fills the field ut->ut_pid (if there is such a field)
// with the process ID of the calling process.
- copy = *entry;
+ copy = *((const struct UT *)(entry));
#if _HAVE_UT_TYPE - 0
copy.ut_type = USER_PROCESS;
#endif
diff --git a/libutil/login_tty.c b/libutil/login_tty.c
index 3979adc..3665858 100644
--- a/libutil/login_tty.c
+++ b/libutil/login_tty.c
@@ -36,7 +36,6 @@
#include <fcntl.h>
#include <utmp.h>
-libutil_hidden_proto(login_tty)
int login_tty(int fd)
{
(void) setsid();
diff --git a/libutil/logout.c b/libutil/logout.c
index 4580455..0181e23 100644
--- a/libutil/logout.c
+++ b/libutil/logout.c
@@ -18,14 +18,14 @@
#include <errno.h>
#include <string.h>
-#include <utmp.h>
#include <sys/time.h>
+#include "internal/utmp.h"
int
logout (const char *line)
{
- struct utmp tmp;
- struct utmp *ut;
+ struct UT tmp;
+ struct UT *ut;
int result = 0;
/* if (utmpname (_PATH_UTMP) == -1) return 0; - why?
diff --git a/libutil/logwtmp.c b/libutil/logwtmp.c
index 6a53b5f..99b772f 100644
--- a/libutil/logwtmp.c
+++ b/libutil/logwtmp.c
@@ -9,13 +9,13 @@
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
-#include <utmp.h>
#include <fcntl.h>
#include <sys/file.h>
+#include "internal/utmp.h"
void logwtmp(const char *line, const char *name, const char *host)
{
- struct utmp lutmp;
+ struct UT lutmp;
memset(&lutmp, 0, sizeof(lutmp));
lutmp.ut_type = (name && *name) ? USER_PROCESS : DEAD_PROCESS;
@@ -36,20 +36,3 @@ void logwtmp(const char *line, const char *name, const char *host)
updwtmp(_PATH_WTMP, &lutmp);
}
-
-#if 0
-/* This is enabled in uClibc/libc/misc/utmp/wtent.c */
-void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
-{
- int fd;
-
- fd = open(wtmp_file, O_APPEND | O_WRONLY);
- if (fd >= 0) {
- if (lockf(fd, F_LOCK, 0) == 0) {
- write(fd, lutmp, sizeof(*lutmp));
- lockf(fd, F_ULOCK, 0);
- close(fd);
- }
- }
-}
-#endif
diff --git a/libutil/openpty.c b/libutil/openpty.c
index bd8b8d9..848dc8d 100644
--- a/libutil/openpty.c
+++ b/libutil/openpty.c
@@ -84,7 +84,6 @@ pts_name (int fd, char **pts, size_t buf_len)
/* Create pseudo tty master slave pair and set terminal attributes
according to TERMP and WINP. Return handles for both ends in
AMASTER and ASLAVE, and return the name of the slave end in NAME. */
-libutil_hidden_proto(openpty)
int
openpty (int *amaster, int *aslave, char *name, struct termios *termp,
struct winsize *winp)
diff --git a/test/.gitignore b/test/.gitignore
index beb5095..0d19285 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -263,6 +263,8 @@ signal/tst-sigset
signal/tst-sigsimple
silly/hello
silly/tiny
+silly/tst-atomic
+silly/tst-atomic-long
stat/memcmp-stat
stat/stat
stat/stat64
diff --git a/test/README b/test/README
index 28225b0..723ce6e 100644
--- a/test/README
+++ b/test/README
@@ -29,6 +29,9 @@ The following make variables may help you in testing:
So, to just run the uClibc tests, try this:
make check UCLIBC_ONLY=1
+You can pass the following 2 environment variables to "make run":
+ - make run SIMULATOR_uclibc=qemu-sh4 SIMULATOR_glibc=qemu-x86_64
+
If you need to test just a subset of all test, delete subdirectories
you do not need.
diff --git a/test/Test.mak b/test/Test.mak
index ee43a0f..a56a201 100644
--- a/test/Test.mak
+++ b/test/Test.mak
@@ -69,7 +69,7 @@ endef
define exec_test
$(showtest)
$(Q)\
- $(WRAPPER) $(WRAPPER_$(tst_src_name)) \
+ $(SIMULATOR) $(WRAPPER) $(WRAPPER_$(tst_src_name)) \
./$(binary_name) $(OPTS) $(OPTS_$(tst_src_name)) > "$(binary_name).out"
2>&1 ; \
ret=$$? ; \
expected_ret="$(RET_$(tst_src_name))" ; \
@@ -85,6 +85,9 @@ endef
test check all: run
run: $(RUN_TARGETS)
+
+$(addsuffix .exe,$(U_TARGETS)): SIMULATOR:=$(SIMULATOR_uclibc)
+$(addsuffix .exe,$(G_TARGETS)): SIMULATOR:=$(SIMULATOR_glibc)
$(RUN_TARGETS):
$(exec_test)
$(diff_test)
diff --git a/test/misc/Makefile.in b/test/misc/Makefile.in
index 2fb9652..09f631f 100644
--- a/test/misc/Makefile.in
+++ b/test/misc/Makefile.in
@@ -20,6 +20,10 @@ ifeq ($(UCLIBC_HAS_UTMPX),)
TESTS_DISABLED += tst-utmpx
endif
+ifeq ($(UCLIBC_HAS_UTMP),)
+TESTS_DISABLED += tst-utmp
+endif
+
DODIFF_dirent := 1
DODIFF_dirent64 := 1
DODIFF_tst-statfs := 1
diff --git a/test/misc/tst-scandir.c b/test/misc/tst-scandir.c
index df62a40..e1c72e3 100644
--- a/test/misc/tst-scandir.c
+++ b/test/misc/tst-scandir.c
@@ -3,7 +3,7 @@
#include <stdio.h> /* perror() */
#include <stdlib.h>
-int skip_all(const struct dirent *dirbuf)
+static int skip_all(const struct dirent *dirbuf)
{
errno = EBADF;
return 0;
diff --git a/test/silly/Makefile.in b/test/silly/Makefile.in
index bb08e0d..9bb4032 100644
--- a/test/silly/Makefile.in
+++ b/test/silly/Makefile.in
@@ -3,3 +3,6 @@
RET_hello := 42
RET_tiny := 42
+
+# missing internal headers, disable these
+GLIBC_TESTS_DISABLED := tst-atomic_glibc tst-atomic-long_glibc
diff --git a/test/silly/hello.c b/test/silly/hello.c
index 4aba926..d330597 100644
--- a/test/silly/hello.c
+++ b/test/silly/hello.c
@@ -1,4 +1,4 @@
-#include<stdio.h>
+#include <stdio.h>
#include <stdlib.h>
int main(void)
diff --git a/libc/sysdeps/linux/sparc/jmpbuf-offsets.h b/test/silly/tst-atomic-long.c
similarity index 75%
copy from libc/sysdeps/linux/sparc/jmpbuf-offsets.h
copy to test/silly/tst-atomic-long.c
index 0d0a96d..d13fb07 100644
--- a/libc/sysdeps/linux/sparc/jmpbuf-offsets.h
+++ b/test/silly/tst-atomic-long.c
@@ -1,6 +1,7 @@
-/* Private macros for accessing __jmp_buf contents. SPARC version.
- Copyright (C) 2006 Free Software Foundation, Inc.
+/* Tests for atomic.h macros.
+ Copyright (C) 2003-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub(a)redhat.com>om>, 2003.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -18,12 +19,9 @@
#include <bits/wordsize.h>
+#define atomic_t long
#if __WORDSIZE == 64
-#define O_mask_was_saved 512
-#define O_gregs 32
-#define O_g1 (O_gregs + 4*8)
-#else
-#define JB_SP 0
-#define JB_FP 1
-#define JB_PC 2
+# define TEST_ATOMIC64 1
#endif
+
+#include "tst-atomic.c"
diff --git a/test/silly/tst-atomic.c b/test/silly/tst-atomic.c
new file mode 100644
index 0000000..fc773b2
--- /dev/null
+++ b/test/silly/tst-atomic.c
@@ -0,0 +1,573 @@
+/* Tests for atomic.h macros.
+ Copyright (C) 2003-2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub(a)redhat.com>om>, 2003.
+
+ 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 <stdio.h>
+#include <atomic.h>
+
+#ifndef atomic_t
+# define atomic_t int
+#endif
+
+#define CHK2(f,a1,a2,rv,new_mem) \
+ retval = f(&mem, a1, a2); \
+ if (retval != rv) { \
+ printf("%s(mem, %lu, %lu): retval %lu != expected %lu\n", \
+ #f, a1, a2, retval, rv); \
+ ret = 1; \
+ } \
+ if (mem != new_mem) { \
+ printf("%s(mem, %lu, %lu): mem %lu != expected %lu\n", \
+ #f, a1, a2, mem, new_mem); \
+ ret = 1; \
+ }
+#define CHK1(f,a1,rv,new_mem) \
+ retval = f(&mem, a1); \
+ if (retval != rv) { \
+ printf("%s(mem, %lu): retval %lu != expected %lu\n", \
+ #f, a1, retval, rv); \
+ ret = 1; \
+ } \
+ if (mem != new_mem) { \
+ printf("%s(mem, %lu): mem %lu != expected %lu\n", \
+ #f, a1, mem, new_mem); \
+ ret = 1; \
+ }
+#define CHK0(f,rv,new_mem) \
+ retval = f(&mem); \
+ if (retval != rv) { \
+ printf("%s(mem): retval %lu != expected %lu\n", \
+ #f, retval, rv); \
+ ret = 1; \
+ } \
+ if (mem != new_mem) { \
+ printf("%s(mem): mem %lu != expected %lu\n", \
+ #f, mem, new_mem); \
+ ret = 1; \
+ }
+
+/* Test various atomic.h macros. */
+static int
+do_test (void)
+{
+ atomic_t mem, expected, retval;
+ int ret = 0;
+
+#ifdef atomic_compare_and_exchange_val_acq
+ mem = 24;
+ CHK2(atomic_compare_and_exchange_val_acq, 35, 24, 24, 35);
+ mem = 12;
+ CHK2(atomic_compare_and_exchange_val_acq, 10, 15, 12, 12);
+ mem = -15;
+ CHK2(atomic_compare_and_exchange_val_acq, -56, -15, -15, -56);
+ mem = -1;
+ CHK2(atomic_compare_and_exchange_val_acq, 17, 0, -1, -1);
+#endif
+
+ mem = 24;
+ CHK2(atomic_compare_and_exchange_bool_acq, 35, 24, 0, 35);
+ mem = 12;
+ CHK2(atomic_compare_and_exchange_bool_acq, 10, 15, 1, 12);
+ mem = -15;
+ CHK2(atomic_compare_and_exchange_bool_acq, -56, -15, 0, -56);
+ mem = -1;
+ CHK2(atomic_compare_and_exchange_bool_acq, 17, 0, 1, -1);
+
+ mem = 64;
+ CHK1(atomic_exchange_acq, 31, 64, 31);
+ mem = 2;
+ CHK1(atomic_exchange_and_add, 11, 2, 13);
+ mem = 2;
+ CHK1(atomic_exchange_and_add_acq, 11, 2, 13);
+ mem = 2;
+ CHK1(atomic_exchange_and_add_rel, 11, 2, 13);
+
+ mem = -21;
+ atomic_add (&mem, 22);
+ if (mem != 1)
+ {
+ printf ("atomic_add(mem, 22): mem %lu != expected 1\n", mem);
+ ret = 1;
+ }
+
+ mem = -1;
+ atomic_increment (&mem);
+ if (mem != 0)
+ {
+ printf ("atomic_increment(mem): mem %lu != expected 0\n", mem);
+ ret = 1;
+ }
+
+ mem = 2;
+ if ((retval = atomic_increment_val (&mem)) != 3)
+ {
+ printf ("atomic_increment_val(mem): retval %lu != expected 3\n",
retval);
+ ret = 1;
+ }
+
+ mem = 0;
+ CHK0(atomic_increment_and_test, 0, 1);
+ mem = 35;
+ CHK0(atomic_increment_and_test, 0, 36);
+ mem = -1;
+ CHK0(atomic_increment_and_test, 1, 0);
+ mem = 17;
+ atomic_decrement (&mem);
+ if (mem != 16)
+ {
+ printf ("atomic_increment(mem): mem %lu != expected 16\n", mem);
+ ret = 1;
+ }
+
+ if ((retval = atomic_decrement_val (&mem)) != 15)
+ {
+ printf ("atomic_decrement_val(mem): retval %lu != expected 15\n",
retval);
+ ret = 1;
+ }
+
+ mem = 0;
+ CHK0(atomic_decrement_and_test, 0, -1);
+
+ mem = 15;
+ CHK0(atomic_decrement_and_test, 0, 14);
+ mem = 1;
+ CHK0(atomic_decrement_and_test, 1, 0);
+ mem = 1;
+ if (atomic_decrement_if_positive (&mem) != 1
+ || mem != 0)
+ {
+ puts ("atomic_decrement_if_positive test 1 failed");
+ ret = 1;
+ }
+
+ mem = 0;
+ if (atomic_decrement_if_positive (&mem) != 0
+ || mem != 0)
+ {
+ puts ("atomic_decrement_if_positive test 2 failed");
+ ret = 1;
+ }
+
+ mem = -1;
+ if (atomic_decrement_if_positive (&mem) != -1
+ || mem != -1)
+ {
+ puts ("atomic_decrement_if_positive test 3 failed");
+ ret = 1;
+ }
+
+ mem = -12;
+ if (! atomic_add_negative (&mem, 10)
+ || mem != -2)
+ {
+ puts ("atomic_add_negative test 1 failed");
+ ret = 1;
+ }
+
+ mem = 0;
+ if (atomic_add_negative (&mem, 100)
+ || mem != 100)
+ {
+ puts ("atomic_add_negative test 2 failed");
+ ret = 1;
+ }
+
+ mem = 15;
+ if (atomic_add_negative (&mem, -10)
+ || mem != 5)
+ {
+ puts ("atomic_add_negative test 3 failed");
+ ret = 1;
+ }
+
+ mem = -12;
+ if (atomic_add_negative (&mem, 14)
+ || mem != 2)
+ {
+ puts ("atomic_add_negative test 4 failed");
+ ret = 1;
+ }
+
+ mem = 0;
+ if (! atomic_add_negative (&mem, -1)
+ || mem != -1)
+ {
+ puts ("atomic_add_negative test 5 failed");
+ ret = 1;
+ }
+
+ mem = -31;
+ if (atomic_add_negative (&mem, 31)
+ || mem != 0)
+ {
+ puts ("atomic_add_negative test 6 failed");
+ ret = 1;
+ }
+
+ mem = -34;
+ if (atomic_add_zero (&mem, 31)
+ || mem != -3)
+ {
+ puts ("atomic_add_zero test 1 failed");
+ ret = 1;
+ }
+
+ mem = -36;
+ if (! atomic_add_zero (&mem, 36)
+ || mem != 0)
+ {
+ puts ("atomic_add_zero test 2 failed");
+ ret = 1;
+ }
+
+ mem = 113;
+ if (atomic_add_zero (&mem, -13)
+ || mem != 100)
+ {
+ puts ("atomic_add_zero test 3 failed");
+ ret = 1;
+ }
+
+ mem = -18;
+ if (atomic_add_zero (&mem, 20)
+ || mem != 2)
+ {
+ puts ("atomic_add_zero test 4 failed");
+ ret = 1;
+ }
+
+ mem = 10;
+ if (atomic_add_zero (&mem, -20)
+ || mem != -10)
+ {
+ puts ("atomic_add_zero test 5 failed");
+ ret = 1;
+ }
+
+ mem = 10;
+ if (! atomic_add_zero (&mem, -10)
+ || mem != 0)
+ {
+ puts ("atomic_add_zero test 6 failed");
+ ret = 1;
+ }
+
+ mem = 0;
+ atomic_bit_set (&mem, 1);
+ if (mem != 2)
+ {
+ puts ("atomic_bit_set test 1 failed");
+ ret = 1;
+ }
+
+ mem = 8;
+ atomic_bit_set (&mem, 3);
+ if (mem != 8)
+ {
+ puts ("atomic_bit_set test 2 failed");
+ ret = 1;
+ }
+
+#ifdef TEST_ATOMIC64
+ mem = 16;
+ atomic_bit_set (&mem, 35);
+ if (mem != 0x800000010LL)
+ {
+ puts ("atomic_bit_set test 3 failed");
+ ret = 1;
+ }
+#endif
+
+ mem = 0;
+ if (atomic_bit_test_set (&mem, 1)
+ || mem != 2)
+ {
+ puts ("atomic_bit_test_set test 1 failed");
+ ret = 1;
+ }
+
+ mem = 8;
+ if (! atomic_bit_test_set (&mem, 3)
+ || mem != 8)
+ {
+ puts ("atomic_bit_test_set test 2 failed");
+ ret = 1;
+ }
+
+#ifdef TEST_ATOMIC64
+ mem = 16;
+ if (atomic_bit_test_set (&mem, 35)
+ || mem != 0x800000010LL)
+ {
+ puts ("atomic_bit_test_set test 3 failed");
+ ret = 1;
+ }
+
+ mem = 0x100000000LL;
+ if (! atomic_bit_test_set (&mem, 32)
+ || mem != 0x100000000LL)
+ {
+ puts ("atomic_bit_test_set test 4 failed");
+ ret = 1;
+ }
+#endif
+
+#ifdef catomic_compare_and_exchange_val_acq
+ mem = 24;
+ if (catomic_compare_and_exchange_val_acq (&mem, 35, 24) != 24
+ || mem != 35)
+ {
+ puts ("catomic_compare_and_exchange_val_acq test 1 failed");
+ ret = 1;
+ }
+
+ mem = 12;
+ if (catomic_compare_and_exchange_val_acq (&mem, 10, 15) != 12
+ || mem != 12)
+ {
+ puts ("catomic_compare_and_exchange_val_acq test 2 failed");
+ ret = 1;
+ }
+
+ mem = -15;
+ if (catomic_compare_and_exchange_val_acq (&mem, -56, -15) != -15
+ || mem != -56)
+ {
+ puts ("catomic_compare_and_exchange_val_acq test 3 failed");
+ ret = 1;
+ }
+
+ mem = -1;
+ if (catomic_compare_and_exchange_val_acq (&mem, 17, 0) != -1
+ || mem != -1)
+ {
+ puts ("catomic_compare_and_exchange_val_acq test 4 failed");
+ ret = 1;
+ }
+#endif
+
+ mem = 24;
+ if (catomic_compare_and_exchange_bool_acq (&mem, 35, 24)
+ || mem != 35)
+ {
+ puts ("catomic_compare_and_exchange_bool_acq test 1 failed");
+ ret = 1;
+ }
+
+ mem = 12;
+ if (! catomic_compare_and_exchange_bool_acq (&mem, 10, 15)
+ || mem != 12)
+ {
+ puts ("catomic_compare_and_exchange_bool_acq test 2 failed");
+ ret = 1;
+ }
+
+ mem = -15;
+ if (catomic_compare_and_exchange_bool_acq (&mem, -56, -15)
+ || mem != -56)
+ {
+ puts ("catomic_compare_and_exchange_bool_acq test 3 failed");
+ ret = 1;
+ }
+
+ mem = -1;
+ if (! catomic_compare_and_exchange_bool_acq (&mem, 17, 0)
+ || mem != -1)
+ {
+ puts ("catomic_compare_and_exchange_bool_acq test 4 failed");
+ ret = 1;
+ }
+
+ mem = 2;
+ if (catomic_exchange_and_add (&mem, 11) != 2
+ || mem != 13)
+ {
+ puts ("catomic_exchange_and_add test failed");
+ ret = 1;
+ }
+
+ mem = -21;
+ catomic_add (&mem, 22);
+ if (mem != 1)
+ {
+ puts ("catomic_add test failed");
+ ret = 1;
+ }
+
+ mem = -1;
+ catomic_increment (&mem);
+ if (mem != 0)
+ {
+ puts ("catomic_increment test failed");
+ ret = 1;
+ }
+
+ mem = 2;
+ if (catomic_increment_val (&mem) != 3)
+ {
+ puts ("catomic_increment_val test failed");
+ ret = 1;
+ }
+
+ mem = 17;
+ catomic_decrement (&mem);
+ if (mem != 16)
+ {
+ puts ("catomic_decrement test failed");
+ ret = 1;
+ }
+
+ if (catomic_decrement_val (&mem) != 15)
+ {
+ puts ("catomic_decrement_val test failed");
+ ret = 1;
+ }
+
+ /* Tests for C11-like atomics. */
+ mem = 11;
+ if (atomic_load_relaxed (&mem) != 11 || atomic_load_acquire (&mem) != 11)
+ {
+ puts ("atomic_load_{relaxed,acquire} test failed");
+ ret = 1;
+ }
+
+ atomic_store_relaxed (&mem, 12);
+ if (mem != 12)
+ {
+ puts ("atomic_store_relaxed test failed");
+ ret = 1;
+ }
+ atomic_store_release (&mem, 13);
+ if (mem != 13)
+ {
+ puts ("atomic_store_release test failed");
+ ret = 1;
+ }
+
+ mem = 14;
+ expected = 14;
+ if (!atomic_compare_exchange_weak_relaxed (&mem, &expected, 25)
+ || mem != 25 || expected != 14)
+ {
+ puts ("atomic_compare_exchange_weak_relaxed test 1 failed");
+ ret = 1;
+ }
+ if (atomic_compare_exchange_weak_relaxed (&mem, &expected, 14)
+ || mem != 25 || expected != 25)
+ {
+ puts ("atomic_compare_exchange_weak_relaxed test 2 failed");
+ ret = 1;
+ }
+ mem = 14;
+ expected = 14;
+ if (!atomic_compare_exchange_weak_acquire (&mem, &expected, 25)
+ || mem != 25 || expected != 14)
+ {
+ puts ("atomic_compare_exchange_weak_acquire test 1 failed");
+ ret = 1;
+ }
+ if (atomic_compare_exchange_weak_acquire (&mem, &expected, 14)
+ || mem != 25 || expected != 25)
+ {
+ puts ("atomic_compare_exchange_weak_acquire test 2 failed");
+ ret = 1;
+ }
+ mem = 14;
+ expected = 14;
+ if (!atomic_compare_exchange_weak_release (&mem, &expected, 25)
+ || mem != 25 || expected != 14)
+ {
+ puts ("atomic_compare_exchange_weak_release test 1 failed");
+ ret = 1;
+ }
+ if (atomic_compare_exchange_weak_release (&mem, &expected, 14)
+ || mem != 25 || expected != 25)
+ {
+ puts ("atomic_compare_exchange_weak_release test 2 failed");
+ ret = 1;
+ }
+
+ mem = 23;
+ if (atomic_exchange_acquire (&mem, 42) != 23 || mem != 42)
+ {
+ puts ("atomic_exchange_acquire test failed");
+ ret = 1;
+ }
+ mem = 23;
+ if (atomic_exchange_release (&mem, 42) != 23 || mem != 42)
+ {
+ puts ("atomic_exchange_release test failed");
+ ret = 1;
+ }
+
+ mem = 23;
+ if (atomic_fetch_add_relaxed (&mem, 1) != 23 || mem != 24)
+ {
+ puts ("atomic_fetch_add_relaxed test failed");
+ ret = 1;
+ }
+ mem = 23;
+ if (atomic_fetch_add_acquire (&mem, 1) != 23 || mem != 24)
+ {
+ puts ("atomic_fetch_add_acquire test failed");
+ ret = 1;
+ }
+ mem = 23;
+ if (atomic_fetch_add_release (&mem, 1) != 23 || mem != 24)
+ {
+ puts ("atomic_fetch_add_release test failed");
+ ret = 1;
+ }
+ mem = 23;
+ if (atomic_fetch_add_acq_rel (&mem, 1) != 23 || mem != 24)
+ {
+ puts ("atomic_fetch_add_acq_rel test failed");
+ ret = 1;
+ }
+
+ mem = 3;
+ if (atomic_fetch_and_acquire (&mem, 2) != 3 || mem != 2)
+ {
+ puts ("atomic_fetch_and_acquire test failed");
+ ret = 1;
+ }
+
+ mem = 4;
+ if (atomic_fetch_or_relaxed (&mem, 2) != 4 || mem != 6)
+ {
+ puts ("atomic_fetch_or_relaxed test failed");
+ ret = 1;
+ }
+ mem = 4;
+ if (atomic_fetch_or_acquire (&mem, 2) != 4 || mem != 6)
+ {
+ puts ("atomic_fetch_or_acquire test failed");
+ ret = 1;
+ }
+
+ /* This is a single-threaded test, so we can't test the effects of the
+ fences. */
+ atomic_thread_fence_acquire ();
+ atomic_thread_fence_release ();
+ atomic_thread_fence_seq_cst ();
+
+ return ret;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/stdlib/Makefile.in b/test/stdlib/Makefile.in
index df3440a..e1cbccf 100644
--- a/test/stdlib/Makefile.in
+++ b/test/stdlib/Makefile.in
@@ -11,8 +11,9 @@ GLIBC_TESTS_DISABLED :=
ifeq ($(UCLIBC_HAS_PTY),)
TESTS_DISABLED += ptytest
endif
+
ifeq ($(UCLIBC_HAS_ARC4RANDOM),)
TESTS_DISABLED += testarc4random
else
-GLIBC_TESTS_DISABLED += testarc4random
+GLIBC_TESTS_DISABLED += testarc4random_glibc
endif
hooks/post-receive
--
uClibc-ng - small C library for embedded systems