Skip to content
Snippets Groups Projects
Commit 9bf49f03 authored by Nadav Har'El's avatar Nadav Har'El
Browse files

Add constructor to spinlock (in C++)

Added constructor to the "spinlock" type (#include <osv/mutex.h>) when
used from C++. This makes it easier to use this type from C++.

Marked constructor as "constexpr" to allow the object to be constructed
in compile time (e.g., a global spinlock variable can be initialized in
bss). Thanks Avi for this trick!
parent 6bc2a896
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,7 @@ typedef struct spinlock { ...@@ -14,6 +14,7 @@ typedef struct spinlock {
bool _lock; bool _lock;
#ifdef __cplusplus #ifdef __cplusplus
// additional convenience methods for C++ // additional convenience methods for C++
inline constexpr spinlock() : _lock(false) { }
inline void lock(); inline void lock();
inline void unlock(); inline void unlock();
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment