This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH 64bit] ssize_t
On Wed, 20 Feb 2013 03:23:08 -0600, Yaakov (Cygwin/X) wrote:
> I just discovered an issue resulting from this commit:
>
> 2002-06-27 Jeff Johnston <jjohnstn@...>
>
> * libc/include/sys/_types.h: Define _ssize_t as int if int is
> 32-bits, otherwise define it as long.
>
> On x86_64-cygwin (as on Linux), int is still 32 bits, but size_t is a
> 64bit unsigned long and ssize_t should be as large but signed.
> Possible patch for newlib attached; corresponding patches for
> cygwin-64bit-branch on cygwin-patches@.
Revised patch, based on Joseph's and Eric's suggestion, attached.
Yaakov
2013-02-20 Yaakov Selkowitz <yselkowitz@...>
* libc/include/sys/_types.h (_ssize_t): Define as signed
equivalent of size_t with GCC.
Index: libc/include/sys/_types.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/_types.h,v
retrieving revision 1.12
diff -u -p -r1.12 _types.h
--- libc/include/sys/_types.h 18 Sep 2007 20:05:17 -0000 1.12
+++ libc/include/sys/_types.h 21 Feb 2013 00:49:55 -0000
@@ -52,12 +52,18 @@ typedef _off64_t _fpos64_t;
#endif
#ifndef __ssize_t_defined
+#ifdef __SIZE_TYPE__
+#define unsigned signed
+typedef __SIZE_TYPE__ _ssize_t;
+#undef unsigned
+#else
#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
typedef int _ssize_t;
#else
typedef long _ssize_t;
#endif
#endif
+#endif
#define __need_wint_t
#include <stddef.h>