| 1 |
|
| 2 |
// Copyright (c) 2003-2019 Xsens Technologies B.V. or subsidiaries worldwide. |
| 3 |
// All rights reserved. |
| 4 |
// |
| 5 |
// Redistribution and use in source and binary forms, with or without modification, |
| 6 |
// are permitted provided that the following conditions are met: |
| 7 |
// |
| 8 |
// 1. Redistributions of source code must retain the above copyright notice, |
| 9 |
// this list of conditions, and the following disclaimer. |
| 10 |
// |
| 11 |
// 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 |
// this list of conditions, and the following disclaimer in the documentation |
| 13 |
// and/or other materials provided with the distribution. |
| 14 |
// |
| 15 |
// 3. Neither the names of the copyright holders nor the names of their contributors |
| 16 |
// may be used to endorse or promote products derived from this software without |
| 17 |
// specific prior written permission. |
| 18 |
// |
| 19 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
| 20 |
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 21 |
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
| 22 |
// THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 |
// SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
| 24 |
// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 25 |
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR |
| 26 |
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 27 |
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS |
| 28 |
// SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES |
| 29 |
// OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE |
| 30 |
// ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES. |
| 31 |
// |
| 32 |
|
| 33 |
#include "xsdebugcounters.h" |
| 34 |
#include <atomic> |
| 35 |
|
| 36 |
#ifdef XSENS_USE_DEBUG_COUNTERS |
| 37 |
volatile std::atomic_int XsVector_allocCount_value(0); |
| 38 |
volatile std::atomic_int XsVector_freeCount_value(0); |
| 39 |
|
| 40 |
volatile std::atomic_int XsMatrix_allocCount_value(0); |
| 41 |
volatile std::atomic_int XsMatrix_freeCount_value(0); |
| 42 |
|
| 43 |
volatile std::atomic_int XsArray_allocCount_value(0); |
| 44 |
volatile std::atomic_int XsArray_freeCount_value(0); |
| 45 |
|
| 46 |
extern "C" |
| 47 |
{ |
| 48 |
|
| 49 |
int XsVector_resetDebugCounts() |
| 50 |
{ |
| 51 |
return XsVector_allocCount_value.exchange(0) + XsVector_freeCount_value.exchange(0); |
| 52 |
} |
| 53 |
|
| 54 |
int XsVector_allocCount() |
| 55 |
{ |
| 56 |
return XsVector_allocCount_value.load(); |
| 57 |
} |
| 58 |
|
| 59 |
int XsVector_freeCount() |
| 60 |
{ |
| 61 |
return XsVector_freeCount_value.load(); |
| 62 |
} |
| 63 |
|
| 64 |
int XsVector_incAllocCount() |
| 65 |
{ |
| 66 |
return ++XsVector_allocCount_value; |
| 67 |
} |
| 68 |
int XsVector_incFreeCount() |
| 69 |
{ |
| 70 |
return ++XsVector_freeCount_value; |
| 71 |
} |
| 72 |
|
| 73 |
int XsMatrix_resetDebugCounts() |
| 74 |
{ |
| 75 |
return XsMatrix_allocCount_value.exchange(0) + XsMatrix_freeCount_value.exchange(0); |
| 76 |
} |
| 77 |
|
| 78 |
int XsMatrix_allocCount() |
| 79 |
{ |
| 80 |
return XsMatrix_allocCount_value.load(); |
| 81 |
} |
| 82 |
|
| 83 |
int XsMatrix_freeCount() |
| 84 |
{ |
| 85 |
return XsMatrix_freeCount_value.load(); |
| 86 |
} |
| 87 |
|
| 88 |
int XsMatrix_incAllocCount() |
| 89 |
{ |
| 90 |
return ++XsMatrix_allocCount_value; |
| 91 |
} |
| 92 |
|
| 93 |
int XsMatrix_incFreeCount() |
| 94 |
{ |
| 95 |
return ++XsMatrix_freeCount_value; |
| 96 |
} |
| 97 |
|
| 98 |
int XsArray_resetDebugCounts() |
| 99 |
{ |
| 100 |
return XsArray_allocCount_value.exchange(0) + XsArray_freeCount_value.exchange(0); |
| 101 |
} |
| 102 |
|
| 103 |
int XsArray_allocCount() |
| 104 |
{ |
| 105 |
return XsArray_allocCount_value.load(); |
| 106 |
} |
| 107 |
|
| 108 |
int XsArray_freeCount() |
| 109 |
{ |
| 110 |
return XsArray_freeCount_value.load(); |
| 111 |
} |
| 112 |
|
| 113 |
int XsArray_incAllocCount() |
| 114 |
{ |
| 115 |
return ++XsArray_allocCount_value; |
| 116 |
} |
| 117 |
|
| 118 |
int XsArray_incFreeCount() |
| 119 |
{ |
| 120 |
return ++XsArray_freeCount_value; |
| 121 |
} |
| 122 |
|
| 123 |
} // extern "C" |
| 124 |
|
| 125 |
#endif |