Skip to content

Commit

Permalink
BadMutex: add versioning.
Browse files Browse the repository at this point in the history
  • Loading branch information
torque committed Mar 2, 2015
1 parent 714ef07 commit 837f88e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions bad-mutex/BadMutex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class BadMutex {
public:
const static unsigned int version = 0x000100;
static BadMutex& getInstance( void );
void lock( void );
void unlock( void );
Expand Down
7 changes: 7 additions & 0 deletions bad-mutex/BadMutex.moon
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ for path in *libraryPaths

assert success, BM

BMVersion = 0x000100
libVer = BM.version!
if libVer < BMVersion or math.floor(libVer/65536%256) > math.floor(BMVersion/65536%256)
error "Library version mismatch. Wanted #{BMVersion}, got #{libVer}."

return {
lock: ->
BM.lock!
Expand All @@ -23,4 +28,6 @@ return {

unlock: ->
BM.unlock!

version: 0x000100
}
4 changes: 4 additions & 0 deletions bad-mutex/BadMutexC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ extern "C" {
EXPORT void unlock( void ) {
BadMutex::getInstance().unlock();
}

EXPORT unsigned int version( void ) {
return BadMutex::version;
}
}
1 change: 1 addition & 0 deletions bad-mutex/BadMutexC.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extern "C" {
EXPORT void lock( void );
EXPORT bool try_lock( void );
EXPORT void unlock( void );
EXPORT unsigned int version( void );

#ifdef __cplusplus
}
Expand Down

0 comments on commit 837f88e

Please sign in to comment.