Skip to content

Commit c42c725

Browse files
author
James Foster
authored
Merge pull request #303 from jgfoster/yield
Allow `yield()` to be defined in library code
2 parents 0e69d9a + 81b62b5 commit c42c725

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515
- Properly report compile errors in GitHub Actions (#296)
1616
- Put build artifacts in a separate directory to reduce clutter.
1717
- Change 266 files from CRLF to LF.
18+
- Replace `#define yield() _NOP()` with `inline void yield() { _NOP(); }` so that other code can define a `yield()` function.
1819
- Update .gitattributes so we have consistent line endings
1920
- Run tests on push as well as on a pull request so developers can see impact
2021

cpp/arduino/Arduino.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ typedef uint8_t byte;
3636
#define highByte(w) ((uint8_t) ((w) >> 8))
3737
#define lowByte(w) ((uint8_t) ((w) & 0xff))
3838

39-
// might as well use that NO-op macro for these, while unit testing
40-
// you need interrupts? interrupt yourself
41-
#define yield() _NOP()
42-
#define interrupts() _NOP()
43-
#define noInterrupts() _NOP()
39+
// using #define for these makes it impossible for other code to use as function
40+
// names!
41+
inline void yield() { _NOP(); }
42+
inline void interrupts() { _NOP(); }
43+
inline void noInterrupts() { _NOP(); }
4444

4545
// TODO: correctly establish this per-board!
4646
#define F_CPU 1000000UL

0 commit comments

Comments
 (0)