aboutsummaryrefslogtreecommitdiffstats
path: root/csource
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2017-05-18 19:41:20 +0200
committerAndrey Konovalov <andreyknvl@google.com>2017-06-12 19:48:23 +0200
commit19015af81522aa5d8aaa16d07306c48c3a61571e (patch)
tree3ee87b94d62ff91158b95153942f09bb9e168cf6 /csource
parent120e26c2fecf4fcabc18af43329171d6afba02b4 (diff)
csource: only emit fail(), exitf() and doexit() when necessary
Diffstat (limited to 'csource')
-rw-r--r--csource/common.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/csource/common.go b/csource/common.go
index d4d6890f0..466e6de43 100644
--- a/csource/common.go
+++ b/csource/common.go
@@ -49,10 +49,18 @@ var commonHeader = `
#include <string.h>
#include <unistd.h>
+#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT)) || defined(SYZ_USE_TMP_DIR) || \
+ defined(SYZ_TUN_ENABLE) || defined(SYZ_SANDBOX_NAMESPACE) || defined(SYZ_SANDBOX_SETUID) || defined(__NR_syz_kvm_setup_cpu)
const int kFailStatus = 67;
-const int kErrorStatus = 68;
const int kRetryStatus = 69;
+#endif
+
+#if defined(SYZ_EXECUTOR)
+const int kErrorStatus = 68;
+#endif
+#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT)) || defined(SYZ_USE_TMP_DIR) || defined(SYZ_HANDLE_SEGV) || \
+ defined(SYZ_TUN_ENABLE) || defined(SYZ_SANDBOX_NAMESPACE) || defined(SYZ_SANDBOX_SETUID) || defined(SYZ_SANDBOX_NONE) || defined(__NR_syz_kvm_setup_cpu)
__attribute__((noreturn)) void doexit(int status)
{
volatile unsigned i;
@@ -60,12 +68,15 @@ __attribute__((noreturn)) void doexit(int status)
for (i = 0;; i++) {
}
}
+#endif
#if defined(SYZ_EXECUTOR)
#define exit use_doexit_instead
#define _exit use_doexit_instead
#endif
+#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT)) || defined(SYZ_USE_TMP_DIR) || \
+ defined(SYZ_TUN_ENABLE) || defined(SYZ_SANDBOX_NAMESPACE) || defined(SYZ_SANDBOX_SETUID) || defined(__NR_syz_kvm_setup_cpu)
__attribute__((noreturn)) void fail(const char* msg, ...)
{
int e = errno;
@@ -77,6 +88,7 @@ __attribute__((noreturn)) void fail(const char* msg, ...)
fprintf(stderr, " (errno %d)\n", e);
doexit((e == ENOMEM || e == EAGAIN) ? kRetryStatus : kFailStatus);
}
+#endif
#if defined(SYZ_EXECUTOR)
__attribute__((noreturn)) void error(const char* msg, ...)
@@ -91,6 +103,7 @@ __attribute__((noreturn)) void error(const char* msg, ...)
}
#endif
+#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT))
__attribute__((noreturn)) void exitf(const char* msg, ...)
{
int e = errno;
@@ -102,6 +115,7 @@ __attribute__((noreturn)) void exitf(const char* msg, ...)
fprintf(stderr, " (errno %d)\n", e);
doexit(kRetryStatus);
}
+#endif
#if defined(SYZ_EXECUTOR) || defined(SYZ_DEBUG)
static int flag_debug;