[newlib-cygwin/main] machine/_default_types.h: define __ptrdiff_t and __wchar_t

Corinna Vinschen corinna@sourceware.org
Thu Feb 12 20:33:20 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a6d97392c787c5f68090fda337d7178383986f42

commit a6d97392c787c5f68090fda337d7178383986f42
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Thu Feb 12 20:02:19 2026 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Thu Feb 12 20:02:19 2026 +0100

    machine/_default_types.h: define __ptrdiff_t and __wchar_t
    
    These are not strictly necessary, but POSIX headers can define
    other types based on them even if stddef.h isn't included.
    It also simplifies porting BSD headers.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 newlib/libc/include/machine/_default_types.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/newlib/libc/include/machine/_default_types.h b/newlib/libc/include/machine/_default_types.h
index 320aa52bbb31..11ff90beb2f0 100644
--- a/newlib/libc/include/machine/_default_types.h
+++ b/newlib/libc/include/machine/_default_types.h
@@ -321,6 +321,20 @@ typedef long __intptr_t;
 typedef unsigned long __uintptr_t;
 #endif
 
+#ifdef __PTRDIFF_TYPE__
+typedef __PTRDIFF_TYPE__ __ptrdiff_t;
+#else
+typedef long int __ptrdiff_t;
+#endif
+
+#ifdef __WCHAR_TYPE__
+typedef __WCHAR_TYPE__ __wchar_t;
+#elif defined (__WCHAR_MAX__) && __WCHAR_MAX__ == 0xffff
+typedef short unsigned int __wchar_t;
+#else
+typedef int __wchar_t;
+#endif
+
 /* clang already defines these types in C++ mode */
 #if !defined(__clang__) || !defined(__cplusplus)
 #ifdef __CHAR16_TYPE__


More information about the Newlib-cvs mailing list