From 85b1f93f8dbbc767c564e494a6353aa3517d5d49 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 16 Oct 2017 12:18:50 +0200 Subject: executor, pkg/ipc: unify ipc protocol between linux and other OSes We currently use more complex and functional protocol on linux, and a simple ad-hoc protocol on other OSes. This leads to code duplication in both ipc and executor. Linux supports coverage, shared memory communication and fork server, which would also be useful for most other OSes. Unify communication protocol and parametrize it by (1) use of shmem or only pipes, (2) use of fork server. This reduces duplication in ipc and executor and will allow to support the useful features for other OSes easily. Finally, this fixes akaros support as it currently uses syz-stress running on host (linux) and executor running on akaros. --- executor/common.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'executor/common.h') diff --git a/executor/common.h b/executor/common.h index 6cb7635f0..980ea74b7 100644 --- a/executor/common.h +++ b/executor/common.h @@ -23,8 +23,15 @@ #endif #if defined(SYZ_EXECUTOR) -#ifndef SYSCALLAPI +#if defined(__GNUC__) #define SYSCALLAPI +#define NORETURN __attribute__((noreturn)) +#define ALIGNED(N) __attribute__((aligned(N))) +#else +// Assuming windows/cl. +#define SYSCALLAPI WINAPI +#define NORETURN __declspec(noreturn) +#define ALIGNED(N) __declspec(align(N)) #endif typedef long(SYSCALLAPI* syscall_t)(long, long, long, long, long, long, long, long, long); @@ -58,7 +65,6 @@ const int kErrorStatus = 68; NORETURN static void fail(const char* msg, ...) { int e = errno; - fflush(stdout); va_list args; va_start(args, msg); vfprintf(stderr, msg, args); @@ -74,7 +80,6 @@ NORETURN static void fail(const char* msg, ...) // kernel error (e.g. wrong syscall return value) NORETURN static void error(const char* msg, ...) { - fflush(stdout); va_list args; va_start(args, msg); vfprintf(stderr, msg, args); @@ -84,12 +89,11 @@ NORETURN static void error(const char* msg, ...) } #endif -#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT)) +#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT) && defined(SYZ_USE_TMP_DIR)) // just exit (e.g. due to temporal ENOMEM error) NORETURN static void exitf(const char* msg, ...) { int e = errno; - fflush(stdout); va_list args; va_start(args, msg); vfprintf(stderr, msg, args); -- cgit mrf-deployment