From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2803 Path: news.gmane.org!not-for-mail From: Jens Gustedt Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH 5/5] Use the weak functions that do nothing as aliases for the default actions Date: Sat, 16 Feb 2013 00:25:07 +0100 Message-ID: References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1360970723 6772 80.91.229.3 (15 Feb 2013 23:25:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Feb 2013 23:25:23 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2804-gllmg-musl=m.gmane.org@lists.openwall.com Sat Feb 16 00:25:45 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1U6Uey-0000PA-18 for gllmg-musl@plane.gmane.org; Sat, 16 Feb 2013 00:25:40 +0100 Original-Received: (qmail 11838 invoked by uid 550); 15 Feb 2013 23:25:20 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 11830 invoked from network); 15 Feb 2013 23:25:19 -0000 X-IronPort-AV: E=Sophos;i="4.84,675,1355094000"; d="scan'208";a="3112386" In-Reply-To: Resent-From: Jens Gustedt Resent-To: musl@lists.openwall.com Resent-Cc: musl X-Mailer: Evolution 3.2.3-0ubuntu6 Xref: news.gmane.org gmane.linux.lib.musl.general:2803 Archived-At: - this unifies the coding of such functions and clearly marks the intent - all such functions with a same type may be overlayed by the compiler. thereby only three such functions must be realized over all the musl C library - when compiled with -ffunction-sections and linked with -Wl,--gc-sections the gcc toolchain is in fact capable to rip superfluous copies from the final libc.so or from the statically linked executable. 2 5 src/aio/aio_readwrite.c 2 4 src/env/__init_security.c 4 7 src/exit/exit.c 2 2 src/exit/quick_exit.c 4 4 src/mman/mmap.c 4 4 src/mman/munmap.c 2 5 src/process/fork.c 3 5 src/process/posix_spawn.c 3 5 src/process/system.c 2 5 src/thread/cancel_dummy.c 6 3 src/thread/cancellation.c 4 6 src/thread/pthread_create.c 2 4 src/thread/pthread_join.c diff --git a/src/aio/aio_readwrite.c b/src/aio/aio_readwrite.c index e4c95aa..4862365 100644 --- a/src/aio/aio_readwrite.c +++ b/src/aio/aio_readwrite.c @@ -5,11 +5,8 @@ #include #include "pthread_impl.h" -static void dummy(void) -{ -} - -weak_alias(dummy, __aio_wake); +WEAK_PROVIDE_VOID; +weak_alias(__weak_dummy_void, __aio_wake); static void notify_signal(struct sigevent *sev) { diff --git a/src/env/__init_security.c b/src/env/__init_security.c index 91b9b10..5b98623 100644 --- a/src/env/__init_security.c +++ b/src/env/__init_security.c @@ -6,10 +6,8 @@ #include "libc.h" #include "atomic.h" -static void dummy(void *ent) -{ -} -weak_alias(dummy, __init_ssp); +WEAK_PROVIDE_VOIDP; +weak_alias(__weak_dummy_voidp, __init_ssp); void __init_security(size_t *aux) { diff --git a/src/exit/exit.c b/src/exit/exit.c index e4932b5..a866e02 100644 --- a/src/exit/exit.c +++ b/src/exit/exit.c @@ -5,14 +5,11 @@ #include "atomic.h" #include "syscall.h" -static void dummy() -{ -} - /* __toread.c, __towrite.c, and atexit.c override these */ -weak_alias(dummy, __funcs_on_exit); -weak_alias(dummy, __flush_on_exit); -weak_alias(dummy, __seek_on_exit); +WEAK_PROVIDE_VOID; +weak_alias(__weak_dummy_void, __funcs_on_exit); +weak_alias(__weak_dummy_void, __flush_on_exit); +weak_alias(__weak_dummy_void, __seek_on_exit); _Noreturn void exit(int code) { diff --git a/src/exit/quick_exit.c b/src/exit/quick_exit.c index 1175d80..79c389f 100644 --- a/src/exit/quick_exit.c +++ b/src/exit/quick_exit.c @@ -3,8 +3,8 @@ #include "atomic.h" #include "libc.h" -static void dummy() { } -weak_alias(dummy, __funcs_on_quick_exit); +WEAK_PROVIDE_VOID; +weak_alias(__weak_dummy_void, __funcs_on_quick_exit); _Noreturn void quick_exit(int code) { diff --git a/src/mman/mmap.c b/src/mman/mmap.c index e99271f..2391eb7 100644 --- a/src/mman/mmap.c +++ b/src/mman/mmap.c @@ -5,10 +5,10 @@ #include "syscall.h" #include "libc.h" -static void dummy1(int x) { } -static void dummy0(void) { } -weak_alias(dummy1, __vm_lock); -weak_alias(dummy0, __vm_unlock); +WEAK_PROVIDE_INT; +WEAK_PROVIDE_VOID; +weak_alias(__weak_dummy_int, __vm_lock); +weak_alias(__weak_dummy_void, __vm_unlock); #define OFF_MASK ((-0x2000ULL << (8*sizeof(long)-1)) | 0xfff) diff --git a/src/mman/munmap.c b/src/mman/munmap.c index 91aefd4..2c18e7c 100644 --- a/src/mman/munmap.c +++ b/src/mman/munmap.c @@ -3,10 +3,10 @@ #include "syscall.h" #include "libc.h" -static void dummy1(int x) { } -static void dummy0(void) { } -weak_alias(dummy1, __vm_lock); -weak_alias(dummy0, __vm_unlock); +WEAK_PROVIDE_INT; +WEAK_PROVIDE_VOID; +weak_alias(__weak_dummy_int, __vm_lock); +weak_alias(__weak_dummy_void, __vm_unlock); int __munmap(void *start, size_t len) { diff --git a/src/process/fork.c b/src/process/fork.c index fb8a430..4a83bc3 100644 --- a/src/process/fork.c +++ b/src/process/fork.c @@ -4,11 +4,8 @@ #include "libc.h" #include "pthread_impl.h" -static void dummy(int x) -{ -} - -weak_alias(dummy, __fork_handler); +WEAK_PROVIDE_INT; +weak_alias(__weak_dummy_int, __fork_handler); pid_t fork(void) { diff --git a/src/process/posix_spawn.c b/src/process/posix_spawn.c index dd45012..e1668b7 100644 --- a/src/process/posix_spawn.c +++ b/src/process/posix_spawn.c @@ -10,11 +10,9 @@ #include "fdop.h" #include "libc.h" -static void dummy_0() -{ -} -weak_alias(dummy_0, __acquire_ptc); -weak_alias(dummy_0, __release_ptc); +WEAK_PROVIDE_VOID; +weak_alias(__weak_dummy_void, __acquire_ptc); +weak_alias(__weak_dummy_void, __release_ptc); struct args { int p[2]; diff --git a/src/process/system.c b/src/process/system.c index 4232bef..6946b35 100644 --- a/src/process/system.c +++ b/src/process/system.c @@ -7,11 +7,9 @@ #include "pthread_impl.h" #include "libc.h" -static void dummy_0() -{ -} -weak_alias(dummy_0, __acquire_ptc); -weak_alias(dummy_0, __release_ptc); +WEAK_PROVIDE_VOID; +weak_alias(__weak_dummy_void, __acquire_ptc); +weak_alias(__weak_dummy_void, __release_ptc); extern char **__environ; diff --git a/src/thread/cancel_dummy.c b/src/thread/cancel_dummy.c index 7246970..655a222 100644 --- a/src/thread/cancel_dummy.c +++ b/src/thread/cancel_dummy.c @@ -6,8 +6,5 @@ long (__syscall_cp)(long nr, long u, long v, long w, long x, long y, long z) return (__syscall)(nr, u, v, w, x, y, z); } -static void dummy() -{ -} - -weak_alias(dummy, __testcancel); +WEAK_PROVIDE_VOID; +weak_alias(__weak_dummy_void, __testcancel); diff --git a/src/thread/cancellation.c b/src/thread/cancellation.c index 9b21764..fa3208e 100644 --- a/src/thread/cancellation.c +++ b/src/thread/cancellation.c @@ -1,10 +1,13 @@ #include "pthread_impl.h" -static void dummy(struct __ptcb *cb) +/* The following two are overwritten by pthread_create.c */ +_Weak +void __weak_dummy_ptcb(struct __ptcb *cb) { } -weak_alias(dummy, __do_cleanup_push); -weak_alias(dummy, __do_cleanup_pop); + +weak_alias(__weak_dummy_ptcb, __do_cleanup_push); +weak_alias(__weak_dummy_ptcb, __do_cleanup_pop); void _pthread_cleanup_push(struct __ptcb *cb, void (*f)(void *), void *x) { diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index 3f30116..77ca0cf 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -2,12 +2,10 @@ #include "stdio_impl.h" #include -static void dummy_0() -{ -} -weak_alias(dummy_0, __acquire_ptc); -weak_alias(dummy_0, __release_ptc); -weak_alias(dummy_0, __pthread_tsd_run_dtors); +WEAK_PROVIDE_VOID; +weak_alias(__weak_dummy_void, __acquire_ptc); +weak_alias(__weak_dummy_void, __release_ptc); +weak_alias(__weak_dummy_void, __pthread_tsd_run_dtors); _Noreturn void pthread_exit(void *result) { diff --git a/src/thread/pthread_join.c b/src/thread/pthread_join.c index 719c91c..87eed62 100644 --- a/src/thread/pthread_join.c +++ b/src/thread/pthread_join.c @@ -1,14 +1,12 @@ #include "pthread_impl.h" #include -static void dummy(void *p) -{ -} +WEAK_PROVIDE_VOIDP; int pthread_join(pthread_t t, void **res) { int tmp; - while ((tmp = t->tid)) __timedwait(&t->tid, tmp, 0, 0, dummy, 0, 0); + while ((tmp = t->tid)) __timedwait(&t->tid, tmp, 0, 0, __weak_dummy_voidp, 0, 0); if (res) *res = t->result; if (t->map_base) munmap(t->map_base, t->map_size); return 0; -- 1.7.9.5