As explained in the release note, libc++ used to provide various global variables as an extension in C++03 mode. Unfortunately, that made our definition non-conforming in all standard modes. This was never a big problem until recently, since we are trying to support C++20 Modules in libc++, and that requires cleaning up the definition of these variables. This change is the first in a series of changes to achieve our end goal. This patch removes the ability for users to rely on the (incorrect) definition of those global variables inside the shared library. The plan is to then remove those definitions from the shared library (which is an ABI break but I don't think it will have impact), and finally to make our definition of those variables conforming in all standard modes. Differential Revision: https://reviews.llvm.org/D145422
44 lines
926 B
C++
44 lines
926 B
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// UNSUPPORTED: no-threads
|
|
// UNSUPPORTED: c++03
|
|
|
|
// <mutex>
|
|
|
|
// template <class Mutex> class lock_guard;
|
|
|
|
// lock_guard(mutex_type& m, adopt_lock_t);
|
|
|
|
#include <mutex>
|
|
#include <cstdlib>
|
|
#include <cassert>
|
|
|
|
#include "make_test_thread.h"
|
|
#include "test_macros.h"
|
|
|
|
std::mutex m;
|
|
|
|
void do_try_lock() {
|
|
assert(m.try_lock() == false);
|
|
}
|
|
|
|
int main(int, char**) {
|
|
{
|
|
m.lock();
|
|
std::lock_guard<std::mutex> lg(m, std::adopt_lock);
|
|
std::thread t = support::make_test_thread(do_try_lock);
|
|
t.join();
|
|
}
|
|
|
|
m.lock();
|
|
m.unlock();
|
|
|
|
return 0;
|
|
}
|