Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * libcucul Canvas for ultrafast compositing of Unicode letters
  3. * libcaca Colour ASCII-Art library
  4. * Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
  5. * All Rights Reserved
  6. *
  7. * $Id$
  8. *
  9. * This library is free software. It comes without any warranty, to
  10. * the extent permitted by applicable law. You can redistribute it
  11. * and/or modify it under the terms of the Do What The Fuck You Want
  12. * To Public License, Version 2, as published by Sam Hocevar. See
  13. * http://sam.zoy.org/wtfpl/COPYING for more details.
  14. */
  15. /*
  16. * This file contains replacement functions for the standard C library
  17. * that must be used when building libcucul and libcaca into a kernel.
  18. */
  19. /* Various defines */
  20. #define NULL ((void *)0)
  21. #define BUFSIZ 4096
  22. #define RAND_MAX ((unsigned int)0x8000000)
  23. #define INT_MAX ((int)0x7fffffff)
  24. #define M_PI 3.14159265358979323846
  25. #define __BYTE_ORDER 1
  26. #define __BIG_ENDIAN 2
  27. /* Assembly code for outb and inb */
  28. extern inline void outb(unsigned char val, unsigned short port);
  29. extern inline unsigned char inb(unsigned short port);
  30. extern inline void outb(unsigned char val, unsigned short port)
  31. {
  32. __asm__ __volatile__ ("outb %b0,%w1" : : "a" (val), "Nd" (port));
  33. }
  34. extern inline unsigned char inb(unsigned short port)
  35. {
  36. unsigned char tmp;
  37. __asm__ __volatile__ ("inb %w1,%0" : "=a" (tmp) : "Nd" (port));
  38. return tmp;
  39. }
  40. /* Various typedefs -- some are x86-specific */
  41. #define CUSTOM_INTTYPES
  42. typedef unsigned int size_t;
  43. typedef struct file
  44. {
  45. void *mem;
  46. } FILE;
  47. struct timeval {
  48. int tv_sec;
  49. int tv_usec;
  50. };
  51. struct timezone {
  52. int tz_minuteswest;
  53. int tz_dsttime;
  54. };
  55. /* Multiboot kernel entry point */
  56. void cmain(unsigned long int magic, unsigned long int addr);
  57. /* The application's entry point */
  58. int main(int argc, char *argv[]);
  59. /* stdlib.h functions */
  60. void *malloc(size_t size);
  61. void free(void *ptr);
  62. void *realloc(void *ptr, size_t size);
  63. char *getenv(const char *name);
  64. int rand(void);
  65. int abs(int j);
  66. void exit(int status);
  67. void srand(unsigned int s);
  68. FILE *stdin, *stdout, *stderr;
  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 strcmp(const char *s1, const char *s2);
  74. int strcasecmp(const char *s1, const char *s2);
  75. int memcmp(const void *s1, const void *s2, size_t n);
  76. char *strdup(const char *s);
  77. /* stdarg.h functions */
  78. typedef void * va_list;
  79. #define va_start(v,a) v = (void *)((uintptr_t)(&a) + sizeof(a))
  80. #define va_end(v)
  81. int vsnprintf(char *str, size_t size, const char *format, va_list ap);
  82. /* stdio.h functions */
  83. FILE *fopen(const char *path, const char *mode);
  84. int feof(FILE *stream);
  85. char *fgets(char *s, int size, FILE *stream);
  86. size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
  87. int fclose(FILE *fp);
  88. int printf(const char *format, ...);
  89. int fprintf(FILE *stream, const char *format, ...);
  90. int fflush(FILE *stream);
  91. int sprintf(char *str, const char *format, ...);
  92. int sscanf(const char *str, const char *format, ...);
  93. /* unistd.h functions */
  94. void usleep(unsigned long usec);
  95. int getpid(void);
  96. /* time.h functions */
  97. int gettimeofday(struct timeval *tv, struct timezone *tz);
  98. int time(void *);
  99. /* math.h functions */
  100. double cos(double x);
  101. double sin(double x);
  102. double sqrt(double x);
  103. /* errno.h functions */
  104. #define ENOENT 2 /* No such file or directory */
  105. #define ENOMEM 12 /* Out of memory */
  106. #define EBUSY 16 /* Device or resource busy */
  107. #define ENODEV 19 /* No such device */
  108. #define EINVAL 22 /* Invalid argument */
  109. #define ENOTTY 25 /* Not a typewriter */
  110. #define ENOSYS 38 /* Function not implemented */
  111. extern int errno;
  112. /* arpa/inet.h functions */
  113. unsigned int htonl(unsigned int hostlong);
  114. unsigned short htons(unsigned short hostlong);