annotate test/test.cc @ 17:41dd962abdd1

*: allow compiling vec in a C++ translation unit this is stupid, but whatever
author Paper <paper@tflc.us>
date Wed, 20 Nov 2024 12:02:15 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
1 #define VEC_IMPLEMENTATION
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
2 #include "vec/vec.h"
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
3
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
4 #include <iostream>
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
5
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
6 /* this test makes sure that vec can be included under C++ */
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
7 int main(void)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
8 {
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
9 int ret = 0;
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
10
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
11 VUINT32x8_ALIGNED_ARRAY(varrin);
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
12 VUINT32x8_ALIGNED_ARRAY(varrout);
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
13
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
14 for (int i = 0; i < 8; i++)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
15 varrin[i] = i;
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
16
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
17 vuint32x8 vec = vuint32x8_load_aligned(varrin);
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
18 vec = vuint32x8_add(vec, vec);
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
19
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
20 vuint32x8_store_aligned(vec, varrout);
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
21
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
22 for (int i = 0; i < 8; i++)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
23 if (varrout[i] != (uint32_t)(varrin[i] + varrin[i]))
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
24 ret |= 1;
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
25
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
26 return ret;
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents:
diff changeset
27 }