span table
[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 #include <ctype.h>
15 #include <limit.h>
16 #else
17
18 int atoi(const char *str);
19 long atol(const char *str);
20 long strtol(const char *str, char **endp, int base);
21
22 void *memset(void *s, int c, unsigned long n);
23 void *memcpy(void *dest, const void *src, unsigned long n);
24 void *memmove(void *dest, const void *src, unsigned long n);
25 unsigned long strlen(const char *s);
26 char *strchr(const char *s, int c);
27 int strcmp(const char *s1, const char *s2);
28 char *strcpy(char *dest, const char *src);
29
30 #ifdef __GNUC__
31 typedef __builtin_va_list va_list;
32 #define va_start(v,l)   __builtin_va_start(v,l)
33 #define va_end(v)               __builtin_va_end(v)
34 #define va_arg(v,l)             __builtin_va_arg(v,l)
35 #else   /* !def __GNUC__ */
36 #error "stdargs implementation for this compiler missing (libvisor/src/vilibc.h)"
37 #endif
38
39 int sprintf(char *buf, const char *fmt, ...);
40 int vsprintf(char *buf, const char *fmt, va_list ap);
41 int snprintf(char *buf, unsigned long sz, const char *fmt, ...);
42 int vsnprintf(char *buf, unsigned long sz, const char *fmt, va_list ap);
43
44 int isalnum(int c);
45 int isalpha(int c);
46 #define isascii(c)      ((c) < 128)
47 int isblank(int c);
48 int isdigit(int c);
49 int isupper(int c);
50 int islower(int c);
51 int isprint(int c);
52 int isspace(int c);
53
54 int toupper(int c);
55 int tolower(int c);
56
57 #endif  /* !HAVE_LIBC */
58
59 struct visor;
60 void vi_error(struct visor *vi, const char *fmt, ...);
61
62 #endif  /* VISOR_LIBC_H_ */