Werner Lemberg pushed to branch master at FreeType / FreeType
Commits:
-
f7c6a06c
by Alex Richardson at 2021-07-15T12:09:04+02:00
2 changed files:
Changes:
1 |
+2021-07-15 Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
|
|
2 |
+ |
|
3 |
+ Support architectures where `long` is smaller than pointers.
|
|
4 |
+ |
|
5 |
+ I am currently trying to compile FreeType for CHERI-extended ISAs
|
|
6 |
+ (CHERI-RISC-V and Arm's Morello), but I am getting compiler warnings
|
|
7 |
+ from the `FT_UINT_TO_POINTER` macro. When compiling with the CHERI
|
|
8 |
+ Clang compiler, not using `uinptr_t` for casts between integers an
|
|
9 |
+ pointers results in the following `-Werror` build failures:
|
|
10 |
+ |
|
11 |
+ ```
|
|
12 |
+ In file included from .../src/truetype/truetype.c:22:
|
|
13 |
+ .../src/truetype/ttgload.c:1925:22: error:
|
|
14 |
+ cast from provenance-free integer type to pointer type will
|
|
15 |
+ give pointer that can not be dereferenced
|
|
16 |
+ [-Werror,-Wcheri-capability-misuse]
|
|
17 |
+ node->data = "" glyph_index );
|
|
18 |
+ ^
|
|
19 |
+ .../include/freetype/internal/compiler-macros.h:79:34: note:
|
|
20 |
+ expanded from macro 'FT_UINT_TO_POINTER'
|
|
21 |
+ ```
|
|
22 |
+ |
|
23 |
+ * include/freetype/internal/compiler-macros.h (FT_UINT_TO_POINTER):
|
|
24 |
+ The ISO C standard compliant fix for this would be to use
|
|
25 |
+ `uintptr_t` from `stdint.h`, but I am not sure if this is supported
|
|
26 |
+ by the minimum compiler version. Therefore, use the
|
|
27 |
+ compiler-defined `__UINTPTR_TYPE__` macro (supported in GCC 4.6+ and
|
|
28 |
+ Clang since about 3.0) before checking for `_WIN64` and falling back
|
|
29 |
+ to `unsigned long`.
|
|
30 |
+ |
|
1 | 31 |
2021-07-13 Oleg Oshmyan <chortos@inbox.lv>
|
2 | 32 |
|
3 | 33 |
[base] Fix `FT_Open_Face`'s handling of user-supplied streams.
|
... | ... | @@ -71,12 +71,18 @@ FT_BEGIN_HEADER |
71 | 71 |
*/
|
72 | 72 |
#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
|
73 | 73 |
|
74 |
-#ifdef _WIN64
|
|
74 |
+#ifdef __UINTPTR_TYPE__
|
|
75 |
+ /*
|
|
76 |
+ * GCC and Clang both provide a `__UINTPTR_TYPE__` that can be used to
|
|
77 |
+ * avoid a dependency on `stdint.h`.
|
|
78 |
+ */
|
|
79 |
+# define FT_UINT_TO_POINTER( x ) (void *)(__UINTPTR_TYPE__)(x)
|
|
80 |
+#elif defined( _WIN64 )
|
|
75 | 81 |
/* only 64bit Windows uses the LLP64 data model, i.e., */
|
76 | 82 |
/* 32-bit integers, 64-bit pointers. */
|
77 |
-#define FT_UINT_TO_POINTER( x ) (void *)(unsigned __int64)(x)
|
|
83 |
+# define FT_UINT_TO_POINTER( x ) (void *)(unsigned __int64)(x)
|
|
78 | 84 |
#else
|
79 |
-#define FT_UINT_TO_POINTER( x ) (void *)(unsigned long)(x)
|
|
85 |
+# define FT_UINT_TO_POINTER( x ) (void *)(unsigned long)(x)
|
|
80 | 86 |
#endif
|
81 | 87 |
|
82 | 88 |
/*
|