From eec7eb4a2bfb71e0831bf36537ae124b4a824286 Mon Sep 17 00:00:00 2001 From: guenther <> Date: Thu, 18 Jan 2018 08:23:44 +0000 Subject: Instead of trying to handle ffs() with the normal rename-mark-hidden-and-alias dance, mark it protected. This works better for both gcc and clang: gcc blocks overriding of internal calls, while clang permits inlining again. ok otto@ --- src/lib/libc/include/namespace.h | 7 +++++-- src/lib/libc/string/ffs.c | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/libc/include/namespace.h b/src/lib/libc/include/namespace.h index 73b845e10f..60766afc0b 100644 --- a/src/lib/libc/include/namespace.h +++ b/src/lib/libc/include/namespace.h @@ -1,4 +1,4 @@ -/* $OpenBSD: namespace.h,v 1.11 2017/11/29 05:13:57 guenther Exp $ */ +/* $OpenBSD: namespace.h,v 1.12 2018/01/18 08:23:44 guenther Exp $ */ #ifndef _LIBC_NAMESPACE_H_ #define _LIBC_NAMESPACE_H_ @@ -135,6 +135,8 @@ #include /* for __dso_hidden and __{weak,strong}_alias */ +#define __dso_protected __attribute__((__visibility__("protected"))) + #define HIDDEN(x) _libc_##x #define CANCEL(x) _libc_##x##_cancel #define WRAP(x) _libc_##x##_wrap @@ -148,6 +150,7 @@ #define PROTO_CANCEL(x) __dso_hidden typeof(x) HIDDEN(x), \ x asm(CANCEL_STRING(x)) #define PROTO_WRAP(x) PROTO_NORMAL(x), WRAP(x) +#define PROTO_PROTECTED(x) __dso_protected typeof(x) x #define DEF_STRONG(x) __strong_alias(x, HIDDEN(x)) #define DEF_WEAK(x) __weak_alias(x, HIDDEN(x)) @@ -156,7 +159,7 @@ #define DEF_SYS(x) __strong_alias(_thread_sys_##x, HIDDEN(x)) #ifdef __clang__ #define DEF_BUILTIN(x) __asm("") -#define BUILTIN __attribute__((__visibility__("protected"))) +#define BUILTIN __dso_protected #else #define DEF_BUILTIN(x) DEF_STRONG(x) #define BUILTIN diff --git a/src/lib/libc/string/ffs.c b/src/lib/libc/string/ffs.c index a75fd9d79f..09d6e35eca 100644 --- a/src/lib/libc/string/ffs.c +++ b/src/lib/libc/string/ffs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */ +/* $OpenBSD: ffs.c,v 1.10 2018/01/18 08:23:44 guenther Exp $ */ /* * Public domain. @@ -38,4 +38,3 @@ ffs(int mask) return (bit + t[ r & 0xf ]); } -DEF_WEAK(ffs); -- cgit v1.2.3-55-g6feb