xref: /haiku/src/system/glue/init_term_dyn.c (revision 1d9d47fc72028bb71b5f232a877231e59cfe2438)
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 
7 #include <user_runtime.h>
8 #include <image.h>
9 
10 #include "init_term_dyn.h"
11 
12 
13 /**	These functions are called from _init()/_fini() (in crti.S, crtn.S)
14  *	_init/_term_before() is called before crtbegin/end code is executed,
15  *	_init/_term_after() after this.
16  *	crtbegin contains code to initialize all global constructors and
17  *	other GCC related things (like exception frames).
18  */
19 
20 
21 void
22 _init_before(image_id id)
23 {
24 	void (*before)(image_id);
25 
26 	if (get_image_symbol(id, B_INIT_BEFORE_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&before) == B_OK)
27 		before(id);
28 }
29 
30 
31 void
32 _init_after(image_id id)
33 {
34 	void (*after)(image_id);
35 
36 	if (get_image_symbol(id, B_INIT_AFTER_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&after) == B_OK)
37 		after(id);
38 }
39 
40 
41 void
42 _term_before(image_id id)
43 {
44 	void (*before)(image_id);
45 
46 	if (get_image_symbol(id, B_TERM_BEFORE_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&before) == B_OK)
47 		before(id);
48 }
49 
50 
51 void
52 _term_after(image_id id)
53 {
54 	void (*after)(image_id);
55 
56 	if (get_image_symbol(id, B_TERM_AFTER_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT, (void **)&after) == B_OK)
57 		after(id);
58 }
59 
60