Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-12-04 18:25:49 +0300
committerJulian Eisel <julian@blender.org>2020-12-04 18:57:32 +0300
commit67b48290853a9d7e8f92764a6a3938c3a804c294 (patch)
tree2e2a855feec81f1528739ffebc5705093452dbc1 /intern/atomic/tests/atomic_test.cc
parentd07009498ac36d067fbccd61cfbcd51d4e2ba310 (diff)
Atomics: Add 16 bit fetch + AND and fetch + OR signed integer operationstemp-atomics-int16
I could use a 16 bit atomic fetch + AND for D9719. The alternative would be to turn a `short` into a `int` in DNA, which isn't a nice workaround. Also adds tests for the new functions.
Diffstat (limited to 'intern/atomic/tests/atomic_test.cc')
-rw-r--r--intern/atomic/tests/atomic_test.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/intern/atomic/tests/atomic_test.cc b/intern/atomic/tests/atomic_test.cc
index 6178b5074a7..661c130c65d 100644
--- a/intern/atomic/tests/atomic_test.cc
+++ b/intern/atomic/tests/atomic_test.cc
@@ -559,6 +559,39 @@ TEST(atomic, atomic_fetch_and_and_int32)
/** \} */
+/** \name 16 bit signed int atomics
+ * \{ */
+
+TEST(atomic, atomic_fetch_and_or_int16)
+{
+ {
+ int16_t value = 12;
+ EXPECT_EQ(atomic_fetch_and_or_int16(&value, 5), 12);
+ EXPECT_EQ(value, 13);
+ }
+
+ {
+ int16_t value = 0x1234;
+ EXPECT_EQ(atomic_fetch_and_or_int16(&value, -0x5678), 0x1234);
+ EXPECT_EQ(value, -0x4444);
+ }
+}
+
+TEST(atomic, atomic_fetch_and_and_int16)
+{
+ {
+ int16_t value = 12;
+ EXPECT_EQ(atomic_fetch_and_and_int16(&value, 5), 12);
+ EXPECT_EQ(value, 4);
+ }
+
+ {
+ int16_t value = 0x1234;
+ EXPECT_EQ(atomic_fetch_and_and_int16(&value, -0x789A), 0x1234);
+ EXPECT_EQ(value, 0x224);
+ }
+}
+
/** \name 8 bit unsigned int atomics
* \{ */