libstdc++
profiler_state.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License along
00021 // with this library; see the file COPYING3.  If not see
00022 // <http://www.gnu.org/licenses/>.
00023 
00024 /** @file profile/impl/profiler_state.h
00025  *  @brief Global profiler state.
00026  */
00027 
00028 // Written by Lixia Liu and Silvius Rus.
00029 
00030 #ifndef _GLIBCXX_PROFILE_PROFILER_STATE_H
00031 #define _GLIBCXX_PROFILE_PROFILER_STATE_H 1
00032 
00033 namespace __gnu_profile
00034 {
00035   enum __state_type { __ON, __OFF, __INVALID };
00036 
00037   _GLIBCXX_PROFILE_DEFINE_DATA(__state_type, __state, __INVALID);
00038 
00039   inline bool
00040   __turn(__state_type __s)
00041   { return (_GLIBCXX_PROFILE_DATA(__state)
00042         == __sync_val_compare_and_swap(&_GLIBCXX_PROFILE_DATA(__state),
00043                        __INVALID, __s)); }
00044 
00045   inline bool
00046   __turn_on()
00047   { return __turn(__ON); }
00048 
00049   inline bool
00050   __turn_off()
00051   { return __turn(__OFF); }
00052 
00053   inline bool
00054   __is_on()
00055   { return _GLIBCXX_PROFILE_DATA(__state) == __ON; }
00056 
00057   inline bool
00058   __is_off()
00059   { return _GLIBCXX_PROFILE_DATA(__state) == __OFF; }
00060 
00061   inline bool
00062   __is_invalid()
00063   { return _GLIBCXX_PROFILE_DATA(__state) == __INVALID; }
00064 
00065 } // end namespace __gnu_profile
00066 #endif /* _GLIBCXX_PROFILE_PROFILER_STATE_H */