summaryrefslogtreecommitdiff
path: root/tests/libc/kernel_stub.h
blob: 65047f9ba25bfaa260f976e3ab930fcfc7992295 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef KERNEL_STUB_H
#define KERNEL_STUB_H

// abaos has a kernel_panic function
// TODO: we should not need this stub, rather, libc functions should
// use other means to abort the process (e.g. with abort), then the
// kernel should catch this exception and issue the kernel_panic itself.
// anyway: the kernel has to decide whether it dies in panic or it
// kills the culprid child an merely goes his way..
void kernel_panic( const char *format, ... );

// definitions to emulate kernel functions by calling Linux kernel
// syscalls directly (careful: works for 32-bit Intel only!)

// those are defined in sys/syscall.h
#define __NR_exit 1
#define __NR_write 4

// defined in unistd.h
#define STDOUT_FILENO 1

long syscall0( long n );
long syscall1( long n, long a1 );
long syscall2( long n, long a1, long a2 );
long syscall3( long n, long a1, long a2, long a3 );

// SSP stub, we don't want to link against libssp

#include <stdint.h>
#include <stdlib.h>
 
#define STACK_CHK_GUARD 0xe2dee396
 
extern uintptr_t __stack_chk_guard;

#endif