Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/sys Move macros wrapping functions from msg.h...



details:   https://anonhg.NetBSD.org/src/rev/524dc851cb14
branches:  trunk
changeset: 1007971:524dc851cb14
user:      kamil <kamil%NetBSD.org@localhost>
date:      Fri Mar 06 14:06:56 2020 +0000

description:
Move macros wrapping functions from msg.h into msg.h

This makes code reusing easier.

diffstat:

 tests/lib/libc/sys/msg.h           |  30 +++++++++++++++++++++++-------
 tests/lib/libc/sys/t_ptrace_wait.c |  20 ++------------------
 2 files changed, 25 insertions(+), 25 deletions(-)

diffs (124 lines):

diff -r ac3a784de9e3 -r 524dc851cb14 tests/lib/libc/sys/msg.h
--- a/tests/lib/libc/sys/msg.h  Fri Mar 06 10:26:59 2020 +0000
+++ b/tests/lib/libc/sys/msg.h  Fri Mar 06 14:06:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.h,v 1.2 2018/03/13 14:45:36 kamil Exp $    */
+/*     $NetBSD: msg.h,v 1.3 2020/03/06 14:06:56 kamil Exp $    */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
        } \
 } while (/*CONSTCOND*/ 0)
 
-static int
+static int __used
 msg_open(struct msg_fds *fds)
 {
        if (pipe(fds->pfd) == -1)
@@ -54,7 +54,7 @@
        return 0;
 }
 
-static void
+static void __used
 msg_close(struct msg_fds *fds)
 {
        CLOSEFD(fds->pfd[0]);
@@ -63,7 +63,7 @@
        CLOSEFD(fds->cfd[1]);
 }
 
-static int
+static int __used
 msg_write_child(const char *info, struct msg_fds *fds, void *msg, size_t len)
 {
        ssize_t rv;
@@ -81,7 +81,7 @@
        return 0;
 }
 
-static int
+static int __used
 msg_write_parent(const char *info, struct msg_fds *fds, void *msg, size_t len)
 {
        ssize_t rv;
@@ -99,7 +99,7 @@
        return 0;
 }
 
-static int
+static int __used
 msg_read_parent(const char *info, struct msg_fds *fds, void *msg, size_t len)
 {
        ssize_t rv;
@@ -117,7 +117,7 @@
        return 0;
 }
 
-static int
+static int __used
 msg_read_child(const char *info, struct msg_fds *fds, void *msg, size_t len)
 {
        ssize_t rv;
@@ -134,3 +134,19 @@
                return 1;
        return 0;
 }
+
+#define PARENT_TO_CHILD(info, fds, msg) \
+    SYSCALL_REQUIRE(msg_write_child(info " to child " # fds, &fds, &msg, \
+       sizeof(msg)) == 0)
+
+#define CHILD_FROM_PARENT(info, fds, msg) \
+    FORKEE_ASSERT(msg_read_parent(info " from parent " # fds, &fds, &msg, \
+       sizeof(msg)) == 0)
+
+#define CHILD_TO_PARENT(info, fds, msg) \
+    FORKEE_ASSERT(msg_write_parent(info " to parent " # fds, &fds, &msg, \
+       sizeof(msg)) == 0)
+
+#define PARENT_FROM_CHILD(info, fds, msg) \
+    SYSCALL_REQUIRE(msg_read_child(info " from parent " # fds, &fds, &msg, \
+       sizeof(msg)) == 0)
diff -r ac3a784de9e3 -r 524dc851cb14 tests/lib/libc/sys/t_ptrace_wait.c
--- a/tests/lib/libc/sys/t_ptrace_wait.c        Fri Mar 06 10:26:59 2020 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.c        Fri Mar 06 14:06:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ptrace_wait.c,v 1.167 2020/03/01 18:22:00 kamil Exp $        */
+/*     $NetBSD: t_ptrace_wait.c,v 1.168 2020/03/06 14:06:56 kamil Exp $        */
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.167 2020/03/01 18:22:00 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.168 2020/03/06 14:06:56 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -97,22 +97,6 @@
 #include "t_ptrace_wait.h"
 #include "msg.h"
 
-#define PARENT_TO_CHILD(info, fds, msg) \
-    SYSCALL_REQUIRE(msg_write_child(info " to child " # fds, &fds, &msg, \
-       sizeof(msg)) == 0)
-
-#define CHILD_FROM_PARENT(info, fds, msg) \
-    FORKEE_ASSERT(msg_read_parent(info " from parent " # fds, &fds, &msg, \
-       sizeof(msg)) == 0)
-
-#define CHILD_TO_PARENT(info, fds, msg) \
-    FORKEE_ASSERT(msg_write_parent(info " to parent " # fds, &fds, &msg, \
-       sizeof(msg)) == 0)
-
-#define PARENT_FROM_CHILD(info, fds, msg) \
-    SYSCALL_REQUIRE(msg_read_child(info " from parent " # fds, &fds, &msg, \
-       sizeof(msg)) == 0)
-
 #define SYSCALL_REQUIRE(expr) ATF_REQUIRE_MSG(expr, "%s: %s", # expr, \
     strerror(errno))
 #define SYSCALL_REQUIRE_ERRNO(res, exp) ATF_REQUIRE_MSG(res == exp, \



Home | Main Index | Thread Index | Old Index