llvm-project/openmp/runtime/src/z_Windows_NT-586_util.cpp
Chandler Carruth 57b08b0944 Update more file headers across all of the LLVM projects in the monorepo
to reflect the new license. These used slightly different spellings that
defeated my regular expressions.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351648
2019-01-19 10:56:40 +00:00

136 lines
3.5 KiB
C++

/*
* z_Windows_NT-586_util.cpp -- platform specific routines.
*/
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
#include "kmp.h"
#if (KMP_ARCH_X86 || KMP_ARCH_X86_64)
/* Only 32-bit "add-exchange" instruction on IA-32 architecture causes us to
use compare_and_store for these routines */
kmp_int8 __kmp_test_then_or8(volatile kmp_int8 *p, kmp_int8 d) {
kmp_int8 old_value, new_value;
old_value = TCR_1(*p);
new_value = old_value | d;
while (!__kmp_compare_and_store8(p, old_value, new_value)) {
KMP_CPU_PAUSE();
old_value = TCR_1(*p);
new_value = old_value | d;
}
return old_value;
}
kmp_int8 __kmp_test_then_and8(volatile kmp_int8 *p, kmp_int8 d) {
kmp_int8 old_value, new_value;
old_value = TCR_1(*p);
new_value = old_value & d;
while (!__kmp_compare_and_store8(p, old_value, new_value)) {
KMP_CPU_PAUSE();
old_value = TCR_1(*p);
new_value = old_value & d;
}
return old_value;
}
kmp_uint32 __kmp_test_then_or32(volatile kmp_uint32 *p, kmp_uint32 d) {
kmp_uint32 old_value, new_value;
old_value = TCR_4(*p);
new_value = old_value | d;
while (!__kmp_compare_and_store32((volatile kmp_int32 *)p, old_value,
new_value)) {
KMP_CPU_PAUSE();
old_value = TCR_4(*p);
new_value = old_value | d;
}
return old_value;
}
kmp_uint32 __kmp_test_then_and32(volatile kmp_uint32 *p, kmp_uint32 d) {
kmp_uint32 old_value, new_value;
old_value = TCR_4(*p);
new_value = old_value & d;
while (!__kmp_compare_and_store32((volatile kmp_int32 *)p, old_value,
new_value)) {
KMP_CPU_PAUSE();
old_value = TCR_4(*p);
new_value = old_value & d;
}
return old_value;
}
kmp_int8 __kmp_test_then_add8(volatile kmp_int8 *p, kmp_int8 d) {
kmp_int64 old_value, new_value;
old_value = TCR_1(*p);
new_value = old_value + d;
while (!__kmp_compare_and_store8(p, old_value, new_value)) {
KMP_CPU_PAUSE();
old_value = TCR_1(*p);
new_value = old_value + d;
}
return old_value;
}
#if KMP_ARCH_X86
kmp_int64 __kmp_test_then_add64(volatile kmp_int64 *p, kmp_int64 d) {
kmp_int64 old_value, new_value;
old_value = TCR_8(*p);
new_value = old_value + d;
while (!__kmp_compare_and_store64(p, old_value, new_value)) {
KMP_CPU_PAUSE();
old_value = TCR_8(*p);
new_value = old_value + d;
}
return old_value;
}
#endif /* KMP_ARCH_X86 */
kmp_uint64 __kmp_test_then_or64(volatile kmp_uint64 *p, kmp_uint64 d) {
kmp_uint64 old_value, new_value;
old_value = TCR_8(*p);
new_value = old_value | d;
while (!__kmp_compare_and_store64((volatile kmp_int64 *)p, old_value,
new_value)) {
KMP_CPU_PAUSE();
old_value = TCR_8(*p);
new_value = old_value | d;
}
return old_value;
}
kmp_uint64 __kmp_test_then_and64(volatile kmp_uint64 *p, kmp_uint64 d) {
kmp_uint64 old_value, new_value;
old_value = TCR_8(*p);
new_value = old_value & d;
while (!__kmp_compare_and_store64((volatile kmp_int64 *)p, old_value,
new_value)) {
KMP_CPU_PAUSE();
old_value = TCR_8(*p);
new_value = old_value & d;
}
return old_value;
}
#endif /* KMP_ARCH_X86 || KMP_ARCH_X86_64 */