From 0053f5ec7d2c0ddf2047821914d08fe669f54a33 Mon Sep 17 00:00:00 2001 From: Sen Han <00hnes@gmail.com> Date: Wed, 25 Jul 2018 19:31:51 +0800 Subject: [PATCH] add a global C config macro ACO_USE_ASAN which could enable the friendly support of address sanitizer (both gcc and clang) --- aco.c | 6 +----- aco.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/aco.c b/aco.c index ee15be3..a9c301c 100644 --- a/aco.c +++ b/aco.c @@ -358,11 +358,7 @@ aco_t* aco_create( assert(0); } -#if defined(__has_feature) - #if __has_feature(address_sanitizer) - __attribute__((no_sanitize_address)) - #endif -#endif +aco_attr_no_asan void aco_resume(aco_t* resume_co){ assert(resume_co != NULL && resume_co->main_co != NULL && resume_co->is_end == 0 diff --git a/aco.h b/aco.h index 9d5c4d4..e4a6f32 100644 --- a/aco.h +++ b/aco.h @@ -136,6 +136,22 @@ struct aco_s{ } \ } while(0) +#if defined(ACO_USE_ASAN) + #if defined(__has_feature) + #if __has_feature(address_sanitizer) + #define aco_attr_no_asan \ + __attribute__((__no_sanitize_address__)) + #endif + #endif + #if defined(__SANITIZE_ADDRESS__) && !defined(aco_attr_no_asan) + #define aco_attr_no_asan \ + __attribute__((__no_sanitize_address__)) + #endif +#endif +#ifndef aco_attr_no_asan + #define aco_attr_no_asan +#endif + extern void aco_runtime_test(void); extern void aco_thread_init(aco_cofuncp_t last_word_co_fp); @@ -164,6 +180,7 @@ extern aco_t* aco_create( // aco's Global Thread Local Storage variable `co` extern __thread aco_t* aco_gtls_co; +aco_attr_no_asan extern void aco_resume(aco_t* resume_co); //extern void aco_yield1(aco_t* yield_co);