Line data Source code
1 :
2 : /* Copyright (c) 2010-2012, Stefan Eilemann <eile@equalizergraphics.com>
3 : *
4 : * This library is free software; you can redistribute it and/or modify it under
5 : * the terms of the GNU Lesser General Public License version 2.1 as published
6 : * by the Free Software Foundation.
7 : *
8 : * This library is distributed in the hope that it will be useful, but WITHOUT
9 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 : * details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this library; if not, write to the Free Software Foundation, Inc.,
15 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 : */
17 :
18 : #include "init.h"
19 :
20 : #include <co/init.h>
21 : #include <lunchbox/atomic.h>
22 :
23 : namespace eq
24 : {
25 : namespace fabric
26 : {
27 : namespace
28 : {
29 15 : static lunchbox::a_int32_t _initialized;
30 : }
31 : extern void _initErrors();
32 : extern void _exitErrors();
33 :
34 10 : bool init( const int argc, char** argv )
35 : {
36 10 : if( ++_initialized > 1 ) // not first
37 0 : return true;
38 :
39 10 : _initErrors();
40 10 : return co::init( argc, argv );
41 : }
42 :
43 10 : bool exit()
44 : {
45 10 : if( --_initialized > 0 ) // not last
46 0 : return true;
47 :
48 10 : const bool ret = co::exit();
49 :
50 10 : _exitErrors();
51 10 : return ret;
52 : }
53 :
54 : }
55 45 : }
|