[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ltp-list
Subject:    [LTP] [PATCH V3 2/3] fixes for 16-bit syscalls testcases
From:       Stanislav Kholmanskikh <stanislav.kholmanskikh () oracle ! com>
Date:       2013-08-29 13:22:14
Message-ID: 1377782535-15955-3-git-send-email-stanislav.kholmanskikh () oracle ! com
[Download RAW message or body]

syscalls/setgroups: moved compat_16.h to ../utils. This header will be
common for all 16-bit syscalls definitions.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 testcases/kernel/syscalls/setgroups/compat_16.h |   85 ----------------------
 testcases/kernel/syscalls/utils/compat_16.h     |   89 +++++++++++++++++++++++
 2 files changed, 89 insertions(+), 85 deletions(-)
 delete mode 100644 testcases/kernel/syscalls/setgroups/compat_16.h
 create mode 100644 testcases/kernel/syscalls/utils/compat_16.h

diff --git a/testcases/kernel/syscalls/setgroups/compat_16.h \
b/testcases/kernel/syscalls/setgroups/compat_16.h deleted file mode 100644
index 0de4e78..0000000
--- a/testcases/kernel/syscalls/setgroups/compat_16.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *
- *   Copyright (c) Red Hat Inc., 2008
- *
- *   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
- */
-
-/* Author: Masatake YAMATO <yamato@redhat.com> */
-
-#ifndef __SETGROUPS_COMPAT_16_H__
-#define __SETGROUPS_COMPAT_16_H__
-
-#include "compat_gid.h"
-#include "linux_syscall_numbers.h"
-
-
-/* For avoiding circular dependency. */
-extern void cleanup(void);
-
-#ifdef TST_USE_COMPAT16_SYSCALL
-
-long
-SETGROUPS(size_t gidsetsize, GID_T *list)
-{
-	return ltp_syscall(__NR_setgroups, gidsetsize, list);
-}
-
-int
-GETGROUPS(int size16, GID_T *list16)
-{
-	int r;
-	int i;
-
-	gid_t *list32;
-
-	list32 = malloc(size16 * sizeof(gid_t));
-	if (list32 == NULL)
-	  tst_brkm(TBROK, NULL, "malloc failed to alloc %zu errno "
-		   " %d ", size16 * sizeof(gid_t), errno);
-
-	r = getgroups(size16, list32);
-	if (r < 0)
-	  goto out;
-
-	for (i = 0; i < r; i++) {
-		if (!GID_SIZE_CHECK(list32[i]))
-		  tst_brkm(TBROK,
-			   cleanup,
-			   "gid returned from getgroups is too large for testing setgroups32");
-		list16[i] = (GID_T)list32[i];
-	}
-
- out:
-	free(list32);
-	return r;
-}
-
-#else
-int
-SETGROUPS(size_t size, const GID_T *list)
-{
-	return setgroups(size, list);
-}
-
-int
-GETGROUPS(int size, GID_T *list)
-{
-	return getgroups(size, list);
-}
-
-#endif	/* TST_USE_COMPAT16_SYSCALL */
-
-#endif /* __SETGROUPS_COMPAT_16_H__ */
diff --git a/testcases/kernel/syscalls/utils/compat_16.h \
b/testcases/kernel/syscalls/utils/compat_16.h new file mode 100644
index 0000000..dc5dafa
--- /dev/null
+++ b/testcases/kernel/syscalls/utils/compat_16.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) Red Hat Inc., 2008
+ *
+ * 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
+ */
+
+/* Author: Masatake YAMATO <yamato@redhat.com> */
+
+#ifndef __SETGROUPS_COMPAT_16_H__
+#define __SETGROUPS_COMPAT_16_H__
+
+#include "compat_gid.h"
+#include "linux_syscall_numbers.h"
+
+
+/* For avoiding circular dependency. */
+static void cleanup(void);
+
+#ifdef TST_USE_COMPAT16_SYSCALL
+
+/*
+ * LTP_COMPAT16_IS_DEFINED(SNAME) - if true, then __NR_SNAME
+ *   is a 16-bit version of SNAME() syscall
+ *
+ * LTP_COMPAT16_IF_DEFINED(SNAME, ...) - action to execute
+ *   if 16-bit version of SNAME syscall is supported
+ *
+ * LTP_COMPAT16_IF_UNDEFINED(SNAME) - action to execute
+ *   if 16-bit version of SNAME syscall is not supported
+ */
+#define LTP_COMPAT16_IS_DEFINED(SNAME) \
+	(__NR_##SNAME##32 != __LTP__NR_INVALID_SYSCALL)
+
+#define LTP_COMPAT16_IF_DEFINED(SNAME, ...) \
+	return ltp_syscall(__NR_##SNAME, ##__VA_ARGS__);
+
+#define LTP_COMPAT16_IF_UNDEFINED(SNAME) \
+	tst_brkm(TCONF, cleanup, \
+		"16-bit version of %s() is not supported on your platform", \
+		#SNAME);
+
+int
+SETGROUPS(size_t gidsetsize, GID_T *list16)
+{
+# if LTP_COMPAT16_IS_DEFINED(setgroups)
+	LTP_COMPAT16_IF_DEFINED(setgroups, gidsetsize, list16)
+# else
+	LTP_COMPAT16_IF_UNDEFINED(setgroups)
+# endif
+}
+
+int
+GETGROUPS(int gidsetsize, GID_T *list16)
+{
+# if LTP_COMPAT16_IS_DEFINED(getgroups)
+	LTP_COMPAT16_IF_DEFINED(getgroups, gidsetsize, list16)
+# else
+	LTP_COMPAT16_IF_UNDEFINED(getgroups)
+# endif
+}
+
+#else
+int
+SETGROUPS(size_t size, const GID_T *list)
+{
+	return setgroups(size, list);
+}
+
+int
+GETGROUPS(int size, GID_T *list)
+{
+	return getgroups(size, list);
+}
+
+#endif	/* TST_USE_COMPAT16_SYSCALL */
+
+#endif /* __SETGROUPS_COMPAT_16_H__ */
-- 
1.7.1


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic