include cleanups: remove unused headers and add feature test macros
[musl] / src / env / __stack_chk_fail.c
1 #include <string.h>
2 #include <stdint.h>
3 #include "pthread_impl.h"
4 #include "atomic.h"
5
6 uintptr_t __stack_chk_guard;
7
8 void __init_ssp(void *entropy)
9 {
10         pthread_t self = __pthread_self_init();
11         uintptr_t canary;
12         if (entropy) memcpy(&canary, entropy, sizeof canary);
13         else canary = (uintptr_t)&canary * 1103515245;
14         a_cas_l(&__stack_chk_guard, 0, canary);
15         self->canary = __stack_chk_guard;
16 }
17
18 void __stack_chk_fail(void)
19 {
20         a_crash();
21 }