xref: /haiku/src/kits/app/InitTerminateLibBe.cpp (revision 9760dcae2038d47442f4658c2575844c6cf92c40)
1 /*
2  * Copyright 2001-2009, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Ingo Weinhold (bonefish@users.sf.net)
7  */
8 
9 //!	Global library initialization/termination routines.
10 
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 
15 #include <MessagePrivate.h>
16 #include <RosterPrivate.h>
17 
18 
19 // debugging
20 //#define DBG(x) x
21 #define DBG(x)
22 #define OUT	printf
23 
24 
25 static void
26 initialize_forked_child()
27 {
28 	DBG(OUT("initialize_forked_child()\n"));
29 
30 	BMessage::Private::StaticReInitForkedChild();
31 
32 	DBG(OUT("initialize_forked_child() done\n"));
33 }
34 
35 
36 extern "C" void
37 initialize_before()
38 {
39 	DBG(OUT("initialize_before()\n"));
40 
41 	BMessage::Private::StaticInit();
42 	BRoster::Private::InitBeRoster();
43 
44 	atfork(initialize_forked_child);
45 
46 	DBG(OUT("initialize_before() done\n"));
47 }
48 
49 
50 extern "C" void
51 initialize_after()
52 {
53 	DBG(OUT("initialize_after()\n"));
54 
55 	DBG(OUT("initialize_after() done\n"));
56 }
57 
58 
59 extern "C" void
60 terminate_after()
61 {
62 	DBG(OUT("terminate_after()\n"));
63 
64 	BRoster::Private::DeleteBeRoster();
65 	BMessage::Private::StaticCleanup();
66 	BMessage::Private::StaticCacheCleanup();
67 
68 	DBG(OUT("terminate_after() done\n"));
69 }
70 
71