Skip to content

Commit e951a88

Browse files
committed
dd unit test, comment out one more forgotten intrinsic function
1 parent 6759dd1 commit e951a88

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <ArduinoUnitTests.h>
2+
#include <Arduino.h>
3+
#include <util/atomic.h>
4+
5+
6+
unittest(atomic)
7+
{
8+
// The macros don't do anything on the host platform, just make sure
9+
// they compile without error.
10+
11+
int a = 1;
12+
int b = 2;
13+
14+
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
15+
a += b;
16+
b++;
17+
}
18+
19+
ATOMIC_BLOCK(ATOMIC_FORCEON) {
20+
a += b;
21+
b++;
22+
}
23+
24+
NONATOMIC_BLOCK(NONATOMIC_RESTORESTATE) {
25+
a += b;
26+
b++;
27+
}
28+
29+
NONATOMIC_BLOCK(NONATOMIC_FORCEOFF) {
30+
a += b;
31+
b++;
32+
}
33+
34+
assertEqual(a, 15);
35+
assertEqual(b, 6);
36+
}
37+
38+
39+
unittest_main()

cpp/arduino/util/atomic.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
/* Internal helper functions. */
4343
static __inline__ uint8_t __iSeiRetVal(void)
4444
{
45-
sei();
45+
// Just do nothing
46+
//sei();
4647
return 1;
4748
}
4849

0 commit comments

Comments
 (0)