This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minrt 0.6.0: overhaul init/fini/exit behaviour
- Loading branch information
1 parent
e2ac164
commit 565650e
Showing
9 changed files
with
81 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
extern void exit(int code) | ||
{ | ||
void __call_exitprocs(int, void*) __attribute__((weak)); | ||
void __minrt_fini_array(void); | ||
|
||
if (__call_exitprocs) | ||
{ | ||
__call_exitprocs(code, NULL); | ||
} | ||
|
||
__minrt_fini_array(); | ||
|
||
_exit(code); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <stddef.h> | ||
|
||
extern void (*__fini_array_start []) (void) __attribute__((weak)); | ||
extern void (*__fini_array_end []) (void) __attribute__((weak)); | ||
|
||
extern void __minrt_fini_array(void) | ||
{ | ||
size_t count; | ||
size_t i; | ||
|
||
count = __fini_array_end - __fini_array_start; | ||
|
||
for (i = count; i > 0; i--) | ||
{ | ||
__fini_array_start[i-1](); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <stddef.h> | ||
|
||
extern void (*__preinit_array_start[]) (void) __attribute__((weak)); | ||
extern void (*__preinit_array_end[]) (void) __attribute__((weak)); | ||
extern void (*__init_array_start[]) (void) __attribute__((weak)); | ||
extern void (*__init_array_end[]) (void) __attribute__((weak)); | ||
|
||
extern void __minrt_init_array(void) | ||
{ | ||
size_t count; | ||
size_t i; | ||
|
||
count = __preinit_array_end - __preinit_array_start; | ||
|
||
for (i = 0; i < count; i++) | ||
{ | ||
__preinit_array_start[i](); | ||
} | ||
|
||
count = __init_array_end - __init_array_start; | ||
|
||
for (i = 0; i < count; i++) | ||
{ | ||
__init_array_start[i](); | ||
} | ||
} |