All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] SPARC fixes
@ 2014-05-08  9:06 Stanislav Kholmanskikh
  2014-05-08  9:06 ` [LTP] [PATCH 1/4] linux syscall numbers: fixed the checkings for SPARC Stanislav Kholmanskikh
                   ` (3 more replies)
  0 siblings, 4 replies; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-05-08  9:06 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Hi!

Here are some fixes to execute LTP on SPARC.

Thanks!


------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 1/4] linux syscall numbers: fixed the checkings for SPARC
  2014-05-08  9:06 [LTP] SPARC fixes Stanislav Kholmanskikh
@ 2014-05-08  9:06 ` Stanislav Kholmanskikh
  2014-05-08  9:06 ` [LTP] [PATCH 2/4] linux syscall numbers: removed unimplemented syscalls for sparc64 Stanislav Kholmanskikh
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-05-08  9:06 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

For sparc64 platforms cpp does not define '__sparc64__', but
defines '__sparc__' and '__arch64__'.

For sparc32 platforms cpp just defines '__sparc__'.

This may cause problems because sparc64 and sparc32 have not equal
sets of system calls.

Modified the ckeckings for SPARC in regen.sh and executed it.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 testcases/kernel/include/linux_syscall_numbers.h |    4 ++--
 testcases/kernel/include/regen.sh                |    6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/include/linux_syscall_numbers.h b/testcases/kernel/include/linux_syscall_numbers.h
index 03664ce..a43f7ca 100644
--- a/testcases/kernel/include/linux_syscall_numbers.h
+++ b/testcases/kernel/include/linux_syscall_numbers.h
@@ -8880,7 +8880,7 @@
 #endif
 
 
-#ifdef __sparc64__
+#if defined(__sparc__) && defined(__arch64__)
 # ifndef __NR_restart_syscall
 #  define __NR_restart_syscall 0
 # endif
@@ -9883,7 +9883,7 @@
 #endif
 
 
-#ifdef __sparc__
+#if defined(__sparc__) && !defined(__arch64__)
 # ifndef __NR_restart_syscall
 #  define __NR_restart_syscall 0
 # endif
diff --git a/testcases/kernel/include/regen.sh b/testcases/kernel/include/regen.sh
index 3e9f0e7..3f7f4aa 100755
--- a/testcases/kernel/include/regen.sh
+++ b/testcases/kernel/include/regen.sh
@@ -59,7 +59,11 @@ for arch in $(cat "${srcdir}/order") ; do
 
 	(
 	echo
-	echo "#ifdef __${arch}__"
+	case ${arch} in
+		sparc64) echo "#if defined(__sparc__) && defined(__arch64__)" ;;
+		sparc) echo "#if defined(__sparc__) && !defined(__arch64__)" ;;
+		*) echo "#ifdef __${arch}__"
+	esac
 	while read line ; do
 		set -- ${line}
 		nr="__NR_$1"
-- 
1.7.1


------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 2/4] linux syscall numbers: removed unimplemented syscalls for sparc64
  2014-05-08  9:06 [LTP] SPARC fixes Stanislav Kholmanskikh
  2014-05-08  9:06 ` [LTP] [PATCH 1/4] linux syscall numbers: fixed the checkings for SPARC Stanislav Kholmanskikh
@ 2014-05-08  9:06 ` Stanislav Kholmanskikh
  2014-05-08  9:06 ` [LTP] [PATCH 3/4] syscalls: corrected the rest of __sparc64__ defines Stanislav Kholmanskikh
  2014-05-08  9:06 ` [LTP] [PATCH 4/4] rt_sigaction*, rt_sigprocmask01, rt_sigsuspend01: SPARC support Stanislav Kholmanskikh
  3 siblings, 0 replies; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-05-08  9:06 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

In accordance with arch/sparc/include/uapi/asm/unistd.h syscalls
with names containing '32' are not defined for sparc64.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 testcases/kernel/include/linux_syscall_numbers.h |   57 ----------------------
 testcases/kernel/include/sparc64.in              |   19 -------
 2 files changed, 0 insertions(+), 76 deletions(-)

diff --git a/testcases/kernel/include/linux_syscall_numbers.h b/testcases/kernel/include/linux_syscall_numbers.h
index a43f7ca..60caaf1 100644
--- a/testcases/kernel/include/linux_syscall_numbers.h
+++ b/testcases/kernel/include/linux_syscall_numbers.h
@@ -8974,21 +8974,12 @@
 # ifndef __NR_utime
 #  define __NR_utime 30
 # endif
-# ifndef __NR_lchown32
-#  define __NR_lchown32 31
-# endif
-# ifndef __NR_fchown32
-#  define __NR_fchown32 32
-# endif
 # ifndef __NR_access
 #  define __NR_access 33
 # endif
 # ifndef __NR_nice
 #  define __NR_nice 34
 # endif
-# ifndef __NR_chown32
-#  define __NR_chown32 35
-# endif
 # ifndef __NR_sync
 #  define __NR_sync 36
 # endif
@@ -9013,9 +9004,6 @@
 # ifndef __NR_times
 #  define __NR_times 43
 # endif
-# ifndef __NR_getuid32
-#  define __NR_getuid32 44
-# endif
 # ifndef __NR_umount2
 #  define __NR_umount2 45
 # endif
@@ -9037,9 +9025,6 @@
 # ifndef __NR_acct
 #  define __NR_acct 51
 # endif
-# ifndef __NR_getgid32
-#  define __NR_getgid32 53
-# endif
 # ifndef __NR_memory_ordering
 #  define __NR_memory_ordering 52
 # endif
@@ -9088,18 +9073,9 @@
 # ifndef __NR_pwrite64
 #  define __NR_pwrite64 68
 # endif
-# ifndef __NR_geteuid32
-#  define __NR_geteuid32 69
-# endif
-# ifndef __NR_getegid32
-#  define __NR_getegid32 70
-# endif
 # ifndef __NR_mmap
 #  define __NR_mmap 71
 # endif
-# ifndef __NR_setreuid32
-#  define __NR_setreuid32 72
-# endif
 # ifndef __NR_munmap
 #  define __NR_munmap 73
 # endif
@@ -9127,9 +9103,6 @@
 # ifndef __NR_getpgrp
 #  define __NR_getpgrp 81
 # endif
-# ifndef __NR_setgroups32
-#  define __NR_setgroups32 82
-# endif
 # ifndef __NR_setitimer
 #  define __NR_setitimer 83
 # endif
@@ -9142,30 +9115,18 @@
 # ifndef __NR_getitimer
 #  define __NR_getitimer 86
 # endif
-# ifndef __NR_setuid32
-#  define __NR_setuid32 87
-# endif
 # ifndef __NR_sethostname
 #  define __NR_sethostname 88
 # endif
-# ifndef __NR_setgid32
-#  define __NR_setgid32 89
-# endif
 # ifndef __NR_dup2
 #  define __NR_dup2 90
 # endif
-# ifndef __NR_setfsuid32
-#  define __NR_setfsuid32 91
-# endif
 # ifndef __NR_fcntl
 #  define __NR_fcntl 92
 # endif
 # ifndef __NR_select
 #  define __NR_select 93
 # endif
-# ifndef __NR_setfsgid32
-#  define __NR_setfsgid32 94
-# endif
 # ifndef __NR_fsync
 #  define __NR_fsync 95
 # endif
@@ -9205,21 +9166,6 @@
 # ifndef __NR_rt_sigsuspend
 #  define __NR_rt_sigsuspend 107
 # endif
-# ifndef __NR_setresuid32
-#  define __NR_setresuid32 108
-# endif
-# ifndef __NR_getresuid32
-#  define __NR_getresuid32 109
-# endif
-# ifndef __NR_setresgid32
-#  define __NR_setresgid32 110
-# endif
-# ifndef __NR_getresgid32
-#  define __NR_getresgid32 111
-# endif
-# ifndef __NR_setregid32
-#  define __NR_setregid32 112
-# endif
 # ifndef __NR_setresuid
 #  define __NR_setresuid 108
 # endif
@@ -9238,9 +9184,6 @@
 # ifndef __NR_sendmsg
 #  define __NR_sendmsg 114
 # endif
-# ifndef __NR_getgroups32
-#  define __NR_getgroups32 115
-# endif
 # ifndef __NR_gettimeofday
 #  define __NR_gettimeofday 116
 # endif
diff --git a/testcases/kernel/include/sparc64.in b/testcases/kernel/include/sparc64.in
index 697378f..e79ba95 100644
--- a/testcases/kernel/include/sparc64.in
+++ b/testcases/kernel/include/sparc64.in
@@ -29,11 +29,8 @@ alarm 27
 sigaltstack 28
 pause 29
 utime 30
-lchown32 31
-fchown32 32
 access 33
 nice 34
-chown32 35
 sync 36
 kill 37
 stat 38
@@ -42,7 +39,6 @@ lstat 40
 dup 41
 pipe 42
 times 43
-getuid32 44
 umount2 45
 setgid 46
 getgid 47
@@ -50,7 +46,6 @@ signal 48
 geteuid 49
 getegid 50
 acct 51
-getgid32 53
 memory_ordering 52
 ioctl 54
 reboot 55
@@ -67,10 +62,7 @@ msync 65
 vfork 66
 pread64 67
 pwrite64 68
-geteuid32 69
-getegid32 70
 mmap 71
-setreuid32 72
 munmap 73
 mprotect 74
 madvise 75
@@ -80,19 +72,14 @@ mincore 78
 getgroups 79
 setgroups 80
 getpgrp 81
-setgroups32 82
 setitimer 83
 ftruncate64 84
 swapon 85
 getitimer 86
-setuid32 87
 sethostname 88
-setgid32 89
 dup2 90
-setfsuid32 91
 fcntl 92
 select 93
-setfsgid32 94
 fsync 95
 setpriority 96
 socket 97
@@ -106,18 +93,12 @@ rt_sigpending 104
 rt_sigtimedwait 105
 rt_sigqueueinfo 106
 rt_sigsuspend 107
-setresuid32 108
-getresuid32 109
-setresgid32 110
-getresgid32 111
-setregid32 112
 setresuid 108
 getresuid 109
 setresgid 110
 getresgid 111
 recvmsg 113
 sendmsg 114
-getgroups32 115
 gettimeofday 116
 getrusage 117
 getsockopt 118
-- 
1.7.1


------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 3/4] syscalls: corrected the rest of __sparc64__ defines
  2014-05-08  9:06 [LTP] SPARC fixes Stanislav Kholmanskikh
  2014-05-08  9:06 ` [LTP] [PATCH 1/4] linux syscall numbers: fixed the checkings for SPARC Stanislav Kholmanskikh
  2014-05-08  9:06 ` [LTP] [PATCH 2/4] linux syscall numbers: removed unimplemented syscalls for sparc64 Stanislav Kholmanskikh
@ 2014-05-08  9:06 ` Stanislav Kholmanskikh
  2014-05-12 12:59   ` chrubis
  2014-05-08  9:06 ` [LTP] [PATCH 4/4] rt_sigaction*, rt_sigprocmask01, rt_sigsuspend01: SPARC support Stanislav Kholmanskikh
  3 siblings, 1 reply; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-05-08  9:06 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

'__sparc64__' is not defined by cpp. We should use
'__sparc__' and '__arch64__' instead.

Author: Jose E. Marchesi <jose.marchesi@oracle.com>
Author: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 testcases/kernel/syscalls/recvmsg/recvmsg01.c |    3 ++-
 testcases/kernel/syscalls/sendmsg/sendmsg01.c |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/recvmsg/recvmsg01.c b/testcases/kernel/syscalls/recvmsg/recvmsg01.c
index bc84a23..102a268 100644
--- a/testcases/kernel/syscalls/recvmsg/recvmsg01.c
+++ b/testcases/kernel/syscalls/recvmsg/recvmsg01.c
@@ -45,7 +45,8 @@
 /* and this test to function correctly.                        */
 #ifndef MSG_CMSG_COMPAT
 
-#if defined (__powerpc64__) || defined (__mips64) || defined (__x86_64__) || defined (__sparc64__)
+#if defined(__powerpc64__) || defined(__mips64) || defined(__x86_64__) || \
+	defined(__sparc__) && defined(__arch64__)
 #define MSG_CMSG_COMPAT 0x80000000
 #else
 #define MSG_CMSG_COMPAT 0
diff --git a/testcases/kernel/syscalls/sendmsg/sendmsg01.c b/testcases/kernel/syscalls/sendmsg/sendmsg01.c
index 58d3364..9e5d4f2 100644
--- a/testcases/kernel/syscalls/sendmsg/sendmsg01.c
+++ b/testcases/kernel/syscalls/sendmsg/sendmsg01.c
@@ -37,7 +37,8 @@
  */
 #ifndef MSG_CMSG_COMPAT
 #if defined(__powerpc64__) || defined(__mips64) || defined(__x86_64__) || \
-     defined(__sparc64__) || defined(__ia64__) || defined(__s390x__)
+	defined(__sparc__) && defined(__arch64__) || defined(__ia64__) || \
+	defined(__s390x__)
 #define MSG_CMSG_COMPAT 0x80000000
 #else
 #define MSG_CMSG_COMPAT 0
-- 
1.7.1


------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 4/4] rt_sigaction*, rt_sigprocmask01, rt_sigsuspend01: SPARC support
  2014-05-08  9:06 [LTP] SPARC fixes Stanislav Kholmanskikh
                   ` (2 preceding siblings ...)
  2014-05-08  9:06 ` [LTP] [PATCH 3/4] syscalls: corrected the rest of __sparc64__ defines Stanislav Kholmanskikh
@ 2014-05-08  9:06 ` Stanislav Kholmanskikh
  2014-05-12 13:08   ` chrubis
  3 siblings, 1 reply; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-05-08  9:06 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Added SPARC support for tests:
 * rt_sigaction01, rt_sigaction02, rt_sigaction03
 * rt_sigprocmask01
 * rt_sigsuspend01

Author: Jose E. Marchesi <jose.marchesi@oracle.com>
Co-author: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 include/ltp_signal.h                               |   39 +++++++++++++++++++-
 .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   32 ++++++++++++++---
 .../kernel/syscalls/rt_sigaction/rt_sigaction02.c  |   13 ++++++-
 .../kernel/syscalls/rt_sigaction/rt_sigaction03.c  |   28 ++++++++++++++
 .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   24 +++++++++++-
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |   24 ++++++++++--
 6 files changed, 147 insertions(+), 13 deletions(-)

diff --git a/include/ltp_signal.h b/include/ltp_signal.h
index e6fb2e0..c050894 100644
--- a/include/ltp_signal.h
+++ b/include/ltp_signal.h
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2009 Cisco Systems, Inc.  All Rights Reserved.
  * Copyright (c) 2009 FUJITSU LIMITED.  All Rights Reserved.
+ * Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -77,6 +78,42 @@
 #define HAVE_SA_RESTORER
 #define SA_RESTORER	0x04000000
 
+#endif /* __x86_64__ */
+
+#ifdef __sparc__
+#if defined __arch64__ || defined __sparcv9
+
+/*
+ * From glibc/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c
+ */
+
+static void __rt_sigreturn_stub(void)
+{
+	__asm__ ("mov %0, %%g1\n\t"
+		"ta  0x6d\n\t"
+		: /* no outputs */
+		: "i" (__NR_rt_sigreturn));
+}
+
+#else /* sparc32 */
+
+/*
+ * From glibc/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c
+ */
+
+static void __sigreturn_stub(void)
+{
+	__asm__ ("mov %0, %%g1\n\t"
+		"ta  0x10\n\t"
+		: /* no outputs */
+		: "i" (__NR_sigreturn));
+}
+
+#endif
+#endif /* __sparc__ */
+
+#if defined __x86_64__ || defined __sparc__
+
 struct kernel_sigaction {
 	__sighandler_t k_sa_handler;
 	unsigned long sa_flags;
@@ -118,7 +155,7 @@ static inline int sig_initial(int sig)
 
 }
 
-#endif /* __x86_64__ */
+#endif /* __x86_64__ || __sparc__*/
 
 #endif /* LTP_RT_SIG_TEST */
 
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index 8f18394..2f8020e 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -1,5 +1,6 @@
 /******************************************************************************/
 /* Copyright (c) Crackerjack Project., 2007                                   */
+/* Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.      */
 /*                                                                            */
 /* This program is free software;  you can redistribute it and/or modify      */
 /* it under the terms of the GNU General Public License as published by       */
@@ -127,21 +128,42 @@ void handler(int sig)
 
 int set_handler(int sig, int sig_to_mask, int mask_flags)
 {
-#ifdef __x86_64__
+#ifdef __sparc__
+	struct sigaction sa;
+	struct kernel_sigaction kact, koact;
+# ifdef __arch64__
+	unsigned long stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
+# else
+	unsigned long stub = ((unsigned long) &__sigreturn_stub) - 8;
+# endif
+
+	sigemptyset(&sa.sa_mask);
+	sigaddset(&sa.sa_mask, sig);
+
+	kact.k_sa_handler = (void *) handler;
+	kact.sa_flags = 0;
+	kact.sa_restorer = NULL;
+	memcpy(&kact.sa_mask, &sa.sa_mask, sizeof(sigset_t));
+
+	return ltp_syscall(__NR_rt_sigaction, sig, &kact,
+			&koact, stub, SIGSETSIZE);
+#else
+
+# ifdef __x86_64__
 	struct kernel_sigaction sa, oldaction;
 	mask_flags |= SA_RESTORER;
 	sa.sa_restorer = restore_rt;
 	sa.k_sa_handler = (void *)handler;
-#else
+# else
 	struct sigaction sa, oldaction;
 	sa.sa_handler = (void *)handler;
-#endif
+# endif
 	sa.sa_flags = mask_flags;
 	sigemptyset(&sa.sa_mask);
 	sigaddset(&sa.sa_mask, sig);
 
 	return ltp_syscall(__NR_rt_sigaction, sig, &sa, &oldaction, SIGSETSIZE);
-
+#endif
 }
 
 int main(int ac, char **av)
@@ -164,7 +186,7 @@ int main(int ac, char **av)
 
 			for (signal = SIGRTMIN; signal <= (SIGRTMAX); signal++) {	//signal for 34 to 65
 
-#ifdef __x86_64__
+#if defined __x86_64__ || defined __sparc__
 				sig_initial(signal);
 #endif
 
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
index 61137df..c272344 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
@@ -1,5 +1,6 @@
 /******************************************************************************/
 /* Copyright (c) Crackerjack Project., 2007                                   */
+/* Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.      */
 /*                                                                            */
 /* This program is free software;  you can redistribute it and/or modify      */
 /* it under the terms of the GNU General Public License as published by       */
@@ -46,6 +47,7 @@
 #include <sys/syscall.h>
 #include <string.h>
 
+#define LTP_RT_SIG_TEST
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
@@ -151,10 +153,19 @@ int main(int ac, char **av)
 					 * EFAULT:                                                      *
 					 * An invalid act or oact value was specified                   *
 					 */
-
+#ifdef __sparc__
+# ifdef __arch64__
+					unsigned long stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
+# else
+					unsigned long stub = ((unsigned long) &__sigreturn_stub) - 8;
+# endif
+					TEST(ltp_syscall(__NR_rt_sigaction, signal,
+							INVAL_STRUCT, NULL, stub, SIGSETSIZE));
+#else
 					TEST(ltp_syscall
 					     (__NR_rt_sigaction, signal,
 					      INVAL_STRUCT, NULL, SIGSETSIZE));
+#endif
 					if ((TEST_RETURN == -1)
 					    && (TEST_ERRNO ==
 						test_cases[0].exp_errno)) {
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
index 12c3b84..9a65d63 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
@@ -1,5 +1,6 @@
 /******************************************************************************/
 /* Copyright (c) Crackerjack Project., 2007                                   */
+/* Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.      */
 /*                                                                            */
 /* This program is free software;  you can redistribute it and/or modify      */
 /* it under the terms of the GNU General Public License as published by       */
@@ -46,6 +47,7 @@
 #include <sys/syscall.h>
 #include <string.h>
 
+#define LTP_RT_SIG_TEST
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
@@ -133,6 +135,31 @@ void handler(int sig)
 
 int set_handler(int sig, int sig_to_mask, int mask_flags)
 {
+#ifdef __sparc__
+	struct sigaction sa;
+	struct kernel_sigaction kact, koact;
+# ifdef __arch64__
+	unsigned long stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
+# else
+	unsigned long stub = ((unsigned long) &__sigreturn_stub) - 8;
+# endif
+
+	sigemptyset(&sa.sa_mask);
+	sigaddset(&sa.sa_mask, sig_to_mask);
+
+	kact.k_sa_handler = (void *) handler;
+	kact.sa_flags = 0;
+	kact.sa_restorer = NULL;
+	memcpy(&kact.sa_mask, &sa.sa_mask, sizeof(sigset_t));
+
+	TEST(ltp_syscall(__NR_rt_sigaction,
+			sig, &kact, &koact, stub, INVAL_SIGSETSIZE));
+	if (TEST_RETURN == 0)
+		return 0;
+	else
+		return TEST_RETURN;
+
+#else
 	struct sigaction sa, oldaction;
 
 	sa.sa_sigaction = (void *)handler;
@@ -154,6 +181,7 @@ int set_handler(int sig, int sig_to_mask, int mask_flags)
 	} else {
 		return TEST_RETURN;
 	}
+#endif
 }
 
 int main(int ac, char **av)
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index 1dbed72..582098c 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -1,5 +1,6 @@
 /******************************************************************************/
 /* Copyright (c) Crackerjack Project., 2007                                   */
+/* Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.      */
 /*                                                                            */
 /* This program is free software;  you can redistribute it and/or modify      */
 /* it under the terms of the GNU General Public License as published by       */
@@ -130,17 +131,30 @@ void sig_handler(int sig)
 
 int main(int ac, char **av)
 {
-#if __x86_64
+#ifdef __sparc__
+	struct kernel_sigaction kact, koact;
+# ifdef __arch64__
+	unsigned long stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
+# else
+	unsigned long stub = ((unsigned long) &__sigreturn_stub) - 8;
+# endif
+	sig_initial(TEST_SIG);
+	kact.sa_flags = 0;
+	kact.k_sa_handler = (void *) sig_handler;
+	kact.sa_restorer = NULL;
+#else
+# ifdef __x86_64__
 	struct kernel_sigaction act, oact;
 	sig_initial(TEST_SIG);
 	act.sa_flags |= SA_RESTORER;
 	act.sa_restorer = restore_rt;
 	act.k_sa_handler = sig_handler;
-#else
+# else
 	struct sigaction act, oact;
 	memset(&act, 0, sizeof(act));
 	memset(&oact, 0, sizeof(oact));
 	act.sa_handler = sig_handler;
+# endif
 #endif
 	sigset_t set, oset;
 	int lc;
@@ -166,8 +180,14 @@ int main(int ac, char **av)
 			}
 
 			/* call rt_sigaction() */
+#ifdef __sparc__
+			TEST(ltp_syscall(__NR_rt_sigaction, TEST_SIG,
+					&kact, &koact, stub,
+					SIGSETSIZE));
+#else
 			TEST(ltp_syscall(__NR_rt_sigaction, TEST_SIG, &act,
 				&oact, SIGSETSIZE));
+#endif
 			if (TEST_RETURN < 0) {
 				tst_brkm(TFAIL | TTERRNO, cleanup,
 					 "rt_sigaction call failed");
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index d14cdf8..4b73940 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -1,5 +1,6 @@
 /********************************************************************************/
 /* Copyright (c) Crackerjack Project., 2007				   	*/
+/* Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.        */
 /*									    	*/
 /* This program is free software;  you can redistribute it and/or modify      	*/
 /* it under the terms of the GNU General Public License as published by       	*/
@@ -128,7 +129,22 @@ int main(int ac, char **av)
 		if (sigemptyset(&set) < 0) {
 			tst_brkm(TFAIL | TERRNO, cleanup, "sigemptyset failed");
 		}
-#ifdef __x86_64__
+#ifdef __sparc__
+		struct kernel_sigaction act, oact;
+# ifdef __arch64__
+		unsigned long stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
+# else
+		unsigned long stub = ((unsigned long) &__sigreturn_stub) - 8;
+# endif
+		sig_initial(SIGALRM);
+		act.k_sa_handler = (void *)sig_handler;
+		act.sa_flags = 0;
+		act.sa_restorer = NULL;
+
+		TEST(ltp_syscall(__NR_rt_sigaction, SIGALRM, &act, &oact,
+				stub, SIGSETSIZE));
+#else
+# ifdef __x86_64__
 		struct kernel_sigaction act, oact;
 		sig_initial(SIGALRM);
 		memset(&act, 0, sizeof(act));
@@ -136,15 +152,15 @@ int main(int ac, char **av)
 		act.sa_flags |= SA_RESTORER;
 		act.sa_restorer = restore_rt;
 		act.k_sa_handler = sig_handler;
-#else
+# else
 		struct sigaction act, oact;
 		memset(&act, 0, sizeof(act));
 		memset(&oact, 0, sizeof(oact));
 		act.sa_handler = sig_handler;
-#endif
-
+# endif
 		TEST(ltp_syscall(__NR_rt_sigaction, SIGALRM, &act, &oact,
 			     SIGSETSIZE));
+#endif
 		if (TEST_RETURN == -1) {
 			tst_brkm(TFAIL | TTERRNO, cleanup,
 				 "rt_sigaction failed");
-- 
1.7.1


------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 3/4] syscalls: corrected the rest of __sparc64__ defines
  2014-05-08  9:06 ` [LTP] [PATCH 3/4] syscalls: corrected the rest of __sparc64__ defines Stanislav Kholmanskikh
@ 2014-05-12 12:59   ` chrubis
  2014-05-13  6:20     ` [LTP] [PATCH 1/2] sendmsg, recvmsg: moved MSG_CMSG_COMPAT definition to a header Stanislav Kholmanskikh
  2014-05-13  6:20     ` [LTP] [PATCH 2/2] msg_common.h: corrected __sparc64__ definition Stanislav Kholmanskikh
  0 siblings, 2 replies; 28+ messages in thread
From: chrubis @ 2014-05-12 12:59 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
> '__sparc64__' is not defined by cpp. We should use
> '__sparc__' and '__arch64__' instead.
> 
> Author: Jose E. Marchesi <jose.marchesi@oracle.com>
> Author: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
> 
> Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
> ---
>  testcases/kernel/syscalls/recvmsg/recvmsg01.c |    3 ++-
>  testcases/kernel/syscalls/sendmsg/sendmsg01.c |    3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/recvmsg/recvmsg01.c b/testcases/kernel/syscalls/recvmsg/recvmsg01.c
> index bc84a23..102a268 100644
> --- a/testcases/kernel/syscalls/recvmsg/recvmsg01.c
> +++ b/testcases/kernel/syscalls/recvmsg/recvmsg01.c
> @@ -45,7 +45,8 @@
>  /* and this test to function correctly.                        */
>  #ifndef MSG_CMSG_COMPAT
>  
> -#if defined (__powerpc64__) || defined (__mips64) || defined (__x86_64__) || defined (__sparc64__)
> +#if defined(__powerpc64__) || defined(__mips64) || defined(__x86_64__) || \
> +	defined(__sparc__) && defined(__arch64__)
>  #define MSG_CMSG_COMPAT 0x80000000
>  #else
>  #define MSG_CMSG_COMPAT 0
> diff --git a/testcases/kernel/syscalls/sendmsg/sendmsg01.c b/testcases/kernel/syscalls/sendmsg/sendmsg01.c
> index 58d3364..9e5d4f2 100644
> --- a/testcases/kernel/syscalls/sendmsg/sendmsg01.c
> +++ b/testcases/kernel/syscalls/sendmsg/sendmsg01.c
> @@ -37,7 +37,8 @@
>   */
>  #ifndef MSG_CMSG_COMPAT
>  #if defined(__powerpc64__) || defined(__mips64) || defined(__x86_64__) || \
> -     defined(__sparc64__) || defined(__ia64__) || defined(__s390x__)
> +	defined(__sparc__) && defined(__arch64__) || defined(__ia64__) || \
> +	defined(__s390x__)
>  #define MSG_CMSG_COMPAT 0x80000000
>  #else
>  #define MSG_CMSG_COMPAT 0

Aren't these two nearly the same? Shouldn't we pull them into a common
header first?

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 4/4] rt_sigaction*, rt_sigprocmask01, rt_sigsuspend01: SPARC support
  2014-05-08  9:06 ` [LTP] [PATCH 4/4] rt_sigaction*, rt_sigprocmask01, rt_sigsuspend01: SPARC support Stanislav Kholmanskikh
@ 2014-05-12 13:08   ` chrubis
       [not found]     ` <5371C09F.7050205@oracle.com>
  0 siblings, 1 reply; 28+ messages in thread
From: chrubis @ 2014-05-12 13:08 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
> Added SPARC support for tests:
>  * rt_sigaction01, rt_sigaction02, rt_sigaction03
>  * rt_sigprocmask01
>  * rt_sigsuspend01
> 
> Author: Jose E. Marchesi <jose.marchesi@oracle.com>
> Co-author: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
> 
> Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
> ---
>  include/ltp_signal.h                               |   39 +++++++++++++++++++-
>  .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   32 ++++++++++++++---
>  .../kernel/syscalls/rt_sigaction/rt_sigaction02.c  |   13 ++++++-
>  .../kernel/syscalls/rt_sigaction/rt_sigaction03.c  |   28 ++++++++++++++
>  .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   24 +++++++++++-
>  .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |   24 ++++++++++--
>  6 files changed, 147 insertions(+), 13 deletions(-)
> 
> diff --git a/include/ltp_signal.h b/include/ltp_signal.h
> index e6fb2e0..c050894 100644
> --- a/include/ltp_signal.h
> +++ b/include/ltp_signal.h
> @@ -1,6 +1,7 @@
>  /*
>   * Copyright (c) 2009 Cisco Systems, Inc.  All Rights Reserved.
>   * Copyright (c) 2009 FUJITSU LIMITED.  All Rights Reserved.
> + * Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
>   *
>   * This program is free software; you can redistribute it and/or modify it
>   * under the terms of version 2 of the GNU General Public License as
> @@ -77,6 +78,42 @@
>  #define HAVE_SA_RESTORER
>  #define SA_RESTORER	0x04000000
>  
> +#endif /* __x86_64__ */
> +
> +#ifdef __sparc__
> +#if defined __arch64__ || defined __sparcv9
> +
> +/*
> + * From glibc/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c
> + */
> +
> +static void __rt_sigreturn_stub(void)
> +{
> +	__asm__ ("mov %0, %%g1\n\t"
> +		"ta  0x6d\n\t"
> +		: /* no outputs */
> +		: "i" (__NR_rt_sigreturn));
> +}
> +
> +#else /* sparc32 */
> +
> +/*
> + * From glibc/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c
> + */
> +
> +static void __sigreturn_stub(void)
> +{
> +	__asm__ ("mov %0, %%g1\n\t"
> +		"ta  0x10\n\t"
> +		: /* no outputs */
> +		: "i" (__NR_sigreturn));
> +}
> +
> +#endif
> +#endif /* __sparc__ */

Do you care to elaborate what are these used for? I can see that you
pass and addres to them to the sparc variant of the rt_sigaction
syscalls below however a line or two about why we do this in the commit
message wouldn't hurt.

> +#if defined __x86_64__ || defined __sparc__
> +
>  struct kernel_sigaction {
>  	__sighandler_t k_sa_handler;
>  	unsigned long sa_flags;
> @@ -118,7 +155,7 @@ static inline int sig_initial(int sig)
>  
>  }
>  
> -#endif /* __x86_64__ */
> +#endif /* __x86_64__ || __sparc__*/
>  
>  #endif /* LTP_RT_SIG_TEST */
>  
> diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> index 8f18394..2f8020e 100644
> --- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> +++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> @@ -1,5 +1,6 @@
>  /******************************************************************************/
>  /* Copyright (c) Crackerjack Project., 2007                                   */
> +/* Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.      */
>  /*                                                                            */
>  /* This program is free software;  you can redistribute it and/or modify      */
>  /* it under the terms of the GNU General Public License as published by       */
> @@ -127,21 +128,42 @@ void handler(int sig)
>  
>  int set_handler(int sig, int sig_to_mask, int mask_flags)
>  {
> -#ifdef __x86_64__
> +#ifdef __sparc__
> +	struct sigaction sa;
> +	struct kernel_sigaction kact, koact;
> +# ifdef __arch64__
> +	unsigned long stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
> +# else
> +	unsigned long stub = ((unsigned long) &__sigreturn_stub) - 8;
> +# endif

These ifdefs are repeated in the lines below over and over, can we put
them in a common header instead?

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 1/2] sendmsg, recvmsg: moved MSG_CMSG_COMPAT definition to a header
  2014-05-12 12:59   ` chrubis
@ 2014-05-13  6:20     ` Stanislav Kholmanskikh
  2014-05-13  6:20     ` [LTP] [PATCH 2/2] msg_common.h: corrected __sparc64__ definition Stanislav Kholmanskikh
  1 sibling, 0 replies; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-05-13  6:20 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

sendmsg01.c and recvmsg01.c both define MSG_CMSG_COMPAT in a
similar way. Moved this definition to a new header file to reduce
code duplication.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 testcases/kernel/syscalls/recvmsg/Makefile    |    2 +
 testcases/kernel/syscalls/recvmsg/recvmsg01.c |   15 +---------
 testcases/kernel/syscalls/sendmsg/Makefile    |    2 +
 testcases/kernel/syscalls/sendmsg/sendmsg01.c |   15 +---------
 testcases/kernel/syscalls/utils/msg_common.h  |   38 +++++++++++++++++++++++++
 5 files changed, 44 insertions(+), 28 deletions(-)
 create mode 100644 testcases/kernel/syscalls/utils/msg_common.h

diff --git a/testcases/kernel/syscalls/recvmsg/Makefile b/testcases/kernel/syscalls/recvmsg/Makefile
index bd617d8..e69c726 100644
--- a/testcases/kernel/syscalls/recvmsg/Makefile
+++ b/testcases/kernel/syscalls/recvmsg/Makefile
@@ -20,4 +20,6 @@ top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+CPPFLAGS		+= -I$(abs_srcdir)/../utils
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/recvmsg/recvmsg01.c b/testcases/kernel/syscalls/recvmsg/recvmsg01.c
index bc84a23..93c9190 100644
--- a/testcases/kernel/syscalls/recvmsg/recvmsg01.c
+++ b/testcases/kernel/syscalls/recvmsg/recvmsg01.c
@@ -40,20 +40,6 @@
  *
  */
 
-/* The #ifndef code below is for 2.5 64-bit kernels, where     */
-/* the MSG_CMSG_COMPAT flag must be 0 in order for the syscall */
-/* and this test to function correctly.                        */
-#ifndef MSG_CMSG_COMPAT
-
-#if defined (__powerpc64__) || defined (__mips64) || defined (__x86_64__) || defined (__sparc64__)
-#define MSG_CMSG_COMPAT 0x80000000
-#else
-#define MSG_CMSG_COMPAT 0
-#endif
-
-#endif
-/***************************************************/
-
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
@@ -71,6 +57,7 @@
 
 #include "test.h"
 #include "usctest.h"
+#include "msg_common.h"
 
 char *TCID = "recvmsg01";
 int testno;
diff --git a/testcases/kernel/syscalls/sendmsg/Makefile b/testcases/kernel/syscalls/sendmsg/Makefile
index bd617d8..e69c726 100644
--- a/testcases/kernel/syscalls/sendmsg/Makefile
+++ b/testcases/kernel/syscalls/sendmsg/Makefile
@@ -20,4 +20,6 @@ top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+CPPFLAGS		+= -I$(abs_srcdir)/../utils
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sendmsg/sendmsg01.c b/testcases/kernel/syscalls/sendmsg/sendmsg01.c
index 58d3364..1795a5e 100644
--- a/testcases/kernel/syscalls/sendmsg/sendmsg01.c
+++ b/testcases/kernel/syscalls/sendmsg/sendmsg01.c
@@ -30,20 +30,6 @@
  *	05/2003 Modified by Manoj Iyer - Make setup function set up lo device.
  */
 
-/*
- * The #ifndef code below is for 2.5 64-bit kernels, where
- * the MSG_CMSG_COMPAT flag must be 0 in order for the syscall
- * and this test to function correctly.
- */
-#ifndef MSG_CMSG_COMPAT
-#if defined(__powerpc64__) || defined(__mips64) || defined(__x86_64__) || \
-     defined(__sparc64__) || defined(__ia64__) || defined(__s390x__)
-#define MSG_CMSG_COMPAT 0x80000000
-#else
-#define MSG_CMSG_COMPAT 0
-#endif
-#endif /* MSG_CMSG_COMPAT */
-
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
@@ -63,6 +49,7 @@
 
 #include "test.h"
 #include "usctest.h"
+#include "msg_common.h"
 
 char *TCID = "sendmsg01";
 int testno;
diff --git a/testcases/kernel/syscalls/utils/msg_common.h b/testcases/kernel/syscalls/utils/msg_common.h
new file mode 100644
index 0000000..0471291
--- /dev/null
+++ b/testcases/kernel/syscalls/utils/msg_common.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) International Business Machines  Corp., 2001
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef LTP_MSG_COMMON
+#define LTP_MSG_COMMON
+
+/* The #ifndef code below is for 2.5 64-bit kernels, where     */
+/* the MSG_CMSG_COMPAT flag must be 0 in order for the syscall */
+/* and this test to function correctly.                        */
+#ifndef MSG_CMSG_COMPAT
+
+#if defined(__powerpc64__) || defined(__mips64) || defined(__x86_64__) || \
+	defined(__sparc64__) || defined(__ia64__) || defined(__s390x__)
+#define MSG_CMSG_COMPAT 0x80000000
+#else
+#define MSG_CMSG_COMPAT 0
+#endif
+
+#endif
+
+
+#endif /* LTP_MSG_COMMON */
-- 
1.7.1


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 2/2] msg_common.h: corrected __sparc64__ definition
  2014-05-12 12:59   ` chrubis
  2014-05-13  6:20     ` [LTP] [PATCH 1/2] sendmsg, recvmsg: moved MSG_CMSG_COMPAT definition to a header Stanislav Kholmanskikh
@ 2014-05-13  6:20     ` Stanislav Kholmanskikh
  2014-05-15 12:30       ` chrubis
  1 sibling, 1 reply; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-05-13  6:20 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

__sparc64__ is not defined by cpp. We should use
'__sparc__' and '__arch64__' instead.

Author: Jose E. Marchesi <jose.marchesi@oracle.com>

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 testcases/kernel/syscalls/utils/msg_common.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/testcases/kernel/syscalls/utils/msg_common.h b/testcases/kernel/syscalls/utils/msg_common.h
index 0471291..2ecd27e 100644
--- a/testcases/kernel/syscalls/utils/msg_common.h
+++ b/testcases/kernel/syscalls/utils/msg_common.h
@@ -26,7 +26,8 @@
 #ifndef MSG_CMSG_COMPAT
 
 #if defined(__powerpc64__) || defined(__mips64) || defined(__x86_64__) || \
-	defined(__sparc64__) || defined(__ia64__) || defined(__s390x__)
+	defined(__ia64__) || defined(__s390x__) || \
+	defined(__sparc__) && defined(__arch64__)
 #define MSG_CMSG_COMPAT 0x80000000
 #else
 #define MSG_CMSG_COMPAT 0
-- 
1.7.1


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 4/4] rt_sigaction*, rt_sigprocmask01, rt_sigsuspend01: SPARC support
       [not found]     ` <5371C09F.7050205@oracle.com>
@ 2014-05-13 11:39       ` chrubis
  2014-05-20 12:24         ` [LTP] [RFC PATCH] A draft of the rt_sigaction syscall wrapper Stanislav Kholmanskikh
  0 siblings, 1 reply; 28+ messages in thread
From: chrubis @ 2014-05-13 11:39 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
> >> +#if defined __x86_64__ || defined __sparc__
> >> +
> >>   struct kernel_sigaction {
> >>   	__sighandler_t k_sa_handler;
> >>   	unsigned long sa_flags;
> >> @@ -118,7 +155,7 @@ static inline int sig_initial(int sig)
> >>
> >>   }
> >>
> >> -#endif /* __x86_64__ */
> >> +#endif /* __x86_64__ || __sparc__*/
> >>
> >>   #endif /* LTP_RT_SIG_TEST */
> >>
> >> diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> >> index 8f18394..2f8020e 100644
> >> --- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> >> +++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
> >> @@ -1,5 +1,6 @@
> >>   /******************************************************************************/
> >>   /* Copyright (c) Crackerjack Project., 2007                                   */
> >> +/* Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.      */
> >>   /*                                                                            */
> >>   /* This program is free software;  you can redistribute it and/or modify      */
> >>   /* it under the terms of the GNU General Public License as published by       */
> >> @@ -127,21 +128,42 @@ void handler(int sig)
> >>
> >>   int set_handler(int sig, int sig_to_mask, int mask_flags)
> >>   {
> >> -#ifdef __x86_64__
> >> +#ifdef __sparc__
> >> +	struct sigaction sa;
> >> +	struct kernel_sigaction kact, koact;
> >> +# ifdef __arch64__
> >> +	unsigned long stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
> >> +# else
> >> +	unsigned long stub = ((unsigned long) &__sigreturn_stub) - 8;
> >> +# endif
> >
> > These ifdefs are repeated in the lines below over and over, can we put
> > them in a common header instead?
> >
> 
> Do you mean just 'these ifdefs':
> +# ifdef __arch64__
> +	unsigned long stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
> +# else
> +	unsigned long stub = ((unsigned long) &__sigreturn_stub) - 8;
> +# endif

At least these, ideally all the common syscall preparation should be in
one header included in all tests.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/2] msg_common.h: corrected __sparc64__ definition
  2014-05-13  6:20     ` [LTP] [PATCH 2/2] msg_common.h: corrected __sparc64__ definition Stanislav Kholmanskikh
@ 2014-05-15 12:30       ` chrubis
  0 siblings, 0 replies; 28+ messages in thread
From: chrubis @ 2014-05-15 12:30 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
> __sparc64__ is not defined by cpp. We should use
> '__sparc__' and '__arch64__' instead.
> 
> Author: Jose E. Marchesi <jose.marchesi@oracle.com>
> 
> Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
> ---
>  testcases/kernel/syscalls/utils/msg_common.h |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/utils/msg_common.h b/testcases/kernel/syscalls/utils/msg_common.h
> index 0471291..2ecd27e 100644
> --- a/testcases/kernel/syscalls/utils/msg_common.h
> +++ b/testcases/kernel/syscalls/utils/msg_common.h
> @@ -26,7 +26,8 @@
>  #ifndef MSG_CMSG_COMPAT
>  
>  #if defined(__powerpc64__) || defined(__mips64) || defined(__x86_64__) || \
> -	defined(__sparc64__) || defined(__ia64__) || defined(__s390x__)
> +	defined(__ia64__) || defined(__s390x__) || \
> +	defined(__sparc__) && defined(__arch64__)
>  #define MSG_CMSG_COMPAT 0x80000000
>  #else
>  #define MSG_CMSG_COMPAT 0

These two patches are OK, acked.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [RFC PATCH] A draft of the rt_sigaction syscall wrapper.
  2014-05-13 11:39       ` chrubis
@ 2014-05-20 12:24         ` Stanislav Kholmanskikh
  2014-05-20 14:42           ` chrubis
  0 siblings, 1 reply; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-05-20 12:24 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
Hi!

I think that instead of an addition of "the common syscall preparation" to a define,
it would be better to implement a wrapper to the rt_sigaction syscall.

Like this one. 

Its basis is a combination of glibc implementations of sigaction() for different
platforms. But it also accepts '-1' for act, oact to check EFAULT errno code 
(glibc implementation doesn't handle such a situtation).

How do you think where the best place is to put this wrapper implementation?

Thank you.

 .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   86 ++++++++++++++++---
 1 files changed, 72 insertions(+), 14 deletions(-)

diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index 8f18394..8516396 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -60,6 +60,76 @@ char *TCID = "rt_sigaction01";
 int testno;
 int TST_TOTAL = 1;
 
+#define INVAL_SA_PTR ((void *)-1)
+
+/* This is a wrapper for __NR_rt_sigaction syscall.
+ * act/oact values of INVAL_SA_PTR is used to pass
+ * an invalid pointer to syscall(__NR_rt_sigaction).
+ *
+ * Based on glibc/sysdeps/unix/sysv/linux/{...}/sigaction.c
+ */
+static int ltp_rt_sigaction(int signum, const struct sigaction *act,
+                       struct sigaction *oact, size_t sigsetsize)
+{
+	int ret;
+	struct kernel_sigaction kact, koact;
+	struct kernel_sigaction *kact_p = NULL;
+	struct kernel_sigaction *koact_p = NULL;
+
+	if (act == INVAL_SA_PTR) {
+		kact_p = INVAL_SA_PTR;
+	} else if (act) {
+		kact.k_sa_handler = act->sa_handler;
+		memcpy(&kact.sa_mask, &act->sa_mask, sizeof(sigset_t));
+		kact.sa_flags = act->sa_flags;
+		kact.sa_restorer = NULL;
+
+		kact_p = &kact;
+	}
+
+	if (oact == INVAL_SA_PTR)
+		koact_p = INVAL_SA_PTR;
+	else if (oact)
+		koact_p = &koact;
+
+#ifdef __sparc__
+# ifdef __arch64__
+	unsigned long stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
+# else
+	unsigned long stub = ((unsigned long) &__sigreturn_stub) - 8;
+# endif
+#endif
+
+#ifdef __x86_64__
+	sig_initial(signum);
+	kact.sa_flags |= SA_RESTORER;
+	kact.sa_restorer = restore_rt;
+#endif
+
+#ifdef __sparc__
+	ret = ltp_syscall(__NR_rt_sigaction, signum,
+			kact_p , koact_p,
+			stub, sigsetsize);
+#else
+	ret = ltp_syscall(__NR_rt_sigaction, signum,
+			kact_p, koact_p,
+			sigsetsize);
+#endif
+
+	if (ret >= 0) {
+		if (oact && (oact != INVAL_SA_PTR)) {
+			oact->sa_handler = koact.k_sa_handler;
+			memcpy(&oact->sa_mask, &koact.sa_mask,
+				sizeof(sigset_t));
+			oact->sa_flags = koact.sa_flags;
+			oact->sa_restorer = koact.sa_restorer;
+		}
+	}
+
+	return ret;
+}
+
+
 /* Extern Global Functions */
 /******************************************************************************/
 /*                                                                            */
@@ -127,21 +197,14 @@ void handler(int sig)
 
 int set_handler(int sig, int sig_to_mask, int mask_flags)
 {
-#ifdef __x86_64__
-	struct kernel_sigaction sa, oldaction;
-	mask_flags |= SA_RESTORER;
-	sa.sa_restorer = restore_rt;
-	sa.k_sa_handler = (void *)handler;
-#else
 	struct sigaction sa, oldaction;
+
 	sa.sa_handler = (void *)handler;
-#endif
 	sa.sa_flags = mask_flags;
 	sigemptyset(&sa.sa_mask);
 	sigaddset(&sa.sa_mask, sig);
 
-	return ltp_syscall(__NR_rt_sigaction, sig, &sa, &oldaction, SIGSETSIZE);
-
+	return ltp_rt_sigaction(sig, &sa, &oldaction, SIGSETSIZE);
 }
 
 int main(int ac, char **av)
@@ -163,11 +226,6 @@ int main(int ac, char **av)
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
 			for (signal = SIGRTMIN; signal <= (SIGRTMAX); signal++) {	//signal for 34 to 65
-
-#ifdef __x86_64__
-				sig_initial(signal);
-#endif
-
 				for (flag = 0;
 				     flag <
 				     (sizeof(test_flags) /
-- 
1.7.1


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [RFC PATCH] A draft of the rt_sigaction syscall wrapper.
  2014-05-20 12:24         ` [LTP] [RFC PATCH] A draft of the rt_sigaction syscall wrapper Stanislav Kholmanskikh
@ 2014-05-20 14:42           ` chrubis
  2014-05-21 10:24             ` [LTP] [PATCH 1/3] rt_sigaction, rt_sigprocmask, rt_sigsuspend: cleanup Stanislav Kholmanskikh
                               ` (5 more replies)
  0 siblings, 6 replies; 28+ messages in thread
From: chrubis @ 2014-05-20 14:42 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
> I think that instead of an addition of "the common syscall preparation" to a define,
> it would be better to implement a wrapper to the rt_sigaction syscall.
> 
> Like this one. 
> 
> Its basis is a combination of glibc implementations of sigaction() for different
> platforms. But it also accepts '-1' for act, oact to check EFAULT errno code 
> (glibc implementation doesn't handle such a situtation).
> 
> How do you think where the best place is to put this wrapper implementation?

Given that the testcases are statically linked with the test library
anyway the easiest solution would be include/lapi/rt_sigaction.h.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 1/3] rt_sigaction, rt_sigprocmask, rt_sigsuspend: cleanup
  2014-05-20 14:42           ` chrubis
@ 2014-05-21 10:24             ` Stanislav Kholmanskikh
  2014-05-21 10:24             ` [LTP] [PATCH 2/3] rt_sigaction, rt_sigprocmask01, rt_sigsuspend: use rt_sigaction wrapper Stanislav Kholmanskikh
                               ` (4 subsequent siblings)
  5 siblings, 0 replies; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-05-21 10:24 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   88 +++-----------
 .../kernel/syscalls/rt_sigaction/rt_sigaction02.c  |   85 +++-----------
 .../kernel/syscalls/rt_sigaction/rt_sigaction03.c  |  105 ++++-------------
 .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |  112 +++++-------------
 .../syscalls/rt_sigprocmask/rt_sigprocmask02.c     |   89 +++------------
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |  125 +++++--------------
 6 files changed, 132 insertions(+), 472 deletions(-)

diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index 8f18394..5ca3ba4 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -12,36 +12,22 @@
 /* the GNU General Public License for more details.                           */
 /*                                                                            */
 /* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
+/* along with this program;  if not, write to the Free Software Foundation,   */
+/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           */
 /*                                                                            */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 /******************************************************************************/
-/*                                                                            */
-/* File:        rt_sigaction01.c                                              */
-/*                                                                            */
 /* Description: This tests the rt_sigaction() syscall                         */
 /*		rt_sigaction alters an action taken by a process on receipt   */
 /* 		of a particular signal. The action is specified by the        */
 /*		sigaction structure. The previous action on the signal is     */
 /*		saved in oact.sigsetsize should indicate the size of a        */
 /*		sigset_t type.                       			      */
-/*                                                                            */
-/* Usage:  <for command-line>                                                 */
-/* rt_sigaction01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
-/*      where,  -c n : Run n copies concurrently.                             */
-/*              -e   : Turn on errno logging.                                 */
-/*              -i n : Execute test n times.                                  */
-/*              -I x : Execute test for x seconds.                            */
-/*              -P x : Pause for x seconds between iterations.                */
-/*              -t   : Turn on syscall timing.                                */
-/*                                                                            */
-/* Total Tests: 1                                                             */
-/*                                                                            */
-/* Test Name:   rt_sigaction01                                             */
-/* History:     Porting from Crackerjack to LTP is done by                    */
-/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -57,75 +43,35 @@
 #include "ltp_signal.h"
 
 char *TCID = "rt_sigaction01";
-int testno;
+static int testno;
 int TST_TOTAL = 1;
 
-/* Extern Global Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    cleanup                                                       */
-/*                                                                            */
-/* Description: Performs all one time clean up for this test on successful    */
-/*              completion,  premature exit or  failure. Closes all temporary */
-/*              files, removes all temporary directories exits the test with  */
-/*              appropriate return code by calling tst_exit() function.       */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*              On success - Exits calling tst_exit(). With '0' return code.  */
-/*                                                                            */
-/******************************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-
 	TEST_CLEANUP;
 	tst_rmdir();
-
 }
 
-/* Local  Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    setup                                                         */
-/*                                                                            */
-/* Description: Performs all one time setup for this test. This function is   */
-/*              typically used to capture signals, create temporary dirs      */
-/*              and temporary files that may be used in the course of this    */
-/*              test.                                                         */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits by calling cleanup().                      */
-/*              On success - returns 0.                                       */
-/*                                                                            */
-/******************************************************************************/
-void setup(void)
+static void setup(void)
 {
-	/* Capture signals if any */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
 
-int test_flags[] =
+static int test_flags[] =
     { SA_RESETHAND | SA_SIGINFO, SA_RESETHAND, SA_RESETHAND | SA_SIGINFO,
 SA_RESETHAND | SA_SIGINFO, SA_NOMASK };
 char *test_flags_list[] =
     { "SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND", "SA_RESETHAND|SA_SIGINFO",
 "SA_RESETHAND|SA_SIGINFO", "SA_NOMASK" };
 
-void handler(int sig)
+static void handler(int sig)
 {
 	tst_resm(TINFO, "Signal Handler Called with signal number %d\n", sig);
 	return;
 }
 
-int set_handler(int sig, int sig_to_mask, int mask_flags)
+static int set_handler(int sig, int sig_to_mask, int mask_flags)
 {
 #ifdef __x86_64__
 	struct kernel_sigaction sa, oldaction;
@@ -141,18 +87,18 @@ int set_handler(int sig, int sig_to_mask, int mask_flags)
 	sigaddset(&sa.sa_mask, sig);
 
 	return ltp_syscall(__NR_rt_sigaction, sig, &sa, &oldaction, SIGSETSIZE);
-
 }
 
 int main(int ac, char **av)
 {
-	int signal, flag;
+	unsigned int flag;
+	int signal;
 	int lc;
 	char *msg;
 
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-	}
 
 	setup();
 
@@ -162,7 +108,7 @@ int main(int ac, char **av)
 
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			for (signal = SIGRTMIN; signal <= (SIGRTMAX); signal++) {	//signal for 34 to 65
+			for (signal = SIGRTMIN; signal <= SIGRTMAX; signal++) {
 
 #ifdef __x86_64__
 				sig_initial(signal);
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
index 61137df..5822a79 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
@@ -12,32 +12,18 @@
 /* the GNU General Public License for more details.                           */
 /*                                                                            */
 /* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
+/* along with this program;  if not, write to the Free Software Foundation,   */
+/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           */
 /*                                                                            */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 /******************************************************************************/
-/*                                                                            */
-/* File:        rt_sigaction02.c                                              */
-/*                                                                            */
 /* Description: This tests the rt_sigaction() syscall                         */
 /*		rt_sigaction Expected EFAULT error check                      */
-/*                                                                            */
-/* Usage:  <for command-line>                                                 */
-/* rt_sigaction02 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
-/*      where,  -c n : Run n copies concurrently.                             */
-/*              -e   : Turn on errno logging.                                 */
-/*              -i n : Execute test n times.                                  */
-/*              -I x : Execute test for x seconds.                            */
-/*              -P x : Pause for x seconds between iterations.                */
-/*              -t   : Turn on syscall timing.                                */
-/*                                                                            */
-/* Total Tests: 1                                                             */
-/*                                                                            */
-/* Test Name:   rt_sigaction02                                             */
-/* History:     Porting from Crackerjack to LTP is done by                    */
-/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -54,70 +40,31 @@
 #define INVAL_STRUCT -1
 
 char *TCID = "rt_sigaction02";
-int testno;
+static int testno;
 int TST_TOTAL = 1;
 
-/* Extern Global Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    cleanup                                                       */
-/*                                                                            */
-/* Description: Performs all one time clean up for this test on successful    */
-/*              completion,  premature exit or  failure. Closes all temporary */
-/*              files, removes all temporary directories exits the test with  */
-/*              appropriate return code by calling tst_exit() function.       */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*              On success - Exits calling tst_exit(). With '0' return code.  */
-/*                                                                            */
-/******************************************************************************/
 void cleanup(void)
 {
-
 	TEST_CLEANUP;
 	tst_rmdir();
 
 	tst_exit();
 }
 
-/* Local  Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    setup                                                         */
-/*                                                                            */
-/* Description: Performs all one time setup for this test. This function is   */
-/*              typically used to capture signals, create temporary dirs      */
-/*              and temporary files that may be used in the course of this    */
-/*              test.                                                         */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits by calling cleanup().                      */
-/*              On success - returns 0.                                       */
-/*                                                                            */
-/******************************************************************************/
 void setup(void)
 {
-	/* Capture signals if any */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
 
-int test_flags[] =
+static int test_flags[] =
     { SA_RESETHAND | SA_SIGINFO, SA_RESETHAND, SA_RESETHAND | SA_SIGINFO,
 SA_RESETHAND | SA_SIGINFO, SA_NOMASK };
 char *test_flags_list[] =
     { "SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND", "SA_RESETHAND|SA_SIGINFO",
 "SA_RESETHAND|SA_SIGINFO", "SA_NOMASK" };
 
-struct test_case_t {
+static struct test_case_t {
 	int exp_errno;
 	char *errdesc;
 } test_cases[] = {
@@ -127,23 +74,24 @@ struct test_case_t {
 
 int main(int ac, char **av)
 {
-	int signal, flag;
+	unsigned int flag;
+	int signal;
 	int lc;
 	char *msg;
 
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-		tst_exit();
-	}
 
 	setup();
 
 	for (lc = 0; TEST_LOOPING(lc); ++lc) {
 		tst_count = 0;
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
+			for (signal = SIGRTMIN; signal <= SIGRTMAX; signal++) {
+				tst_resm(TINFO, "Signal %d", signal);
 
-			for (signal = SIGRTMIN; signal <= (SIGRTMAX); signal++) {	//signal for 34 to 65
-				for (flag = 0; flag < 5; flag++) {
+				for (flag = 0; flag < (sizeof(test_flags) / sizeof(test_flags[0])); flag++) {
 
 					/*                                                              *
 					 * long sys_rt_sigaction (int sig, const struct sigaction *act, *
@@ -178,7 +126,6 @@ int main(int ac, char **av)
 							 test_flags_list[flag]);
 					}
 				}
-				printf("\n");
 			}
 
 		}
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
index 12c3b84..8920138 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
@@ -12,32 +12,18 @@
 /* the GNU General Public License for more details.                           */
 /*                                                                            */
 /* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
+/* along with this program;  if not, write to the Free Software Foundation,   */
+/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           */
 /*                                                                            */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 /******************************************************************************/
-/*                                                                            */
-/* File:        rt_sigaction03.c                                              */
-/*                                                                            */
 /* Description: This tests the rt_sigaction() syscall                         */
 /*		rt_sigaction Expected EINVAL error check                      */
-/*                                                                            */
-/* Usage:  <for command-line>                                                 */
-/* rt_sigaction03 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
-/*      where,  -c n : Run n copies concurrently.                             */
-/*              -e   : Turn on errno logging.                                 */
-/*              -i n : Execute test n times.                                  */
-/*              -I x : Execute test for x seconds.                            */
-/*              -P x : Pause for x seconds between iterations.                */
-/*              -t   : Turn on syscall timing.                                */
-/*                                                                            */
-/* Total Tests: 1                                                             */
-/*                                                                            */
-/* Test Name:   rt_sigaction03                                             */
-/* History:     Porting from Crackerjack to LTP is done by                    */
-/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -54,70 +40,29 @@
 #define INVAL_SIGSETSIZE -1
 
 char *TCID = "rt_sigaction03";
-int testno;
+static int testno;
 int TST_TOTAL = 1;
 
-/* Extern Global Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    cleanup                                                       */
-/*                                                                            */
-/* Description: Performs all one time clean up for this test on successful    */
-/*              completion,  premature exit or  failure. Closes all temporary */
-/*              files, removes all temporary directories exits the test with  */
-/*              appropriate return code by calling tst_exit() function.       */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*              On success - Exits calling tst_exit(). With '0' return code.  */
-/*                                                                            */
-/******************************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-
 	TEST_CLEANUP;
 	tst_rmdir();
-
-	tst_exit();
 }
 
-/* Local  Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    setup                                                         */
-/*                                                                            */
-/* Description: Performs all one time setup for this test. This function is   */
-/*              typically used to capture signals, create temporary dirs      */
-/*              and temporary files that may be used in the course of this    */
-/*              test.                                                         */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits by calling cleanup().                      */
-/*              On success - returns 0.                                       */
-/*                                                                            */
-/******************************************************************************/
-void setup(void)
+static void setup(void)
 {
-	/* Capture signals if any */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
 
-int test_flags[] =
+static int test_flags[] =
     { SA_RESETHAND | SA_SIGINFO, SA_RESETHAND, SA_RESETHAND | SA_SIGINFO,
 SA_RESETHAND | SA_SIGINFO, SA_NOMASK };
 char *test_flags_list[] =
     { "SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND", "SA_RESETHAND|SA_SIGINFO",
 "SA_RESETHAND|SA_SIGINFO", "SA_NOMASK" };
 
-struct test_case_t {
+static struct test_case_t {
 	int exp_errno;
 	char *errdesc;
 } test_cases[] = {
@@ -125,13 +70,13 @@ struct test_case_t {
 	EINVAL, "EINVAL"}
 };
 
-void handler(int sig)
+static void handler(int sig)
 {
 	tst_resm(TINFO, "Signal Handler Called with signal number %d\n", sig);
 	return;
 }
 
-int set_handler(int sig, int sig_to_mask, int mask_flags)
+static int set_handler(int sig, int sig_to_mask, int mask_flags)
 {
 	struct sigaction sa, oldaction;
 
@@ -147,25 +92,20 @@ int set_handler(int sig, int sig_to_mask, int mask_flags)
 	 * sigsetsize was not equivalent to the size of a sigset_t type *
 	 */
 
-	TEST(ltp_syscall
-	     (__NR_rt_sigaction, sig, &sa, &oldaction, INVAL_SIGSETSIZE));
-	if (TEST_RETURN == 0) {
-		return 0;
-	} else {
-		return TEST_RETURN;
-	}
+	return ltp_syscall(__NR_rt_sigaction, sig, &sa, &oldaction,
+			INVAL_SIGSETSIZE);
 }
 
 int main(int ac, char **av)
 {
-	int signal, flag;
+	unsigned int flag;
+	int signal;
 	int lc;
 	char *msg;
 
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-		tst_exit();
-	}
 
 	setup();
 
@@ -173,8 +113,10 @@ int main(int ac, char **av)
 		tst_count = 0;
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			for (signal = SIGRTMIN; signal <= (SIGRTMAX); signal++) {	//signal for 34 to 65
-				for (flag = 0; flag < 5; flag++) {
+			for (signal = SIGRTMIN; signal <= (SIGRTMAX); signal++) {
+				tst_resm(TINFO, "Signal %d", signal);
+
+				for (flag = 0; flag < (sizeof(test_flags) / sizeof(test_flags[0])); flag++) {
 					TEST(set_handler
 					     (signal, 0, test_flags[flag]));
 					if ((TEST_RETURN == -1)
@@ -200,7 +142,6 @@ int main(int ac, char **av)
 							 test_flags_list[flag]);
 					}
 				}
-				printf("\n");
 			}
 
 		}
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index 1dbed72..f13edbf 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -12,14 +12,14 @@
 /* the GNU General Public License for more details.                           */
 /*                                                                            */
 /* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 59 Temple Place, Suite TEST_SIG0, Boston, MA 02111-1307 USA    */
+/* along with this program;  if not, write to the Free Software Foundation,   */
+/* Inc., 59 Temple Place, Suite TEST_SIG0, Boston, MA 02111-1307 USA          */
 /*                                                                            */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak <maknayak@in.ibm.com>                       */
 /******************************************************************************/
+
 /******************************************************************************/
-/*                                                                            */
-/* File:        rt_sigprocmask01.c                                              */
-/*                                                                            */
 /* Description: This tests the rt_sigprocmask() syscall                       */
 /*		rt_sigprocmask changes the list of currently blocked signals. */
 /*		The set value stores the signal mask of the pending signals.  */
@@ -37,22 +37,8 @@
 /*		SIG_SETMASK						      */
 /*		    The set of blocked signals is set to the set argument.    */
 /*		    sigsetsize should indicate the size of a sigset_t type.   */
-/*                                                                            */
-/* Usage:  <for command-line>                                                 */
-/* rt_sigprocmask01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                      */
-/*      where,  -c n : Run n copies concurrently.                             */
-/*              -e   : Turn on errno logging.                                 */
-/*              -i n : Execute test n times.                                  */
-/*              -I x : Execute test for x seconds.                            */
-/*              -P x : Pause for x seconds between iterations.                */
-/*              -t   : Turn on syscall timing.                                */
-/*                                                                            */
-/* Total Tests: 1                                                             */
-/*                                                                            */
-/* Test Name:   rt_sigprocmask01                                              */
-/* History:     Porting from Crackerjack to LTP is done by                    */
-/*              Manas Kumar Nayak <maknayak@in.ibm.com>                       */
 /******************************************************************************/
+
 #include <stdio.h>
 #include <signal.h>
 #include <errno.h>
@@ -64,65 +50,25 @@
 #include "ltp_signal.h"
 
 char *TCID = "rt_sigprocmask01";
-int testno;
+static int testno;
 int TST_TOTAL = 8;
 
+static int sig_count;
+
 #define TEST_SIG SIGRTMIN+1
 
-/* Extern Global Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    cleanup                                                       */
-/*                                                                            */
-/* Description: Performs all one time clean up for this test on successful    */
-/*              completion,  premature exit or  failure. Closes all temporary */
-/*              files, removes all temporary directories exits the test with  */
-/*              appropriate return code by calling tst_exit() function.       */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*              On success - Exits calling tst_exit(). With '0' return code.  */
-/*                                                                            */
-/******************************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-
 	TEST_CLEANUP;
 	tst_rmdir();
-
 }
 
-/* Local  Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    setup                                                         */
-/*                                                                            */
-/* Description: Performs all one time setup for this test. This function is   */
-/*              typically used to capture signals, create temporary dirs      */
-/*              and temporary files that may be used in the course of this    */
-/*              test.                                                         */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits by calling cleanup().                      */
-/*              On success - returns 0.                                       */
-/*                                                                            */
-/******************************************************************************/
-void setup(void)
+static void setup(void)
 {
-	/* Capture signals if any */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
 
-int sig_count = 0;
-
 void sig_handler(int sig)
 {
 	sig_count++;
@@ -146,9 +92,9 @@ int main(int ac, char **av)
 	int lc;
 	char *msg;
 
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-	}
 
 	setup();
 
@@ -156,35 +102,34 @@ int main(int ac, char **av)
 		tst_count = 0;
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			if (sigemptyset(&set) < 0) {
+			if (sigemptyset(&set) < 0)
 				tst_brkm(TFAIL | TERRNO, cleanup,
 					 "sigemptyset call failed");
-			}
-			if (sigaddset(&set, TEST_SIG) < 0) {
+
+			if (sigaddset(&set, TEST_SIG) < 0)
 				tst_brkm(TFAIL | TERRNO, cleanup,
 					 "sigaddset call failed");
-			}
 
 			/* call rt_sigaction() */
 			TEST(ltp_syscall(__NR_rt_sigaction, TEST_SIG, &act,
 				&oact, SIGSETSIZE));
-			if (TEST_RETURN < 0) {
+			if (TEST_RETURN < 0)
 				tst_brkm(TFAIL | TTERRNO, cleanup,
 					 "rt_sigaction call failed");
-			}
+
 			/* call rt_sigprocmask() to block signal#TEST_SIG */
 			TEST(ltp_syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set,
 				     &oset, SIGSETSIZE));
-			if (TEST_RETURN == -1) {
+			if (TEST_RETURN == -1)
 				tst_brkm(TFAIL | TTERRNO, cleanup,
 					 "rt_sigprocmask call failed");
-			}
+
 			/* Make sure that the masked process is indeed
 			 * masked. */
-			if (kill(getpid(), TEST_SIG) < 0) {
+			if (kill(getpid(), TEST_SIG) < 0)
 				tst_brkm(TFAIL | TERRNO, cleanup,
 					 "call to kill() failed");
-			}
+
 			if (sig_count) {
 				tst_brkm(TFAIL | TERRNO, cleanup,
 					 "rt_sigprocmask() failed to change "
@@ -193,26 +138,26 @@ int main(int ac, char **av)
 				/* call rt_sigpending() */
 				TEST(ltp_syscall(__NR_rt_sigpending, &oset,
 					     SIGSETSIZE));
-				if (TEST_RETURN == -1) {
+				if (TEST_RETURN == -1)
 					tst_brkm(TFAIL | TTERRNO, cleanup,
 						 "rt_sigpending call failed");
-				}
+
 				TEST(sigismember(&oset, TEST_SIG));
-				if (TEST_RETURN == 0) {
+				if (TEST_RETURN == 0)
 					tst_brkm(TFAIL | TTERRNO,
 						 cleanup,
 						 "sigismember call failed");
-				}
+
 				/* call rt_sigprocmask() to unblock
 				 * signal#TEST_SIG */
 				TEST(ltp_syscall(__NR_rt_sigprocmask,
 					     SIG_UNBLOCK, &set, &oset,
 					     SIGSETSIZE));
-				if (TEST_RETURN == -1) {
+				if (TEST_RETURN == -1)
 					tst_brkm(TFAIL | TTERRNO,
 						 cleanup,
 						 "rt_sigprocmask call failed");
-				}
+
 				if (sig_count) {
 					tst_resm(TPASS,
 						 "rt_sigprocmask "
@@ -224,7 +169,6 @@ int main(int ac, char **av)
 						 "rt_sigprocmask "
 						 "functionality failed");
 				}
-
 			}
 
 		}
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.c
index 32f406b..124592c 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.c
@@ -12,14 +12,14 @@
 /* the GNU General Public License for more details.                           */
 /*                                                                            */
 /* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
+/* along with this program;  if not, write to the Free Software Foundation,   */
+/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           */
 /*                                                                            */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 /******************************************************************************/
-/*                                                                            */
-/* File:        rt_sigprocmask02.c                                              */
-/*                                                                            */
 /* Description: This tests the rt_sigprocmask() syscall                       */
 /*		rt_sigprocmask changes the list of currently blocked signals. */
 /*		The set value stores the signal mask of the pending signals.  */
@@ -49,23 +49,8 @@
 /* 			    invalid. 					      */
 /* 			-EFAULT						      */
 /* 			    An invalid set, act, or oact was specified.       */
-/*                                                                            */
-/*									      */
-/* Usage:  <for command-line>                                                 */
-/* rt_sigprocmask02 [-c n] [-e][-i n] [-I x] [-p x] [-t]                      */
-/*      where,  -c n : Run n copies concurrently.                             */
-/*              -e   : Turn on errno logging.                                 */
-/*              -i n : Execute test n times.                                  */
-/*              -I x : Execute test for x seconds.                            */
-/*              -P x : Pause for x seconds between iterations.                */
-/*              -t   : Turn on syscall timing.                                */
-/*                                                                            */
-/* Total Tests: 1                                                             */
-/*                                                                            */
-/* Test Name:   rt_sigprocmask02                                              */
-/* History:     Porting from Crackerjack to LTP is done by                    */
-/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 #include <stdio.h>
 #include <signal.h>
 #include <errno.h>
@@ -78,61 +63,21 @@
 char *TCID = "rt_sigprocmask02";
 int TST_TOTAL = 2;
 
-/* Extern Global Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    cleanup                                                       */
-/*                                                                            */
-/* Description: Performs all one time clean up for this test on successful    */
-/*              completion,  premature exit or  failure. Closes all temporary */
-/*              files, removes all temporary directories exits the test with  */
-/*              appropriate return code by calling tst_exit() function.       */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*              On success - Exits calling tst_exit(). With '0' return code.  */
-/*                                                                            */
-/******************************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-
 	TEST_CLEANUP;
 	tst_rmdir();
-
 }
 
-/* Local  Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    setup                                                         */
-/*                                                                            */
-/* Description: Performs all one time setup for this test. This function is   */
-/*              typically used to capture signals, create temporary dirs      */
-/*              and temporary files that may be used in the course of this    */
-/*              test.                                                         */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits by calling cleanup().                      */
-/*              On success - returns 0.                                       */
-/*                                                                            */
-/******************************************************************************/
-void setup(void)
+static void setup(void)
 {
-	/* Capture signals if any */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
 
-sigset_t set;
+static sigset_t set;
 
-struct test_case_t {
+static struct test_case_t {
 	sigset_t *ss;
 	int sssize;
 	int exp_errno;
@@ -150,21 +95,18 @@ int main(int ac, char **av)
 	sigset_t s;
 	char *msg;
 
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-		tst_exit();
-	}
 
 	setup();
 
 	tst_count = 0;
 
 	TEST(sigfillset(&s));
-	if (TEST_RETURN == -1) {
-		tst_resm(TFAIL | TTERRNO, "Call to sigfillset() failed.");
-		cleanup();
-		tst_exit();
-	}
+	if (TEST_RETURN == -1)
+		tst_brkm(TFAIL | TTERRNO, cleanup,
+			"Call to sigfillset() failed.");
 
 	for (i = 0; i < test_count; i++) {
 		TEST(ltp_syscall(__NR_rt_sigprocmask, SIG_BLOCK,
@@ -183,5 +125,4 @@ int main(int ac, char **av)
 
 	cleanup();
 	tst_exit();
-
 }
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index d14cdf8..6ee41d0 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -1,42 +1,27 @@
-/********************************************************************************/
-/* Copyright (c) Crackerjack Project., 2007				   	*/
-/*									    	*/
-/* This program is free software;  you can redistribute it and/or modify      	*/
-/* it under the terms of the GNU General Public License as published by       	*/
-/* the Free Software Foundation; either version 2 of the License, or	  	*/
-/* (at your option) any later version.						*/
-/*									    	*/
-/* This program is distributed in the hope that it will be useful,	    	*/
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of	    	*/
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See		  	*/
-/* the GNU General Public License for more details.			   	*/
-/*									    	*/
-/* You should have received a copy of the GNU General Public License	  	*/
-/* along with this program;  if not, write to the Free Software	       	*/
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    	*/
-/*									    	*/
-/******************************************************************************	*/
-/******************************************************************************	*/
-/*									    	*/
-/* File:	rt_sigsuspend01.c					   	*/
-/*									    	*/
-/* Description: This tests the rt_sigsuspend() syscall.		      	*/
-/*									       	*/
-/* Usage:  <for command-line>						 	*/
-/* rt_sigsuspend01 [-c n] [-e][-i n] [-I x] [-p x] [-t]		     	*/
-/*      where,  -c n : Run n copies concurrently.			     	*/
-/*	      -e   : Turn on errno logging.				 	*/
-/*	      -i n : Execute test n times.				  	*/
-/*	      -I x : Execute test for x seconds.			    	*/
-/*	      -P x : Pause for x seconds between iterations.			*/
-/*	      -t   : Turn on syscall timing.					*/
-/*									    	*/
-/* Total Tests: 2							     	*/
-/*									    	*/
-/* Test Name:   rt_sigsuspend01					     	*/
-/* History:     Porting from Crackerjack to LTP is done by		    	*/
-/*	      Manas Kumar Nayak maknayak@in.ibm.com>				*/
-/********************************************************************************/
+/******************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007                                   */
+/*                                                                            */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software Foundation,   */
+/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           */
+/*                                                                            */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
+/******************************************************************************/
+
+/******************************************************************************/
+/* Description: This tests the rt_sigsuspend() syscall.                       */
+/******************************************************************************/
 
 #include <stdio.h>
 #include <signal.h>
@@ -49,75 +34,33 @@
 #include "ltp_signal.h"
 
 char *TCID = "rt_sigsuspend01";
-int testno;
 int TST_TOTAL = 1;
 
-/* Extern Global Functions */
-/******************************************************************************/
-/*									    */
-/* Function:    cleanup						       */
-/*									    */
-/* Description: Performs all one time clean up for this test on successful    */
-/*	      completion,  premature exit or  failure. Closes all temporary */
-/*	      files, removes all temporary directories exits the test with  */
-/*	      appropriate return code by calling tst_exit() function.       */
-/*									    */
-/* Input:       None.							 */
-/*									    */
-/* Output:      None.							 */
-/*									    */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*	      On success - Exits calling tst_exit(). With '0' return code.  */
-/*									    */
-/******************************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-
 	TEST_CLEANUP;
 	tst_rmdir();
-
 }
 
-/* Local  Functions */
-/******************************************************************************/
-/*									    */
-/* Function:    setup							 */
-/*									    */
-/* Description: Performs all one time setup for this test. This function is   */
-/*	      typically used to capture signals, create temporary dirs      */
-/*	      and temporary files that may be used in the course of this    */
-/*	      test.							 */
-/*									    */
-/* Input:       None.							 */
-/*									    */
-/* Output:      None.							 */
-/*									    */
-/* Return:      On failure - Exits by calling cleanup().		      */
-/*	      On success - returns 0.				       */
-/*									    */
-/******************************************************************************/
-void setup(void)
+static void setup(void)
 {
-	/* Capture signals if any */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
 
-void sig_handler(int sig)
+static void sig_handler(int sig)
 {
 }
 
 int main(int ac, char **av)
 {
-
 	sigset_t set, set1, set2;
 	int lc;
 	char *msg;
 
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-	}
 
 	setup();
 
@@ -125,9 +68,8 @@ int main(int ac, char **av)
 
 		tst_count = 0;
 
-		if (sigemptyset(&set) < 0) {
+		if (sigemptyset(&set) < 0)
 			tst_brkm(TFAIL | TERRNO, cleanup, "sigemptyset failed");
-		}
 #ifdef __x86_64__
 		struct kernel_sigaction act, oact;
 		sig_initial(SIGALRM);
@@ -145,16 +87,15 @@ int main(int ac, char **av)
 
 		TEST(ltp_syscall(__NR_rt_sigaction, SIGALRM, &act, &oact,
 			     SIGSETSIZE));
-		if (TEST_RETURN == -1) {
+		if (TEST_RETURN == -1)
 			tst_brkm(TFAIL | TTERRNO, cleanup,
 				 "rt_sigaction failed");
-		}
+
 		TEST(ltp_syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0,
 			     &set1, SIGSETSIZE));
-		if (TEST_RETURN == -1) {
+		if (TEST_RETURN == -1)
 			tst_brkm(TFAIL | TTERRNO, cleanup,
 				 "rt_sigprocmask failed");
-		}
 
 		TEST(alarm(5));
 		int result;
-- 
1.7.1


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 2/3] rt_sigaction, rt_sigprocmask01, rt_sigsuspend: use rt_sigaction wrapper
  2014-05-20 14:42           ` chrubis
  2014-05-21 10:24             ` [LTP] [PATCH 1/3] rt_sigaction, rt_sigprocmask, rt_sigsuspend: cleanup Stanislav Kholmanskikh
@ 2014-05-21 10:24             ` Stanislav Kholmanskikh
  2014-06-04 15:53               ` chrubis
  2014-05-21 10:24             ` [LTP] [PATCH 3/3] ltp_rt_sigaction: added SPARC support Stanislav Kholmanskikh
                               ` (3 subsequent siblings)
  5 siblings, 1 reply; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-05-21 10:24 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

These testcases use many pieces of duplicated code to test
syscall(__NR_rt_sigaction). Thus it's not beautiful to add support
for other architectures there.

To overcome this I implemented a wrapper for the rt_sigaction syscall,
and made the test cases use it.

And struct kernel_sigaction is not specific only for x86_64.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---

ltp_rt_sigaction is tightly couples with stuff in ltp_signal.h,
therefore I put it there.


 include/ltp_signal.h                               |   70 ++++++++++++++++++--
 .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   15 +----
 .../kernel/syscalls/rt_sigaction/rt_sigaction02.c  |    8 +--
 .../kernel/syscalls/rt_sigaction/rt_sigaction03.c  |    4 +-
 .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   13 +---
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |   13 +----
 6 files changed, 74 insertions(+), 49 deletions(-)

diff --git a/include/ltp_signal.h b/include/ltp_signal.h
index e6fb2e0..31bb0b0 100644
--- a/include/ltp_signal.h
+++ b/include/ltp_signal.h
@@ -55,6 +55,15 @@
 
 #ifdef LTP_RT_SIG_TEST
 
+#define INVAL_SA_PTR ((void *)-1)
+
+struct kernel_sigaction {
+	__sighandler_t k_sa_handler;
+	unsigned long sa_flags;
+	void (*sa_restorer) (void);
+	sigset_t sa_mask;
+};
+
 #ifdef __x86_64__
 
 /*
@@ -77,13 +86,6 @@
 #define HAVE_SA_RESTORER
 #define SA_RESTORER	0x04000000
 
-struct kernel_sigaction {
-	__sighandler_t k_sa_handler;
-	unsigned long sa_flags;
-	void (*sa_restorer) (void);
-	sigset_t sa_mask;
-};
-
 void (*restore_rt)(void);
 
 static void handler_h(int signal)
@@ -120,6 +122,60 @@ static inline int sig_initial(int sig)
 
 #endif /* __x86_64__ */
 
+/* This is a wrapper for __NR_rt_sigaction syscall.
+ * act/oact values of INVAL_SA_PTR is used to pass
+ * an invalid pointer to syscall(__NR_rt_sigaction)
+ *
+ * Based on glibc/sysdeps/unix/sysv/linux/{...}/sigaction.c
+ */
+
+static int ltp_rt_sigaction(int signum, const struct sigaction *act,
+			struct sigaction *oact, size_t sigsetsize)
+{
+	int ret;
+	struct kernel_sigaction kact, koact;
+	struct kernel_sigaction *kact_p = NULL;
+	struct kernel_sigaction *koact_p = NULL;
+
+	if (act == INVAL_SA_PTR) {
+		kact_p = INVAL_SA_PTR;
+	} else if (act) {
+		kact.k_sa_handler = act->sa_handler;
+		memcpy(&kact.sa_mask, &act->sa_mask, sizeof(sigset_t));
+		kact.sa_flags = act->sa_flags;
+		kact.sa_restorer = NULL;
+
+		kact_p = &kact;
+	}
+
+	if (oact == INVAL_SA_PTR)
+		koact_p = INVAL_SA_PTR;
+	else if (oact)
+		koact_p = &koact;
+
+#ifdef __x86_64__
+	sig_initial(signum);
+	kact.sa_flags |= SA_RESTORER;
+	kact.sa_restorer = restore_rt;
+#endif
+
+	ret = ltp_syscall(__NR_rt_sigaction, signum,
+			kact_p, koact_p,
+			sigsetsize);
+
+	if (ret >= 0) {
+		if (oact && (oact != INVAL_SA_PTR)) {
+			oact->sa_handler = koact.k_sa_handler;
+			memcpy(&oact->sa_mask, &koact.sa_mask,
+				sizeof(sigset_t));
+			oact->sa_flags = koact.sa_flags;
+			oact->sa_restorer = koact.sa_restorer;
+		}
+	}
+
+	return ret;
+}
+
 #endif /* LTP_RT_SIG_TEST */
 
 #endif
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index 5ca3ba4..ac05c64 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -73,20 +73,14 @@ static void handler(int sig)
 
 static int set_handler(int sig, int sig_to_mask, int mask_flags)
 {
-#ifdef __x86_64__
-	struct kernel_sigaction sa, oldaction;
-	mask_flags |= SA_RESTORER;
-	sa.sa_restorer = restore_rt;
-	sa.k_sa_handler = (void *)handler;
-#else
 	struct sigaction sa, oldaction;
+
 	sa.sa_handler = (void *)handler;
-#endif
 	sa.sa_flags = mask_flags;
 	sigemptyset(&sa.sa_mask);
 	sigaddset(&sa.sa_mask, sig);
 
-	return ltp_syscall(__NR_rt_sigaction, sig, &sa, &oldaction, SIGSETSIZE);
+	return ltp_rt_sigaction(sig, &sa, &oldaction, SIGSETSIZE);
 }
 
 int main(int ac, char **av)
@@ -109,11 +103,6 @@ int main(int ac, char **av)
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
 			for (signal = SIGRTMIN; signal <= SIGRTMAX; signal++) {
-
-#ifdef __x86_64__
-				sig_initial(signal);
-#endif
-
 				for (flag = 0;
 				     flag <
 				     (sizeof(test_flags) /
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
index 5822a79..1b2d22a 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
@@ -32,13 +32,12 @@
 #include <sys/syscall.h>
 #include <string.h>
 
+#define LTP_RT_SIG_TEST
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
 #include "ltp_signal.h"
 
-#define INVAL_STRUCT -1
-
 char *TCID = "rt_sigaction02";
 static int testno;
 int TST_TOTAL = 1;
@@ -100,9 +99,8 @@ int main(int ac, char **av)
 					 * An invalid act or oact value was specified                   *
 					 */
 
-					TEST(ltp_syscall
-					     (__NR_rt_sigaction, signal,
-					      INVAL_STRUCT, NULL, SIGSETSIZE));
+					TEST(ltp_rt_sigaction(signal,
+						INVAL_SA_PTR, NULL, SIGSETSIZE));
 					if ((TEST_RETURN == -1)
 					    && (TEST_ERRNO ==
 						test_cases[0].exp_errno)) {
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
index 8920138..f974567 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
@@ -32,6 +32,7 @@
 #include <sys/syscall.h>
 #include <string.h>
 
+#define LTP_RT_SIG_TEST
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
@@ -92,8 +93,7 @@ static int set_handler(int sig, int sig_to_mask, int mask_flags)
 	 * sigsetsize was not equivalent to the size of a sigset_t type *
 	 */
 
-	return ltp_syscall(__NR_rt_sigaction, sig, &sa, &oldaction,
-			INVAL_SIGSETSIZE);
+	return ltp_rt_sigaction(sig, &sa, &oldaction, INVAL_SIGSETSIZE);
 }
 
 int main(int ac, char **av)
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index f13edbf..2b131c2 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -76,18 +76,11 @@ void sig_handler(int sig)
 
 int main(int ac, char **av)
 {
-#if __x86_64
-	struct kernel_sigaction act, oact;
-	sig_initial(TEST_SIG);
-	act.sa_flags |= SA_RESTORER;
-	act.sa_restorer = restore_rt;
-	act.k_sa_handler = sig_handler;
-#else
 	struct sigaction act, oact;
 	memset(&act, 0, sizeof(act));
 	memset(&oact, 0, sizeof(oact));
 	act.sa_handler = sig_handler;
-#endif
+
 	sigset_t set, oset;
 	int lc;
 	char *msg;
@@ -111,8 +104,8 @@ int main(int ac, char **av)
 					 "sigaddset call failed");
 
 			/* call rt_sigaction() */
-			TEST(ltp_syscall(__NR_rt_sigaction, TEST_SIG, &act,
-				&oact, SIGSETSIZE));
+			TEST(ltp_rt_sigaction(TEST_SIG, &act, &oact,
+						SIGSETSIZE));
 			if (TEST_RETURN < 0)
 				tst_brkm(TFAIL | TTERRNO, cleanup,
 					 "rt_sigaction call failed");
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index 6ee41d0..5c77648 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -70,23 +70,12 @@ int main(int ac, char **av)
 
 		if (sigemptyset(&set) < 0)
 			tst_brkm(TFAIL | TERRNO, cleanup, "sigemptyset failed");
-#ifdef __x86_64__
-		struct kernel_sigaction act, oact;
-		sig_initial(SIGALRM);
-		memset(&act, 0, sizeof(act));
-		memset(&oact, 0, sizeof(oact));
-		act.sa_flags |= SA_RESTORER;
-		act.sa_restorer = restore_rt;
-		act.k_sa_handler = sig_handler;
-#else
 		struct sigaction act, oact;
 		memset(&act, 0, sizeof(act));
 		memset(&oact, 0, sizeof(oact));
 		act.sa_handler = sig_handler;
-#endif
 
-		TEST(ltp_syscall(__NR_rt_sigaction, SIGALRM, &act, &oact,
-			     SIGSETSIZE));
+		TEST(ltp_rt_sigaction(SIGALRM, &act, &oact, SIGSETSIZE));
 		if (TEST_RETURN == -1)
 			tst_brkm(TFAIL | TTERRNO, cleanup,
 				 "rt_sigaction failed");
-- 
1.7.1


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 3/3] ltp_rt_sigaction: added SPARC support
  2014-05-20 14:42           ` chrubis
  2014-05-21 10:24             ` [LTP] [PATCH 1/3] rt_sigaction, rt_sigprocmask, rt_sigsuspend: cleanup Stanislav Kholmanskikh
  2014-05-21 10:24             ` [LTP] [PATCH 2/3] rt_sigaction, rt_sigprocmask01, rt_sigsuspend: use rt_sigaction wrapper Stanislav Kholmanskikh
@ 2014-05-21 10:24             ` Stanislav Kholmanskikh
  2014-05-21 10:31               ` Stanislav Kholmanskikh
  2014-06-04 15:49               ` chrubis
  2014-06-17  9:08             ` [LTP] [PATCH V2 1/3] rt_sigaction, rt_sigprocmask, rt_sigsuspend: cleanup Stanislav Kholmanskikh
                               ` (2 subsequent siblings)
  5 siblings, 2 replies; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-05-21 10:24 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Based on patches by Jose E. Marchesi <jose.marchesi@oracle.com>.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 include/ltp_signal.h |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/include/ltp_signal.h b/include/ltp_signal.h
index 31bb0b0..a60ee7c 100644
--- a/include/ltp_signal.h
+++ b/include/ltp_signal.h
@@ -122,6 +122,46 @@ static inline int sig_initial(int sig)
 
 #endif /* __x86_64__ */
 
+#ifdef __sparc__
+#if defined __arch64__ || defined __sparcv9
+
+/*
+ * From glibc/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c
+ */
+
+static void __rt_sigreturn_stub(void)
+{
+	__asm__ ("mov %0, %%g1\n\t"
+		"ta  0x6d\n\t"
+		: /* no outputs */
+		: "i" (__NR_rt_sigreturn));
+}
+
+#else /* sparc32 */
+
+/*
+ * From glibc/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c
+ */
+
+static void __rt_sigreturn_stub(void)
+{
+	__asm__ ("mov %0, %%g1\n\t"
+		"ta  0x10\n\t"
+		: /* no outputs */
+		: "i" (__NR_rt_sigreturn));
+}
+
+static void __sigreturn_stub(void)
+{
+	__asm__ ("mov %0, %%g1\n\t"
+		"ta  0x10\n\t"
+		: /* no outputs */
+		: "i" (__NR_sigreturn));
+}
+
+#endif
+#endif /* __sparc__ */
+
 /* This is a wrapper for __NR_rt_sigaction syscall.
  * act/oact values of INVAL_SA_PTR is used to pass
  * an invalid pointer to syscall(__NR_rt_sigaction)
@@ -159,9 +199,28 @@ static int ltp_rt_sigaction(int signum, const struct sigaction *act,
 	kact.sa_restorer = restore_rt;
 #endif
 
+#ifdef __sparc__
+	unsigned long stub = 0;
+# if defined __arch64__ || defined __sparcv9
+	stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
+# else /* sparc32 */
+	if ((kact.sa_flags & SA_SIGINFO) != 0)
+		stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
+	else
+		stub = ((unsigned long) &__sigreturn_stub) - 8;
+# endif
+#endif
+
+
+#ifdef __sparc__
+	ret = ltp_syscall(__NR_rt_sigaction, signum,
+			kact_p, koact_p,
+			stub, sigsetsize);
+#else
 	ret = ltp_syscall(__NR_rt_sigaction, signum,
 			kact_p, koact_p,
 			sigsetsize);
+#endif
 
 	if (ret >= 0) {
 		if (oact && (oact != INVAL_SA_PTR)) {
-- 
1.7.1


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 3/3] ltp_rt_sigaction: added SPARC support
  2014-05-21 10:24             ` [LTP] [PATCH 3/3] ltp_rt_sigaction: added SPARC support Stanislav Kholmanskikh
@ 2014-05-21 10:31               ` Stanislav Kholmanskikh
  2014-06-04 15:49               ` chrubis
  1 sibling, 0 replies; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-05-21 10:31 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko



On 05/21/2014 02:24 PM, Stanislav Kholmanskikh wrote:
> Based on patches by Jose E. Marchesi <jose.marchesi@oracle.com>.
>
> Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>

Sorry, I forgot to mention why we are doing this in the commit message.

If the patches are ok, I'll add a few strings at the push time.

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 3/3] ltp_rt_sigaction: added SPARC support
  2014-05-21 10:24             ` [LTP] [PATCH 3/3] ltp_rt_sigaction: added SPARC support Stanislav Kholmanskikh
  2014-05-21 10:31               ` Stanislav Kholmanskikh
@ 2014-06-04 15:49               ` chrubis
  1 sibling, 0 replies; 28+ messages in thread
From: chrubis @ 2014-06-04 15:49 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
> Based on patches by Jose E. Marchesi <jose.marchesi@oracle.com>.
> 
> Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
> ---
>  include/ltp_signal.h |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 59 insertions(+), 0 deletions(-)
> 
> diff --git a/include/ltp_signal.h b/include/ltp_signal.h
> index 31bb0b0..a60ee7c 100644
> --- a/include/ltp_signal.h
> +++ b/include/ltp_signal.h
> @@ -122,6 +122,46 @@ static inline int sig_initial(int sig)
>  
>  #endif /* __x86_64__ */
>  
> +#ifdef __sparc__
> +#if defined __arch64__ || defined __sparcv9

It's a bit more readable if we indent the innter ifdefs as:

#ifdef __sparc__
# if defined __arch64__ || defined __sparcv9

# endif
#endif /* __sparc__ */

> +/*
> + * From glibc/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c
> + */
> +
> +static void __rt_sigreturn_stub(void)
> +{
> +	__asm__ ("mov %0, %%g1\n\t"
> +		"ta  0x6d\n\t"
> +		: /* no outputs */
> +		: "i" (__NR_rt_sigreturn));
> +}
> +
> +#else /* sparc32 */
> +
> +/*
> + * From glibc/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c
> + */
> +
> +static void __rt_sigreturn_stub(void)
> +{
> +	__asm__ ("mov %0, %%g1\n\t"
> +		"ta  0x10\n\t"
> +		: /* no outputs */
> +		: "i" (__NR_rt_sigreturn));
> +}
> +
> +static void __sigreturn_stub(void)
> +{
> +	__asm__ ("mov %0, %%g1\n\t"
> +		"ta  0x10\n\t"
> +		: /* no outputs */
> +		: "i" (__NR_sigreturn));
> +}
> +
> +#endif
> +#endif /* __sparc__ */
> +
>  /* This is a wrapper for __NR_rt_sigaction syscall.
>   * act/oact values of INVAL_SA_PTR is used to pass
>   * an invalid pointer to syscall(__NR_rt_sigaction)
> @@ -159,9 +199,28 @@ static int ltp_rt_sigaction(int signum, const struct sigaction *act,
>  	kact.sa_restorer = restore_rt;
>  #endif
>  
> +#ifdef __sparc__
> +	unsigned long stub = 0;
> +# if defined __arch64__ || defined __sparcv9
> +	stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
> +# else /* sparc32 */
> +	if ((kact.sa_flags & SA_SIGINFO) != 0)
> +		stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
> +	else
> +		stub = ((unsigned long) &__sigreturn_stub) - 8;
> +# endif
> +#endif

Here they are intended correctly.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/3] rt_sigaction, rt_sigprocmask01, rt_sigsuspend: use rt_sigaction wrapper
  2014-05-21 10:24             ` [LTP] [PATCH 2/3] rt_sigaction, rt_sigprocmask01, rt_sigsuspend: use rt_sigaction wrapper Stanislav Kholmanskikh
@ 2014-06-04 15:53               ` chrubis
  0 siblings, 0 replies; 28+ messages in thread
From: chrubis @ 2014-06-04 15:53 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
> diff --git a/include/ltp_signal.h b/include/ltp_signal.h
> index e6fb2e0..31bb0b0 100644
> --- a/include/ltp_signal.h
> +++ b/include/ltp_signal.h
> @@ -55,6 +55,15 @@
>  
>  #ifdef LTP_RT_SIG_TEST

I know that the code was there allready. However can we split the header
into two and include the second one when needed in tests instead of
defining LTP_RT_SIG_TEST macro?

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH V2 1/3] rt_sigaction, rt_sigprocmask, rt_sigsuspend: cleanup
  2014-05-20 14:42           ` chrubis
                               ` (2 preceding siblings ...)
  2014-05-21 10:24             ` [LTP] [PATCH 3/3] ltp_rt_sigaction: added SPARC support Stanislav Kholmanskikh
@ 2014-06-17  9:08             ` Stanislav Kholmanskikh
  2014-06-17  9:08             ` [LTP] [PATCH V2 2/3] rt_sigaction, rt_sigprocmask01, rt_sigsuspend: use rt_sigaction wrapper Stanislav Kholmanskikh
  2014-06-17  9:08             ` [LTP] [PATCH V2 3/3] ltp_rt_sigaction.h: added SPARC support Stanislav Kholmanskikh
  5 siblings, 0 replies; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-06-17  9:08 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
No changes since V1.


 .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   88 +++-----------
 .../kernel/syscalls/rt_sigaction/rt_sigaction02.c  |   85 +++-----------
 .../kernel/syscalls/rt_sigaction/rt_sigaction03.c  |  105 ++++-------------
 .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |  112 +++++-------------
 .../syscalls/rt_sigprocmask/rt_sigprocmask02.c     |   89 +++------------
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |  125 +++++--------------
 6 files changed, 132 insertions(+), 472 deletions(-)

diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index fda733c..fb698f8 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -12,36 +12,22 @@
 /* the GNU General Public License for more details.                           */
 /*                                                                            */
 /* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
+/* along with this program;  if not, write to the Free Software Foundation,   */
+/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           */
 /*                                                                            */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 /******************************************************************************/
-/*                                                                            */
-/* File:        rt_sigaction01.c                                              */
-/*                                                                            */
 /* Description: This tests the rt_sigaction() syscall                         */
 /*		rt_sigaction alters an action taken by a process on receipt   */
 /* 		of a particular signal. The action is specified by the        */
 /*		sigaction structure. The previous action on the signal is     */
 /*		saved in oact.sigsetsize should indicate the size of a        */
 /*		sigset_t type.                       			      */
-/*                                                                            */
-/* Usage:  <for command-line>                                                 */
-/* rt_sigaction01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
-/*      where,  -c n : Run n copies concurrently.                             */
-/*              -e   : Turn on errno logging.                                 */
-/*              -i n : Execute test n times.                                  */
-/*              -I x : Execute test for x seconds.                            */
-/*              -P x : Pause for x seconds between iterations.                */
-/*              -t   : Turn on syscall timing.                                */
-/*                                                                            */
-/* Total Tests: 1                                                             */
-/*                                                                            */
-/* Test Name:   rt_sigaction01                                             */
-/* History:     Porting from Crackerjack to LTP is done by                    */
-/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -57,75 +43,35 @@
 #include "ltp_signal.h"
 
 char *TCID = "rt_sigaction01";
-int testno;
+static int testno;
 int TST_TOTAL = 1;
 
-/* Extern Global Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    cleanup                                                       */
-/*                                                                            */
-/* Description: Performs all one time clean up for this test on successful    */
-/*              completion,  premature exit or  failure. Closes all temporary */
-/*              files, removes all temporary directories exits the test with  */
-/*              appropriate return code by calling tst_exit() function.       */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*              On success - Exits calling tst_exit(). With '0' return code.  */
-/*                                                                            */
-/******************************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-
 	TEST_CLEANUP;
 	tst_rmdir();
-
 }
 
-/* Local  Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    setup                                                         */
-/*                                                                            */
-/* Description: Performs all one time setup for this test. This function is   */
-/*              typically used to capture signals, create temporary dirs      */
-/*              and temporary files that may be used in the course of this    */
-/*              test.                                                         */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits by calling cleanup().                      */
-/*              On success - returns 0.                                       */
-/*                                                                            */
-/******************************************************************************/
-void setup(void)
+static void setup(void)
 {
-	/* Capture signals if any */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
 
-int test_flags[] =
+static int test_flags[] =
     { SA_RESETHAND | SA_SIGINFO, SA_RESETHAND, SA_RESETHAND | SA_SIGINFO,
 SA_RESETHAND | SA_SIGINFO, SA_NOMASK };
 char *test_flags_list[] =
     { "SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND", "SA_RESETHAND|SA_SIGINFO",
 "SA_RESETHAND|SA_SIGINFO", "SA_NOMASK" };
 
-void handler(int sig)
+static void handler(int sig)
 {
 	tst_resm(TINFO, "Signal Handler Called with signal number %d\n", sig);
 	return;
 }
 
-int set_handler(int sig, int sig_to_mask, int mask_flags)
+static int set_handler(int sig, int sig_to_mask, int mask_flags)
 {
 #ifdef __x86_64__
 	struct kernel_sigaction sa, oldaction;
@@ -141,18 +87,18 @@ int set_handler(int sig, int sig_to_mask, int mask_flags)
 	sigaddset(&sa.sa_mask, sig);
 
 	return ltp_syscall(__NR_rt_sigaction, sig, &sa, &oldaction, SIGSETSIZE);
-
 }
 
 int main(int ac, char **av)
 {
-	int signal, flag;
+	unsigned int flag;
+	int signal;
 	int lc;
 	const char *msg;
 
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-	}
 
 	setup();
 
@@ -162,7 +108,7 @@ int main(int ac, char **av)
 
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			for (signal = SIGRTMIN; signal <= (SIGRTMAX); signal++) {	//signal for 34 to 65
+			for (signal = SIGRTMIN; signal <= SIGRTMAX; signal++) {
 
 #ifdef __x86_64__
 				sig_initial(signal);
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
index bf0605c..8cf0f14 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
@@ -12,32 +12,18 @@
 /* the GNU General Public License for more details.                           */
 /*                                                                            */
 /* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
+/* along with this program;  if not, write to the Free Software Foundation,   */
+/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           */
 /*                                                                            */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 /******************************************************************************/
-/*                                                                            */
-/* File:        rt_sigaction02.c                                              */
-/*                                                                            */
 /* Description: This tests the rt_sigaction() syscall                         */
 /*		rt_sigaction Expected EFAULT error check                      */
-/*                                                                            */
-/* Usage:  <for command-line>                                                 */
-/* rt_sigaction02 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
-/*      where,  -c n : Run n copies concurrently.                             */
-/*              -e   : Turn on errno logging.                                 */
-/*              -i n : Execute test n times.                                  */
-/*              -I x : Execute test for x seconds.                            */
-/*              -P x : Pause for x seconds between iterations.                */
-/*              -t   : Turn on syscall timing.                                */
-/*                                                                            */
-/* Total Tests: 1                                                             */
-/*                                                                            */
-/* Test Name:   rt_sigaction02                                             */
-/* History:     Porting from Crackerjack to LTP is done by                    */
-/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -54,70 +40,31 @@
 #define INVAL_STRUCT -1
 
 char *TCID = "rt_sigaction02";
-int testno;
+static int testno;
 int TST_TOTAL = 1;
 
-/* Extern Global Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    cleanup                                                       */
-/*                                                                            */
-/* Description: Performs all one time clean up for this test on successful    */
-/*              completion,  premature exit or  failure. Closes all temporary */
-/*              files, removes all temporary directories exits the test with  */
-/*              appropriate return code by calling tst_exit() function.       */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*              On success - Exits calling tst_exit(). With '0' return code.  */
-/*                                                                            */
-/******************************************************************************/
 void cleanup(void)
 {
-
 	TEST_CLEANUP;
 	tst_rmdir();
 
 	tst_exit();
 }
 
-/* Local  Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    setup                                                         */
-/*                                                                            */
-/* Description: Performs all one time setup for this test. This function is   */
-/*              typically used to capture signals, create temporary dirs      */
-/*              and temporary files that may be used in the course of this    */
-/*              test.                                                         */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits by calling cleanup().                      */
-/*              On success - returns 0.                                       */
-/*                                                                            */
-/******************************************************************************/
 void setup(void)
 {
-	/* Capture signals if any */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
 
-int test_flags[] =
+static int test_flags[] =
     { SA_RESETHAND | SA_SIGINFO, SA_RESETHAND, SA_RESETHAND | SA_SIGINFO,
 SA_RESETHAND | SA_SIGINFO, SA_NOMASK };
 char *test_flags_list[] =
     { "SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND", "SA_RESETHAND|SA_SIGINFO",
 "SA_RESETHAND|SA_SIGINFO", "SA_NOMASK" };
 
-struct test_case_t {
+static struct test_case_t {
 	int exp_errno;
 	char *errdesc;
 } test_cases[] = {
@@ -127,23 +74,24 @@ struct test_case_t {
 
 int main(int ac, char **av)
 {
-	int signal, flag;
+	unsigned int flag;
+	int signal;
 	int lc;
 	const char *msg;
 
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-		tst_exit();
-	}
 
 	setup();
 
 	for (lc = 0; TEST_LOOPING(lc); ++lc) {
 		tst_count = 0;
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
+			for (signal = SIGRTMIN; signal <= SIGRTMAX; signal++) {
+				tst_resm(TINFO, "Signal %d", signal);
 
-			for (signal = SIGRTMIN; signal <= (SIGRTMAX); signal++) {	//signal for 34 to 65
-				for (flag = 0; flag < 5; flag++) {
+				for (flag = 0; flag < (sizeof(test_flags) / sizeof(test_flags[0])); flag++) {
 
 					/*                                                              *
 					 * long sys_rt_sigaction (int sig, const struct sigaction *act, *
@@ -178,7 +126,6 @@ int main(int ac, char **av)
 							 test_flags_list[flag]);
 					}
 				}
-				printf("\n");
 			}
 
 		}
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
index 4111da9..9ae8d0e 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
@@ -12,32 +12,18 @@
 /* the GNU General Public License for more details.                           */
 /*                                                                            */
 /* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
+/* along with this program;  if not, write to the Free Software Foundation,   */
+/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           */
 /*                                                                            */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 /******************************************************************************/
-/*                                                                            */
-/* File:        rt_sigaction03.c                                              */
-/*                                                                            */
 /* Description: This tests the rt_sigaction() syscall                         */
 /*		rt_sigaction Expected EINVAL error check                      */
-/*                                                                            */
-/* Usage:  <for command-line>                                                 */
-/* rt_sigaction03 [-c n] [-e][-i n] [-I x] [-p x] [-t]                        */
-/*      where,  -c n : Run n copies concurrently.                             */
-/*              -e   : Turn on errno logging.                                 */
-/*              -i n : Execute test n times.                                  */
-/*              -I x : Execute test for x seconds.                            */
-/*              -P x : Pause for x seconds between iterations.                */
-/*              -t   : Turn on syscall timing.                                */
-/*                                                                            */
-/* Total Tests: 1                                                             */
-/*                                                                            */
-/* Test Name:   rt_sigaction03                                             */
-/* History:     Porting from Crackerjack to LTP is done by                    */
-/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -54,70 +40,29 @@
 #define INVAL_SIGSETSIZE -1
 
 char *TCID = "rt_sigaction03";
-int testno;
+static int testno;
 int TST_TOTAL = 1;
 
-/* Extern Global Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    cleanup                                                       */
-/*                                                                            */
-/* Description: Performs all one time clean up for this test on successful    */
-/*              completion,  premature exit or  failure. Closes all temporary */
-/*              files, removes all temporary directories exits the test with  */
-/*              appropriate return code by calling tst_exit() function.       */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*              On success - Exits calling tst_exit(). With '0' return code.  */
-/*                                                                            */
-/******************************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-
 	TEST_CLEANUP;
 	tst_rmdir();
-
-	tst_exit();
 }
 
-/* Local  Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    setup                                                         */
-/*                                                                            */
-/* Description: Performs all one time setup for this test. This function is   */
-/*              typically used to capture signals, create temporary dirs      */
-/*              and temporary files that may be used in the course of this    */
-/*              test.                                                         */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits by calling cleanup().                      */
-/*              On success - returns 0.                                       */
-/*                                                                            */
-/******************************************************************************/
-void setup(void)
+static void setup(void)
 {
-	/* Capture signals if any */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
 
-int test_flags[] =
+static int test_flags[] =
     { SA_RESETHAND | SA_SIGINFO, SA_RESETHAND, SA_RESETHAND | SA_SIGINFO,
 SA_RESETHAND | SA_SIGINFO, SA_NOMASK };
 char *test_flags_list[] =
     { "SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND", "SA_RESETHAND|SA_SIGINFO",
 "SA_RESETHAND|SA_SIGINFO", "SA_NOMASK" };
 
-struct test_case_t {
+static struct test_case_t {
 	int exp_errno;
 	char *errdesc;
 } test_cases[] = {
@@ -125,13 +70,13 @@ struct test_case_t {
 	EINVAL, "EINVAL"}
 };
 
-void handler(int sig)
+static void handler(int sig)
 {
 	tst_resm(TINFO, "Signal Handler Called with signal number %d\n", sig);
 	return;
 }
 
-int set_handler(int sig, int sig_to_mask, int mask_flags)
+static int set_handler(int sig, int sig_to_mask, int mask_flags)
 {
 	struct sigaction sa, oldaction;
 
@@ -147,25 +92,20 @@ int set_handler(int sig, int sig_to_mask, int mask_flags)
 	 * sigsetsize was not equivalent to the size of a sigset_t type *
 	 */
 
-	TEST(ltp_syscall
-	     (__NR_rt_sigaction, sig, &sa, &oldaction, INVAL_SIGSETSIZE));
-	if (TEST_RETURN == 0) {
-		return 0;
-	} else {
-		return TEST_RETURN;
-	}
+	return ltp_syscall(__NR_rt_sigaction, sig, &sa, &oldaction,
+			INVAL_SIGSETSIZE);
 }
 
 int main(int ac, char **av)
 {
-	int signal, flag;
+	unsigned int flag;
+	int signal;
 	int lc;
 	const char *msg;
 
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-		tst_exit();
-	}
 
 	setup();
 
@@ -173,8 +113,10 @@ int main(int ac, char **av)
 		tst_count = 0;
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			for (signal = SIGRTMIN; signal <= (SIGRTMAX); signal++) {	//signal for 34 to 65
-				for (flag = 0; flag < 5; flag++) {
+			for (signal = SIGRTMIN; signal <= (SIGRTMAX); signal++) {
+				tst_resm(TINFO, "Signal %d", signal);
+
+				for (flag = 0; flag < (sizeof(test_flags) / sizeof(test_flags[0])); flag++) {
 					TEST(set_handler
 					     (signal, 0, test_flags[flag]));
 					if ((TEST_RETURN == -1)
@@ -200,7 +142,6 @@ int main(int ac, char **av)
 							 test_flags_list[flag]);
 					}
 				}
-				printf("\n");
 			}
 
 		}
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index 2d13212..bdfa6dd 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -12,14 +12,14 @@
 /* the GNU General Public License for more details.                           */
 /*                                                                            */
 /* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 59 Temple Place, Suite TEST_SIG0, Boston, MA 02111-1307 USA    */
+/* along with this program;  if not, write to the Free Software Foundation,   */
+/* Inc., 59 Temple Place, Suite TEST_SIG0, Boston, MA 02111-1307 USA          */
 /*                                                                            */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak <maknayak@in.ibm.com>                       */
 /******************************************************************************/
+
 /******************************************************************************/
-/*                                                                            */
-/* File:        rt_sigprocmask01.c                                              */
-/*                                                                            */
 /* Description: This tests the rt_sigprocmask() syscall                       */
 /*		rt_sigprocmask changes the list of currently blocked signals. */
 /*		The set value stores the signal mask of the pending signals.  */
@@ -37,22 +37,8 @@
 /*		SIG_SETMASK						      */
 /*		    The set of blocked signals is set to the set argument.    */
 /*		    sigsetsize should indicate the size of a sigset_t type.   */
-/*                                                                            */
-/* Usage:  <for command-line>                                                 */
-/* rt_sigprocmask01 [-c n] [-e][-i n] [-I x] [-p x] [-t]                      */
-/*      where,  -c n : Run n copies concurrently.                             */
-/*              -e   : Turn on errno logging.                                 */
-/*              -i n : Execute test n times.                                  */
-/*              -I x : Execute test for x seconds.                            */
-/*              -P x : Pause for x seconds between iterations.                */
-/*              -t   : Turn on syscall timing.                                */
-/*                                                                            */
-/* Total Tests: 1                                                             */
-/*                                                                            */
-/* Test Name:   rt_sigprocmask01                                              */
-/* History:     Porting from Crackerjack to LTP is done by                    */
-/*              Manas Kumar Nayak <maknayak@in.ibm.com>                       */
 /******************************************************************************/
+
 #include <stdio.h>
 #include <signal.h>
 #include <errno.h>
@@ -64,65 +50,25 @@
 #include "ltp_signal.h"
 
 char *TCID = "rt_sigprocmask01";
-int testno;
+static int testno;
 int TST_TOTAL = 8;
 
+static int sig_count;
+
 #define TEST_SIG SIGRTMIN+1
 
-/* Extern Global Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    cleanup                                                       */
-/*                                                                            */
-/* Description: Performs all one time clean up for this test on successful    */
-/*              completion,  premature exit or  failure. Closes all temporary */
-/*              files, removes all temporary directories exits the test with  */
-/*              appropriate return code by calling tst_exit() function.       */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*              On success - Exits calling tst_exit(). With '0' return code.  */
-/*                                                                            */
-/******************************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-
 	TEST_CLEANUP;
 	tst_rmdir();
-
 }
 
-/* Local  Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    setup                                                         */
-/*                                                                            */
-/* Description: Performs all one time setup for this test. This function is   */
-/*              typically used to capture signals, create temporary dirs      */
-/*              and temporary files that may be used in the course of this    */
-/*              test.                                                         */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits by calling cleanup().                      */
-/*              On success - returns 0.                                       */
-/*                                                                            */
-/******************************************************************************/
-void setup(void)
+static void setup(void)
 {
-	/* Capture signals if any */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
 
-int sig_count = 0;
-
 void sig_handler(int sig)
 {
 	sig_count++;
@@ -146,9 +92,9 @@ int main(int ac, char **av)
 	int lc;
 	const char *msg;
 
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-	}
 
 	setup();
 
@@ -156,35 +102,34 @@ int main(int ac, char **av)
 		tst_count = 0;
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
-			if (sigemptyset(&set) < 0) {
+			if (sigemptyset(&set) < 0)
 				tst_brkm(TFAIL | TERRNO, cleanup,
 					 "sigemptyset call failed");
-			}
-			if (sigaddset(&set, TEST_SIG) < 0) {
+
+			if (sigaddset(&set, TEST_SIG) < 0)
 				tst_brkm(TFAIL | TERRNO, cleanup,
 					 "sigaddset call failed");
-			}
 
 			/* call rt_sigaction() */
 			TEST(ltp_syscall(__NR_rt_sigaction, TEST_SIG, &act,
 				&oact, SIGSETSIZE));
-			if (TEST_RETURN < 0) {
+			if (TEST_RETURN < 0)
 				tst_brkm(TFAIL | TTERRNO, cleanup,
 					 "rt_sigaction call failed");
-			}
+
 			/* call rt_sigprocmask() to block signal#TEST_SIG */
 			TEST(ltp_syscall(__NR_rt_sigprocmask, SIG_BLOCK, &set,
 				     &oset, SIGSETSIZE));
-			if (TEST_RETURN == -1) {
+			if (TEST_RETURN == -1)
 				tst_brkm(TFAIL | TTERRNO, cleanup,
 					 "rt_sigprocmask call failed");
-			}
+
 			/* Make sure that the masked process is indeed
 			 * masked. */
-			if (kill(getpid(), TEST_SIG) < 0) {
+			if (kill(getpid(), TEST_SIG) < 0)
 				tst_brkm(TFAIL | TERRNO, cleanup,
 					 "call to kill() failed");
-			}
+
 			if (sig_count) {
 				tst_brkm(TFAIL | TERRNO, cleanup,
 					 "rt_sigprocmask() failed to change "
@@ -193,26 +138,26 @@ int main(int ac, char **av)
 				/* call rt_sigpending() */
 				TEST(ltp_syscall(__NR_rt_sigpending, &oset,
 					     SIGSETSIZE));
-				if (TEST_RETURN == -1) {
+				if (TEST_RETURN == -1)
 					tst_brkm(TFAIL | TTERRNO, cleanup,
 						 "rt_sigpending call failed");
-				}
+
 				TEST(sigismember(&oset, TEST_SIG));
-				if (TEST_RETURN == 0) {
+				if (TEST_RETURN == 0)
 					tst_brkm(TFAIL | TTERRNO,
 						 cleanup,
 						 "sigismember call failed");
-				}
+
 				/* call rt_sigprocmask() to unblock
 				 * signal#TEST_SIG */
 				TEST(ltp_syscall(__NR_rt_sigprocmask,
 					     SIG_UNBLOCK, &set, &oset,
 					     SIGSETSIZE));
-				if (TEST_RETURN == -1) {
+				if (TEST_RETURN == -1)
 					tst_brkm(TFAIL | TTERRNO,
 						 cleanup,
 						 "rt_sigprocmask call failed");
-				}
+
 				if (sig_count) {
 					tst_resm(TPASS,
 						 "rt_sigprocmask "
@@ -224,7 +169,6 @@ int main(int ac, char **av)
 						 "rt_sigprocmask "
 						 "functionality failed");
 				}
-
 			}
 
 		}
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.c
index d1d5a9d..ef8f954 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask02.c
@@ -12,14 +12,14 @@
 /* the GNU General Public License for more details.                           */
 /*                                                                            */
 /* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
+/* along with this program;  if not, write to the Free Software Foundation,   */
+/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           */
 /*                                                                            */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 /******************************************************************************/
-/*                                                                            */
-/* File:        rt_sigprocmask02.c                                              */
-/*                                                                            */
 /* Description: This tests the rt_sigprocmask() syscall                       */
 /*		rt_sigprocmask changes the list of currently blocked signals. */
 /*		The set value stores the signal mask of the pending signals.  */
@@ -49,23 +49,8 @@
 /* 			    invalid. 					      */
 /* 			-EFAULT						      */
 /* 			    An invalid set, act, or oact was specified.       */
-/*                                                                            */
-/*									      */
-/* Usage:  <for command-line>                                                 */
-/* rt_sigprocmask02 [-c n] [-e][-i n] [-I x] [-p x] [-t]                      */
-/*      where,  -c n : Run n copies concurrently.                             */
-/*              -e   : Turn on errno logging.                                 */
-/*              -i n : Execute test n times.                                  */
-/*              -I x : Execute test for x seconds.                            */
-/*              -P x : Pause for x seconds between iterations.                */
-/*              -t   : Turn on syscall timing.                                */
-/*                                                                            */
-/* Total Tests: 1                                                             */
-/*                                                                            */
-/* Test Name:   rt_sigprocmask02                                              */
-/* History:     Porting from Crackerjack to LTP is done by                    */
-/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
+
 #include <stdio.h>
 #include <signal.h>
 #include <errno.h>
@@ -78,61 +63,21 @@
 char *TCID = "rt_sigprocmask02";
 int TST_TOTAL = 2;
 
-/* Extern Global Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    cleanup                                                       */
-/*                                                                            */
-/* Description: Performs all one time clean up for this test on successful    */
-/*              completion,  premature exit or  failure. Closes all temporary */
-/*              files, removes all temporary directories exits the test with  */
-/*              appropriate return code by calling tst_exit() function.       */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*              On success - Exits calling tst_exit(). With '0' return code.  */
-/*                                                                            */
-/******************************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-
 	TEST_CLEANUP;
 	tst_rmdir();
-
 }
 
-/* Local  Functions */
-/******************************************************************************/
-/*                                                                            */
-/* Function:    setup                                                         */
-/*                                                                            */
-/* Description: Performs all one time setup for this test. This function is   */
-/*              typically used to capture signals, create temporary dirs      */
-/*              and temporary files that may be used in the course of this    */
-/*              test.                                                         */
-/*                                                                            */
-/* Input:       None.                                                         */
-/*                                                                            */
-/* Output:      None.                                                         */
-/*                                                                            */
-/* Return:      On failure - Exits by calling cleanup().                      */
-/*              On success - returns 0.                                       */
-/*                                                                            */
-/******************************************************************************/
-void setup(void)
+static void setup(void)
 {
-	/* Capture signals if any */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
 
-sigset_t set;
+static sigset_t set;
 
-struct test_case_t {
+static struct test_case_t {
 	sigset_t *ss;
 	int sssize;
 	int exp_errno;
@@ -150,21 +95,18 @@ int main(int ac, char **av)
 	sigset_t s;
 	const char *msg;
 
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-		tst_exit();
-	}
 
 	setup();
 
 	tst_count = 0;
 
 	TEST(sigfillset(&s));
-	if (TEST_RETURN == -1) {
-		tst_resm(TFAIL | TTERRNO, "Call to sigfillset() failed.");
-		cleanup();
-		tst_exit();
-	}
+	if (TEST_RETURN == -1)
+		tst_brkm(TFAIL | TTERRNO, cleanup,
+			"Call to sigfillset() failed.");
 
 	for (i = 0; i < test_count; i++) {
 		TEST(ltp_syscall(__NR_rt_sigprocmask, SIG_BLOCK,
@@ -183,5 +125,4 @@ int main(int ac, char **av)
 
 	cleanup();
 	tst_exit();
-
 }
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index b27e9c6..f0fc96f 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -1,42 +1,27 @@
-/********************************************************************************/
-/* Copyright (c) Crackerjack Project., 2007				   	*/
-/*									    	*/
-/* This program is free software;  you can redistribute it and/or modify      	*/
-/* it under the terms of the GNU General Public License as published by       	*/
-/* the Free Software Foundation; either version 2 of the License, or	  	*/
-/* (at your option) any later version.						*/
-/*									    	*/
-/* This program is distributed in the hope that it will be useful,	    	*/
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of	    	*/
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See		  	*/
-/* the GNU General Public License for more details.			   	*/
-/*									    	*/
-/* You should have received a copy of the GNU General Public License	  	*/
-/* along with this program;  if not, write to the Free Software	       	*/
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    	*/
-/*									    	*/
-/******************************************************************************	*/
-/******************************************************************************	*/
-/*									    	*/
-/* File:	rt_sigsuspend01.c					   	*/
-/*									    	*/
-/* Description: This tests the rt_sigsuspend() syscall.		      	*/
-/*									       	*/
-/* Usage:  <for command-line>						 	*/
-/* rt_sigsuspend01 [-c n] [-e][-i n] [-I x] [-p x] [-t]		     	*/
-/*      where,  -c n : Run n copies concurrently.			     	*/
-/*	      -e   : Turn on errno logging.				 	*/
-/*	      -i n : Execute test n times.				  	*/
-/*	      -I x : Execute test for x seconds.			    	*/
-/*	      -P x : Pause for x seconds between iterations.			*/
-/*	      -t   : Turn on syscall timing.					*/
-/*									    	*/
-/* Total Tests: 2							     	*/
-/*									    	*/
-/* Test Name:   rt_sigsuspend01					     	*/
-/* History:     Porting from Crackerjack to LTP is done by		    	*/
-/*	      Manas Kumar Nayak maknayak@in.ibm.com>				*/
-/********************************************************************************/
+/******************************************************************************/
+/* Copyright (c) Crackerjack Project., 2007                                   */
+/*                                                                            */
+/* This program is free software;  you can redistribute it and/or modify      */
+/* it under the terms of the GNU General Public License as published by       */
+/* the Free Software Foundation; either version 2 of the License, or          */
+/* (at your option) any later version.                                        */
+/*                                                                            */
+/* This program is distributed in the hope that it will be useful,            */
+/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
+/* the GNU General Public License for more details.                           */
+/*                                                                            */
+/* You should have received a copy of the GNU General Public License          */
+/* along with this program;  if not, write to the Free Software Foundation,   */
+/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           */
+/*                                                                            */
+/* History:     Porting from Crackerjack to LTP is done by                    */
+/*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
+/******************************************************************************/
+
+/******************************************************************************/
+/* Description: This tests the rt_sigsuspend() syscall.                       */
+/******************************************************************************/
 
 #include <stdio.h>
 #include <signal.h>
@@ -49,75 +34,33 @@
 #include "ltp_signal.h"
 
 char *TCID = "rt_sigsuspend01";
-int testno;
 int TST_TOTAL = 1;
 
-/* Extern Global Functions */
-/******************************************************************************/
-/*									    */
-/* Function:    cleanup						       */
-/*									    */
-/* Description: Performs all one time clean up for this test on successful    */
-/*	      completion,  premature exit or  failure. Closes all temporary */
-/*	      files, removes all temporary directories exits the test with  */
-/*	      appropriate return code by calling tst_exit() function.       */
-/*									    */
-/* Input:       None.							 */
-/*									    */
-/* Output:      None.							 */
-/*									    */
-/* Return:      On failure - Exits calling tst_exit(). Non '0' return code.   */
-/*	      On success - Exits calling tst_exit(). With '0' return code.  */
-/*									    */
-/******************************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-
 	TEST_CLEANUP;
 	tst_rmdir();
-
 }
 
-/* Local  Functions */
-/******************************************************************************/
-/*									    */
-/* Function:    setup							 */
-/*									    */
-/* Description: Performs all one time setup for this test. This function is   */
-/*	      typically used to capture signals, create temporary dirs      */
-/*	      and temporary files that may be used in the course of this    */
-/*	      test.							 */
-/*									    */
-/* Input:       None.							 */
-/*									    */
-/* Output:      None.							 */
-/*									    */
-/* Return:      On failure - Exits by calling cleanup().		      */
-/*	      On success - returns 0.				       */
-/*									    */
-/******************************************************************************/
-void setup(void)
+static void setup(void)
 {
-	/* Capture signals if any */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
 
-void sig_handler(int sig)
+static void sig_handler(int sig)
 {
 }
 
 int main(int ac, char **av)
 {
-
 	sigset_t set, set1, set2;
 	int lc;
 	const char *msg;
 
-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
-	}
 
 	setup();
 
@@ -125,9 +68,8 @@ int main(int ac, char **av)
 
 		tst_count = 0;
 
-		if (sigemptyset(&set) < 0) {
+		if (sigemptyset(&set) < 0)
 			tst_brkm(TFAIL | TERRNO, cleanup, "sigemptyset failed");
-		}
 #ifdef __x86_64__
 		struct kernel_sigaction act, oact;
 		sig_initial(SIGALRM);
@@ -145,16 +87,15 @@ int main(int ac, char **av)
 
 		TEST(ltp_syscall(__NR_rt_sigaction, SIGALRM, &act, &oact,
 			     SIGSETSIZE));
-		if (TEST_RETURN == -1) {
+		if (TEST_RETURN == -1)
 			tst_brkm(TFAIL | TTERRNO, cleanup,
 				 "rt_sigaction failed");
-		}
+
 		TEST(ltp_syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0,
 			     &set1, SIGSETSIZE));
-		if (TEST_RETURN == -1) {
+		if (TEST_RETURN == -1)
 			tst_brkm(TFAIL | TTERRNO, cleanup,
 				 "rt_sigprocmask failed");
-		}
 
 		TEST(alarm(5));
 		int result;
-- 
1.7.1


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH V2 2/3] rt_sigaction, rt_sigprocmask01, rt_sigsuspend: use rt_sigaction wrapper
  2014-05-20 14:42           ` chrubis
                               ` (3 preceding siblings ...)
  2014-06-17  9:08             ` [LTP] [PATCH V2 1/3] rt_sigaction, rt_sigprocmask, rt_sigsuspend: cleanup Stanislav Kholmanskikh
@ 2014-06-17  9:08             ` Stanislav Kholmanskikh
  2014-06-17  9:08             ` [LTP] [PATCH V2 3/3] ltp_rt_sigaction.h: added SPARC support Stanislav Kholmanskikh
  5 siblings, 0 replies; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-06-17  9:08 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

These testcases use many pieces of duplicated code to test
syscall(__NR_rt_sigaction). Thus it's not beautiful to add support
for other architectures there.

To overcome this I:
 * moved everything inside '#ifdef LTP_RT_SIG_TEST' to a separate
   header file - 'include/lapi/rt_sigaction.h'
   So if we need to test the rt_sigaction syscall, we include 'lapi/sigaction.h',
   otherwise - include 'ltp_signal.h'.

 * moved struct kernel_sigaction out of '#ifdef __x86_64__', because
   it is not specific only for x86_64

 * implemented a wrapper for the rt_sigaction syscall and put it
   into 'include/lapi/rt_sigaction.h'

 * modified the above test cases to use this wrapper

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
Changes since V1:
 * Splitted include/ltp_signal.h into two headers


 include/lapi/rt_sigaction.h                        |  154 ++++++++++++++++++++
 include/ltp_signal.h                               |   69 ---------
 .../kernel/syscalls/rt_sigaction/rt_sigaction01.c  |   18 +--
 .../kernel/syscalls/rt_sigaction/rt_sigaction02.c  |    9 +-
 .../kernel/syscalls/rt_sigaction/rt_sigaction03.c  |    5 +-
 .../syscalls/rt_sigprocmask/rt_sigprocmask01.c     |   16 +--
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       |   16 +--
 7 files changed, 168 insertions(+), 119 deletions(-)
 create mode 100644 include/lapi/rt_sigaction.h

diff --git a/include/lapi/rt_sigaction.h b/include/lapi/rt_sigaction.h
new file mode 100644
index 0000000..efe7f69
--- /dev/null
+++ b/include/lapi/rt_sigaction.h
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2009 Cisco Systems, Inc.  All Rights Reserved.
+ * Copyright (c) 2009 FUJITSU LIMITED.  All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like.  Any license provided herein, whether implied or
+ * otherwise, applies only to this software file.  Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Author: Liu Bo <liubo2009@cn.fujitsu.com>
+ * Author: Garrett Cooper <yanegomi@gmail.com>
+ *
+ */
+
+#ifndef LTP_RT_SIGACTION_H
+#define LTP_RT_SIGACTION_H
+
+#include "ltp_signal.h"
+
+#define INVAL_SA_PTR ((void *)-1)
+
+struct kernel_sigaction {
+	__sighandler_t k_sa_handler;
+	unsigned long sa_flags;
+	void (*sa_restorer) (void);
+	sigset_t sa_mask;
+};
+
+#ifdef __x86_64__
+
+/*
+ * From asm/signal.h -- this value isn't exported anywhere outside of glibc and
+ * asm/signal.h and is only required for the rt_sig* function family because
+ * sigaction(2), et all, appends this if necessary to
+ * (struct sigaction).sa_flags. HEH.
+ *
+ * I do #undef though, just in case...
+ *
+ * Also, from .../arch/x86/kernel/signal.c:448 for v2.6.30 (something or
+ * other):
+ *
+ * x86-64 should always use SA_RESTORER.
+ *
+ * -- thus SA_RESTORER must always be defined along with
+ * (struct sigaction).sa_restorer for this architecture.
+ */
+#undef SA_RESTORER
+#define HAVE_SA_RESTORER
+#define SA_RESTORER     0x04000000
+
+void (*restore_rt)(void);
+
+static void handler_h(int signal)
+{
+	return;
+}
+
+/* Setup an initial signal handler for signal number = sig for x86_64. */
+static inline int sig_initial(int sig)
+{
+	int ret_code = -1;
+	struct sigaction act, oact;
+
+	act.sa_handler = handler_h;
+	act.sa_flags = 0;
+	/* Clear out the signal set. */
+	if (sigemptyset(&act.sa_mask) < 0) {
+		/* Add the signal to the mask set. */
+	} else if (sigaddset(&act.sa_mask, sig) < 0) {
+		/* Set act.sa_restorer via syscall(2) */
+	} else if (sigaction(sig, &act, &oact) < 0) {
+		/* Copy oact.sa_restorer via syscall(2) */
+	} else if (sigaction(sig, &act, &oact) < 0) {
+		/* And voila -- we just tricked the kernel into giving us our
+		 * restorer function! */
+	} else {
+		restore_rt = oact.sa_restorer;
+		ret_code = 0;
+	}
+
+	return ret_code;
+}
+
+#endif /* __x86_64__ */
+
+/* This is a wrapper for __NR_rt_sigaction syscall.
+ * act/oact values of INVAL_SA_PTR is used to pass
+ * an invalid pointer to syscall(__NR_rt_sigaction)
+ *
+ * Based on glibc/sysdeps/unix/sysv/linux/{...}/sigaction.c
+ */
+
+static int ltp_rt_sigaction(int signum, const struct sigaction *act,
+			struct sigaction *oact, size_t sigsetsize)
+{
+	int ret;
+	struct kernel_sigaction kact, koact;
+	struct kernel_sigaction *kact_p = NULL;
+	struct kernel_sigaction *koact_p = NULL;
+
+	if (act == INVAL_SA_PTR) {
+		kact_p = INVAL_SA_PTR;
+	} else if (act) {
+		kact.k_sa_handler = act->sa_handler;
+		memcpy(&kact.sa_mask, &act->sa_mask, sizeof(sigset_t));
+		kact.sa_flags = act->sa_flags;
+		kact.sa_restorer = NULL;
+
+		kact_p = &kact;
+	}
+
+	if (oact == INVAL_SA_PTR)
+		koact_p = INVAL_SA_PTR;
+	else if (oact)
+		koact_p = &koact;
+
+#ifdef __x86_64__
+	sig_initial(signum);
+	kact.sa_flags |= SA_RESTORER;
+	kact.sa_restorer = restore_rt;
+#endif
+
+	ret = ltp_syscall(__NR_rt_sigaction, signum,
+			kact_p, koact_p,
+			sigsetsize);
+
+	if (ret >= 0) {
+		if (oact && (oact != INVAL_SA_PTR)) {
+			oact->sa_handler = koact.k_sa_handler;
+			memcpy(&oact->sa_mask, &koact.sa_mask,
+				sizeof(sigset_t));
+			oact->sa_flags = koact.sa_flags;
+			oact->sa_restorer = koact.sa_restorer;
+		}
+	}
+
+	return ret;
+}
+
+#endif /* LTP_RT_SIGACTION_H */
diff --git a/include/ltp_signal.h b/include/ltp_signal.h
index e6fb2e0..294007b 100644
--- a/include/ltp_signal.h
+++ b/include/ltp_signal.h
@@ -53,73 +53,4 @@
 #define SIGSETSIZE (_NSIG / 8)
 #endif
 
-#ifdef LTP_RT_SIG_TEST
-
-#ifdef __x86_64__
-
-/*
- * From asm/signal.h -- this value isn't exported anywhere outside of glibc and
- * asm/signal.h and is only required for the rt_sig* function family because
- * sigaction(2), et all, appends this if necessary to
- * (struct sigaction).sa_flags. HEH.
- *
- * I do #undef though, just in case...
- *
- * Also, from .../arch/x86/kernel/signal.c:448 for v2.6.30 (something or
- * other):
- *
- * x86-64 should always use SA_RESTORER.
- *
- * -- thus SA_RESTORER must always be defined along with
- * (struct sigaction).sa_restorer for this architecture.
- */
-#undef SA_RESTORER
-#define HAVE_SA_RESTORER
-#define SA_RESTORER	0x04000000
-
-struct kernel_sigaction {
-	__sighandler_t k_sa_handler;
-	unsigned long sa_flags;
-	void (*sa_restorer) (void);
-	sigset_t sa_mask;
-};
-
-void (*restore_rt)(void);
-
-static void handler_h(int signal)
-{
-	return;
-}
-
-/* Setup an initial signal handler for signal number = sig for x86_64. */
-static inline int sig_initial(int sig)
-{
-	int ret_code = -1;
-	struct sigaction act, oact;
-
-	act.sa_handler = handler_h;
-	act.sa_flags = 0;
-	/* Clear out the signal set. */
-	if (sigemptyset(&act.sa_mask) < 0) {
-		/* Add the signal to the mask set. */
-	} else if (sigaddset(&act.sa_mask, sig) < 0) {
-		/* Set act.sa_restorer via syscall(2) */
-	} else if (sigaction(sig, &act, &oact) < 0) {
-		/* Copy oact.sa_restorer via syscall(2) */
-	} else if (sigaction(sig, &act, &oact) < 0) {
-		/* And voila -- we just tricked the kernel into giving us our
-		 * restorer function! */
-	} else {
-		restore_rt = oact.sa_restorer;
-		ret_code = 0;
-	}
-
-	return ret_code;
-
-}
-
-#endif /* __x86_64__ */
-
-#endif /* LTP_RT_SIG_TEST */
-
 #endif
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
index fb698f8..396f798 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01.c
@@ -36,11 +36,10 @@
 #include <sys/syscall.h>
 #include <string.h>
 
-#define LTP_RT_SIG_TEST
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
-#include "ltp_signal.h"
+#include "lapi/rt_sigaction.h"
 
 char *TCID = "rt_sigaction01";
 static int testno;
@@ -73,20 +72,14 @@ static void handler(int sig)
 
 static int set_handler(int sig, int sig_to_mask, int mask_flags)
 {
-#ifdef __x86_64__
-	struct kernel_sigaction sa, oldaction;
-	mask_flags |= SA_RESTORER;
-	sa.sa_restorer = restore_rt;
-	sa.k_sa_handler = (void *)handler;
-#else
 	struct sigaction sa, oldaction;
+
 	sa.sa_handler = (void *)handler;
-#endif
 	sa.sa_flags = mask_flags;
 	sigemptyset(&sa.sa_mask);
 	sigaddset(&sa.sa_mask, sig);
 
-	return ltp_syscall(__NR_rt_sigaction, sig, &sa, &oldaction, SIGSETSIZE);
+	return ltp_rt_sigaction(sig, &sa, &oldaction, SIGSETSIZE);
 }
 
 int main(int ac, char **av)
@@ -109,11 +102,6 @@ int main(int ac, char **av)
 		for (testno = 0; testno < TST_TOTAL; ++testno) {
 
 			for (signal = SIGRTMIN; signal <= SIGRTMAX; signal++) {
-
-#ifdef __x86_64__
-				sig_initial(signal);
-#endif
-
 				for (flag = 0;
 				     flag <
 				     (sizeof(test_flags) /
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
index 8cf0f14..5989657 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction02.c
@@ -35,9 +35,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
-#include "ltp_signal.h"
-
-#define INVAL_STRUCT -1
+#include "lapi/rt_sigaction.h"
 
 char *TCID = "rt_sigaction02";
 static int testno;
@@ -100,9 +98,8 @@ int main(int ac, char **av)
 					 * An invalid act or oact value was specified                   *
 					 */
 
-					TEST(ltp_syscall
-					     (__NR_rt_sigaction, signal,
-					      INVAL_STRUCT, NULL, SIGSETSIZE));
+					TEST(ltp_rt_sigaction(signal,
+						INVAL_SA_PTR, NULL, SIGSETSIZE));
 					if ((TEST_RETURN == -1)
 					    && (TEST_ERRNO ==
 						test_cases[0].exp_errno)) {
diff --git a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
index 9ae8d0e..1b1554a 100644
--- a/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
+++ b/testcases/kernel/syscalls/rt_sigaction/rt_sigaction03.c
@@ -35,7 +35,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
-#include "ltp_signal.h"
+#include "lapi/rt_sigaction.h"
 
 #define INVAL_SIGSETSIZE -1
 
@@ -92,8 +92,7 @@ static int set_handler(int sig, int sig_to_mask, int mask_flags)
 	 * sigsetsize was not equivalent to the size of a sigset_t type *
 	 */
 
-	return ltp_syscall(__NR_rt_sigaction, sig, &sa, &oldaction,
-			INVAL_SIGSETSIZE);
+	return ltp_rt_sigaction(sig, &sa, &oldaction, INVAL_SIGSETSIZE);
 }
 
 int main(int ac, char **av)
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
index bdfa6dd..035ecdb 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
+++ b/testcases/kernel/syscalls/rt_sigprocmask/rt_sigprocmask01.c
@@ -46,8 +46,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
-#define LTP_RT_SIG_TEST
-#include "ltp_signal.h"
+#include "lapi/rt_sigaction.h"
 
 char *TCID = "rt_sigprocmask01";
 static int testno;
@@ -76,18 +75,11 @@ void sig_handler(int sig)
 
 int main(int ac, char **av)
 {
-#if __x86_64
-	struct kernel_sigaction act, oact;
-	sig_initial(TEST_SIG);
-	act.sa_flags |= SA_RESTORER;
-	act.sa_restorer = restore_rt;
-	act.k_sa_handler = sig_handler;
-#else
 	struct sigaction act, oact;
 	memset(&act, 0, sizeof(act));
 	memset(&oact, 0, sizeof(oact));
 	act.sa_handler = sig_handler;
-#endif
+
 	sigset_t set, oset;
 	int lc;
 	const char *msg;
@@ -111,8 +103,8 @@ int main(int ac, char **av)
 					 "sigaddset call failed");
 
 			/* call rt_sigaction() */
-			TEST(ltp_syscall(__NR_rt_sigaction, TEST_SIG, &act,
-				&oact, SIGSETSIZE));
+			TEST(ltp_rt_sigaction(TEST_SIG, &act, &oact,
+						SIGSETSIZE));
 			if (TEST_RETURN < 0)
 				tst_brkm(TFAIL | TTERRNO, cleanup,
 					 "rt_sigaction call failed");
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index f0fc96f..edcb4a8 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -30,8 +30,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "linux_syscall_numbers.h"
-#define LTP_RT_SIG_TEST
-#include "ltp_signal.h"
+#include "lapi/rt_sigaction.h"
 
 char *TCID = "rt_sigsuspend01";
 int TST_TOTAL = 1;
@@ -70,23 +69,12 @@ int main(int ac, char **av)
 
 		if (sigemptyset(&set) < 0)
 			tst_brkm(TFAIL | TERRNO, cleanup, "sigemptyset failed");
-#ifdef __x86_64__
-		struct kernel_sigaction act, oact;
-		sig_initial(SIGALRM);
-		memset(&act, 0, sizeof(act));
-		memset(&oact, 0, sizeof(oact));
-		act.sa_flags |= SA_RESTORER;
-		act.sa_restorer = restore_rt;
-		act.k_sa_handler = sig_handler;
-#else
 		struct sigaction act, oact;
 		memset(&act, 0, sizeof(act));
 		memset(&oact, 0, sizeof(oact));
 		act.sa_handler = sig_handler;
-#endif
 
-		TEST(ltp_syscall(__NR_rt_sigaction, SIGALRM, &act, &oact,
-			     SIGSETSIZE));
+		TEST(ltp_rt_sigaction(SIGALRM, &act, &oact, SIGSETSIZE));
 		if (TEST_RETURN == -1)
 			tst_brkm(TFAIL | TTERRNO, cleanup,
 				 "rt_sigaction failed");
-- 
1.7.1


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH V2 3/3] ltp_rt_sigaction.h: added SPARC support
  2014-05-20 14:42           ` chrubis
                               ` (4 preceding siblings ...)
  2014-06-17  9:08             ` [LTP] [PATCH V2 2/3] rt_sigaction, rt_sigprocmask01, rt_sigsuspend: use rt_sigaction wrapper Stanislav Kholmanskikh
@ 2014-06-17  9:08             ` Stanislav Kholmanskikh
  2014-06-23 15:21               ` chrubis
  2014-08-11 15:04               ` chrubis
  5 siblings, 2 replies; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-06-17  9:08 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

syscall(__NR_rt_sigaction) on SPARC requires more arguments, than
it does in x86_64 environment.

Therefore to make ltp_rt_sigaction() work on SPARC, we modify it
the same way as it's done in glibc, i.e. by hiding the additional
argument - the stub - inside the wrapper.

Based on patches by Jose E. Marchesi <jose.marchesi@oracle.com>.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
Changes since V1:
 * Added indentions to ifdefs
 * Added a more detailed description message

 include/lapi/rt_sigaction.h |   59 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/include/lapi/rt_sigaction.h b/include/lapi/rt_sigaction.h
index efe7f69..9ea5e0f 100644
--- a/include/lapi/rt_sigaction.h
+++ b/include/lapi/rt_sigaction.h
@@ -97,6 +97,46 @@ static inline int sig_initial(int sig)
 
 #endif /* __x86_64__ */
 
+#ifdef __sparc__
+# if defined __arch64__ || defined __sparcv9
+
+/*
+ * From glibc/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c
+ */
+
+static void __rt_sigreturn_stub(void)
+{
+	__asm__ ("mov %0, %%g1\n\t"
+		"ta  0x6d\n\t"
+		: /* no outputs */
+		: "i" (__NR_rt_sigreturn));
+}
+
+# else /* sparc32 */
+
+/*
+ * From glibc/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c
+ */
+
+static void __rt_sigreturn_stub(void)
+{
+	__asm__ ("mov %0, %%g1\n\t"
+		"ta  0x10\n\t"
+		: /* no outputs */
+		: "i" (__NR_rt_sigreturn));
+}
+
+static void __sigreturn_stub(void)
+{
+	__asm__ ("mov %0, %%g1\n\t"
+		"ta  0x10\n\t"
+		: /* no outputs */
+		: "i" (__NR_sigreturn));
+}
+
+# endif
+#endif /* __sparc__ */
+
 /* This is a wrapper for __NR_rt_sigaction syscall.
  * act/oact values of INVAL_SA_PTR is used to pass
  * an invalid pointer to syscall(__NR_rt_sigaction)
@@ -134,9 +174,28 @@ static int ltp_rt_sigaction(int signum, const struct sigaction *act,
 	kact.sa_restorer = restore_rt;
 #endif
 
+#ifdef __sparc__
+	unsigned long stub = 0;
+# if defined __arch64__ || defined __sparcv9
+	stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
+# else /* sparc32 */
+	if ((kact.sa_flags & SA_SIGINFO) != 0)
+		stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
+	else
+		stub = ((unsigned long) &__sigreturn_stub) - 8;
+# endif
+#endif
+
+
+#ifdef __sparc__
+	ret = ltp_syscall(__NR_rt_sigaction, signum,
+			kact_p, koact_p,
+			stub, sigsetsize);
+#else
 	ret = ltp_syscall(__NR_rt_sigaction, signum,
 			kact_p, koact_p,
 			sigsetsize);
+#endif
 
 	if (ret >= 0) {
 		if (oact && (oact != INVAL_SA_PTR)) {
-- 
1.7.1


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH V2 3/3] ltp_rt_sigaction.h: added SPARC support
  2014-06-17  9:08             ` [LTP] [PATCH V2 3/3] ltp_rt_sigaction.h: added SPARC support Stanislav Kholmanskikh
@ 2014-06-23 15:21               ` chrubis
  2014-08-11 15:04               ` chrubis
  1 sibling, 0 replies; 28+ messages in thread
From: chrubis @ 2014-06-23 15:21 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
Whole patchset looks good to me, acked.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH V2 3/3] ltp_rt_sigaction.h: added SPARC support
  2014-06-17  9:08             ` [LTP] [PATCH V2 3/3] ltp_rt_sigaction.h: added SPARC support Stanislav Kholmanskikh
  2014-06-23 15:21               ` chrubis
@ 2014-08-11 15:04               ` chrubis
       [not found]                 ` <53E9C7B8.1040504@oracle.com>
  1 sibling, 1 reply; 28+ messages in thread
From: chrubis @ 2014-08-11 15:04 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
I've started to prepare for release and tried to build LTP on as much
arch/distro combination I could, for ia64 the rt_sigaction fails with:

In file included from rt_sigaction01.c:42:
[  349s] ../../../../include/lapi/rt_sigaction.h: In function
'ltp_rt_sigaction':
[  349s] ../../../../include/lapi/rt_sigaction.h:206: error: 'struct
sigaction' has no member named 'sa_restorer'
[  349s] rt_sigaction01.c: In function 'set_handler':
[  349s] rt_sigaction01.c:73: warning: unused parameter 'sig_to_mask'
[  349s] make[4]: *** [rt_sigaction01] Error 1
[  349s] make[4]: Leaving directory
`/usr/src/packages/BUILD/ltp-full-git/testcases/kernel/syscalls/rt_sigaction'
[  349s] make[3]: *** [all] Error 2
[  349s] make[3]: Leaving directory
`/usr/src/packages/BUILD/ltp-full-git/testcases/kernel/syscalls'
[  349s] make[2]: *** [all] Error 2
[  349s] make[2]: Leaving directory
`/usr/src/packages/BUILD/ltp-full-git/testcases/kernel'
[  349s] make[1]: *** [all] Error 2
[  349s] make[1]: Leaving directory
`/usr/src/packages/BUILD/ltp-full-git/testcases'
[  349s] make: *** [testcases-all] Error 2
[  349s] error: Bad exit status from /var/tmp/rpm-tmp.20244 (%build)

Looking into glibc they have #ifdef HAVE_SA_RESTORER around code that
accesses the field. I guess that we have to add corresponding configure
check and ifdef too...

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH V2 3/3] ltp_rt_sigaction.h: added SPARC support
       [not found]                 ` <53E9C7B8.1040504@oracle.com>
@ 2014-08-12  9:04                   ` chrubis
       [not found]                     ` <53E9F644.5000101@oracle.com>
  0 siblings, 1 reply; 28+ messages in thread
From: chrubis @ 2014-08-12  9:04 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
> > I've started to prepare for release and tried to build LTP on as much
> > arch/distro combination I could, for ia64 the rt_sigaction fails with:
> >
> > In file included from rt_sigaction01.c:42:
> > [  349s] ../../../../include/lapi/rt_sigaction.h: In function
> > 'ltp_rt_sigaction':
> > [  349s] ../../../../include/lapi/rt_sigaction.h:206: error: 'struct
> > sigaction' has no member named 'sa_restorer'
> > [  349s] rt_sigaction01.c: In function 'set_handler':
> > [  349s] rt_sigaction01.c:73: warning: unused parameter 'sig_to_mask'
> > [  349s] make[4]: *** [rt_sigaction01] Error 1
> > [  349s] make[4]: Leaving directory
> > `/usr/src/packages/BUILD/ltp-full-git/testcases/kernel/syscalls/rt_sigaction'
> > [  349s] make[3]: *** [all] Error 2
> > [  349s] make[3]: Leaving directory
> > `/usr/src/packages/BUILD/ltp-full-git/testcases/kernel/syscalls'
> > [  349s] make[2]: *** [all] Error 2
> > [  349s] make[2]: Leaving directory
> > `/usr/src/packages/BUILD/ltp-full-git/testcases/kernel'
> > [  349s] make[1]: *** [all] Error 2
> > [  349s] make[1]: Leaving directory
> > `/usr/src/packages/BUILD/ltp-full-git/testcases'
> > [  349s] make: *** [testcases-all] Error 2
> > [  349s] error: Bad exit status from /var/tmp/rpm-tmp.20244 (%build)
> >
> > Looking into glibc they have #ifdef HAVE_SA_RESTORER around code that
> > accesses the field. I guess that we have to add corresponding configure
> > check and ifdef too...
> >
> 
> I looked at all sigaction.c files under glibc/sysdeps/unix/sysv/linux 
> and found that in most of them kernel_sigaction.h file is used.
> 
> And only these architectures don't have .sa_restorer field:
>   * s390/s390-64/sigaction.c
>   * ia64/sigaction.c

Strange it fails to compile only on ia64 for me, s390 and s390x seems to
be fine.

> What do you think about this approach (everything inside rt_sigaction.h):
>   * define HAVE_SA_RESTORER for all architectures except the two above
>   * protect all accesses to .sa_restorer (both in 'struct sigaction' and 
> 'struct kernel_sigaction') with #ifdef HAVE_SA_RESTORER

Sounds good to me.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH V2 3/3] ltp_rt_sigaction.h: added SPARC support
       [not found]                     ` <53E9F644.5000101@oracle.com>
@ 2014-08-12 11:26                       ` chrubis
  2014-08-12 11:59                         ` [LTP] [PATCH] rt_sigaction.h: define HAVE_SA_RESTORER for most platforms Stanislav Kholmanskikh
  0 siblings, 1 reply; 28+ messages in thread
From: chrubis @ 2014-08-12 11:26 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
> Sorry, I was incorrect.
> 
> If a sigaction.c includes kernel_sigaction.h, it implies that the 
> sigaction() implementation uses 'struct kernel_sigaction'.
> 
> But this fact doesn't mean that 'struct sigaction' for this platform 
> has/doesn't have .sa_restorer member.
> 
> It seems that only:
>   * alpha
>   * ia64
>   * hppa
> 
> platforms don't have .sa_restorer in 'struct sigaction'.

That seems to be consistent with my expectations, however I cannot test
LTP compilation on alpha and hppa.

But in the end I think that we are fine with ifdefing out the
sa_restorer on these platfors. Can you plase push such patch?

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH] rt_sigaction.h: define HAVE_SA_RESTORER for most platforms
  2014-08-12 11:26                       ` chrubis
@ 2014-08-12 11:59                         ` Stanislav Kholmanskikh
  2014-08-12 12:24                           ` chrubis
  0 siblings, 1 reply; 28+ messages in thread
From: Stanislav Kholmanskikh @ 2014-08-12 11:59 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

On some platforms LTP fails to compile, because (struct sigaction)
doesn't have .sa_restorer member. For example - ia64.

To overcome such failures we employ HAVE_SA_RESTORER define.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
Verified on SPARC, x86_64, i386.


 include/lapi/rt_sigaction.h |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/include/lapi/rt_sigaction.h b/include/lapi/rt_sigaction.h
index 9ea5e0f..46f6a50 100644
--- a/include/lapi/rt_sigaction.h
+++ b/include/lapi/rt_sigaction.h
@@ -40,6 +40,11 @@ struct kernel_sigaction {
 	sigset_t sa_mask;
 };
 
+/* This macro marks if (struct sigaction) has .sa_restorer member */
+#if !defined(__ia64__) && !defined(__alpha__) && !defined(__hppa__)
+# define HAVE_SA_RESTORER
+#endif
+
 #ifdef __x86_64__
 
 /*
@@ -59,7 +64,6 @@ struct kernel_sigaction {
  * (struct sigaction).sa_restorer for this architecture.
  */
 #undef SA_RESTORER
-#define HAVE_SA_RESTORER
 #define SA_RESTORER     0x04000000
 
 void (*restore_rt)(void);
@@ -203,7 +207,9 @@ static int ltp_rt_sigaction(int signum, const struct sigaction *act,
 			memcpy(&oact->sa_mask, &koact.sa_mask,
 				sizeof(sigset_t));
 			oact->sa_flags = koact.sa_flags;
+#ifdef HAVE_SA_RESTORER
 			oact->sa_restorer = koact.sa_restorer;
+#endif
 		}
 	}
 
-- 
1.7.1


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] rt_sigaction.h: define HAVE_SA_RESTORER for most platforms
  2014-08-12 11:59                         ` [LTP] [PATCH] rt_sigaction.h: define HAVE_SA_RESTORER for most platforms Stanislav Kholmanskikh
@ 2014-08-12 12:24                           ` chrubis
  0 siblings, 0 replies; 28+ messages in thread
From: chrubis @ 2014-08-12 12:24 UTC (permalink / raw)
  To: Stanislav Kholmanskikh; +Cc: vasily.isaenko, ltp-list

Hi!
> On some platforms LTP fails to compile, because (struct sigaction)
> doesn't have .sa_restorer member. For example - ia64.
> 
> To overcome such failures we employ HAVE_SA_RESTORER define.
> 
> Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
> ---
> Verified on SPARC, x86_64, i386.

I've tested that this patch fixes compilation failure on ia64, feel free
to push it with my tested-by.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2014-08-12 12:25 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-08  9:06 [LTP] SPARC fixes Stanislav Kholmanskikh
2014-05-08  9:06 ` [LTP] [PATCH 1/4] linux syscall numbers: fixed the checkings for SPARC Stanislav Kholmanskikh
2014-05-08  9:06 ` [LTP] [PATCH 2/4] linux syscall numbers: removed unimplemented syscalls for sparc64 Stanislav Kholmanskikh
2014-05-08  9:06 ` [LTP] [PATCH 3/4] syscalls: corrected the rest of __sparc64__ defines Stanislav Kholmanskikh
2014-05-12 12:59   ` chrubis
2014-05-13  6:20     ` [LTP] [PATCH 1/2] sendmsg, recvmsg: moved MSG_CMSG_COMPAT definition to a header Stanislav Kholmanskikh
2014-05-13  6:20     ` [LTP] [PATCH 2/2] msg_common.h: corrected __sparc64__ definition Stanislav Kholmanskikh
2014-05-15 12:30       ` chrubis
2014-05-08  9:06 ` [LTP] [PATCH 4/4] rt_sigaction*, rt_sigprocmask01, rt_sigsuspend01: SPARC support Stanislav Kholmanskikh
2014-05-12 13:08   ` chrubis
     [not found]     ` <5371C09F.7050205@oracle.com>
2014-05-13 11:39       ` chrubis
2014-05-20 12:24         ` [LTP] [RFC PATCH] A draft of the rt_sigaction syscall wrapper Stanislav Kholmanskikh
2014-05-20 14:42           ` chrubis
2014-05-21 10:24             ` [LTP] [PATCH 1/3] rt_sigaction, rt_sigprocmask, rt_sigsuspend: cleanup Stanislav Kholmanskikh
2014-05-21 10:24             ` [LTP] [PATCH 2/3] rt_sigaction, rt_sigprocmask01, rt_sigsuspend: use rt_sigaction wrapper Stanislav Kholmanskikh
2014-06-04 15:53               ` chrubis
2014-05-21 10:24             ` [LTP] [PATCH 3/3] ltp_rt_sigaction: added SPARC support Stanislav Kholmanskikh
2014-05-21 10:31               ` Stanislav Kholmanskikh
2014-06-04 15:49               ` chrubis
2014-06-17  9:08             ` [LTP] [PATCH V2 1/3] rt_sigaction, rt_sigprocmask, rt_sigsuspend: cleanup Stanislav Kholmanskikh
2014-06-17  9:08             ` [LTP] [PATCH V2 2/3] rt_sigaction, rt_sigprocmask01, rt_sigsuspend: use rt_sigaction wrapper Stanislav Kholmanskikh
2014-06-17  9:08             ` [LTP] [PATCH V2 3/3] ltp_rt_sigaction.h: added SPARC support Stanislav Kholmanskikh
2014-06-23 15:21               ` chrubis
2014-08-11 15:04               ` chrubis
     [not found]                 ` <53E9C7B8.1040504@oracle.com>
2014-08-12  9:04                   ` chrubis
     [not found]                     ` <53E9F644.5000101@oracle.com>
2014-08-12 11:26                       ` chrubis
2014-08-12 11:59                         ` [LTP] [PATCH] rt_sigaction.h: define HAVE_SA_RESTORER for most platforms Stanislav Kholmanskikh
2014-08-12 12:24                           ` chrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.