xref: /haiku/src/system/glue/init_term_dyn.c (revision 893988af824e65e49e55f517b157db8386e8002b)
1 /*
2  * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #include <user_runtime.h>
7 #include <image.h>
8 
9 #include "init_term_dyn.h"
10 
11 
12 // include the version glue -- it's separate for the kernel add-ons only
13 #include "haiku_version_glue.c"
14 
15 
16 /**	These functions are called from _init()/_fini() (in crti.S, crtn.S)
17  *	_init/_term_before() is called before crtbegin/end code is executed,
18  *	_init/_term_after() after this.
19  *	crtbegin contains code to initialize all global constructors and
20  *	other GCC related things (like exception frames).
21  */
22 
23 
24 void
25 _init_before(image_id id)
26 {
27 	void (*before)(image_id);
28 
29 	if (get_image_symbol(id, B_INIT_BEFORE_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&before) == B_OK)
30 		before(id);
31 }
32 
33 
34 void
35 _init_after(image_id id)
36 {
37 	void (*after)(image_id);
38 
39 	if (get_image_symbol(id, B_INIT_AFTER_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&after) == B_OK)
40 		after(id);
41 }
42 
43 
44 void
45 _term_before(image_id id)
46 {
47 	void (*before)(image_id);
48 
49 	if (get_image_symbol(id, B_TERM_BEFORE_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&before) == B_OK)
50 		before(id);
51 }
52 
53 
54 void
55 _term_after(image_id id)
56 {
57 	void (*after)(image_id);
58 
59 	if (get_image_symbol(id, B_TERM_AFTER_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&after) == B_OK)
60 		after(id);
61 }
62 
63