public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] Allow mutex initialization without PI configured
@ 2014-07-28 22:33 Gary S. Robertson
  2014-07-29  8:05 ` Jan Stancek
  2014-07-29 10:53 ` chrubis
  0 siblings, 2 replies; 3+ messages in thread
From: Gary S. Robertson @ 2014-07-28 22:33 UTC (permalink / raw)
  To: ltp-list; +Cc: mike.holmes

From: "Gary S. Robertson" <gary.robertson@linaro.org>

LTP seems primarily intended to be built and run on the same machine,
and thus uses autotools / autoconf to determine the features of the host
machine's environment prior to compilation.  However, when distributing
precompiled binaries, or when building in a cross-compilation environment,
it is better not to disable features based on the compile-time environment.

This patch removes compile-time dependencies on priority-inheriting mutexes
and allows the code to attempt initialization of PI mutexes even
if the runtime environment lacks that feature... in which case
the associated test(s) should fail.

Without this patch, init_pi_mutex() may be compiled as an empty function,
allowing subsequent operations to be attempted on an un-inititalized mutex.
Likewise, testpi-3 may fail to initialize a mutex before starting pthreads
which attempt to use the mutex.

Signed-off-by: Gary S. Robertson <gary.robertson@linaro.org>
---
 testcases/realtime/lib/librttest.c            |    2 --
 testcases/realtime/stress/pi-tests/testpi-3.c |    2 --
 2 files changed, 4 deletions(-)

diff --git a/testcases/realtime/lib/librttest.c b/testcases/realtime/lib/librttest.c
index 0dd6019..9f37d08 100644
--- a/testcases/realtime/lib/librttest.c
+++ b/testcases/realtime/lib/librttest.c
@@ -586,7 +586,6 @@ void *busy_work_us(int us)
 
 void init_pi_mutex(pthread_mutex_t * m)
 {
-#if HAVE_DECL_PTHREAD_PRIO_INHERIT
 	pthread_mutexattr_t attr;
 	int ret;
 	int protocol;
@@ -609,7 +608,6 @@ void init_pi_mutex(pthread_mutex_t * m)
 	if ((ret = pthread_mutex_init(m, &attr)) != 0) {
 		printf("Failed to init mutex: %d (%s)\n", ret, strerror(ret));
 	}
-#endif1G
 
 	/* FIXME: does any of this need to be destroyed ? */
 }
diff --git a/testcases/realtime/stress/pi-tests/testpi-3.c b/testcases/realtime/stress/pi-tests/testpi-3.c
index 30f38f6..807c9cc 100644
--- a/testcases/realtime/stress/pi-tests/testpi-3.c
+++ b/testcases/realtime/stress/pi-tests/testpi-3.c
@@ -365,7 +365,6 @@ int main(int argc, char *argv[])
 
 	printf("Start %s\n", argv[0]);
 
-#if HAVE_DECL_PTHREAD_PRIO_INHERIT
 	if (!nopi) {
 		pthread_mutexattr_t mutexattr;
 		int protocol;
@@ -386,7 +385,6 @@ int main(int argc, char *argv[])
 			printf("Failed to init mutex: %d\n", retc);
 		}
 	}
-#endif
 
 	startThread(&arg1);
 	startThread(&arg2);
-- 
1.7.9.5


------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-29 10:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-28 22:33 [LTP] [PATCH] Allow mutex initialization without PI configured Gary S. Robertson
2014-07-29  8:05 ` Jan Stancek
2014-07-29 10:53 ` chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox