<sys/cdefs.h>: For C++, unhide our interfaces via __{BEGIN,END}_DECLS.
authorSascha Wildner <saw@online.de>
Sun, 11 Mar 2012 12:50:29 +0000 (13:50 +0100)
committerSascha Wildner <saw@online.de>
Sun, 11 Mar 2012 13:26:53 +0000 (14:26 +0100)
This follows up on a previous (pthread specific) commit by alexh
(e7322b09faff75b1298e9bfe444633425d173536) that used a per-proto
macro. Revert this commit, too. In principle, we do it like NetBSD
now.

See http://gcc.gnu.org/wiki/Visibility in the GCC wiki for details
on the issue.

This solution was suggested by Martin Husemann in a thread about
xulrunner building issues:

http://mail-index.netbsd.org/tech-pkg/2012/03/11/msg008680.html

Reported-and-tested-by: marino and others
include/pthread.h
include/pthread_np.h
sys/sys/cdefs.h

index 30c4e07..d9eb6e1 100644 (file)
@@ -140,136 +140,136 @@ enum pthread_mutextype {
  * Thread function prototype definitions:
  */
 __BEGIN_DECLS
-int            pthread_atfork(void (*)(void), void (*)(void), void (*)(void)) __exported;
-int            pthread_attr_destroy(pthread_attr_t *) __exported;
+int            pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
+int            pthread_attr_destroy(pthread_attr_t *);
 int            pthread_attr_getguardsize(const pthread_attr_t * __restrict,
-                       size_t *) __exported;
+                       size_t *);
 int            pthread_attr_getstack(const pthread_attr_t * __restrict,
-                                     void ** __restrict, size_t * __restrict) __exported;
-int            pthread_attr_getstacksize(const pthread_attr_t *, size_t *) __exported;
-int            pthread_attr_getstackaddr(const pthread_attr_t *, void **) __exported;
-int            pthread_attr_getdetachstate(const pthread_attr_t *, int *) __exported;
-int            pthread_attr_init(pthread_attr_t *) __exported;
-int            pthread_attr_setguardsize(pthread_attr_t *, size_t) __exported;
-int            pthread_attr_setstack(pthread_attr_t *, void *, size_t) __exported;
-int            pthread_attr_setstacksize(pthread_attr_t *, size_t) __exported;
-int            pthread_attr_setstackaddr(pthread_attr_t *, void *) __exported;
-int            pthread_attr_setdetachstate(pthread_attr_t *, int) __exported;
-int            pthread_barrier_destroy(pthread_barrier_t *) __exported;
+                                     void ** __restrict, size_t * __restrict);
+int            pthread_attr_getstacksize(const pthread_attr_t *, size_t *);
+int            pthread_attr_getstackaddr(const pthread_attr_t *, void **);
+int            pthread_attr_getdetachstate(const pthread_attr_t *, int *);
+int            pthread_attr_init(pthread_attr_t *);
+int            pthread_attr_setguardsize(pthread_attr_t *, size_t);
+int            pthread_attr_setstack(pthread_attr_t *, void *, size_t);
+int            pthread_attr_setstacksize(pthread_attr_t *, size_t);
+int            pthread_attr_setstackaddr(pthread_attr_t *, void *);
+int            pthread_attr_setdetachstate(pthread_attr_t *, int);
+int            pthread_barrier_destroy(pthread_barrier_t *);
 int            pthread_barrier_init(pthread_barrier_t *,
-                       const pthread_barrierattr_t *, unsigned) __exported;
-int            pthread_barrier_wait(pthread_barrier_t *) __exported;
-int            pthread_barrierattr_destroy(pthread_barrierattr_t *) __exported;
-int            pthread_barrierattr_init(pthread_barrierattr_t *) __exported;
+                       const pthread_barrierattr_t *, unsigned);
+int            pthread_barrier_wait(pthread_barrier_t *);
+int            pthread_barrierattr_destroy(pthread_barrierattr_t *);
+int            pthread_barrierattr_init(pthread_barrierattr_t *);
 int            pthread_barrierattr_getpshared(const pthread_barrierattr_t *,
-                       int *) __exported;
-int            pthread_barrierattr_setpshared(pthread_barrierattr_t *, int) __exported;
-void           pthread_cleanup_pop(int) __exported;
-void           pthread_cleanup_push(void (*) (void *), void *) __exported;
-int            pthread_condattr_destroy(pthread_condattr_t *) __exported;
-int            pthread_condattr_init(pthread_condattr_t *) __exported;
+                       int *);
+int            pthread_barrierattr_setpshared(pthread_barrierattr_t *, int);
+void           pthread_cleanup_pop(int);
+void           pthread_cleanup_push(void (*) (void *), void *);
+int            pthread_condattr_destroy(pthread_condattr_t *);
+int            pthread_condattr_init(pthread_condattr_t *);
 
