Skip to content

Commit 0053f5e

Browse files
committed
add a global C config macro ACO_USE_ASAN which could enable the friendly support of address sanitizer (both gcc and clang)
1 parent fe45b30 commit 0053f5e

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

aco.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,7 @@ aco_t* aco_create(
358358
assert(0);
359359
}
360360

361-
#if defined(__has_feature)
362-
#if __has_feature(address_sanitizer)
363-
__attribute__((no_sanitize_address))
364-
#endif
365-
#endif
361+
aco_attr_no_asan
366362
void aco_resume(aco_t* resume_co){
367363
assert(resume_co != NULL && resume_co->main_co != NULL
368364
&& resume_co->is_end == 0

aco.h

+17
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,22 @@ struct aco_s{
136136
} \
137137
} while(0)
138138

139+
#if defined(ACO_USE_ASAN)
140+
#if defined(__has_feature)
141+
#if __has_feature(address_sanitizer)
142+
#define aco_attr_no_asan \
143+
__attribute__((__no_sanitize_address__))
144+
#endif
145+
#endif
146+
#if defined(__SANITIZE_ADDRESS__) && !defined(aco_attr_no_asan)
147+
#define aco_attr_no_asan \
148+
__attribute__((__no_sanitize_address__))
149+
#endif
150+
#endif
151+
#ifndef aco_attr_no_asan
152+
#define aco_attr_no_asan
153+
#endif
154+
139155
extern void aco_runtime_test(void);
140156

141157
extern void aco_thread_init(aco_cofuncp_t last_word_co_fp);
@@ -164,6 +180,7 @@ extern aco_t* aco_create(
164180
// aco's Global Thread Local Storage variable `co`
165181
extern __thread aco_t* aco_gtls_co;
166182

183+
aco_attr_no_asan
167184
extern void aco_resume(aco_t* resume_co);
168185

169186
//extern void aco_yield1(aco_t* yield_co);

0 commit comments

Comments
 (0)