# profiler_state.h

Go to the documentation of this file.

    00001 // -*- C++ -*-
    00002 //
    00003 // Copyright (C) 2009 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 terms
    00007 // of the GNU General Public License as published by the Free Software
    00008 // Foundation; either version 2, or (at your option) any later
    00009 // version.
    00010
    00011 // This library is distributed in the hope that it will be useful, but
    00012 // WITHOUT ANY WARRANTY; without even the implied warranty of
    00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014 // General Public License for more details.
    00015
    00016 // You should have received a copy of the GNU General Public License
    00017 // along with this library; see the file COPYING.  If not, write to
    00018 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
    00019 // MA 02111-1307, USA.
    00020
    00021 // As a special exception, you may use this file as part of a free
    00022 // software library without restriction.  Specifically, if other files
    00023 // instantiate templates or use macros or inline functions from this
    00024 // file, or you compile this file and link it with other files to
    00025 // produce an executable, this file does not by itself cause the
    00026 // resulting executable to be covered by the GNU General Public
    00027 // License.  This exception does not however invalidate any other
    00028 // reasons why the executable file might be covered by the GNU General
    00029 // Public License.
    00030
    00031 /** @file profile/impl/profiler_state.h
    00032  *  @brief Global profiler state.
    00033  */
    00034
    00035 // Written by Lixia Liu and Silvius Rus.
    00036
    00037 #ifndef _GLIBCXX_PROFILE_PROFILER_STATE_H
    00038 #define _GLIBCXX_PROFILE_PROFILER_STATE_H 1
    00039
    00040 namespace __gnu_profile
    00041 {
    00042
    00043 enum __state_type { __ON, __OFF, __INVALID };
    00044
    00045 _GLIBCXX_PROFILE_DEFINE_DATA(__state_type, __state, __INVALID);
    00046
    00047 inline bool __turn(__state_type __s)
    00048 {
    00049   return (_GLIBCXX_PROFILE_DATA(__state)
    00050           == __sync_val_compare_and_swap(&_GLIBCXX_PROFILE_DATA(__state),
    00051                                          __INVALID, __s));
    00052 }
    00053
    00054 inline bool __turn_on()
    00055 { return __turn(__ON); }
    00056
    00057 inline bool __turn_off()
    00058 { return __turn(__OFF); }
    00059
    00060 inline bool __is_on()
    00061 { return _GLIBCXX_PROFILE_DATA(__state) == __ON; }
    00062
    00063 inline bool __is_off()
    00064 { return _GLIBCXX_PROFILE_DATA(__state) == __OFF; }
    00065
    00066 inline bool __is_invalid()
    00067 { return _GLIBCXX_PROFILE_DATA(__state) == __INVALID; }
    00068
    00069 } // end namespace __gnu_profile
    00070 #endif /* _GLIBCXX_PROFILE_PROFILER_STATE_H */