-int            pthread_condattr_getpshared(const pthread_condattr_t *, int *) __exported;
-int            pthread_condattr_setpshared(pthread_condattr_t *, int) __exported;
+int            pthread_condattr_getpshared(const pthread_condattr_t *, int *);
+int            pthread_condattr_setpshared(pthread_condattr_t *, int);
 
-int            pthread_condattr_getclock(const pthread_condattr_t *, clockid_t *) __exported;
-int            pthread_condattr_setclock(pthread_condattr_t *, clockid_t) __exported;
+int            pthread_condattr_getclock(const pthread_condattr_t *, clockid_t *);
+int            pthread_condattr_setclock(pthread_condattr_t *, clockid_t);
 
-int            pthread_cond_broadcast(pthread_cond_t *) __exported;
-int            pthread_cond_destroy(pthread_cond_t *) __exported;
+int            pthread_cond_broadcast(pthread_cond_t *);
+int            pthread_cond_destroy(pthread_cond_t *);
 int            pthread_cond_init(pthread_cond_t *,
-                                 const pthread_condattr_t *) __exported;
-int            pthread_cond_signal(pthread_cond_t *) __exported;
+                                 const pthread_condattr_t *);
+int            pthread_cond_signal(pthread_cond_t *);
 int            pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *,
-                                      const struct timespec *) __exported;
-int            pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *) __exported;
+                                      const struct timespec *);
+int            pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);
 int            pthread_create(pthread_t *, const pthread_attr_t *,
-                              void *(*) (void *), void *) __exported;
-int            pthread_detach(pthread_t) __exported;
-int            pthread_equal(pthread_t, pthread_t) __exported;
+                              void *(*) (void *), void *);
+int            pthread_detach(pthread_t);
+int            pthread_equal(pthread_t, pthread_t);
 void           pthread_exit(void *) __dead2;
-void           *pthread_getspecific(pthread_key_t) __exported;
-int            pthread_join(pthread_t, void **) __exported;
-int            pthread_key_create(pthread_key_t *, void (*) (void *)) __exported;
-int            pthread_key_delete(pthread_key_t) __exported;
-int            pthread_mutexattr_init(pthread_mutexattr_t *) __exported;
-int            pthread_mutexattr_destroy(pthread_mutexattr_t *) __exported;
-int            pthread_mutexattr_gettype(pthread_mutexattr_t *, int *) __exported;
-int            pthread_mutexattr_settype(pthread_mutexattr_t *, int) __exported;
-int            pthread_mutex_destroy(pthread_mutex_t *) __exported;
+void           *pthread_getspecific(pthread_key_t);
+int            pthread_join(pthread_t, void **);
+int            pthread_key_create(pthread_key_t *, void (*) (void *));
+int            pthread_key_delete(pthread_key_t);
+int            pthread_mutexattr_init(pthread_mutexattr_t *);
+int            pthread_mutexattr_destroy(pthread_mutexattr_t *);
+int            pthread_mutexattr_gettype(pthread_mutexattr_t *, int *);
+int            pthread_mutexattr_settype(pthread_mutexattr_t *, int);
+int            pthread_mutex_destroy(pthread_mutex_t *);
 int            pthread_mutex_init(pthread_mutex_t *,
-                                  const pthread_mutexattr_t *) __exported;
-int            pthread_mutex_lock(pthread_mutex_t *) __exported;
+                                  const pthread_mutexattr_t *);
+int            pthread_mutex_lock(pthread_mutex_t *);
 int            pthread_mutex_timedlock(pthread_mutex_t *,
-                                       const struct timespec *) __exported;
-int            pthread_mutex_trylock(pthread_mutex_t *) __exported;
-int            pthread_mutex_unlock(pthread_mutex_t *) __exported;
-int            pthread_once(pthread_once_t *, void (*) (void)) __exported;
-int            pthread_rwlock_destroy(pthread_rwlock_t *) __exported;
+                                       const struct timespec *);
+int            pthread_mutex_trylock(pthread_mutex_t *);
+int            pthread_mutex_unlock(pthread_mutex_t *);
+int            pthread_once(pthread_once_t *, void (*) (void));
+int            pthread_rwlock_destroy(pthread_rwlock_t *);
 int            pthread_rwlock_init(pthread_rwlock_t *,
-                                   const pthread_rwlockattr_t *) __exported;
-int            pthread_rwlock_rdlock(pthread_rwlock_t *) __exported;
+                                   const pthread_rwlockattr_t *);
+int            pthread_rwlock_rdlock(pthread_rwlock_t *);
 int            pthread_rwlock_timedrdlock(pthread_rwlock_t *,
-                                   const struct timespec *) __exported;
-int            pthread_rwlock_tryrdlock(pthread_rwlock_t *) __exported;
-int            pthread_rwlock_trywrlock(pthread_rwlock_t *) __exported;
-int            pthread_rwlock_unlock(pthread_rwlock_t *) __exported;
-int            pthread_rwlock_wrlock(pthread_rwlock_t *) __exported;
+                                   const struct timespec *);
+int            pthread_rwlock_tryrdlock(pthread_rwlock_t *);
+int            pthread_rwlock_trywrlock(pthread_rwlock_t *);
+int            pthread_rwlock_unlock(pthread_rwlock_t *);
+int            pthread_rwlock_wrlock(pthread_rwlock_t *);
 int            pthread_rwlock_timedwrlock(pthread_rwlock_t *,
-                                   const struct timespec *) __exported;
-int            pthread_rwlockattr_init(pthread_rwlockattr_t *) __exported;
+                                   const struct timespec *);
+int            pthread_rwlockattr_init(pthread_rwlockattr_t *);
 int            pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *,
-                                             int *) __exported;
-int            pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int) __exported;
-int            pthread_rwlockattr_destroy(pthread_rwlockattr_t *) __exported;
-pthread_t      pthread_self(void) __exported;
-int            pthread_setspecific(pthread_key_t, const void *) __exported;
+                                             int *);
+int            pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);
+int            pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
+pthread_t      pthread_self(void);
+int            pthread_setspecific(pthread_key_t, const void *);
 
-int            pthread_spin_destroy(pthread_spinlock_t *) __exported;
-int            pthread_spin_init(pthread_spinlock_t *, int) __exported;
-int            pthread_spin_lock(pthread_spinlock_t *) __exported;
-int            pthread_spin_trylock(pthread_spinlock_t *) __exported;
-int            pthread_spin_unlock(pthread_spinlock_t *) __exported;
+int            pthread_spin_destroy(pthread_spinlock_t *);
+int            pthread_spin_init(pthread_spinlock_t *, int);
+int            pthread_spin_lock(pthread_spinlock_t *);
+int            pthread_spin_trylock(pthread_spinlock_t *);
+int            pthread_spin_unlock(pthread_spinlock_t *);
 
-int            pthread_cancel(pthread_t) __exported;
-int            pthread_setcancelstate(int, int *) __exported;
-int            pthread_setcanceltype(int, int *) __exported;
-void           pthread_testcancel(void) __exported;
+int            pthread_cancel(pthread_t);
+int            pthread_setcancelstate(int, int *);
+int            pthread_setcanceltype(int, int *);
+void           pthread_testcancel(void);
 
