summaryrefslogtreecommitdiff
path: root/src/libc.c
blob: f83395bb1fd3493010b12aac8daaa871877d3eca (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <unistd.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/syscall.h>

// Stuff that doesn't exist in glibc

void
__assert2(const char* file, int line, const char* function, const char* failed_expression)
{
   fprintf(stderr"%s:%d%s: assertion \"%s\" failed", file, line, function, failed_expression);
   abort();
}

pid_t
gettid(void)
{
   return syscall(SYS_gettid);
}

#include "libc-sha1.h"

// Stuff needed for runtime compatibility, but not neccessary for linking
// Also stuff that exists in glibc, but needs to be wrapped for runtime compatibility

const char *bionic__ctype_, *bionic__tolower_tab_, *bionic__toupper_tab_;
char bionic___sF[0x54];
int bionic___errno;

int
bionic_stat(const char *restrict path, struct stat *restrict buf)
{
   return stat(path, buf);
}

int
bionic_lstat(const char *restrict path, struct stat *restrict buf)
{
   return lstat(path, buf);
}

int
bionic_fstat(int fd, struct stat *buf)
{
   return fstat(fd, buf);
}

int
bionic___isfinitef(float f)
{
   return isfinite(f);
}

uintptr_t bionic___stack_chk_guard = 4;

__attribute__((noreturn))
void bionic___stack_chk_fail(void)
{
   abort();
}