Skip to content

Commit 837f88e

Browse files
committed
BadMutex: add versioning.
1 parent 714ef07 commit 837f88e

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

bad-mutex/BadMutex.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
class BadMutex {
66
public:
7+
const static unsigned int version = 0x000100;
78
static BadMutex& getInstance( void );
89
void lock( void );
910
void unlock( void );

bad-mutex/BadMutex.moon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ for path in *libraryPaths
1414

1515
assert success, BM
1616

17+
BMVersion = 0x000100
18+
libVer = BM.version!
19+
if libVer < BMVersion or math.floor(libVer/65536%256) > math.floor(BMVersion/65536%256)
20+
error "Library version mismatch. Wanted #{BMVersion}, got #{libVer}."
21+
1722
return {
1823
lock: ->
1924
BM.lock!
@@ -23,4 +28,6 @@ return {
2328

2429
unlock: ->
2530
BM.unlock!
31+
32+
version: 0x000100
2633
}

bad-mutex/BadMutexC.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ extern "C" {
1313
EXPORT void unlock( void ) {
1414
BadMutex::getInstance().unlock();
1515
}
16+
17+
EXPORT unsigned int version( void ) {
18+
return BadMutex::version;
19+
}
1620
}

bad-mutex/BadMutexC.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern "C" {
1414
EXPORT void lock( void );
1515
EXPORT bool try_lock( void );
1616
EXPORT void unlock( void );
17+
EXPORT unsigned int version( void );
1718

1819
#ifdef __cplusplus
1920
}

0 commit comments

Comments
 (0)