-int            pthread_getprio(pthread_t) __exported;
-int            pthread_setprio(pthread_t, int) __exported;
-void           pthread_yield(void) __exported;
+int            pthread_getprio(pthread_t);
+int            pthread_setprio(pthread_t, int);
+void           pthread_yield(void);
 
-int            pthread_mutexattr_getpshared(const pthread_mutexattr_t *, int *) __exported;
-int            pthread_mutexattr_setpshared(pthread_mutexattr_t *, int) __exported;
+int            pthread_mutexattr_getpshared(const pthread_mutexattr_t *, int *);
+int            pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
 
-int            pthread_mutexattr_getprioceiling(pthread_mutexattr_t *, int *) __exported;
-int            pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int) __exported;
-int            pthread_mutex_getprioceiling(pthread_mutex_t *, int *) __exported;
-int            pthread_mutex_setprioceiling(pthread_mutex_t *, int, int *) __exported;
+int            pthread_mutexattr_getprioceiling(pthread_mutexattr_t *, int *);
+int            pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
+int            pthread_mutex_getprioceiling(pthread_mutex_t *, int *);
+int            pthread_mutex_setprioceiling(pthread_mutex_t *, int, int *);
 
-int            pthread_mutexattr_getprotocol(pthread_mutexattr_t *, int *) __exported;
-int            pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int) __exported;
+int            pthread_mutexattr_getprotocol(pthread_mutexattr_t *, int *);
+int            pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
 
-int            pthread_attr_getinheritsched(const pthread_attr_t *, int *) __exported;
+int            pthread_attr_getinheritsched(const pthread_attr_t *, int *);
 int            pthread_attr_getschedparam(const pthread_attr_t *,
-                                          struct sched_param *) __exported;
-int            pthread_attr_getschedpolicy(const pthread_attr_t *, int *) __exported;
-int            pthread_attr_getscope(const pthread_attr_t *, int *) __exported;
-int            pthread_attr_setinheritsched(pthread_attr_t *, int) __exported;
+                                          struct sched_param *);
+int            pthread_attr_getschedpolicy(const pthread_attr_t *, int *);
+int            pthread_attr_getscope(const pthread_attr_t *, int *);
+int            pthread_attr_setinheritsched(pthread_attr_t *, int);
 int            pthread_attr_setschedparam(pthread_attr_t *,
-                                          const struct sched_param *) __exported;
-int            pthread_attr_setschedpolicy(pthread_attr_t *, int) __exported;
-int            pthread_attr_setscope(pthread_attr_t *, int) __exported;
+                                          const struct sched_param *);
+int            pthread_attr_setschedpolicy(pthread_attr_t *, int);
+int            pthread_attr_setscope(pthread_attr_t *, int);
 int            pthread_getschedparam(pthread_t pthread, int *,
-                                     struct sched_param *) __exported;
+                                     struct sched_param *);
 int            pthread_setschedparam(pthread_t, int,
-                                     const struct sched_param *) __exported;
-int            pthread_getconcurrency(void) __exported;
-int            pthread_setconcurrency(int) __exported;
+                                     const struct sched_param *);
+int            pthread_getconcurrency(void);
+int            pthread_setconcurrency(int);
 
-int            pthread_attr_setfloatstate(pthread_attr_t *, int) __exported;
-int            pthread_attr_getfloatstate(pthread_attr_t *, int *) __exported;
+int            pthread_attr_setfloatstate(pthread_attr_t *, int);
+int            pthread_attr_getfloatstate(pthread_attr_t *, int *);
 __END_DECLS
 
 #endif
index 73cf364..6313088 100644 (file)
@@ -30,7 +30,6 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/include/pthread_np.h,v 1.7.2.4 2003/01/10 15:41:17 fjoe Exp $
- * $DragonFly: src/include/pthread_np.h,v 1.4 2005/10/10 13:53:57 davidxu Exp $
  */
 #ifndef _PTHREAD_NP_H_
 #define _PTHREAD_NP_H_
