Skip to content
Snippets Groups Projects
Commit 6f490584 authored by rswindell's avatar rswindell
Browse files

Define protected_int_value() macros to perform a thread-safe read of the

current protected-interger value.
parent e129b164
Branches
Tags
No related merge requests found
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* * * *
* Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html * * Copyright 2014 Rob Swindell - http://www.synchro.net/copyright.html *
* * * *
* This library is free software; you can redistribute it and/or * * This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
...@@ -169,9 +169,13 @@ int protected_int64_init(protected_int64_t*, int64_t value); ...@@ -169,9 +169,13 @@ int protected_int64_init(protected_int64_t*, int64_t value);
/* Return new value: */ /* Return new value: */
int32_t protected_int32_adjust(protected_int32_t*, int32_t adjustment); int32_t protected_int32_adjust(protected_int32_t*, int32_t adjustment);
#define protected_int32_value(i) protected_int32_adjust(&i,0)
uint32_t protected_uint32_adjust(protected_uint32_t*,int32_t adjustment); uint32_t protected_uint32_adjust(protected_uint32_t*,int32_t adjustment);
#define protected_uint32_value(i) protected_uint32_adjust(&i,0)
int64_t protected_int64_adjust(protected_int64_t*, int64_t adjustment); int64_t protected_int64_adjust(protected_int64_t*, int64_t adjustment);
#define protected_int64_value(i) protected_int64_adjust(&i,0)
uint64_t protected_uint64_adjust(protected_uint64_t*,int64_t adjustment); uint64_t protected_uint64_adjust(protected_uint64_t*,int64_t adjustment);
#define protected_uint64_value(i) protected_uint64_adjust(&i,0)
/* Return 0 on success, non-zero on failure (see pthread_mutex_destroy): */ /* Return 0 on success, non-zero on failure (see pthread_mutex_destroy): */
#define protected_int32_destroy(i) pthread_mutex_destroy(&i.mutex) #define protected_int32_destroy(i) pthread_mutex_destroy(&i.mutex)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment