From dfb4e2167c0963c8528f9534aa86816a1ec14e47 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 16 Jan 2019 17:36:54 +0100 Subject: [PATCH] Drop xbt_os_mutex_* functions. --- doc/doxygen/module-xbt.doc | 1 - include/xbt.h | 1 - include/xbt/xbt_os_thread.h | 35 ------------ src/bindings/java/JavaContext.hpp | 1 - src/include/xbt/parmap.hpp | 1 - src/kernel/context/ContextBoost.hpp | 1 - src/kernel/context/ContextRaw.hpp | 1 - src/kernel/context/ContextThread.cpp | 1 - src/kernel/context/ContextThread.hpp | 1 - src/kernel/context/ContextUnix.hpp | 1 - src/xbt/xbt_os_thread.c | 82 ---------------------------- tools/cmake/DefinePackages.cmake | 2 - tools/cmake/Flags.cmake | 2 +- 13 files changed, 1 insertion(+), 129 deletions(-) delete mode 100644 include/xbt/xbt_os_thread.h delete mode 100644 src/xbt/xbt_os_thread.c diff --git a/doc/doxygen/module-xbt.doc b/doc/doxygen/module-xbt.doc index 6a0c84635b..c9b0295445 100644 --- a/doc/doxygen/module-xbt.doc +++ b/doc/doxygen/module-xbt.doc @@ -77,7 +77,6 @@ /** @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 */ /** @} */ diff --git a/include/xbt.h b/include/xbt.h index 8e603dbaa8..557b45f7bd 100644 --- a/include/xbt.h +++ b/include/xbt.h @@ -29,7 +29,6 @@ #endif #include -#include #include #endif /* XBT_H */ diff --git a/include/xbt/xbt_os_thread.h b/include/xbt/xbt_os_thread.h deleted file mode 100644 index a1c4de9697..0000000000 --- a/include/xbt/xbt_os_thread.h +++ /dev/null @@ -1,35 +0,0 @@ -/* 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 -#include - -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 */ diff --git a/src/bindings/java/JavaContext.hpp b/src/bindings/java/JavaContext.hpp index 47fe472983..108b2f2f59 100644 --- a/src/bindings/java/JavaContext.hpp +++ b/src/bindings/java/JavaContext.hpp @@ -14,7 +14,6 @@ #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" diff --git a/src/include/xbt/parmap.hpp b/src/include/xbt/parmap.hpp index b82c126914..fc8f6da80b 100644 --- a/src/include/xbt/parmap.hpp +++ b/src/include/xbt/parmap.hpp @@ -10,7 +10,6 @@ #include "src/internal_config.h" // HAVE_FUTEX_H #include "src/kernel/context/Context.hpp" -#include "xbt/xbt_os_thread.h" #include #include diff --git a/src/kernel/context/ContextBoost.hpp b/src/kernel/context/ContextBoost.hpp index a23d96b55f..99dad30f29 100644 --- a/src/kernel/context/ContextBoost.hpp +++ b/src/kernel/context/ContextBoost.hpp @@ -20,7 +20,6 @@ #include #include -#include #include "src/internal_config.h" #include "src/kernel/context/Context.hpp" diff --git a/src/kernel/context/ContextRaw.hpp b/src/kernel/context/ContextRaw.hpp index b966a153f9..89e72bc46b 100644 --- a/src/kernel/context/ContextRaw.hpp +++ b/src/kernel/context/ContextRaw.hpp @@ -12,7 +12,6 @@ #include #include -#include #include "src/kernel/context/ContextSwapped.hpp" diff --git a/src/kernel/context/ContextThread.cpp b/src/kernel/context/ContextThread.cpp index b78153fc4a..a3c60882e0 100644 --- a/src/kernel/context/ContextThread.cpp +++ b/src/kernel/context/ContextThread.cpp @@ -10,7 +10,6 @@ #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 #include diff --git a/src/kernel/context/ContextThread.hpp b/src/kernel/context/ContextThread.hpp index 0dfc83b44f..4c76ae2e38 100644 --- a/src/kernel/context/ContextThread.hpp +++ b/src/kernel/context/ContextThread.hpp @@ -11,7 +11,6 @@ #include "simgrid/simix.hpp" #include "src/kernel/context/Context.hpp" #include "src/xbt/OsSemaphore.hpp" -#include "xbt/xbt_os_thread.h" #include diff --git a/src/kernel/context/ContextUnix.hpp b/src/kernel/context/ContextUnix.hpp index 350a87cd03..211da7e48c 100644 --- a/src/kernel/context/ContextUnix.hpp +++ b/src/kernel/context/ContextUnix.hpp @@ -15,7 +15,6 @@ #include #include -#include #include "src/internal_config.h" #include "src/kernel/context/ContextSwapped.hpp" diff --git a/src/xbt/xbt_os_thread.c b/src/xbt/xbt_os_thread.c deleted file mode 100644 index e7a5c990a1..0000000000 --- a/src/xbt/xbt_os_thread.c +++ /dev/null @@ -1,82 +0,0 @@ -/* 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 -#endif - -#include - -#include -#include -#include - -#if defined(_WIN32) -#include -#elif defined(__MACH__) && defined(__APPLE__) -#include -#include -#include -#else -#include -#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 -#include - -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); -} diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 584ff4ce18..ac60b023ad 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -292,7 +292,6 @@ set(XBT_SRC 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 @@ -780,7 +779,6 @@ set(headers_to_install 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 diff --git a/tools/cmake/Flags.cmake b/tools/cmake/Flags.cmake index 653f50d61b..f2e828e87b 100644 --- a/tools/cmake/Flags.cmake +++ b/tools/cmake/Flags.cmake @@ -157,7 +157,7 @@ if(enable_model-checking AND enable_compile_optimizations) 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") -- 2.20.1