Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 01 Jun 2012 16:36:40 +0000
From:      gmiller@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r236884 - in soc2012/gmiller/locking-head: include lib/libthr/thread
Message-ID:  <20120601163640.747B01065670@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gmiller
Date: Fri Jun  1 16:36:40 2012
New Revision: 236884
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=236884

Log:
  Modify the build to produce a linker error when linking code compiled with
  LOCK_PROFILING with libthr, and make libthr_profile compatible with code
  compiled without LOCK_PROFILING.
  

Modified:
  soc2012/gmiller/locking-head/include/pthread.h
  soc2012/gmiller/locking-head/lib/libthr/thread/thr_cond.c
  soc2012/gmiller/locking-head/lib/libthr/thread/thr_mutex.c

Modified: soc2012/gmiller/locking-head/include/pthread.h
==============================================================================
--- soc2012/gmiller/locking-head/include/pthread.h	Fri Jun  1 16:33:45 2012	(r236883)
+++ soc2012/gmiller/locking-head/include/pthread.h	Fri Jun  1 16:36:40 2012	(r236884)
@@ -179,12 +179,6 @@
 			__pthread_cleanup_pop_imp(execute);			\
 		}
 
-#ifdef LOCK_PROFILING
-#define		_PTHREAD_PROFILE_PARMS , const char *, int
-#else
-#define		_PTHREAD_PROFILE_PARMS /* */
-#endif
-
 int		pthread_condattr_destroy(pthread_condattr_t *);
 int		pthread_condattr_getclock(const pthread_condattr_t *,
 			clockid_t *);
@@ -198,10 +192,9 @@
 			const pthread_condattr_t *);
 int		pthread_cond_signal(pthread_cond_t *);
 int		pthread_cond_timedwait(pthread_cond_t *,
-		    pthread_mutex_t *, const struct timespec *
-		    _PTHREAD_PROFILE_PARMS);
-int		pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *
-		    _PTHREAD_PROFILE_PARMS);
+				       pthread_mutex_t *,
+				       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 *);
 int		pthread_detach(pthread_t);
@@ -223,10 +216,10 @@
 int		pthread_mutex_destroy(pthread_mutex_t *);
 int		pthread_mutex_init(pthread_mutex_t *,
 			const pthread_mutexattr_t *);
-int		pthread_mutex_lock(pthread_mutex_t * _PTHREAD_PROFILE_PARMS);
-int		pthread_mutex_trylock(pthread_mutex_t * _PTHREAD_PROFILE_PARMS);
+int		pthread_mutex_lock(pthread_mutex_t *);
+int		pthread_mutex_trylock(pthread_mutex_t *);
 int		pthread_mutex_timedlock(pthread_mutex_t *,
-			const struct timespec * _PTHREAD_PROFILE_PARMS);
+			const struct timespec *);
 int		pthread_mutex_unlock(pthread_mutex_t *);
 int		pthread_once(pthread_once_t *, void (*) (void));
 int		pthread_rwlock_destroy(pthread_rwlock_t *);
@@ -304,22 +297,39 @@
 
 #ifdef LOCK_PROFILING
 
-#ifndef pthread_mutex_lock
+int		_pthread_cond_timedwait_profiled(pthread_cond_t *,
+						 pthread_mutex_t *,
+						 const struct timespec *,
+						 const char *, int);
+int		_pthread_cond_wait_profiled(pthread_cond_t *,
+					    pthread_mutex_t *,
+					    const char *,
+					    int);
+int		_pthread_mutex_lock_profiled(pthread_mutex_t *,
+					     const char *,
+					     int);
+int		_pthread_mutex_trylock_profiled(pthread_mutex_t *,
+						const char *,
+						int);
+int		_pthread_mutex_timedlock_profiled(pthread_mutex_t *,
+						  const struct timespec *,
+						  const char *,
+						  int);
+
+#ifdef pthread_mutex_lock
+
+#undef pthread_mutex_lock
+#undef pthread_mutex_trylock
+#undef pthread_mutex_timedlock
+
+#endif
+
 #define		pthread_mutex_lock(m)                                         \
-		pthread_mutex_lock (m, __FILE__, __LINE__)
+		_pthread_mutex_lock(m, __FILE__, __LINE__)
 #define		pthread_mutex_trylock(m)                                      \
-		pthread_mutex_trylock (m, __FILE__, __LINE__)
+		_pthread_mutex_trylock(m, __FILE__, __LINE__)
 #define		pthread_mutex_timedlock(m, t)			\
-		pthread_mutex_timedlock (m, t, __FILE__, __LINE__)
-#endif
-
-#define		_pthread_mutex_lock(m)                                        \
-		_pthread_mutex_lock (m, __FILE__, __LINE__)
-#define		_pthread_mutex_trylock(m)                                     \
-		_pthread_mutex_trylock (m, __FILE__, __LINE__)
-#define		_pthread_mutex_timedlock(m, t)			\
-		_pthread_mutex_timedlock (m, t, __FILE__, __LINE__)
-
+		_pthread_mutex_timedlock(m, t, __FILE__, __LINE__)
 #endif
 
 #endif

Modified: soc2012/gmiller/locking-head/lib/libthr/thread/thr_cond.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libthr/thread/thr_cond.c	Fri Jun  1 16:33:45 2012	(r236883)
+++ soc2012/gmiller/locking-head/lib/libthr/thread/thr_cond.c	Fri Jun  1 16:36:40 2012	(r236884)
@@ -39,15 +39,28 @@
 /*
  * Prototypes
  */
-int	__pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex _PROFILE_PARMS);
+int	__pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
 int	__pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
-		       const struct timespec * abstime _PROFILE_PARMS);
+				 const struct timespec *abstime);
 static int cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
 static int cond_wait_common(pthread_cond_t *cond, pthread_mutex_t *mutex,
-		    const struct timespec *abstime, int cancel _PROFILE_PARMS);
+			    const struct timespec *abstime, int cancel
+			    _PROFILE_PARMS);
 static int cond_signal_common(pthread_cond_t *cond);
 static int cond_broadcast_common(pthread_cond_t *cond);
 
+#ifdef LOCK_PROFILING
+int	__pthread_cond_wait_profiled(pthread_cond_t *cond,
+				     pthread_mutex_t *mutex,
+				     const char *file,
+				     int line);
+int	__pthread_cond_timedwait_profiled(pthread_cond_t *cond,
+					  pthread_mutex_t *mutex,
+					  const struct timespec * abstime,
+					  const char *file,
+					  int line);
+#endif
+
 /*
  * Double underscore versions are cancellation points.  Single underscore
  * versions are not and are provided for libc internal usage (which
@@ -300,14 +313,36 @@
 }
 
 int
-_pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex _PROFILE_PARMS)
+_pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+#ifdef LOCK_PROFILING
+{
+	return (_pthread_cond_wait_profiled(cond, mutex, __FILE__, __LINE__));
+}
+
+int
+_pthread_cond_wait_profiled(pthread_cond_t *cond,
+			     pthread_mutex_t *mutex,
+			     const char *file,
+			     int line)
+#endif
 {
 
 	return (cond_wait_common(cond, mutex, NULL, 0 _PROFILE_PASS));
 }
 
 int
-__pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex _PROFILE_PARMS)
+__pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+#ifdef LOCK_PROFILING
+{
+  return (__pthread_cond_wait_profiled(cond, mutex, __FILE__, __LINE__));
+}
+
+int
+__pthread_cond_wait_profiled(pthread_cond_t *cond,
+			     pthread_mutex_t *mutex,
+			     const char *file,
+			     int line)
+#endif
 {
 
 	return (cond_wait_common(cond, mutex, NULL, 1 _PROFILE_PASS));
@@ -315,7 +350,19 @@
 
 int
 _pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
-		       const struct timespec * abstime _PROFILE_PARMS)
+		       const struct timespec *abstime)
+#ifdef LOCK_PROFILING
+{
+  return (_pthread_cond_timedwait_profiled(cond, mutex, abstime,
+					   __FILE__, __LINE__));
+}
+
+int
+_pthread_cond_timedwait_profiled(pthread_cond_t *cond, pthread_mutex_t *mutex,
+				 const struct timespec *abstime,
+				 const char *file,
+				 int line)
+#endif
 {
 
 	if (abstime == NULL || abstime->tv_sec < 0 || abstime->tv_nsec < 0 ||
@@ -327,7 +374,19 @@
 
 int
 __pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
-		       const struct timespec *abstime _PROFILE_PARMS)
+		       const struct timespec *abstime)
+#ifdef LOCK_PROFILING
+{
+  return (__pthread_cond_timedwait_profiled(cond, mutex, abstime,
+					    __FILE__, __LINE__));
+}
+
+int
+__pthread_cond_timedwait_profiled(pthread_cond_t *cond, pthread_mutex_t *mutex,
+				  const struct timespec *abstime,
+				  const char *file,
+				  int line)
+#endif
 {
 
 	if (abstime == NULL || abstime->tv_sec < 0 || abstime->tv_nsec < 0 ||

Modified: soc2012/gmiller/locking-head/lib/libthr/thread/thr_mutex.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libthr/thread/thr_mutex.c	Fri Jun  1 16:33:45 2012	(r236883)
+++ soc2012/gmiller/locking-head/lib/libthr/thread/thr_mutex.c	Fri Jun  1 16:36:40 2012	(r236884)
@@ -76,10 +76,10 @@
  */
 int	__pthread_mutex_init(pthread_mutex_t *mutex,
 		const pthread_mutexattr_t *mutex_attr);
-int	__pthread_mutex_trylock(pthread_mutex_t *mutex _PROFILE_PARMS);
-int	__pthread_mutex_lock(pthread_mutex_t *mutex _PROFILE_PARMS);
+int	__pthread_mutex_trylock(pthread_mutex_t *mutex);
+int	__pthread_mutex_lock(pthread_mutex_t *mutex);
 int	__pthread_mutex_timedlock(pthread_mutex_t *mutex,
-		const struct timespec *abstime _PROFILE_PARMS);
+		const struct timespec *abstime);
 int	_pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
     		void *(calloc_cb)(size_t, size_t));
 int	_pthread_mutex_getspinloops_np(pthread_mutex_t *mutex, int *count);
@@ -96,6 +96,19 @@
 static int	mutex_lock_sleep(struct pthread *, pthread_mutex_t,
 				const struct timespec * _PROFILE_PARMS);
 
+#ifdef LOCK_PROFILING
+int	__pthread_mutex_trylock_profiled(pthread_mutex_t *mutex,
+					 const char *file,
+					 int line);
+int	__pthread_mutex_lock_profiled(pthread_mutex_t *mutex,
+				      const char *file,
+				      int line);
+int	__pthread_mutex_timedlock_profiled(pthread_mutex_t *mutex,
+					   const struct timespec *abstime,
+					   const char *file,
+					   int line);
+#endif
+
 __weak_reference(__pthread_mutex_init, pthread_mutex_init);
 __strong_reference(__pthread_mutex_init, _pthread_mutex_init);
 __weak_reference(__pthread_mutex_lock, pthread_mutex_lock);
@@ -340,7 +353,17 @@
 }
 
 int
-__pthread_mutex_trylock(pthread_mutex_t *mutex _PROFILE_PARMS)
+__pthread_mutex_trylock(pthread_mutex_t *mutex)
+#ifdef LOCK_PROFILING
+{
+	return (__pthread_mutex_trylock_profiled(mutex, __FILE__, __LINE__));
+}
+
+int
+__pthread_mutex_trylock_profiled(pthread_mutex_t *mutex,
+				 const char *file,
+				 int line)
+#endif
 {
 	struct pthread_mutex *m;
 
@@ -444,7 +467,17 @@
 }
 
 int
-__pthread_mutex_lock(pthread_mutex_t *mutex _PROFILE_PARMS)
+__pthread_mutex_lock(pthread_mutex_t *mutex)
+#ifdef LOCK_PROFILING
+{
+	return (__pthread_mutex_lock_profiled(mutex, __FILE__, __LINE__));
+}
+
+int
+__pthread_mutex_lock_profiled(pthread_mutex_t *mutex,
+			      const char *file,
+			      int line)
+#endif
 {
 	struct pthread_mutex	*m;
 
@@ -456,7 +489,20 @@
 }
 
 int
-__pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *abstime _PROFILE_PARMS)
+__pthread_mutex_timedlock(pthread_mutex_t *mutex,
+			  const struct timespec *abstime)
+#ifdef LOCK_PROFILING
+{
+	return (__pthread_mutex_timedlock_profiled(mutex, abstime,
+						   __FILE__, __LINE__));
+}
+
+int
+__pthread_mutex_timedlock_profiled(pthread_mutex_t *mutex,
+				   const struct timespec *abstime,
+				   const char *file,
+				   int line)
+#endif
 {
 	struct pthread_mutex	*m;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120601163640.747B01065670>