[libdispatch-dev] [PATCH 02/17] move __private_extern__ detection to an autoconf macro
Paolo Bonzini
bonzini at gnu.org
Sun Oct 18 08:04:02 PDT 2009
Starting to move less-than-obvious configure code into external
macros. At the same time I add support for the GCC visibility
attribute.
---
Makefile.am | 2 ++
compat/private_extern.h | 26 --------------------------
configure.ac | 11 ++---------
m4/private-extern.m4 | 31 +++++++++++++++++++++++++++++++
src/internal.h | 3 ---
5 files changed, 35 insertions(+), 38 deletions(-)
delete mode 100644 compat/private_extern.h
create mode 100644 m4/private-extern.m4
diff --git a/Makefile.am b/Makefile.am
index 26baf7a..5f6e393 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,8 @@
#
#
#
+ACLOCAL_AMFLAGS = -I m4
+AUTOMAKE_OPTIONS = foreign
SUBDIRS= \
dispatch \
diff --git a/compat/private_extern.h b/compat/private_extern.h
deleted file mode 100644
index 5d2d858..0000000
--- a/compat/private_extern.h
+++ /dev/null
@@ -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__ */
diff --git a/configure.ac b/configure.ac
index 83c0236..90d13d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,6 +7,7 @@ AC_INIT([libdispatch], [1.0], [libdispatch at macosforge.org], [libdispatch])
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([SIGEMT], [], [], [[#include <signal.h>]])
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
diff --git a/m4/private-extern.m4 b/m4/private-extern.m4
new file mode 100644
index 0000000..f227eb6
--- /dev/null
+++ b/m4/private-extern.m4
@@ -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
+
+])
diff --git a/src/internal.h b/src/internal.h
index 1e84165..6e2f6e5 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -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
--
1.6.2.5
More information about the libdispatch-dev
mailing list