All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] lib: Add SAFE_MSYNC() macro to LTP library
@ 2023-09-14 11:45 Avinesh Kumar
  2023-09-14 11:45 ` [LTP] [PATCH v3] syscalls/mmap01: Rewrite the test using new LTP API Avinesh Kumar
  2023-11-15 10:05 ` [LTP] [PATCH] lib: Add SAFE_MSYNC() macro to LTP library Petr Vorel
  0 siblings, 2 replies; 4+ messages in thread
From: Avinesh Kumar @ 2023-09-14 11:45 UTC (permalink / raw)
  To: ltp

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-16 11:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-14 11:45 [LTP] [PATCH] lib: Add SAFE_MSYNC() macro to LTP library Avinesh Kumar
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

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.