2009-11-20 06:33:15 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// ThreadLocal test program for The Loki Library
|
|
|
|
// Copyright (c) 2009 by Richard Sposato
|
|
|
|
// The copyright on this file is protected under the terms of the MIT license.
|
|
|
|
//
|
2011-09-29 20:36:38 +00:00
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
2009-11-20 06:33:15 +00:00
|
|
|
//
|
2011-09-29 20:36:38 +00:00
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
// SOFTWARE.
|
2009-11-20 06:33:15 +00:00
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2011-09-29 20:36:38 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
|
2011-10-03 05:05:41 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace ::std;
|
2009-11-20 06:33:15 +00:00
|
|
|
|
2011-09-29 20:36:38 +00:00
|
|
|
extern bool TestThreadLocalClassStaticValue( void );
|
2009-11-20 06:33:15 +00:00
|
|
|
|
2011-09-29 20:36:38 +00:00
|
|
|
extern bool TestThreadLocalFunctionStaticValue( void );
|
2009-11-20 06:33:15 +00:00
|
|
|
|
2011-09-29 20:36:38 +00:00
|
|
|
extern bool TestThreadLocalStaticValue( void );
|
2009-11-20 06:33:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2011-09-29 20:36:38 +00:00
|
|
|
int main( int argc, const char * const argv[] )
|
2009-11-20 06:33:15 +00:00
|
|
|
{
|
2011-09-29 20:36:38 +00:00
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
2011-10-03 05:05:41 +00:00
|
|
|
|
2009-11-20 06:33:15 +00:00
|
|
|
bool okay = true;
|
2011-10-03 05:05:41 +00:00
|
|
|
cout << "Starting ThreadLocal tests." << endl;
|
|
|
|
cout << "If any tests fail, or any assertions fail," << endl
|
2009-11-20 06:33:15 +00:00
|
|
|
<< "then your compiler does not implement thread_local storage correctly." << endl;
|
2011-10-03 05:05:41 +00:00
|
|
|
|
|
|
|
cout << endl << "Testing static thread_local storage inside classes." << endl;
|
|
|
|
okay = TestThreadLocalClassStaticValue();
|
|
|
|
if ( okay )
|
|
|
|
cout << "Your compiler correctly implements thread_local storage for class static values." << endl;
|
|
|
|
else
|
|
|
|
cout << "Your compiler does not properly implement thread_local storage for class static values." << endl;
|
|
|
|
|
2009-11-20 06:33:15 +00:00
|
|
|
cout << endl << "Testing static thread_local storage inside functions." << endl;
|
|
|
|
okay = TestThreadLocalFunctionStaticValue();
|
|
|
|
if ( okay )
|
|
|
|
cout << "Your compiler correctly implements thread_local storage for function static values." << endl;
|
|
|
|
else
|
|
|
|
cout << "Your compiler does not properly implement thread_local storage for function static values." << endl;
|
2011-10-03 05:05:41 +00:00
|
|
|
|
|
|
|
cout << endl << "Testing standalone static thread_local storage." << endl;
|
|
|
|
okay = TestThreadLocalStaticValue();
|
|
|
|
if ( okay )
|
|
|
|
cout << "Your compiler correctly implements thread_local storage for standalone static values." << endl;
|
|
|
|
else
|
|
|
|
cout << "Your compiler does not properly implement thread_local storage for standalone static values." << endl;
|
|
|
|
|
|
|
|
::std::cout << "Please press enter key to continue." << ::std::endl;
|
|
|
|
::std::cin.get();
|
|
|
|
|
2009-11-20 06:33:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|