881c6ede9d0e58c70c23c4de76b381fe012412df
[visor] / libvisor / src / vilibc.h
1 #ifndef VISOR_LIBC_H_
2 #define VISOR_LIBC_H_
3
4 /* XXX let's pretend we don't have a libc to test our own code
5 #ifdef __STDC_HOSTED__
6 #define HAVE_LIBC
7 #endif
8 */
9
10 #ifdef HAVE_LIBC
11 #include <stdlib.h>
12 #include <string.h>
13 #include <stdarg.h>
14 #else
15
16 void *memset(void *s, int c, unsigned long n);
17 void *memcpy(void *dest, const void *src, unsigned long n);
18 void *memmove(void *dest, const void *src, unsigned long n);
19 unsigned long strlen(const char *s);
20 int strcmp(const char *s1, const char *s2);
21
22 #ifdef __GNUC__
23 typedef __builtin_va_list va_list;
24 #define va_start(v,l)   __builtin_va_start(v,l)
25 #define va_end(v)       __builtin_va_end(v)
26 #define va_arg(v,l)     __builtin_va_arg(v,l)
27 #else   /* !def __GNUC__ */
28 #error "stdargs implementation for this compiler missing (libvisor/src/vilibc.h)"
29 #endif
30
31 int sprintf(char *buf, const char *fmt, ...);
32 int vsprintf(char *buf, const char *fmt, va_list ap);
33 int snprintf(char *buf, unsigned long sz, const char *fmt, ...);
34 int vsnprintf(char *buf, unsigned long sz, const char *fmt, va_list ap);
35
36 #endif  /* !HAVE_LIBC */
37
38 struct visor;
39 void vi_error(struct visor *vi, const char *fmt, ...);
40
41 #endif  /* VISOR_LIBC_H_ */