2 * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
7 #include <user_runtime.h>
10 #include "init_term_dyn.h"
13 // include the version glue -- it's separate for the kernel add-ons only
14 #include "haiku_version_glue.c"
17 /*! These functions are called from _init()/_fini() (in crti.S, crtn.S)
18 __haiku_{init,term}_before() is called before crtbegin/end code is
19 executed, __haiku_{init,term}_after() after this. crtbegin contains
20 code to initialize all global constructors and other GCC related things
21 (like exception frames).
25 #define HIDDEN_FUNCTION(function) asm volatile(".hidden " #function)
29 __haiku_init_before(image_id id
)
31 void (*before
)(image_id
);
33 HIDDEN_FUNCTION(__haiku_init_before
);
35 if (get_image_symbol(id
, B_INIT_BEFORE_FUNCTION_NAME
, B_SYMBOL_TYPE_TEXT
,
36 (void**)&before
) == B_OK
) {
43 __haiku_init_after(image_id id
)
45 void (*after
)(image_id
);
47 HIDDEN_FUNCTION(__haiku_init_after
);
49 if (get_image_symbol(id
, B_INIT_AFTER_FUNCTION_NAME
, B_SYMBOL_TYPE_TEXT
,
50 (void**)&after
) == B_OK
) {
57 __haiku_term_before(image_id id
)
59 void (*before
)(image_id
);
61 HIDDEN_FUNCTION(__haiku_term_before
);
63 if (get_image_symbol(id
, B_TERM_BEFORE_FUNCTION_NAME
, B_SYMBOL_TYPE_TEXT
,
64 (void**)&before
) == B_OK
) {
71 __haiku_term_after(image_id id
)
73 void (*after
)(image_id
);
75 HIDDEN_FUNCTION(__haiku_term_after
);
77 if (get_image_symbol(id
, B_TERM_AFTER_FUNCTION_NAME
, B_SYMBOL_TYPE_TEXT
,
78 (void**)&after
) == B_OK
) {