Revision: 57 http://trac.macosforge.org/projects/libdispatch/changeset/57 Author: robert@fledge.watson.org Date: 2009-10-27 16:11:08 -0700 (Tue, 27 Oct 2009) Log Message: ----------- Move __private_extern__ definition to config.h from compat header, use gcc __attribute__((visibility("hidden"))) if available. Place tests for this in new 'm4' directory. This is not identical to the submitted patch in that AUTOMAKE_OPTIONS is no longer required (I believe) as a result of Love's suggested tweak to configure.ac in r55. Submitted by: Paolo Bonzini <bonzini@gnu.org> Revision Links: -------------- http://trac.macosforge.org/projects/libdispatch/changeset/55 Modified Paths: -------------- trunk/Makefile.am trunk/configure.ac trunk/src/internal.h Added Paths: ----------- trunk/m4/ trunk/m4/private-extern.m4 Removed Paths: ------------- trunk/compat/private_extern.h Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2009-10-27 22:59:39 UTC (rev 56) +++ trunk/Makefile.am 2009-10-27 23:11:08 UTC (rev 57) @@ -1,6 +1,7 @@ # # # +ACLOCAL_AMFLAGS = -I m4 SUBDIRS= \ dispatch \ Deleted: trunk/compat/private_extern.h =================================================================== --- trunk/compat/private_extern.h 2009-10-27 22:59:39 UTC (rev 56) +++ trunk/compat/private_extern.h 2009-10-27 23:11:08 UTC (rev 57) @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2009 Apple Inc. All rights reserved. - * - * @APPLE_APACHE_LICENSE_HEADER_START@ - * - * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @APPLE_APACHE_LICENSE_HEADER_END@ - */ - -#ifndef __COMPAT_PRIVATE_EXTERN_H__ -#define __COMPAT_PRIVATE_EXTERN_H__ - -#define __private_extern__ extern - -#endif /* __COMPAT_PRIVATE_EXTERN_H__ */ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2009-10-27 22:59:39 UTC (rev 56) +++ trunk/configure.ac 2009-10-27 23:11:08 UTC (rev 57) @@ -7,6 +7,7 @@ AC_REVISION([$$]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_HEADER([config/config.h]) +AC_CONFIG_MACRO_DIR([m4]) AM_MAINTAINER_MODE # @@ -181,15 +182,7 @@ AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK], [], [], [[#include <sys/mount.h>]]) AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time malloc_create_zone sem_init]) -# -# Does the platform support __private_extern__? There is surely a better way -# to check this. -# -AC_TRY_LINK([], [ - __private_extern__ int foo; -], [ - AC_DEFINE(HAVE_PRIVATE_EXTERN,, Define if __private_extern__ present) -]) +DISPATCH_C_PRIVATE_EXTERN # # Detect compiler support for Blocks; perhaps someday -fblocks won't be Added: trunk/m4/private-extern.m4 =================================================================== --- trunk/m4/private-extern.m4 (rev 0) +++ trunk/m4/private-extern.m4 2009-10-27 23:11:08 UTC (rev 57) @@ -0,0 +1,31 @@ +# +# Does the platform support __private_extern__? There is surely a better way +# to check this. +# +AC_DEFUN([DISPATCH_C_PRIVATE_EXTERN], [ + +AC_CACHE_CHECK([for __attribute__((visibility("hidden")))], + dispatch_cv_hidden_visibility_attribute, [ + AC_TRY_LINK([], + [extern __attribute__ ((visibility ("hidden"))) int foo;], + [dispatch_cv_hidden_visibility_attribute=yes], + [dispatch_cv_hidden_visibility_attribute=no])]) + +AC_CACHE_CHECK([for __private_extern__], + dispatch_cv_private_extern, [ + AC_TRY_LINK([], [__private_extern__ int foo;], + [dispatch_cv_private_extern=yes], + [dispatch_cv_private_extern=no])]) + +if test $dispatch_cv_private_extern = yes; then + AC_DEFINE(HAVE_PRIVATE_EXTERN,, Define if __private_extern__ present) +elif test $dispatch_cv_hidden_visibility_attribute = yes; then + AC_DEFINE(HAVE_PRIVATE_EXTERN,, Define if __private_extern__ present) + AC_DEFINE([__private_extern__], [extern __attribute__ ((visibility ("hidden")))], + [Define to a replacement for __private_extern]) +else + AC_DEFINE([__private_extern__], [extern], + [Define to a replacement for __private_extern]) +fi + +]) Modified: trunk/src/internal.h =================================================================== --- trunk/src/internal.h 2009-10-27 22:59:39 UTC (rev 56) +++ trunk/src/internal.h 2009-10-27 23:11:08 UTC (rev 57) @@ -39,9 +39,6 @@ #ifdef HAVE_AVAILABILITY_H #include <Availability.h> #endif -#ifndef HAVE_PRIVATE_EXTERN -#include <compat/private_extern.h> -#endif #if !HAVE_DECL_FD_COPY #include <compat/fd_copy.h> #endif