From: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org
Subject: [PATCH 2/3] c/r: Add CR_COPY() macro (v4)
Date: Thu, 19 Mar 2009 15:41:18 -0400 [thread overview]
Message-ID: <1237491679-14433-3-git-send-email-danms@us.ibm.com> (raw)
In-Reply-To: <1237491679-14433-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
As suggested by Dave[1], this provides us a way to make the copy-in and
copy-out processes symmetric. CR_COPY_ARRAY() provides us a way to do
the same thing but for arrays. It's not critical, but it helps us unify
the checkpoint and restart paths for some things.
Changelog:
Mar 04:
. Removed semicolons
. Added build-time check for __must_be_array in CR_COPY_ARRAY
Feb 27:
. Changed CR_COPY() to use assignment, eliminating the need
for the CR_COPY_BIT() macro
. Add CR_COPY_ARRAY() macro to help copying register arrays,
etc
. Move the macro definitions inside the CR #ifdef
Feb 25:
. Changed WARN_ON() to BUILD_BUG_ON()
Signed-off-by: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
1: https://lists.linux-foundation.org/pipermail/containers/2009-February/015821.html (all the way at the bottom)
---
include/linux/checkpoint.h | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/include/linux/checkpoint.h b/include/linux/checkpoint.h
index e77393f..f748a75 100644
--- a/include/linux/checkpoint.h
+++ b/include/linux/checkpoint.h
@@ -120,6 +120,29 @@ static inline int cr_enabled(void)
return 1;
}
+#define CR_CPT 1
+#define CR_RST 2
+
+#define CR_COPY(op, a, b) \
+ do { \
+ if (op == CR_CPT) \
+ a = b; \
+ else \
+ b = a; \
+ } while (0)
+
+/* Copy @count items from @b to @a if op is CR_CPT (otherwise,
+ * copy in the reverse direction)
+ */
+#define CR_COPY_ARRAY(op, a, b, count) \
+ do { \
+ BUILD_BUG_ON(sizeof(*a) != sizeof(*b)); \
+ if (op == CR_CPT) \
+ memcpy(a, b, count * sizeof(*a)); \
+ else \
+ memcpy(b, a, count * sizeof(*a)); \
+ } while (__must_be_array(a) && __must_be_array(b) && 0)
+
#else /* !CONFIG_CHECKPOINT_RESTART */
static inline void files_deny_checkpointing(struct files_struct *files) {}
--
1.6.1
next prev parent reply other threads:[~2009-03-19 19:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-19 19:41 c/r: Add s390 support (resend) Dan Smith
[not found] ` <1237491679-14433-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-03-19 19:41 ` [PATCH 1/3] s390: Expose a constant for the number of words representing the CRs Dan Smith
2009-03-19 19:41 ` Dan Smith [this message]
2009-03-19 19:41 ` [PATCH 3/3] c/r: define s390-specific checkpoint-restart code (v7) Dan Smith
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=1237491679-14433-3-git-send-email-danms@us.ibm.com \
--to=danms-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox