1 | /* |
---|
2 | * libcucul Unicode canvas library |
---|
3 | * libcaca ASCII-Art library |
---|
4 | * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> |
---|
5 | * All Rights Reserved |
---|
6 | * |
---|
7 | * This library is free software; you can redistribute it and/or |
---|
8 | * modify it under the terms of the Do What The Fuck You Want To |
---|
9 | * Public License, Version 2, as published by Sam Hocevar. See |
---|
10 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
11 | */ |
---|
12 | |
---|
13 | /** \file kernel.h |
---|
14 | * \version \$Id: kernel.h 568 2006-03-09 12:47:37Z sam $ |
---|
15 | * \author Sam Hocevar <sam@zoy.org> |
---|
16 | * \brief Kernel features |
---|
17 | * |
---|
18 | * This file contains replacement functions for the standard C library |
---|
19 | * that must be used when building libcucul and libcaca into a kernel. |
---|
20 | */ |
---|
21 | |
---|
22 | /* Various defines */ |
---|
23 | #define NULL ((void *)0) |
---|
24 | #define BUFSIZ 4096 |
---|
25 | #define RAND_MAX ((unsigned int)0x8000000) |
---|
26 | #define INT_MAX ((int)0x7fffffff) |
---|
27 | #define __BYTE_ORDER 1 |
---|
28 | #define __BIG_ENDIAN 2 |
---|
29 | |
---|
30 | /* Various typedefs -- some are x86-specific */ |
---|
31 | #define CUSTOM_INTTYPES |
---|
32 | typedef unsigned char uint8_t; |
---|
33 | typedef unsigned short uint16_t; |
---|
34 | typedef unsigned int uint32_t; |
---|
35 | typedef unsigned int uintptr_t; |
---|
36 | |
---|
37 | typedef unsigned int size_t; |
---|
38 | |
---|
39 | typedef struct file |
---|
40 | { |
---|
41 | void *mem; |
---|
42 | } FILE; |
---|
43 | |
---|
44 | struct timeval { |
---|
45 | int tv_sec; |
---|
46 | int tv_usec; |
---|
47 | }; |
---|
48 | |
---|
49 | struct timezone { |
---|
50 | int tz_minuteswest; |
---|
51 | int tz_dsttime; |
---|
52 | }; |
---|
53 | |
---|
54 | /* Multiboot kernel entry point */ |
---|
55 | void cmain(unsigned long int magic, unsigned long int addr); |
---|
56 | |
---|
57 | /* The application's entry point */ |
---|
58 | int main(int argc, char *argv[]); |
---|
59 | |
---|
60 | /* stdlib.h functions */ |
---|
61 | void *malloc(size_t size); |
---|
62 | void free(void *ptr); |
---|
63 | void *realloc(void *ptr, size_t size); |
---|
64 | char *getenv(const char *name); |
---|
65 | int rand(void); |
---|
66 | int abs(int j); |
---|
67 | void exit(int status); |
---|
68 | |
---|
69 | /* string.h functions */ |
---|
70 | void *memset(void *s, int c, size_t n); |
---|
71 | void *memcpy(void *dest, const void *src, size_t n); |
---|
72 | size_t strlen(const char *s); |
---|
73 | int strcasecmp(const char *s1, const char *s2); |
---|
74 | |
---|
75 | /* stdarg.h functions */ |
---|
76 | typedef void * va_list; |
---|
77 | #define va_start(v,a) v = (void *)((uintptr_t)(&a) + sizeof(a)) |
---|
78 | #define va_end(v) |
---|
79 | int vsnprintf(char *str, size_t size, const char *format, va_list ap); |
---|
80 | |
---|
81 | /* stdio.h functions */ |
---|
82 | FILE *fopen(const char *path, const char *mode); |
---|
83 | int feof(FILE *stream); |
---|
84 | char *fgets(char *s, int size, FILE *stream); |
---|
85 | int fclose(FILE *fp); |
---|
86 | int printf(const char *format, ...); |
---|
87 | int sprintf(char *str, const char *format, ...); |
---|
88 | int sscanf(const char *str, const char *format, ...); |
---|
89 | |
---|
90 | /* unistd.h functions */ |
---|
91 | void usleep(unsigned long usec); |
---|
92 | |
---|
93 | /* time.h functions */ |
---|
94 | int gettimeofday(struct timeval *tv, struct timezone *tz); |
---|
95 | |
---|