]> git.buserror.net Git - polintos/scott/priv.git/blob - kernel/include/kern/libc.h
Initial checkin from Perforce.
[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         void *memcpy(void *dest, const void *src, size_t len);
18         void *memmove(void *dest, const void *src, size_t len);
19         int memcmp(const void *b1, const void *b2, size_t len);
20         void *memset(void *b, int ch, size_t len);
21
22         size_t strnlen(const char *s, size_t n);
23         size_t strlen(const char *s);
24
25         char *strcpy(char *dest, const char *src);
26         char *strncpy(char *dest, const char *src, size_t len);
27
28         void bzero(void *b, size_t len);
29         
30         void *malloc(size_t size);
31         void free(void *ptr);
32         void abort();
33 }
34
35 void run_ctors();
36
37 // Placement new operators
38
39 inline void *operator new(size_t len, void *addr)
40 {
41         return addr;
42 }
43
44 inline void *operator new[](size_t len, void *addr)
45 {
46         return addr;
47 }
48
49 #endif