@@ -44,21 +43,21 @@ typedef void        (*pthread_switch_routine_t) (pthread_t, pthread_t);
  * Non-POSIX thread function prototype definitions:
  */
 __BEGIN_DECLS
-int pthread_attr_setcreatesuspend_np (pthread_attr_t *) __exported;
-int pthread_attr_get_np (pthread_t, pthread_attr_t *) __exported;
-int pthread_main_np (void) __exported;
-int pthread_multi_np (void) __exported;
-int pthread_mutexattr_getkind_np (pthread_mutexattr_t) __exported;
-int pthread_mutexattr_setkind_np (pthread_mutexattr_t *, int) __exported;
-void pthread_resume_all_np (void) __exported;
-int pthread_resume_np (pthread_t) __exported;
-void pthread_set_name_np (pthread_t, const char *) __exported;
-int pthread_single_np (void) __exported;
-void pthread_suspend_all_np (void) __exported;
-int pthread_suspend_np (pthread_t) __exported;
-int pthread_switch_add_np (pthread_switch_routine_t) __exported;
-int pthread_switch_delete_np (pthread_switch_routine_t) __exported;
-int pthread_timedjoin_np (pthread_t, void **, const struct timespec *) __exported;
+int pthread_attr_setcreatesuspend_np (pthread_attr_t *);
+int pthread_attr_get_np (pthread_t, pthread_attr_t *);
+int pthread_main_np (void);
+int pthread_multi_np (void);
+int pthread_mutexattr_getkind_np (pthread_mutexattr_t);
+int pthread_mutexattr_setkind_np (pthread_mutexattr_t *, int);
+void pthread_resume_all_np (void);
+int pthread_resume_np (pthread_t);
+void pthread_set_name_np (pthread_t, const char *);
+int pthread_single_np (void);
+void pthread_suspend_all_np (void);
+int pthread_suspend_np (pthread_t);
+int pthread_switch_add_np (pthread_switch_routine_t);
+int pthread_switch_delete_np (pthread_switch_routine_t);
+int pthread_timedjoin_np (pthread_t, void **, const struct timespec *);
 __END_DECLS
 
 #endif
index a737c18..8d5e8d7 100644 (file)
  *
  *     @(#)cdefs.h     8.8 (Berkeley) 1/9/95
  * $FreeBSD: src/sys/sys/cdefs.h,v 1.28.2.8 2002/09/18 04:05:13 mikeh Exp $
- * $DragonFly: src/sys/sys/cdefs.h,v 1.20 2008/11/20 11:27:24 hasso Exp $
  */
 
 #ifndef        _SYS_CDEFS_H_
 #define        _SYS_CDEFS_H_
 
-#if defined(__cplusplus)
-#define        __BEGIN_DECLS   extern "C" {
-#define        __END_DECLS     }
-#else
-#define        __BEGIN_DECLS
-#define        __END_DECLS
-#endif
-
 /*
  * Macro to test if we are using a specific version of gcc or later.
  */
 #define __GNUC_PREREQ__(ma, mi) 0
 #endif
 
+#if defined(__cplusplus)
+#if __GNUC_PREREQ__(4, 0)
+#define        __BEGIN_DECLS   _Pragma("GCC visibility push(default)") extern "C" {
+#define        __END_DECLS     } _Pragma("GCC visibility pop")
+#else
+#define        __BEGIN_DECLS   extern "C" {
+#define        __END_DECLS     }
+#endif
+#else
+#define        __BEGIN_DECLS
+#define        __END_DECLS
+#endif
+
 /*
  * The __VM_CACHELINE_SIZE macro defines the common cache line alignment
  * size that can be found across most recent and somewhat latest Intel
 #endif
 
 #if __GNUC_PREREQ__(4, 0)
-#define __exported     __attribute__((__visibility__("default")))
 #define __dso_public   __attribute__((__visibility__("default")))
 #define __dso_hidden   __attribute__((__visibility__("hidden")))
 #else
-#define __exported
 #define __dso_public
 #define __dso_hidden
 #endif