1 /* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_KERNEL_CONTEXT_PRIVATE_HPP
7 #define SIMGRID_KERNEL_CONTEXT_PRIVATE_HPP
9 #include "src/internal_config.h"
11 #if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT
12 #include <sanitizer/asan_interface.h>
13 #define ASAN_ONLY(expr) expr
14 #define ASAN_START_SWITCH(fake_stack_save, bottom, size) __sanitizer_start_switch_fiber(fake_stack_save, bottom, size)
15 #define ASAN_FINISH_SWITCH(fake_stack_save, bottom_old, size_old) \
16 __sanitizer_finish_switch_fiber(fake_stack_save, bottom_old, size_old)
18 #define ASAN_ONLY(expr) (void)0
19 #define ASAN_START_SWITCH(fake_stack_save, bottom, size) (void)0
20 #define ASAN_FINISH_SWITCH(fake_stack_save, bottom_old, size_old) (void)0
23 /* We are using the bottom of the stack to save some information, like the
24 * valgrind_stack_id. Define smx_context_usable_stack_size to give the remaining
25 * size for the stack. Round its value to a multiple of 16 (asan wants the stacks to be aligned this way). */
27 #define smx_context_usable_stack_size \
28 ((smx_context_stack_size - sizeof(unsigned int)) & ~0xf) /* for valgrind_stack_id */
30 #define smx_context_usable_stack_size (smx_context_stack_size & ~0xf)