CHECK_FUNCTION_EXISTS(getdtablesize HAVE_GETDTABLESIZE)
CHECK_FUNCTION_EXISTS(sysconf HAVE_SYSCONF)
CHECK_FUNCTION_EXISTS(popen HAVE_POPEN)
+CHECK_FUNCTION_EXISTS(process_vm_readv HAVE_PROCESS_VM_READV)
+CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP)
CHECK_SYMBOL_EXISTS(vasprintf stdio.h HAVE_VASPRINTF)
if(MINGW)
set(HAVE_VASPRINTF 1)
endif()
-CHECK_FUNCTION_EXISTS(process_vm_readv HAVE_PROCESS_VM_READV)
-CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP)
#Check if __thread is defined
execute_process(
if(NOT CMAKE_CROSSCOMPILING)
try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR
- ${CMAKE_BINARY_DIR}
- ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_stacksetup.c
+ ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_stacksetup.c
+ RUN_OUTPUT_VARIABLE stack_setup
COMPILE_DEFINITIONS "${makecontext_CPPFLAGS}"
)
endif()
- if(EXISTS ${CMAKE_BINARY_DIR}/conftestval)
- file(READ ${CMAKE_BINARY_DIR}/conftestval MAKECONTEXT_ADDR_SIZE)
- string(REPLACE "\n" "" MAKECONTEXT_ADDR_SIZE "${MAKECONTEXT_ADDR_SIZE}")
- string(REGEX MATCH ;^.*,;MAKECONTEXT_ADDR "${MAKECONTEXT_ADDR_SIZE}")
- string(REGEX MATCH ;,.*$; MAKECONTEXT_SIZE "${MAKECONTEXT_ADDR_SIZE}")
- string(REPLACE "," "" makecontext_addr "${MAKECONTEXT_ADDR}")
- string(REPLACE "," "" makecontext_size "${MAKECONTEXT_SIZE}")
- set(pth_skaddr_makecontext "#define pth_skaddr_makecontext(skaddr,sksize) (${makecontext_addr})")
- set(pth_sksize_makecontext "#define pth_sksize_makecontext(skaddr,sksize) (${makecontext_size})")
+ LIST(LENGTH stack_setup stack_setup_len)
+ if("${stack_setup_len}" STREQUAL "2")
+ LIST(GET stack_setup 0 makecontext_addr)
+ LIST(GET stack_setup 1 makecontext_size)
+ set(sg_makecontext_stack_addr "#define sg_makecontext_stack_addr(skaddr) (${makecontext_addr})")
+ set(sg_makecontext_stack_size "#define sg_makecontext_stack_size(sksize) (${makecontext_size})")
+ else()
+ message(FATAL_ERROR "Could not figure out the stack setup. Compil: ${RUN_makecontext_VAR}. Exec: ${COMPILE_makecontext_VAR}. Output: ${stack_setup}")
endif()
endif()
* Makecontext expects integer arguments, we the context
* variable is decomposed into a serie of integers and
* each integer is passed as argument to makecontext. */
-static
-void simgrid_makecontext(ucontext_t* ucp, void (*func)(int first, ...), void* arg)
+static void simgrid_makecontext(ucontext_t* ucp, void (*func)(int first, ...), void* arg)
{
int ctx_addr[CTX_ADDR_LEN];
memcpy(ctx_addr, &arg, sizeof(void*));
makecontext(ucp, (void (*)()) func, 2, ctx_addr[0], ctx_addr[1]);
break;
default:
- xbt_die("Ucontexts are not supported on this arch yet (addr len = %zu/%zu = %zu)",
- sizeof(void*), sizeof(int), CTX_ADDR_LEN);
+ xbt_die("Ucontexts are not supported on this arch yet (addr len = %zu/%zu = %zu)", sizeof(void*), sizeof(int), CTX_ADDR_LEN);
}
}
void_pfn_smxprocess_t cleanup_func, smx_process_t process)
: Context(std::move(code), cleanup_func, process)
{
- /* if the user provided a function for the process then use it,
- otherwise it is the context for maestro */
+ /* if the user provided a function for the process then use it, otherwise it is the context for maestro */
if (has_code()) {
this->stack_ = (char*) SIMIX_context_stack_new();
getcontext(&this->uc_);
this->uc_.uc_link = nullptr;
- this->uc_.uc_stack.ss_sp = pth_skaddr_makecontext(
- this->stack_, smx_context_usable_stack_size);
- this->uc_.uc_stack.ss_size = pth_sksize_makecontext(
- this->stack_, smx_context_usable_stack_size);
+ this->uc_.uc_stack.ss_sp = sg_makecontext_stack_addr(this->stack_);
+ this->uc_.uc_stack.ss_size = sg_makecontext_stack_size(smx_context_usable_stack_size);
simgrid_makecontext(&this->uc_, smx_ctx_sysv_wrapper, this);
} else {
if (process != NULL && sysv_maestro_context == NULL)
#cmakedefine PROCESSOR_x86_64 @PROCESSOR_x86_64@
#cmakedefine CMAKE_SYSTEM_PROCESSOR @CMAKE_SYSTEM_PROCESSOR@
-/* Variables for the ucontexts */
-@pth_skaddr_makecontext@
-@pth_sksize_makecontext@
+/* Variables for the SysV contexts */
+@sg_makecontext_stack_addr@
+@sg_makecontext_stack_size@
+#cmakedefine PTH_STACKGROWTH @PTH_STACKGROWTH@ /* Does the stack growth upward, or downward? */
/* MC variables */
#cmakedefine HAVE_GETDTABLESIZE @HAVE_GETDTABLESIZE@ /* getdtablesize: get descriptor table size */
/* Other checks */
#cmakedefine ADDR2LINE "@ADDR2LINE@" /* Path to the addr2line tool */
#cmakedefine HAVE_GRAPHVIZ @HAVE_GRAPHVIZ@ /* The graphviz library */
-#cmakedefine PTH_STACKGROWTH @PTH_STACKGROWTH@ /* Does the stack growth upward, or downward? */
int main(int argc, char *argv[])
{
- FILE *f;
- char result[1024];
int sksize = 32768;
char *skbuf = (char *) malloc(sksize * 2 + 2 * sizeof(union alltypes));
if (skbuf == NULL)
if (handler_addr < skaddr + sksize) {
/* stack was placed into lower area */
if (*(skaddr + sksize) != 'A')
- sprintf(result, "(skaddr)+(sksize)-%d,(sksize)-%d", sizeof(union alltypes), sizeof(union alltypes));
+ printf("(skaddr)+(sksize)-%d;(sksize)-%d", sizeof(union alltypes), sizeof(union alltypes));
else
- strcpy(result, "(skaddr)+(sksize),(sksize)");
+ printf("(skaddr)+(sksize);(sksize)");
} else {
/* stack was placed into higher area */
if (*(skaddr + sksize * 2) != 'A')
- sprintf(result, "(skaddr),(sksize)-%d", sizeof(union alltypes));
+ printf("(skaddr);(sksize)-%d", sizeof(union alltypes));
else
- strcpy(result, "(skaddr),(sksize)");
+ printf("(skaddr);(sksize)");
}
- if ((f = fopen("conftestval", "w")) == NULL)
- exit(1);
- fprintf(f, "%s\n", result);
- fclose(f);
- exit(0);
- return 1;
+ return 0;
}