• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2  *
3  * ftstdlib.h
4  *
5  *   ANSI-specific library and header configuration file (specification
6  *   only).
7  *
8  * Copyright (C) 2002-2023 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   /**************************************************************************
21    *
22    * This file is used to group all `#includes` to the ANSI~C library that
23    * FreeType normally requires.  It also defines macros to rename the
24    * standard functions within the FreeType source code.
25    *
26    * Load a file which defines `FTSTDLIB_H_` before this one to override it.
27    *
28    */
29 
30 
31 #ifndef FTSTDLIB_H_
32 #define FTSTDLIB_H_
33 
34 
35 #include <stddef.h>
36 
37 #define ft_ptrdiff_t  ptrdiff_t
38 
39 
40   /**************************************************************************
41    *
42    *                          integer limits
43    *
44    * `UINT_MAX` and `ULONG_MAX` are used to automatically compute the size of
45    * `int` and `long` in bytes at compile-time.  So far, this works for all
46    * platforms the library has been tested on.  We also check `ULLONG_MAX`
47    * to see whether we can use 64-bit `long long` later on.
48    *
49    * Note that on the extremely rare platforms that do not provide integer
50    * types that are _exactly_ 16 and 32~bits wide (e.g., some old Crays where
51    * `int` is 36~bits), we do not make any guarantee about the correct
52    * behaviour of FreeType~2 with all fonts.
53    *
54    * In these cases, `ftconfig.h` will refuse to compile anyway with a
55    * message like 'couldn't find 32-bit type' or something similar.
56    *
57    */
58 
59 
60 #include <limits.h>
61 
62 #define FT_CHAR_BIT    CHAR_BIT
63 #define FT_USHORT_MAX  USHRT_MAX
64 #define FT_INT_MAX     INT_MAX
65 #define FT_INT_MIN     INT_MIN
66 #define FT_UINT_MAX    UINT_MAX
67 #define FT_LONG_MIN    LONG_MIN
68 #define FT_LONG_MAX    LONG_MAX
69 #define FT_ULONG_MAX   ULONG_MAX
70 #ifdef LLONG_MAX
71 #define FT_LLONG_MAX   LLONG_MAX
72 #endif
73 #ifdef LLONG_MIN
74 #define FT_LLONG_MIN   LLONG_MIN
75 #endif
76 #ifdef ULLONG_MAX
77 #define FT_ULLONG_MAX  ULLONG_MAX
78 #endif
79 
80 
81   /**************************************************************************
82    *
83    *                character and string processing
84    *
85    */
86 
87 
88 #include <string.h>
89 
90 #define ft_memchr   memchr
91 #define ft_memcmp   memcmp
92 #define ft_memcpy   memcpy
93 #define ft_memmove  memmove
94 #define ft_memset   memset
95 #define ft_strcat   strcat
96 #define ft_strcmp   strcmp
97 #define ft_strcpy   strcpy
98 #define ft_strlen   strlen
99 #define ft_strncmp  strncmp
100 #define ft_strncpy  strncpy
101 #define ft_strrchr  strrchr
102 #define ft_strstr   strstr
103 
104 
105   /**************************************************************************
106    *
107    *                          file handling
108    *
109    */
110 
111 
112 #include <stdio.h>
113 
114 #define FT_FILE     FILE
115 #define ft_fclose   fclose
116 #define ft_fopen    fopen
117 #define ft_fread    fread
118 #define ft_fseek    fseek
119 #define ft_ftell    ftell
120 #define ft_sprintf  sprintf
121 
122 
123   /**************************************************************************
124    *
125    *                            sorting
126    *
127    */
128 
129 
130 #include <stdlib.h>
131 
132 #define ft_qsort  qsort
133 
134 
135   /**************************************************************************
136    *
137    *                       memory allocation
138    *
139    */
140 
141 
142 #define ft_scalloc   calloc
143 #define ft_sfree     free
144 #define ft_smalloc   malloc
145 #define ft_srealloc  realloc
146 
147 
148   /**************************************************************************
149    *
150    *                         miscellaneous
151    *
152    */
153 
154 
155 #define ft_strtol  strtol
156 #define ft_getenv  getenv
157 
158 
159   /**************************************************************************
160    *
161    *                        execution control
162    *
163    */
164 
165 
166 #include <setjmp.h>
167 
168 #define ft_jmp_buf     jmp_buf  /* note: this cannot be a typedef since  */
169                                 /*       `jmp_buf` is defined as a macro */
170                                 /*       on certain platforms            */
171 
172 #define ft_longjmp     longjmp
173 #define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */
174 
175 
176   /* The following is only used for debugging purposes, i.e., if   */
177   /* `FT_DEBUG_LEVEL_ERROR` or `FT_DEBUG_LEVEL_TRACE` are defined. */
178 
179 #include <stdarg.h>
180 
181 
182 #endif /* FTSTDLIB_H_ */
183 
184 
185 /* END */
186