summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtchang%redhat.com <devnull@localhost>2005-04-29 21:02:55 +0000
committerwtchang%redhat.com <devnull@localhost>2005-04-29 21:02:55 +0000
commit3988085ee4f23e0d9ca720754caaa10ab5a4186a (patch)
tree18e456b59753736b015d1a39ef39deb0215024af
parent996073ea897c610c8faa093b574838aedcd98641 (diff)
downloadnspr-hg-3988085ee4f23e0d9ca720754caaa10ab5a4186a.tar.gz
Bugzilla Bug 273336: Checked in Brian Ryner's patch:
Add support for using gcc's visibility pragma to treat all function and method declarations as "hidden" unless declared otherwise. Create wrappers for system headers that cause them to be treated as default-visibility declarations. This gives a substantial code size and performance win on compilers that support it. r=darin sr=dbaron. Modified Files: configure configure.in config/Makefile.in config/autoconf.mk.in config/config.mk pr/include/prtypes.h pr/src/md/unix/uxproces.c pr/tests/sel_spd.c Added Files: config/gcc_hidden.h config/make-system-wrappers.pl config/system-headers
-rw-r--r--config/Makefile.in11
-rw-r--r--config/autoconf.mk.in3
-rw-r--r--config/config.mk8
-rw-r--r--config/gcc_hidden.h2
-rw-r--r--config/make-system-wrappers.pl59
-rw-r--r--config/system-headers168
-rwxr-xr-xconfigure122
-rw-r--r--configure.in48
-rw-r--r--pr/include/prtypes.h22
-rw-r--r--pr/src/md/unix/uxproces.c2
-rw-r--r--pr/tests/sel_spd.c2
11 files changed, 404 insertions, 43 deletions
diff --git a/config/Makefile.in b/config/Makefile.in
index 1b83ffa5..7a1ccbd9 100644
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -46,6 +46,10 @@ include $(MOD_DEPTH)/config/autoconf.mk
# Indicate that this directory builds build tools.
INTERNAL_TOOLS = 1
+# For sanity's sake, we compile nsinstall without the wrapped system
+# headers, so that we can use it to set up the wrapped system headers.
+VISIBILITY_FLAGS =
+
# autoconf.mk must be deleted last (from the top-level directory)
# because it is included by every makefile.
DIST_GARBAGE = nsprincl.mk nsprincl.sh nspr-config
@@ -136,6 +140,13 @@ endef
export:: $(TARGETS)
rm -f $(dist_bindir)/nspr-config
+ifdef WRAP_SYSTEM_INCLUDES
+export::
+ if test ! -d system_wrappers; then mkdir system_wrappers; fi
+ $(PERL) $(srcdir)/make-system-wrappers.pl system_wrappers < $(srcdir)/system-headers
+ $(INSTALL) system_wrappers $(dist_includedir)
+endif
+
$(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
@$(MAKE_OBJDIR)
ifeq ($(MOZ_OS2_TOOLS),VACPP)
diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in
index 92800154..066832be 100644
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -111,3 +111,6 @@ OBJECT_MODE = @OBJECT_MODE@
ifdef OBJECT_MODE
export OBJECT_MODE
endif
+
+VISIBILITY_FLAGS = @VISIBILITY_FLAGS@
+WRAP_SYSTEM_INCLUDES = @WRAP_SYSTEM_INCLUDES@
diff --git a/config/config.mk b/config/config.mk
index 697a6015..10ebfdab 100644
--- a/config/config.mk
+++ b/config/config.mk
@@ -62,10 +62,10 @@ endif
NFSPWD = $(MOD_DEPTH)/config/nfspwd
-CFLAGS = $(CC_ONLY_FLAGS) $(OPTIMIZER) $(OS_CFLAGS)\
- $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
-CCCFLAGS = $(CCC_ONLY_FLAGS) $(OPTIMIZER) $(OS_CFLAGS)\
- $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
+CFLAGS = $(VISIBILITY_FLAGS) $(CC_ONLY_FLAGS) $(OPTIMIZER)\
+ $(OS_CFLAGS) $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
+CCCFLAGS = $(VISIBILITY_FLAGS) $(CCC_ONLY_FLAGS) $(OPTIMIZER)\
+ $(OS_CFLAGS) $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
# For purify
NOMD_CFLAGS = $(CC_ONLY_FLAGS) $(OPTIMIZER) $(NOMD_OS_CFLAGS)\
$(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
diff --git a/config/gcc_hidden.h b/config/gcc_hidden.h
new file mode 100644
index 00000000..58140c15
--- /dev/null
+++ b/config/gcc_hidden.h
@@ -0,0 +1,2 @@
+/* Begin all files as hidden visibility */
+#pragma GCC visibility push(hidden)
diff --git a/config/make-system-wrappers.pl b/config/make-system-wrappers.pl
new file mode 100644
index 00000000..31c9af4a
--- /dev/null
+++ b/config/make-system-wrappers.pl
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# IBM Corporation.
+# Portions created by the Initial Developer are Copyright (C) 2004
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Brian Ryner <bryner@brianryner.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+$output_dir = shift;
+
+while (<STDIN>) {
+ chomp;
+ if (-e "$output_dir/$_") {
+ next;
+ }
+
+ if (/(.*)\/[^\/*]/) {
+ mkdir "$output_dir/$1";
+ }
+
+ open OUT, ">$output_dir/$_";
+ print OUT "#pragma GCC system_header\n"; # suppress include_next warning
+ print OUT "#pragma GCC visibility push(default)\n";
+ print OUT "#include_next \<$_\>\n";
+ print OUT "#pragma GCC visibility pop\n";
+ close OUT;
+}
+
diff --git a/config/system-headers b/config/system-headers
new file mode 100644
index 00000000..7a2869e7
--- /dev/null
+++ b/config/system-headers
@@ -0,0 +1,168 @@
+Aliases.h
+arpa/inet.h
+assert.h
+bsd/libc.h
+bsd/syscall.h
+bstring.h
+builtin.h
+c_asm.h
+CFBundle.h
+CFData.h
+CFDictionary.h
+CFString.h
+CFURL.h
+CodeFragments.h
+commdlg.h
+crt_externs.h
+crypt.h
+ctype.h
+descrip.h
+Devices.h
+direct.h
+dirent.h
+dlfcn.h
+dl.h
+DriverServices.h
+dvidef.h
+errno.h
+Errors.h
+Events.h
+fcntl.h
+fibdef.h
+files.h
+Files.h
+float.h
+Folders.h
+Gestalt.h
+getopt.h
+grp.h
+ia64/sys/inline.h
+ifaddrs.h
+image.h
+ints.h
+iodef.h
+io.h
+iostream.h
+kernel/OS.h
+lib$routines.h
+limits.h
+loader.h
+locale.h
+LowMem.h
+MacErrors.h
+machine/builtins.h
+machine/clock.h
+machine/endian.h
+machine/inline.h
+mach-o/dyld.h
+MacTypes.h
+Math64.h
+math.h
+mbstring.h
+memory.h
+MixedMode.h
+model.h
+mswsock.h
+Multiprocessing.h
+mutex.h
+netdb.h
+net/if.h
+netinet/in.h
+netinet/in_systm.h
+netinet/tcp.h
+OpenTptInternet.h
+OpenTransport.h
+os2.h
+OS.h
+osreldate.h
+OSUtils.h
+poll.h
+PPCToolbox.h
+Processes.h
+process.h
+pthread.h
+pwd.h
+QDOffscreen.h
+Resources.h
+rld_interface.h
+rpc/types.h
+semaphore.h
+setjmp.h
+share.h
+signal.h
+ssdef.h
+starlet.h
+stat.h
+stdarg.h
+stddef.h
+stdio.h
+stdlib.h
+string.h
+stropts.h
+stsdef.h
+support/SupportDefs.h
+support/TLS.h
+synch.h
+sys/atomic_op.h
+syscall.h
+sys/file.h
+sys/filio.h
+sys/immu.h
+sys/ioctl.h
+sys/ipc.h
+sys/ldr.h
+sys/locking.h
+sys/lwp.h
+sys/mman.h
+sys/mpctl.h
+sys/param.h
+sys/pda.h
+sys/poll.h
+sys/prctl.h
+sys/priv.h
+sys/procfs.h
+sys/pstat.h
+sys/regset.h
+sys/resource.h
+sys/sched.h
+sys/select.h
+sys/sem.h
+sys/sendfile.h
+sys/shm.h
+sys/socket.h
+sys/stack.h
+sys/stat.h
+sys/statvfs.h
+sys/syscall.h
+sys/sysctl.h
+sys/sysmp.h
+sys/syssgi.h
+sys/systeminfo.h
+sys/timeb.h
+sys/time.h
+sys/times.h
+sys/types.h
+sys/ucontext.h
+sys/uio.h
+sys/utsname.h
+sys/wait.h
+task.h
+TextUtils.h
+thread.h
+time.h
+Timer.h
+types.h
+Types.h
+ucontext.h
+ucx$inetdef.h
+ulocks.h
+unistd.h
+unix.h
+unixlib.h
+utime.h
+wchar.h
+winbase.h
+win/compobj.h
+windef.h
+windows.h
+winsock.h
diff --git a/configure b/configure
index a2544dba..de37a5b6 100755
--- a/configure
+++ b/configure
@@ -2574,6 +2574,66 @@ else
echo "$ac_t""no" 1>&6
fi
+if test "$GNU_CC"; then
+ echo $ac_n "checking for visibility(hidden) attribute""... $ac_c" 1>&6
+echo "configure:2580: checking for visibility(hidden) attribute" >&5
+if eval "test \"`echo '$''{'ac_cv_visibility_hidden'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+ int foo __attribute__ ((visibility ("hidden"))) = 1;
+EOF
+ ac_cv_visibility_attribute=no
+ if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
+ if grep '\.hidden.*foo' conftest.s >/dev/null; then
+ ac_cv_visibility_hidden=yes
+ fi
+ fi
+ rm -f conftest.cs
+
+fi
+
+echo "$ac_t""$ac_cv_visibility_hidden" 1>&6
+ if test $ac_cv_visibility_hidden = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_VISIBILITY_HIDDEN_ATTRIBUTE 1
+EOF
+
+ echo $ac_n "checking for visibility pragma support""... $ac_c" 1>&6
+echo "configure:2604: checking for visibility pragma support" >&5
+if eval "test \"`echo '$''{'ac_cv_visibility_pragma'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#pragma GCC visibility push(hidden)
+ int foo_hidden = 1;
+#pragma GCC visibility push(default)
+ int foo_default = 1;
+EOF
+ ac_cv_visibility_pragma=no
+ if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
+ if grep '\.hidden.*foo_hidden' conftest.s >/dev/null; then
+ if ! grep '\.hidden.*foo_default' conftest.s > /dev/null; then
+ ac_cv_visibility_pragma=yes
+ fi
+ fi
+ fi
+ rm -f conftest.cs
+
+fi
+
+echo "$ac_t""$ac_cv_visibility_pragma" 1>&6
+ if test $ac_cv_visibility_pragma = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_VISIBILITY_PRAGMA 1
+EOF
+
+ VISIBILITY_FLAGS='-I$(dist_includedir)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
+ WRAP_SYSTEM_INCLUDES=1
+ fi
+ fi
+fi # GNU_CC
+
fi # SKIP_COMPILER_CHECKS
if test -z "$SKIP_PATH_CHECKS"; then
@@ -2582,7 +2642,7 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2586: checking for $ac_word" >&5
+echo "configure:2646: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2827,17 +2887,17 @@ EOF
DSO_LDOPTS='-brtl -bnortllib -bM:SRE -bnoentry -bexpall -blibpath:/usr/lib:/lib'
ac_safe=`echo "sys/atomic_op.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for sys/atomic_op.h""... $ac_c" 1>&6
-echo "configure:2831: checking for sys/atomic_op.h" >&5
+echo "configure:2891: checking for sys/atomic_op.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2836 "configure"
+#line 2896 "configure"
#include "confdefs.h"
#include <sys/atomic_op.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2841: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2901: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2994,7 +3054,7 @@ EOF
_DEBUG_FLAGS='-gdwarf-2 -O0'
MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
echo $ac_n "checking for gethostbyaddr in -lbind""... $ac_c" 1>&6
-echo "configure:2998: checking for gethostbyaddr in -lbind" >&5
+echo "configure:3058: checking for gethostbyaddr in -lbind" >&5
ac_lib_var=`echo bind'_'gethostbyaddr | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3002,7 +3062,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lbind $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3006 "configure"
+#line 3066 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3013,7 +3073,7 @@ int main() {
gethostbyaddr()
; return 0; }
EOF
-if { (eval echo configure:3017: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3077: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -4218,17 +4278,17 @@ EOF
_OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000"
ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6
-echo "configure:4222: checking for machine/builtins.h" >&5
+echo "configure:4282: checking for machine/builtins.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4227 "configure"
+#line 4287 "configure"
#include "confdefs.h"
#include <machine/builtins.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4232: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4292: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -4770,7 +4830,7 @@ case $target in
;;
*)
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:4774: checking for dlopen in -ldl" >&5
+echo "configure:4834: checking for dlopen in -ldl" >&5
ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -4778,7 +4838,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4782 "configure"
+#line 4842 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -4789,7 +4849,7 @@ int main() {
dlopen()
; return 0; }
EOF
-if { (eval echo configure:4793: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4853: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -4806,17 +4866,17 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6
-echo "configure:4810: checking for dlfcn.h" >&5
+echo "configure:4870: checking for dlfcn.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4815 "configure"
+#line 4875 "configure"
#include "confdefs.h"
#include <dlfcn.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4820: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4880: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -4849,13 +4909,13 @@ esac
if test $ac_cv_prog_gcc = yes; then
echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:4853: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:4913: checking whether ${CC-cc} needs -traditional" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_pattern="Autoconf.*'x'"
cat > conftest.$ac_ext <<EOF
-#line 4859 "configure"
+#line 4919 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@@ -4873,7 +4933,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
-#line 4877 "configure"
+#line 4937 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@@ -4897,12 +4957,12 @@ fi
for ac_func in lchown strerror
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4901: checking for $ac_func" >&5
+echo "configure:4961: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4906 "configure"
+#line 4966 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -4925,7 +4985,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:4929: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4989: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -4966,7 +5026,7 @@ hpux*)
if test -z "$GNU_CC"; then
echo $ac_n "checking for +Olit support""... $ac_c" 1>&6
-echo "configure:4970: checking for +Olit support" >&5
+echo "configure:5030: checking for +Olit support" >&5
if eval "test \"`echo '$''{'ac_cv_hpux_usable_olit_option'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -5000,7 +5060,7 @@ esac
echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
-echo "configure:5004: checking for pthread_create in -lpthreads" >&5
+echo "configure:5064: checking for pthread_create in -lpthreads" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@@ -5022,7 +5082,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
-echo "configure:5026: checking for pthread_create in -lpthread" >&5
+echo "configure:5086: checking for pthread_create in -lpthread" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@@ -5044,7 +5104,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
-echo "configure:5048: checking for pthread_create in -lc_r" >&5
+echo "configure:5108: checking for pthread_create in -lc_r" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@@ -5066,7 +5126,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
-echo "configure:5070: checking for pthread_create in -lc" >&5
+echo "configure:5130: checking for pthread_create in -lc" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@@ -5218,7 +5278,7 @@ if test -n "$USE_PTHREADS"; then
rm -f conftest*
ac_cv_have_dash_pthread=no
echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6
-echo "configure:5222: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:5282: checking whether ${CC-cc} accepts -pthread" >&5
echo 'int main() { return 0; }' | cat > conftest.c
${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
if test $? -eq 0; then
@@ -5241,7 +5301,7 @@ echo "configure:5222: checking whether ${CC-cc} accepts -pthread" >&5
ac_cv_have_dash_pthreads=no
if test "$ac_cv_have_dash_pthread" = "no"; then
echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6
-echo "configure:5245: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:5305: checking whether ${CC-cc} accepts -pthreads" >&5
echo 'int main() { return 0; }' | cat > conftest.c
${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
if test $? -eq 0; then
@@ -5649,6 +5709,8 @@ esac
+
+
MAKEFILES="
Makefile
config/Makefile
@@ -5938,6 +6000,8 @@ s%@DLLFLAGS@%$DLLFLAGS%g
s%@EXEFLAGS@%$EXEFLAGS%g
s%@OS_DLLFLAGS@%$OS_DLLFLAGS%g
s%@CYGWIN_WRAPPER@%$CYGWIN_WRAPPER%g
+s%@VISIBILITY_FLAGS@%$VISIBILITY_FLAGS%g
+s%@WRAP_SYSTEM_INCLUDES@%$WRAP_SYSTEM_INCLUDES%g
CEOF
EOF
diff --git a/configure.in b/configure.in
index 7137dd18..a1522383 100644
--- a/configure.in
+++ b/configure.in
@@ -484,6 +484,52 @@ else
AC_MSG_RESULT([no])
fi
+dnl ===============================================================
+dnl Check for .hidden assembler directive and visibility attribute.
+dnl Borrowed from glibc configure.in
+dnl ===============================================================
+if test "$GNU_CC"; then
+ AC_CACHE_CHECK(for visibility(hidden) attribute,
+ ac_cv_visibility_hidden,
+ [cat > conftest.c <<EOF
+ int foo __attribute__ ((visibility ("hidden"))) = 1;
+EOF
+ ac_cv_visibility_attribute=no
+ if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
+ if grep '\.hidden.*foo' conftest.s >/dev/null; then
+ ac_cv_visibility_hidden=yes
+ fi
+ fi
+ rm -f conftest.[cs]
+ ])
+ if test $ac_cv_visibility_hidden = yes; then
+ AC_DEFINE(HAVE_VISIBILITY_HIDDEN_ATTRIBUTE)
+ AC_CACHE_CHECK(for visibility pragma support,
+ ac_cv_visibility_pragma,
+ [cat > conftest.c <<EOF
+#pragma GCC visibility push(hidden)
+ int foo_hidden = 1;
+#pragma GCC visibility push(default)
+ int foo_default = 1;
+EOF
+ ac_cv_visibility_pragma=no
+ if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
+ if grep '\.hidden.*foo_hidden' conftest.s >/dev/null; then
+ if ! grep '\.hidden.*foo_default' conftest.s > /dev/null; then
+ ac_cv_visibility_pragma=yes
+ fi
+ fi
+ fi
+ rm -f conftest.[cs]
+ ])
+ if test $ac_cv_visibility_pragma = yes; then
+ AC_DEFINE(HAVE_VISIBILITY_PRAGMA)
+ VISIBILITY_FLAGS='-I$(dist_includedir)/system_wrappers -include $(topsrcdir)/config/gcc_hidden.h'
+ WRAP_SYSTEM_INCLUDES=1
+ fi
+ fi
+fi # GNU_CC
+
fi # SKIP_COMPILER_CHECKS
dnl ========================================================
@@ -2510,6 +2556,8 @@ AC_SUBST(DLLFLAGS)
AC_SUBST(EXEFLAGS)
AC_SUBST(OS_DLLFLAGS)
AC_SUBST(CYGWIN_WRAPPER)
+AC_SUBST(VISIBILITY_FLAGS)
+AC_SUBST(WRAP_SYSTEM_INCLUDES)
dnl ========================================================
dnl Generate output files.
diff --git a/pr/include/prtypes.h b/pr/include/prtypes.h
index 6b954881..3eb15548 100644
--- a/pr/include/prtypes.h
+++ b/pr/include/prtypes.h
@@ -178,15 +178,21 @@
#else /* Unix */
-#define PR_EXPORT(__type) extern __type
-#define PR_EXPORT_DATA(__type) extern __type
-#define PR_IMPORT(__type) extern __type
-#define PR_IMPORT_DATA(__type) extern __type
+#ifdef HAVE_VISIBILITY_PRAGMA
+#define PR_VISIBILITY_DEFAULT __attribute__((visibility("default")))
+#else
+#define PR_VISIBILITY_DEFAULT
+#endif
-#define PR_EXTERN(__type) extern __type
-#define PR_IMPLEMENT(__type) __type
-#define PR_EXTERN_DATA(__type) extern __type
-#define PR_IMPLEMENT_DATA(__type) __type
+#define PR_EXPORT(__type) extern PR_VISIBILITY_DEFAULT __type
+#define PR_EXPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
+#define PR_IMPORT(__type) extern PR_VISIBILITY_DEFAULT __type
+#define PR_IMPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
+
+#define PR_EXTERN(__type) extern PR_VISIBILITY_DEFAULT __type
+#define PR_IMPLEMENT(__type) PR_VISIBILITY_DEFAULT __type
+#define PR_EXTERN_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
+#define PR_IMPLEMENT_DATA(__type) PR_VISIBILITY_DEFAULT __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
diff --git a/pr/src/md/unix/uxproces.c b/pr/src/md/unix/uxproces.c
index 43fdd290..c5c8be94 100644
--- a/pr/src/md/unix/uxproces.c
+++ b/pr/src/md/unix/uxproces.c
@@ -49,7 +49,7 @@
#if defined(DARWIN)
#include <crt_externs.h>
#else
-extern char **environ;
+PR_IMPORT_DATA(char **) environ;
#endif
/*
diff --git a/pr/tests/sel_spd.c b/pr/tests/sel_spd.c
index 6760e640..c3b79652 100644
--- a/pr/tests/sel_spd.c
+++ b/pr/tests/sel_spd.c
@@ -455,7 +455,7 @@ int main(int argc, char **argv)
{
#if defined(XP_UNIX) || defined(XP_OS2_EMX)
int opt;
- extern char *optarg;
+ PR_IMPORT_DATA(char *) optarg;
#endif
#if defined(XP_UNIX) || defined(XP_OS2_EMX)