CHECK_FUNCTION_EXISTS(makecontext HAVE_MAKECONTEXT)
CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP)
CHECK_FUNCTION_EXISTS(process_vm_readv HAVE_PROCESS_VM_READV)
+CHECK_FUNCTION_EXISTS(strdup SIMGRID_HAVE_STRDUP)
+CHECK_FUNCTION_EXISTS(_strdup SIMGRID_HAVE__STRDUP)
#Check if __thread is defined
execute_process(
/* If Model-Checking support was requested */
#cmakedefine HAVE_MC @HAVE_MC@
+#cmakedefine SIMGRID_HAVE_STRDUP @SIMGRID_HAVE_STRDUP@
+#cmakedefine SIMGRID_HAVE__STRDUP @SIMGRID_HAVE__STRDUP@
+
SG_END_DECL()
#endif /* SIMGRID_PUBLIC_CONFIG_H */
{
char *res = NULL;
if (s) {
+# if defined(SIMGRID_HAVE_STRDUP)
res = strdup(s);
+# elif defined(SIMGRID_HAVE__STRDUP)
+ res = _strdup(s);
+# else
+ size_t len = strlen(s);
+ res = malloc(len + 1);
+ if (res)
+ memcpy(res, s, len + 1);
+# endif
if (!res)
xbt_die("memory allocation error (strdup returned NULL)");
}
return res;
}
#else /* non __GNUC__ */
-# define xbt_strdup(s) strdup(s)
+# if defined(SIMGRID_HAVE_STRDUP)
+# define xbt_strdup(s) strdup(s)
+# elif defined(SIMGRID_HAVE__STRDUP
+# define xbt_strdup(s) _strdup(s)
+# else
+# error Missing strdup
+# endif
# define xbt_malloc(n) malloc(n)
# define xbt_malloc0(n) calloc(n,1)
# define xbt_realloc(p,s) realloc(p,s)