/** @defgroup XBT_graph General purpose graph library */
/** @defgroup XBT_parmap Parallel map */
/** @defgroup XBT_synchro Simulated Synchronization */
- /** @defgroup XBT_thread Thread stuff */
/** @defgroup XBT_context Portable context implementation */
/** @defgroup XBT_replay Replay */
/** @} */
#endif
#include <xbt/cunit.h>
-#include <xbt/xbt_os_thread.h>
#include <xbt/xbt_os_time.h>
#endif /* XBT_H */
+++ /dev/null
-/* xbt/xbt_os_thread.h -- Thread portability layer */
-
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef XBT_OS_THREAD_H
-#define XBT_OS_THREAD_H
-
-#include <xbt/base.h>
-#include <xbt/function_types.h>
-
-#include <pthread.h>
-
-SG_BEGIN_DECL()
-
-/** @addtogroup XBT_thread
- * @brief Thread portability layer
- *
- * This section describes the thread portability layer. It defines types and functions very close to the pthread API,
- * but it's portable to windows too.
- *
- * @{
- */
-
-/** @brief Thread mutex data type (opaque structure) */
-typedef struct xbt_os_mutex_ *xbt_os_mutex_t;
-XBT_PUBLIC xbt_os_mutex_t xbt_os_mutex_init(void);
-XBT_PUBLIC void xbt_os_mutex_acquire(xbt_os_mutex_t mutex);
-XBT_PUBLIC void xbt_os_mutex_release(xbt_os_mutex_t mutex);
-XBT_PUBLIC void xbt_os_mutex_destroy(xbt_os_mutex_t mutex);
-
-/** @} */
-
-SG_END_DECL()
-#endif /* XBT_OS_THREAD_H */
# Version of the used prog languages
sonar.java.source=7
-sonar.java.binaries=CMakeFiles/simgrid-java_jar.dir,examples/java
+sonar.java.binaries=CMakeFiles/simgrid-java_jar.dir,examples/deprecated/java
# Don't talk to me: travis don't like your verbosity
# sonar.verbose=true
#include "simgrid/simix.h"
#include "src/kernel/context/ContextThread.hpp"
#include "src/simix/smx_private.hpp"
-#include "xbt/xbt_os_thread.h"
#include "jmsg.hpp"
#include "src/internal_config.h" // HAVE_FUTEX_H
#include "src/kernel/context/Context.hpp"
-#include "xbt/xbt_os_thread.h"
#include <boost/optional.hpp>
#include <condition_variable>
#include <simgrid/simix.hpp>
#include <xbt/parmap.hpp>
-#include <xbt/xbt_os_thread.h>
#include "src/internal_config.h"
#include "src/kernel/context/Context.hpp"
#include <vector>
#include <xbt/parmap.hpp>
-#include <xbt/xbt_os_thread.h>
#include "src/kernel/context/ContextSwapped.hpp"
#include "src/simix/smx_private.hpp"
#include "src/xbt_modinter.h" /* prototype of os thread module's init/exit in XBT */
#include "xbt/function_types.h"
-#include "xbt/xbt_os_thread.h"
#include <functional>
#include <utility>
#include "simgrid/simix.hpp"
#include "src/kernel/context/Context.hpp"
#include "src/xbt/OsSemaphore.hpp"
-#include "xbt/xbt_os_thread.h"
#include <thread>
#include <simgrid/simix.hpp>
#include <xbt/parmap.hpp>
-#include <xbt/xbt_os_thread.h>
#include "src/internal_config.h"
#include "src/kernel/context/ContextSwapped.hpp"
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include <stdarg.h>
#include <ctype.h>
-#include <stdio.h> /* snprintf */
-#include <stdlib.h> /* snprintf */
+#include <mutex>
+#include <stdarg.h>
+#include <stdio.h> /* snprintf */
+#include <stdlib.h> /* snprintf */
#include "src/internal_config.h"
#include "src/xbt_modinter.h"
-#include "src/xbt/log_private.h"
+#include "src/xbt/log_private.hpp"
#include "xbt/asserts.h"
#include "xbt/dynar.h"
#include "xbt/ex.h"
#include "xbt/misc.h"
#include "xbt/str.h"
#include "xbt/sysdep.h"
-#include "xbt/xbt_os_thread.h"
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
int xbt_log_no_loc = 0; /* if set to true (with --log=no_loc), file localization will be omitted (for tesh tests) */
-static xbt_os_mutex_t log_cat_init_mutex = NULL;
+static std::recursive_mutex* log_cat_init_mutex = nullptr;
/** @addtogroup XBT_log
*
xbt_log_default_layout = xbt_log_layout_simple_new(NULL);
_XBT_LOGV(XBT_LOG_ROOT_CAT).appender = xbt_log_default_appender;
_XBT_LOGV(XBT_LOG_ROOT_CAT).layout = xbt_log_default_layout;
- log_cat_init_mutex = xbt_os_mutex_init();
+ log_cat_init_mutex = new std::recursive_mutex();
}
static void xbt_log_help(void);
void xbt_log_postexit(void)
{
XBT_VERB("Exiting log");
- xbt_os_mutex_destroy(log_cat_init_mutex);
+ delete log_cat_init_mutex;
xbt_dynar_free(&xbt_log_settings);
log_cat_exit(&_XBT_LOGV(XBT_LOG_ROOT_CAT));
}
xbt_log_category_t cat = ev->cat;
xbt_assert(ev->priority >= 0, "Negative logging priority naturally forbidden");
- xbt_assert(ev->priority < sizeof(xbt_log_priority_names), "Priority %d is greater than the biggest allowed value",
- ev->priority);
+ xbt_assert(static_cast<size_t>(ev->priority) < sizeof(xbt_log_priority_names)/sizeof(xbt_log_priority_names[0]),
+ "Priority %d is greater than the biggest allowed value", ev->priority);
while (1) {
xbt_log_appender_t appender = cat->appender;
/* The static buffer was too small, use a dynamically expanded one */
ev->buffer_size = XBT_LOG_DYNAMIC_BUFFER_SIZE;
- ev->buffer = xbt_malloc(ev->buffer_size);
+ ev->buffer = static_cast<char*>(xbt_malloc(ev->buffer_size));
while (1) {
va_start(ev->ap, fmt);
done = cat->layout->do_layout(cat->layout, ev, fmt);
if (done)
break; /* Got it */
ev->buffer_size *= 2;
- ev->buffer = xbt_realloc(ev->buffer, ev->buffer_size);
+ ev->buffer = static_cast<char*>(xbt_realloc(ev->buffer, ev->buffer_size));
}
appender->do_append(appender, ev->buffer);
xbt_free(ev->buffer);
{
DISABLE_XBT_LOG_CAT_INIT();
if (log_cat_init_mutex != NULL)
- xbt_os_mutex_acquire(log_cat_init_mutex);
+ log_cat_init_mutex->lock();
if (category->initialized) {
if (log_cat_init_mutex != NULL)
- xbt_os_mutex_release(log_cat_init_mutex);
+ log_cat_init_mutex->unlock();
return priority >= category->threshold;
}
category->initialized = 1;
if (log_cat_init_mutex != NULL)
- xbt_os_mutex_release(log_cat_init_mutex);
+ log_cat_init_mutex->unlock();
return priority >= category->threshold;
}
#include "swag.h"
#include "src/internal_config.h"
-#include "xbt/xbt_os_thread.h"
#include "xbt/mmalloc.h"
#include "xbt/ex.h"
#include "xbt/dynar.h"
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/internal_config.h"
-#include "src/xbt/log_private.h"
+#include "src/xbt/log_private.hpp"
#include "xbt/sysdep.h"
#include <errno.h>
#include <stdio.h>
static void free_(xbt_log_appender_t this_) {
if (this_->data != stderr)
- fclose(this_->data);
+ fclose(static_cast<FILE*>(this_->data));
}
xbt_log_appender_t xbt_log_appender_file_new(char *arg) {
static void free_append2_(xbt_log_appender_t this_)
{
- xbt_log_append2_file_t data = this_->data;
+ xbt_log_append2_file_t data = static_cast<xbt_log_append2_file_t>(this_->data);
if (data->file)
fclose(data->file);
xbt_free(data->filename);
xbt_assert(arg);
char* buf=xbt_strdup(arg);
char* sep=strchr(buf,':');
- xbt_assert(sep>0);
+ xbt_assert(sep != NULL);
data->filename=xbt_strdup(sep+1);
*sep='\0';
char *endptr;
#include "simgrid/host.h"
#include "simgrid/msg.h" /* MSG_get_clock */
-#include "src/xbt/log_private.h"
+#include "src/xbt/log_private.hpp"
#include "xbt/sysdep.h"
#include <stdio.h>
int precision = -1;
int length = -1;
- for (char* q = l->data ; *q != '\0' ; q++) {
+ for (char* q = static_cast<char*>(l->data) ; *q != '\0' ; q++) {
if (*q == '%') {
q++;
do {
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/sysdep.h"
-#include "src/xbt/log_private.h"
+#include "src/xbt/log_private.hpp"
#include "simgrid/host.h" /* sg_host_self_get_name */
#include "simgrid/msg.h" /* MSG_get_clock */
+++ /dev/null
-/* xbt_os_thread -- portability layer over the pthread API */
-/* Used in RL to get win/lin portability, and in SG when CONTEXT_THREAD */
-/* in SG, when using HAVE_UCONTEXT_CONTEXTS, xbt_os_thread_stub is used instead */
-
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include "src/internal_config.h"
-#if HAVE_PTHREAD_SETAFFINITY
-#define _GNU_SOURCE
-#include <sched.h>
-#endif
-
-#include <pthread.h>
-
-#if defined(__FreeBSD__)
-#include "pthread_np.h"
-#define cpu_set_t cpuset_t
-#endif
-
-#include <limits.h>
-#include <semaphore.h>
-#include <errno.h>
-
-#if defined(_WIN32)
-#include <windows.h>
-#elif defined(__MACH__) && defined(__APPLE__)
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#else
-#include <unistd.h>
-#endif
-
-#include "xbt/sysdep.h"
-#include "xbt/ex.h"
-#include "src/internal_config.h"
-#include "xbt/xbt_os_time.h" /* Portable time facilities */
-#include "xbt/xbt_os_thread.h" /* This module */
-#include "src/xbt_modinter.h" /* Initialization/finalization of this module */
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_sync_os, xbt, "Synchronization mechanism (OS-level)");
-
-/****** mutex related functions ******/
-typedef struct xbt_os_mutex_ {
- pthread_mutex_t m;
-} s_xbt_os_mutex_t;
-
-#include <time.h>
-#include <math.h>
-
-xbt_os_mutex_t xbt_os_mutex_init(void)
-{
- pthread_mutexattr_t Attr;
- pthread_mutexattr_init(&Attr);
- pthread_mutexattr_settype(&Attr, PTHREAD_MUTEX_RECURSIVE);
-
- xbt_os_mutex_t res = xbt_new(s_xbt_os_mutex_t, 1);
- int errcode = pthread_mutex_init(&(res->m), &Attr);
- xbt_assert(errcode==0, "pthread_mutex_init() failed: %s", strerror(errcode));
-
- return res;
-}
-
-void xbt_os_mutex_acquire(xbt_os_mutex_t mutex)
-{
- int errcode = pthread_mutex_lock(&(mutex->m));
- xbt_assert(errcode==0, "pthread_mutex_lock(%p) failed: %s", mutex, strerror(errcode));
-}
-
-void xbt_os_mutex_release(xbt_os_mutex_t mutex)
-{
- int errcode = pthread_mutex_unlock(&(mutex->m));
- xbt_assert(errcode==0, "pthread_mutex_unlock(%p) failed: %s", mutex, strerror(errcode));
-}
-
-void xbt_os_mutex_destroy(xbt_os_mutex_t mutex)
-{
- if (!mutex)
- return;
-
- int errcode = pthread_mutex_destroy(&(mutex->m));
- xbt_assert(errcode == 0, "pthread_mutex_destroy(%p) failed: %s", mutex, strerror(errcode));
- free(mutex);
-}
energy-consumption energy-ptask
io-file io-raw-storage io-file-remote
platform-properties
+ task-priority
plugin-hostload
trace_integration)
ADD_TESH_FACTORIES(tesh-msg-${x} "raw"
#!/usr/bin/env tesh
! output sort 19
-$ $SG_TEST_EXENV ${bindir:=.}/task-priority$EXEEXT ${platfdir}/small_platform.xml ${srcdir}/task-priority_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ $SG_TEST_EXENV ${bindir:=.}/task-priority$EXEEXT ${platfdir}/small_platform.xml ${srcdir:=.}/task-priority_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (1:test@Fafard) Hello! Running a task of size 7.6296e+07 with priority 1
> [ 0.000000] (2:test@Fafard) Hello! Running a task of size 7.6296e+07 with priority 2
> [ 1.500000] (2:test@Fafard) Goodbye now!
ENDIF()
if (NOT enable_memcheck AND NOT enable_address_sanitizer)
- ADD_TESH_FACTORIES(stack-overflow "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simix/stack-overflow --setenv srcdir=${CMAKE_HOME_DIRECTORY} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simix/stack-overflow stack-overflow.tesh)
+ ADD_TESH_FACTORIES(stack-overflow "ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simix/stack-overflow --setenv srcdir=${CMAKE_HOME_DIRECTORY} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simix/stack-overflow stack-overflow.tesh)
endif()
if (NOT enable_memcheck)
ADD_TESH_FACTORIES(generic-simcalls "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simix/generic-simcalls --setenv srcdir=${CMAKE_HOME_DIRECTORY} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simix/generic-simcalls generic-simcalls.tesh)
foreach (factory raw thread boost ucontext)
string (TOUPPER have_${factory}_contexts VARNAME)
+ if (release AND ${VARNAME} AND (WIN32 OR CMAKE_SYSTEM_NAME MATCHES "Darwin"))
+ SET_TESTS_PROPERTIES(stack-overflow-${factory} PROPERTIES WILL_FAIL true)
+ endif()
if (${factory} STREQUAL "thread" OR ${VARNAME})
- if (release AND (WIN32 OR CMAKE_SYSTEM_NAME MATCHES "Darwin"))
- SET_TESTS_PROPERTIES(stack-overflow-${factory} PROPERTIES WILL_FAIL true)
- endif()
ADD_TESH(tesh-simix-factory-${factory} --cfg contexts/factory:${factory} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/simix/check-defaults --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/simix/check-defaults factory_${factory}.tesh)
endif()
endforeach()
src/xbt/automaton/parserPromela.tab.hacc
src/xbt/automaton/parserPromela.yacc
src/xbt/dict_private.h
- src/xbt/log_private.h
+ src/xbt/log_private.hpp
src/xbt/mallocator_private.h
src/xbt/mmalloc/mfree.c
src/xbt/dynar.cpp
src/xbt/exception.cpp
src/xbt/graph.c
- src/xbt/log.c
+ src/xbt/log.cpp
src/xbt/mallocator.c
src/xbt/memory_map.cpp
src/xbt/memory_map.hpp
src/xbt/parmap.cpp
src/xbt/snprintf.c
src/xbt/string.cpp
- src/xbt/xbt_log_appender_file.c
- src/xbt/xbt_log_layout_format.c
- src/xbt/xbt_log_layout_simple.c
+ src/xbt/xbt_log_appender_file.cpp
+ src/xbt/xbt_log_layout_format.cpp
+ src/xbt/xbt_log_layout_simple.cpp
src/xbt/xbt_main.cpp
src/xbt/xbt_os_file.cpp
src/xbt/xbt_os_synchro.cpp
- src/xbt/xbt_os_thread.c
src/xbt/xbt_os_time.c
src/xbt/xbt_replay.cpp
src/xbt/xbt_str.cpp
include/xbt/system_error.hpp
include/xbt/utility.hpp
include/xbt/virtu.h
- include/xbt/xbt_os_thread.h
include/xbt/xbt_os_time.h
)
set(source_of_generated_headers
else()
add_custom_target(check COMMAND make test)
endif()
+add_dependencies(check tests)
#######################################
### Fill in the "make xxx-clean" target ###
foreach(s
src/kernel/lmm/fair_bottleneck.cpp src/kernel/lmm/lagrange.cpp src/kernel/lmm/maxmin.cpp
src/xbt/mmalloc/mm.c
- src/xbt/log.c src/xbt/xbt_log_appender_file.c
- src/xbt/xbt_log_layout_format.c src/xbt/xbt_log_layout_simple.c
+ src/xbt/log.cpp src/xbt/xbt_log_appender_file.cpp
+ src/xbt/xbt_log_layout_format.cpp src/xbt/xbt_log_layout_simple.cpp
src/xbt/dict.cpp src/xbt/dict_elm.c src/xbt/dict_cursor.c
src/xbt/dynar.cpp
src/xbt/xbt_str.cpp src/xbt/snprintf.c
- src/xbt/xbt_os_time.c src/xbt/xbt_os_thread.c
+ src/xbt/xbt_os_time.c
src/xbt/backtrace_linux.cpp
${MC_SRC_BASE} ${MC_SRC})
set (mcCFLAGS "-O3 -funroll-loops -fno-strict-aliasing")