ftstdlib.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /***************************************************************************/
  2. /* */
  3. /* ftstdlib.h */
  4. /* */
  5. /* ANSI-specific library and header configuration file (specification */
  6. /* only). */
  7. /* */
  8. /* Copyright 2002, 2003, 2004, 2005, 2006, 2007 by */
  9. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  10. /* */
  11. /* This file is part of the FreeType project, and may only be used, */
  12. /* modified, and distributed under the terms of the FreeType project */
  13. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  14. /* this file you indicate that you have read the license and */
  15. /* understand and accept it fully. */
  16. /* */
  17. /***************************************************************************/
  18. /*************************************************************************/
  19. /* */
  20. /* This file is used to group all #includes to the ANSI C library that */
  21. /* FreeType normally requires. It also defines macros to rename the */
  22. /* standard functions within the FreeType source code. */
  23. /* */
  24. /* Load a file which defines __FTSTDLIB_H__ before this one to override */
  25. /* it. */
  26. /* */
  27. /*************************************************************************/
  28. #ifndef __FTSTDLIB_H__
  29. #define __FTSTDLIB_H__
  30. #include <stddef.h>
  31. #define ft_ptrdiff_t ptrdiff_t
  32. /**********************************************************************/
  33. /* */
  34. /* integer limits */
  35. /* */
  36. /* UINT_MAX and ULONG_MAX are used to automatically compute the size */
  37. /* of `int' and `long' in bytes at compile-time. So far, this works */
  38. /* for all platforms the library has been tested on. */
  39. /* */
  40. /* Note that on the extremely rare platforms that do not provide */
  41. /* integer types that are _exactly_ 16 and 32 bits wide (e.g. some */
  42. /* old Crays where `int' is 36 bits), we do not make any guarantee */
  43. /* about the correct behaviour of FT2 with all fonts. */
  44. /* */
  45. /* In these case, `ftconfig.h' will refuse to compile anyway with a */
  46. /* message like `couldn't find 32-bit type' or something similar. */
  47. /* */
  48. /* IMPORTANT NOTE: We do not define aliases for heap management and */
  49. /* i/o routines (i.e. malloc/free/fopen/fread/...) */
  50. /* since these functions should all be encapsulated */
  51. /* by platform-specific implementations of */
  52. /* `ftsystem.c'. */
  53. /* */
  54. /**********************************************************************/
  55. #include <limits.h>
  56. #define FT_CHAR_BIT CHAR_BIT
  57. #define FT_INT_MAX INT_MAX
  58. #define FT_UINT_MAX UINT_MAX
  59. #define FT_ULONG_MAX ULONG_MAX
  60. /**********************************************************************/
  61. /* */
  62. /* character and string processing */
  63. /* */
  64. /**********************************************************************/
  65. #include <string.h>
  66. #define ft_memchr memchr
  67. #define ft_memcmp memcmp
  68. #define ft_memcpy memcpy
  69. #define ft_memmove memmove
  70. #define ft_memset memset
  71. #define ft_strcat strcat
  72. #define ft_strcmp strcmp
  73. #define ft_strcpy strcpy
  74. #define ft_strlen strlen
  75. #define ft_strncmp strncmp
  76. #define ft_strncpy strncpy
  77. #define ft_strrchr strrchr
  78. #define ft_strstr strstr
  79. /**********************************************************************/
  80. /* */
  81. /* file handling */
  82. /* */
  83. /**********************************************************************/
  84. #include <stdio.h>
  85. #define FT_FILE FILE
  86. #define ft_fclose fclose
  87. #define ft_fopen fopen
  88. #define ft_fread fread
  89. #define ft_fseek fseek
  90. #define ft_ftell ftell
  91. #define ft_sprintf sprintf
  92. /**********************************************************************/
  93. /* */
  94. /* sorting */
  95. /* */
  96. /**********************************************************************/
  97. #include <stdlib.h>
  98. #define ft_qsort qsort
  99. #define ft_exit exit /* only used to exit from unhandled exceptions */
  100. /**********************************************************************/
  101. /* */
  102. /* memory allocation */
  103. /* */
  104. /**********************************************************************/
  105. #define ft_scalloc calloc
  106. #define ft_sfree free
  107. #define ft_smalloc malloc
  108. #define ft_srealloc realloc
  109. /**********************************************************************/
  110. /* */
  111. /* miscellaneous */
  112. /* */
  113. /**********************************************************************/
  114. #define ft_atol atol
  115. #define ft_labs labs
  116. /**********************************************************************/
  117. /* */
  118. /* execution control */
  119. /* */
  120. /**********************************************************************/
  121. #include <setjmp.h>
  122. #define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */
  123. /* jmp_buf is defined as a macro */
  124. /* on certain platforms */
  125. #define ft_longjmp longjmp
  126. #define ft_setjmp( b ) setjmp( *(jmp_buf*) &(b) ) /* same thing here */
  127. /* the following is only used for debugging purposes, i.e., if */
  128. /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */
  129. #include <stdarg.h>
  130. #endif /* __FTSTDLIB_H__ */
  131. /* END */