source: libcaca/trunk/kernel/kernel.h @ 568

Last change on this file since 568 was 568, checked in by Sam Hocevar, 14 years ago
  • Added glue code to compile libcaca without a libc and build applications as multiboot kernels.
  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
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
32typedef unsigned char uint8_t;
33typedef unsigned short uint16_t;
34typedef unsigned int uint32_t;
35typedef unsigned int uintptr_t;
36
37typedef unsigned int size_t;
38
39typedef struct file
40{
41    void *mem;
42} FILE;
43
44struct timeval {
45    int tv_sec;
46    int tv_usec;
47};
48
49struct timezone {
50    int tz_minuteswest;
51    int tz_dsttime;
52};
53
54/* Multiboot kernel entry point */
55void cmain(unsigned long int magic, unsigned long int addr);
56
57/* The application's entry point */
58int main(int argc, char *argv[]);
59
60/* stdlib.h functions */
61void *malloc(size_t size);
62void free(void *ptr);
63void *realloc(void *ptr, size_t size);
64char *getenv(const char *name);
65int rand(void);
66int abs(int j);
67void exit(int status);
68
69/* string.h functions */
70void *memset(void *s, int c, size_t n);
71void *memcpy(void *dest, const void *src, size_t n);
72size_t strlen(const char *s);
73int strcasecmp(const char *s1, const char *s2);
74
75/* stdarg.h functions */
76typedef void * va_list;
77#define va_start(v,a) v = (void *)((uintptr_t)(&a) + sizeof(a))
78#define va_end(v)
79int vsnprintf(char *str, size_t size, const char *format, va_list ap);
80
81/* stdio.h functions */
82FILE *fopen(const char *path, const char *mode);
83int feof(FILE *stream);
84char *fgets(char *s, int size, FILE *stream);
85int fclose(FILE *fp);
86int printf(const char *format, ...);
87int sprintf(char *str, const char *format, ...);
88int sscanf(const char *str, const char *format, ...);
89
90/* unistd.h functions */
91void usleep(unsigned long usec);
92
93/* time.h functions */
94int gettimeofday(struct timeval *tv, struct timezone *tz);
95
Note: See TracBrowser for help on using the repository browser.