Hi/2.

Paul Eggert wrote:
> KO Myung-Hun wrote:
>> +#ifndef __KLIBC__
>>   typedef long int gl_intptr_t;
>>   typedef unsigned long int gl_uintptr_t;
>> +#else
>> +typedef int gl_intptr_t;
>> +typedef unsigned int gl_uintptr_t;
>> +#endif
> 
> This looks brittle.
> 
> First, why is it used at all?  That is, what's wrong with kLIBC's
> stdint.h, which causes gnulib to replace stdint.h?
> 

Sorry, I didn't check this.

> Second, since kLIBC has its own intptr_t etc., I expect it'll be better
> to use kLIBC's version rather than guess what it will be in future
> versions.  How about something like this instead?
> 
> /* kLIBC's stdint.h defines _INTPTR_T_DECLARED and needs its own
>    definitions of intptr_t and uintptr_t (which use int and unsigned)
>    to avoid clashes with declarations of system functions like sbrk.  */
> #ifndef _INTPTR_T_DECLARED
> # undef intptr_t
> # undef uintptr_t
> typedef long int gl_intptr_t;
> typedef unsigned long int gl_uintptr_t;
> # define intptr_t gl_intptr_t
> # define uintptr_t gl_uintptr_t
> #endif

This works well. Thanks.

-- 
KO Myung-Hun

Using Mozilla SeaMonkey 2.7.2
Under OS/2 Warp 4 for Korean with FixPak #15
In VirtualBox v4.1.32 on Intel Core i7-3615QM 2.30GHz with 8GB RAM

Korean OS/2 User Community : http://www.ecomstation.co.kr

From 51845f95204323c6cf36c635dabaa2536a245515 Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <k...@chollian.net>
Date: Sat, 27 Apr 2013 15:32:04 +0900
Subject: [PATCH] stdint: check _INTPTR_T_DECLARED before defining intptr_t and
 uintptr_t

OS/2 kLIBC's stdint.h defines _INTPTR_T_DECLARED and needs its own
definitions of intptr_t and uintptr_t (which use int and unsigned)
to avoid clashes with declarations of system functions like sbrk.

* lib/stdint.in.h (intptr_t, uintptr_t): Check
_INTPTR_T_DECLARED before defining them.
---
 lib/stdint.in.h | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index 98ee423..79f67a6 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -288,12 +288,17 @@ typedef gl_uint_fast32_t gl_uint_fast16_t;
 
 /* 7.18.1.4. Integer types capable of holding object pointers */
 
-#undef intptr_t
-#undef uintptr_t
+/* kLIBC's stdint.h defines _INTPTR_T_DECLARED and needs its own
+   definitions of intptr_t and uintptr_t (which use int and unsigned)
+   to avoid clashes with declarations of system functions like sbrk.  */
+#ifndef _INTPTR_T_DECLARED
+# undef intptr_t
+# undef uintptr_t
 typedef long int gl_intptr_t;
 typedef unsigned long int gl_uintptr_t;
-#define intptr_t gl_intptr_t
-#define uintptr_t gl_uintptr_t
+# define intptr_t gl_intptr_t
+# define uintptr_t gl_uintptr_t
+#endif
 
 /* 7.18.1.5. Greatest-width integer types */
 
-- 
1.8.5.2

Reply via email to