]> git.buserror.net Git - polintos/scott/priv.git/blob - kernel/include/kern/libc.h
GCC 4.2.1 fixes, plus a couple library functions.
[polintos/scott/priv.git] / kernel / include / kern / libc.h
1 #ifndef _KERN_LIBC_H
2 #define _KERN_LIBC_H
3
4 #include <kern/types.h>
5 #include <stdarg.h>
6
7 size_t vsnprintf(char *buf, size_t size, const char *str, va_list args);
8 size_t snprintf(char *buf, size_t size, const char *str, ...)
9 __attribute__((format(printf, 3, 4)));
10 size_t sprintf(char *buf, const char *str, ...)
11 __attribute__((format(printf, 2, 3)));
12 size_t printf(const char *str, ...)
13 __attribute__((format(printf, 1, 2)));
14
15 // These are C-ABI so libgcc and libsupc++ can use them.
16 extern "C" {
17         // FIXME: template/alignof versions
18         void *memcpy(void *dest, const void *src, size_t len);
19         void *memmove(void *dest, const void *src, size_t len);
20         int memcmp(const void *b1, const void *b2, size_t len);
21         void *memset(void *b, int ch, size_t len);
22
23         size_t strnlen(const char *s, size_t n);
24         size_t strlen(const char *s);
25
26         char *strcpy(char *dest, const char *src);
27         char *strncpy(char *dest, const char *src, size_t len);
28         char *strcat(char *dest, const char *src);
29         char *strncat(char *dest, const char *src, size_t len);
30
31         void bzero(void *b, size_t len);
32         
33         void *malloc(size_t size);
34         void free(void *ptr);
35         void abort();
36 }
37
38 void run_ctors();
39
40 // Placement new operators
41
42 inline void *operator new(size_t len, void *addr)
43 {
44         return addr;
45 }
46
47 inline void *operator new[](size_t len, void *addr)
48 {
49         return addr;
50 }
51
52 #endif