From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- .../log/config/pthread-mutex-robust/Jamfile.jam | 19 +++++++++++ .../pthread-mutex-robust/pthread_mutex_robust.cpp | 37 ++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/boost/libs/log/config/pthread-mutex-robust/Jamfile.jam create mode 100644 src/boost/libs/log/config/pthread-mutex-robust/pthread_mutex_robust.cpp (limited to 'src/boost/libs/log/config/pthread-mutex-robust') diff --git a/src/boost/libs/log/config/pthread-mutex-robust/Jamfile.jam b/src/boost/libs/log/config/pthread-mutex-robust/Jamfile.jam new file mode 100644 index 00000000..6082e66e --- /dev/null +++ b/src/boost/libs/log/config/pthread-mutex-robust/Jamfile.jam @@ -0,0 +1,19 @@ +# +# Copyright Andrey Semashev 2015. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +# + +import project ; +import log-platform-config ; + +project /boost/log/pthread-mutex-robust + : source-location . + : requirements + @log-platform-config.set-platform-defines + + off + ; + +obj pthread_mutex_robust : pthread_mutex_robust.cpp ; diff --git a/src/boost/libs/log/config/pthread-mutex-robust/pthread_mutex_robust.cpp b/src/boost/libs/log/config/pthread-mutex-robust/pthread_mutex_robust.cpp new file mode 100644 index 00000000..36415aca --- /dev/null +++ b/src/boost/libs/log/config/pthread-mutex-robust/pthread_mutex_robust.cpp @@ -0,0 +1,37 @@ +/* + * Copyright Andrey Semashev 2015. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + +#include +#include + +int main(int, char*[]) +{ + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); + pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); + pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST); + + pthread_mutex_t m; + pthread_mutex_init(&m, &attr); + pthread_mutexattr_destroy(&attr); + + int err = pthread_mutex_lock(&m); + if (err == EOWNERDEAD) + { + err = pthread_mutex_consistent(&m); + } + + if (err != ENOTRECOVERABLE) + { + pthread_mutex_unlock(&m); + } + + pthread_mutex_destroy(&m); + + return 0; +} -- cgit v1.2.3