You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

96 lines
2.4 KiB

  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. /** \file kernel.h
  13. * \version \$Id$
  14. * \author Sam Hocevar <sam@zoy.org>
  15. * \brief Kernel features
  16. *
  17. * This file contains replacement functions for the standard C library
  18. * that must be used when building libcucul and libcaca into a kernel.
  19. */
  20. /* Various defines */
  21. #define NULL ((void *)0)
  22. #define BUFSIZ 4096
  23. #define RAND_MAX ((unsigned int)0x8000000)
  24. #define INT_MAX ((int)0x7fffffff)
  25. #define __BYTE_ORDER 1
  26. #define __BIG_ENDIAN 2
  27. /* Various typedefs -- some are x86-specific */
  28. #define CUSTOM_INTTYPES
  29. typedef unsigned char uint8_t;
  30. typedef unsigned short uint16_t;
  31. typedef unsigned int uint32_t;
  32. typedef unsigned int uintptr_t;
  33. typedef unsigned int size_t;
  34. typedef struct file
  35. {
  36. void *mem;
  37. } FILE;
  38. struct timeval {
  39. int tv_sec;
  40. int tv_usec;
  41. };
  42. struct timezone {
  43. int tz_minuteswest;
  44. int tz_dsttime;
  45. };
  46. /* Multiboot kernel entry point */
  47. void cmain(unsigned long int magic, unsigned long int addr);
  48. /* The application's entry point */
  49. int main(int argc, char *argv[]);
  50. /* stdlib.h functions */
  51. void *malloc(size_t size);
  52. void free(void *ptr);
  53. void *realloc(void *ptr, size_t size);
  54. char *getenv(const char *name);
  55. int rand(void);
  56. int abs(int j);
  57. void exit(int status);
  58. /* string.h functions */
  59. void *memset(void *s, int c, size_t n);
  60. void *memcpy(void *dest, const void *src, size_t n);
  61. size_t strlen(const char *s);
  62. int strcasecmp(const char *s1, const char *s2);
  63. /* stdarg.h functions */
  64. typedef void * va_list;
  65. #define va_start(v,a) v = (void *)((uintptr_t)(&a) + sizeof(a))
  66. #define va_end(v)
  67. int vsnprintf(char *str, size_t size, const char *format, va_list ap);
  68. /* stdio.h functions */
  69. FILE *fopen(const char *path, const char *mode);
  70. int feof(FILE *stream);
  71. char *fgets(char *s, int size, FILE *stream);
  72. int fclose(FILE *fp);
  73. int printf(const char *format, ...);
  74. int sprintf(char *str, const char *format, ...);
  75. int sscanf(const char *str, const char *format, ...);
  76. /* unistd.h functions */
  77. void usleep(unsigned long usec);
  78. /* time.h functions */
  79. int gettimeofday(struct timeval *tv, struct timezone *tz);