1 /* 2 * Copyright 2001-2011, 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 <LooperList.h> 16 #include <MessagePrivate.h> 17 #include <RosterPrivate.h> 18 #include <TokenSpace.h> 19 20 21 // debugging 22 //#define DBG(x) x 23 #define DBG(x) 24 #define OUT printf 25 26 27 static void 28 initialize_forked_child() 29 { 30 DBG(OUT("initialize_forked_child()\n")); 31 32 BMessage::Private::StaticReInitForkedChild(); 33 BPrivate::gLooperList.InitAfterFork(); 34 BPrivate::gDefaultTokens.InitAfterFork(); 35 36 DBG(OUT("initialize_forked_child() done\n")); 37 } 38 39 40 extern "C" void 41 initialize_before() 42 { 43 DBG(OUT("initialize_before()\n")); 44 45 BMessage::Private::StaticInit(); 46 BRoster::Private::InitBeRoster(); 47 48 atfork(initialize_forked_child); 49 50 DBG(OUT("initialize_before() done\n")); 51 } 52 53 54 extern "C" void 55 initialize_after() 56 { 57 DBG(OUT("initialize_after()\n")); 58 59 DBG(OUT("initialize_after() done\n")); 60 } 61 62 63 extern "C" void 64 terminate_after() 65 { 66 DBG(OUT("terminate_after()\n")); 67 68 BRoster::Private::DeleteBeRoster(); 69 BMessage::Private::StaticCleanup(); 70 BMessage::Private::StaticCacheCleanup(); 71 72 DBG(OUT("terminate_after() done\n")); 73 } 74 75