From: Avinesh Kumar <akumar@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] lib: Add SAFE_MSYNC() macro to LTP library
Date: Thu, 14 Sep 2023 17:15:18 +0530 [thread overview]
Message-ID: <20230914114520.5212-1-akumar@suse.de> (raw)
Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
include/tst_safe_macros.h | 6 ++++++
lib/tst_safe_macros.c | 19 +++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 0cf3d7878..c899c4f2c 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -86,6 +86,12 @@ void *safe_realloc(const char *file, const int lineno, void *ptr, size_t size);
#define SAFE_MUNMAP(addr, length) \
safe_munmap(__FILE__, __LINE__, NULL, (addr), (length))
+int safe_msync(const char *file, const int lineno, void *addr,
+ size_t length, int flags);
+
+#define SAFE_MSYNC(addr, length, flags) \
+ safe_msync(__FILE__, __LINE__, (addr), (length), (flags))
+
#define SAFE_OPEN(pathname, oflags, ...) \
safe_open(__FILE__, __LINE__, NULL, (pathname), (oflags), \
##__VA_ARGS__)
diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c
index c4cdc87e7..7f28d43e5 100644
--- a/lib/tst_safe_macros.c
+++ b/lib/tst_safe_macros.c
@@ -591,3 +591,22 @@ void safe_cmd(const char *file, const int lineno, const char *const argv[],
tst_brk_(file, lineno, TBROK, "%s failed (%d)", argv[0], rval);
}
}
+
+int safe_msync(const char *file, const int lineno, void *addr,
+ size_t length, int flags)
+{
+ int rval;
+
+ rval = msync(addr, length, flags);
+
+ if (rval == -1) {
+ tst_brk_(file, lineno, TBROK | TERRNO,
+ "msync(%p, %zu, %d) failed", addr, length, flags);
+ } else if (rval) {
+ tst_brk_(file, lineno, TBROK | TERRNO,
+ "Invalid msync(%p, %zu, %d) return value %d",
+ addr, length, flags, rval);
+ }
+
+ return rval;
+}
--
2.42.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2023-09-14 11:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-14 11:45 Avinesh Kumar [this message]
2023-09-14 11:45 ` [LTP] [PATCH v3] syscalls/mmap01: Rewrite the test using new LTP API Avinesh Kumar
2023-11-16 10:43 ` Richard Palethorpe
2023-11-15 10:05 ` [LTP] [PATCH] lib: Add SAFE_MSYNC() macro to LTP library Petr Vorel
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=20230914114520.5212-1-akumar@suse.de \
--to=akumar@suse.de \
--cc=ltp@lists.linux.it \
/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.