Prev: [PATCH v21 100/100] c/r: add an entry for checkpoint/restart in MAINTAINERS
Next: [PATCH v21 098/100] c/r: Add a checkpoint handler to the 'sit' device
From: Oren Laadan on 1 May 2010 10:50 From: Dan Smith <danms(a)us.ibm.com> As suggested by Dave[1], this provides us a way to make the copy-in and copy-out processes symmetric. CKPT_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 CKPT_COPY_ARRAY Feb 27: . Changed CKPT_COPY() to use assignment, eliminating the need for the CKPT_COPY_BIT() macro . Add CKPT_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() Cc: linux-s390(a)vger.kernel.org Signed-off-by: Dan Smith <danms(a)us.ibm.com> Signed-off-by: Oren Laadan <orenl(a)cs.columbia.edu> Acked-by: Serge E. Hallyn <serue(a)us.ibm.com> Tested-by: Serge E. Hallyn <serue(a)us.ibm.com> 1: https://lists.linux-foundation.org/pipermail/containers/2009-February/015821.html (all the way at the bottom) --- include/linux/checkpoint.h | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/include/linux/checkpoint.h b/include/linux/checkpoint.h index 2f72a6a..cd76f70 100644 --- a/include/linux/checkpoint.h +++ b/include/linux/checkpoint.h @@ -246,6 +246,34 @@ static inline int ckpt_validate_errno(int errno) return (errno >= 0) && (errno < MAX_ERRNO); } +/* useful macros to copy fields and buffers to/from ckpt_hdr_xxx structures */ +#define CKPT_CPT 1 +#define CKPT_RST 2 + +#define CKPT_COPY(op, SAVE, LIVE) \ + do { \ + if (op == CKPT_CPT) \ + SAVE = LIVE; \ + else \ + LIVE = SAVE; \ + } while (0) + +/* + * Copy @count items from @LIVE to @SAVE if op is CKPT_CPT (otherwise, + * copy in the reverse direction) + */ +#define CKPT_COPY_ARRAY(op, SAVE, LIVE, count) \ + do { \ + (void)__must_be_array(SAVE); \ + (void)__must_be_array(LIVE); \ + BUILD_BUG_ON(sizeof(*SAVE) != sizeof(*LIVE)); \ + if (op == CKPT_CPT) \ + memcpy(SAVE, LIVE, count * sizeof(*SAVE)); \ + else \ + memcpy(LIVE, SAVE, count * sizeof(*SAVE)); \ + } while (0) + + /* debugging flags */ #define CKPT_DBASE 0x1 /* anything */ #define CKPT_DSYS 0x2 /* generic (system) */ -- 1.6.3.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |