From: chrubis@suse.cz
To: Mike Frysinger <vapier@gentoo.org>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH???v3] lib/cloner.c: add function ltp_clone7 when clone supports???7 arguments
Date: Thu, 9 Jan 2014 17:37:16 +0100 [thread overview]
Message-ID: <20140109163716.GA8938@rei> (raw)
In-Reply-To: <201401090947.12749.vapier@gentoo.org>
[-- Attachment #1: Type: text/plain, Size: 131 bytes --]
Hi!
And here is a patch. (note that it should be applied over the two
allready commited patches)
--
Cyril Hrubis
chrubis@suse.cz
[-- Attachment #2: 0001-lib-cloner.c-add-ltp_clone7-and-fix-build.patch --]
[-- Type: text/x-diff, Size: 7683 bytes --]
From eeb4ae48cb0dfcb3b89d1a368a8870dc5f35aae2 Mon Sep 17 00:00:00 2001
From: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
Date: Thu, 9 Jan 2014 20:10:11 +0800
Subject: [PATCH 1/2] lib/cloner.c: add ltp_clone7() and fix build
The seven argument clone breaks compilation on older distributions
(SLES10, RHEL4, etc.). It was introduced by commit 5f5cb63b7ddb.
This commit adds a configure check and ltp_clone7() library function.
Now the ltp_clone() is the same old ltp_clone() with five arguments and
ltp_clone7() is the new one with eight arguments (but it calls clone
with seven arguments, thus the name).
Tests that does not need the additional arguments should call the
ltp_clone() the rest should call ltp_clone7(). If seven argument clone
is not supproted the ltp_clone7() will return -1 and set errno to
ENOSYS.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
configure.ac | 1 +
include/test.h | 4 ++-
lib/cloner.c | 55 ++++++++++++++++++++++---------
m4/ltp-clone7args.m4 | 38 +++++++++++++++++++++
testcases/kernel/syscalls/clone/clone08.c | 9 +++--
5 files changed, 88 insertions(+), 19 deletions(-)
create mode 100644 m4/ltp-clone7args.m4
diff --git a/configure.ac b/configure.ac
index 4af7662..9e3df00 100644
--- a/configure.ac
+++ b/configure.ac
@@ -171,5 +171,6 @@ LTP_CHECK_FS_IOC_FLAGS
LTP_CHECK_MREMAP_FIXED
LTP_CHECK_KERNEL_DEVEL
LTP_CHECK_XFS_QUOTACTL
+LTP_CHECK_CLONE_SUPPORTS_7_ARGS
AC_OUTPUT
diff --git a/include/test.h b/include/test.h
index ffc1c8c..5211aea 100644
--- a/include/test.h
+++ b/include/test.h
@@ -199,7 +199,9 @@ void maybe_run_child(void (*child)(), char *fmt, ...);
int self_exec(char *argv0, char *fmt, ...);
/* Functions from lib/cloner.c */
-int ltp_clone(unsigned long clone_flags, int (*fn)(void *arg), void *arg,
+int ltp_clone(unsigned long flags, int (*fn)(void *arg), void *arg,
+ size_t stack_size, void *stack);
+int ltp_clone7(unsigned long flags, int (*fn)(void *arg), void *arg,
size_t stack_size, void *stack, ...);
int ltp_clone_malloc(unsigned long clone_flags, int (*fn)(void *arg),
void *arg, size_t stacksize);
diff --git a/lib/cloner.c b/lib/cloner.c
index cb4dc6e..d6aa428 100644
--- a/lib/cloner.c
+++ b/lib/cloner.c
@@ -18,7 +18,7 @@
*/
#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
+# define _GNU_SOURCE
#endif
#include <stdio.h>
@@ -29,6 +29,7 @@
#include <sched.h>
#include <stdarg.h>
#include "test.h"
+#include "config.h"
#undef clone /* we want to use clone() */
@@ -39,30 +40,25 @@ extern int __clone2(int (*fn) (void *arg), void *child_stack_base,
pid_t *parent_tid, void *tls, pid_t *child_tid);
#endif
+#ifndef CLONE_SUPPORTS_7_ARGS
+# define clone(fn, stack, flags, arg, ptid, tls, ctid) \
+ clone(fn, stack, flags, arg)
+#endif
+
/*
* ltp_clone: wrapper for clone to hide the architecture dependencies.
* 1. hppa takes bottom of stack and no stacksize (stack grows up)
* 2. __ia64__ takes bottom of stack and uses clone2
* 3. all others take top of stack (stack grows down)
*/
-int
-ltp_clone(unsigned long clone_flags, int (*fn) (void *arg), void *arg,
- size_t stack_size, void *stack, ...)
+static int
+ltp_clone_(unsigned long flags, int (*fn)(void *arg), void *arg,
+ size_t stack_size, void *stack, pid_t *ptid, void *tls, pid_t *ctid)
{
int ret;
- pid_t *parent_tid, *child_tid;
- void *tls;
- va_list arg_clone;
-
- va_start(arg_clone, stack);
- parent_tid = va_arg(arg_clone, pid_t *);
- tls = va_arg(arg_clone, void *);
- child_tid = va_arg(arg_clone, pid_t *);
- va_end(arg_clone);
#if defined(__ia64__)
- ret = clone2(fn, stack, stack_size, clone_flags, arg,
- parent_tid, tls, child_tid);
+ ret = clone2(fn, stack, stack_size, flags, arg, ptid, tls, ctid);
#else
# if defined(__hppa__) || defined(__metag__)
/*
@@ -78,12 +74,39 @@ ltp_clone(unsigned long clone_flags, int (*fn) (void *arg), void *arg,
stack += stack_size;
# endif
- ret = clone(fn, stack, clone_flags, arg, parent_tid, tls, child_tid);
+ ret = clone(fn, stack, flags, arg, ptid, tls, ctid);
#endif
return ret;
}
+int ltp_clone(unsigned long flags, int (*fn)(void *arg), void *arg,
+ size_t stack_size, void *stack)
+{
+ return ltp_clone_(flags, fn, arg, stack_size, stack, NULL, NULL, NULL);
+}
+
+int ltp_clone7(unsigned long flags, int (*fn)(void *arg), void *arg,
+ size_t stack_size, void *stack, ...)
+{
+ pid_t *ptid, *ctid;
+ void *tls;
+ va_list arg_clone;
+
+ va_start(arg_clone, stack);
+ ptid = va_arg(arg_clone, pid_t *);
+ tls = va_arg(arg_clone, void *);
+ ctid = va_arg(arg_clone, pid_t *);
+ va_end(arg_clone);
+
+#ifdef CLONE_SUPPORTS_7_ARGS
+ return ltp_clone_(flags, fn, arg, stack_size, stack, ptid, tls, ctid);
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+}
+
/*
* ltp_clone_malloc: also does the memory allocation for clone with a
* caller-specified size.
diff --git a/m4/ltp-clone7args.m4 b/m4/ltp-clone7args.m4
new file mode 100644
index 0000000..5857575
--- /dev/null
+++ b/m4/ltp-clone7args.m4
@@ -0,0 +1,38 @@
+dnl
+dnl Copyright (c) Linux Test Project, 2014
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+dnl the GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+dnl
+
+dnl
+dnl LTP_CHECK_CLONE_SUPPORTS_7_ARGS
+dnl -------------------------------
+dnl
+AC_DEFUN([LTP_CHECK_CLONE_SUPPORTS_7_ARGS],[
+AH_TEMPLATE(CLONE_SUPPORTS_7_ARGS,
+[Define to 1 if clone() supports 7 arguments.])
+AC_MSG_CHECKING([if clone() supports 7 args])
+AC_TRY_LINK([#define _GNU_SOURCE
+ #include <sched.h>
+ #include <stdlib.h>],
+ [
+ #ifdef __ia64__
+ __clone2(NULL, NULL, 0, 0, NULL, NULL, NULL, NULL);
+ #else
+ clone(NULL, NULL, 0, NULL, NULL, NULL, NULL);
+ #endif
+ ],
+ AC_DEFINE(CLONE_SUPPORTS_7_ARGS) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
+])
diff --git a/testcases/kernel/syscalls/clone/clone08.c b/testcases/kernel/syscalls/clone/clone08.c
index b098f4a..1258b4e 100644
--- a/testcases/kernel/syscalls/clone/clone08.c
+++ b/testcases/kernel/syscalls/clone/clone08.c
@@ -24,6 +24,8 @@
#include "safe_macros.h"
#include "linux_syscall_numbers.h"
+char *TCID = "clone08";
+
static pid_t ptid, ctid, tgid;
static void *child_stack;
@@ -76,7 +78,6 @@ static struct test_case {
test_clone_thread, child_clone_thread},
};
-char *TCID = "clone08";
int TST_TOTAL = ARRAY_SIZE(test_cases);
int main(int ac, char **av)
@@ -122,8 +123,12 @@ static void cleanup(void)
static long clone_child(const struct test_case *t, int use_tst)
{
- TEST(ltp_clone(t->flags, t->do_child, NULL, CHILD_STACK_SIZE,
+ TEST(ltp_clone7(t->flags, t->do_child, NULL, CHILD_STACK_SIZE,
child_stack, &ptid, NULL, &ctid));
+
+ if (TEST_RETURN == -1 && TTERRNO == ENOSYS)
+ tst_brmk(TCONF, cleanup, "clone does not support 7 args");
+
if (TEST_RETURN == -1) {
if (use_tst) {
tst_brkm(TBROK | TTERRNO, cleanup, "%s clone() failed",
--
1.8.3.2
[-- Attachment #3: Type: text/plain, Size: 388 bytes --]
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
[-- Attachment #4: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2014-01-09 16:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-18 9:29 [LTP] [PATCH v5 1/2] lib/cloner.c: add more args zenglg.jy
2013-12-23 1:11 ` Wanlong Gao
2014-01-07 14:09 ` chrubis
[not found] ` <1389181297.2879.11.camel@G08JYZSD130126>
2014-01-08 13:20 ` chrubis
[not found] ` <1389191490.2879.27.camel@G08JYZSD130126>
2014-01-08 15:15 ` [LTP] [PATCH] clone/clone08.c: check whether clone supports 7 arguments chrubis
[not found] ` <1389254938.2025.3.camel@G08JYZSD130126>
2014-01-09 11:36 ` chrubis
[not found] ` <1389269411.2149.8.camel@G08JYZSD130126>
2014-01-09 13:27 ` [LTP] [PATCH???v3] lib/cloner.c: add function ltp_clone7 when clone supports???7 arguments chrubis
[not found] ` <201401090947.12749.vapier@gentoo.org>
2014-01-09 15:04 ` chrubis
2014-01-09 16:37 ` chrubis [this message]
[not found] ` <629935924.13499645.1389289589284.JavaMail.root@redhat.com>
2014-01-09 18:08 ` chrubis
[not found] ` <201401091417.16506.vapier@gentoo.org>
2014-01-13 16:02 ` chrubis
[not found] ` <201401081447.46449.vapier@gentoo.org>
2014-01-09 11:24 ` [LTP] [PATCH] clone/clone08.c: check whether clone supports 7 arguments chrubis
[not found] ` <201401090803.39606.vapier@gentoo.org>
2014-01-09 13:09 ` chrubis
[not found] ` <201401090900.59568.vapier@gentoo.org>
2014-01-09 14:34 ` chrubis
2014-01-09 13:23 ` Jan Stancek
2014-01-09 13:51 ` Mike Frysinger
2014-01-09 14:10 ` Jan Stancek
2014-01-09 14:30 ` Mike Frysinger
2014-01-09 14:39 ` chrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140109163716.GA8938@rei \
--to=chrubis@suse.cz \
--cc=ltp-list@lists.sourceforge.net \
--cc=vapier@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.