Re: stdint.h, C++ and __STDC_LIMIT_MACROS

2015-11-02 Thread Pedro Alves
On 11/02/2015 01:36 AM, Paul Eggert wrote:
> Pedro Alves wrote:
>> and gnulib is deciding that the system's stdint.h is good enough
>> At least, I don't get a stdint.h replacement.
> 
> Since gnulib's test program contains this:
> 
> intmax_t i = INTMAX_MAX;
> 
> I'm surprised that gnulib decided that the system's stdint.h was good enough. 
> Perhaps you could investigate why.
> 

Thanks Paul.

AFAICS, that doesn't compile, the test fails, but I still don't
get a replacement.  config.log has this:

~~~
conftest.cpp:150:14: error: 'INTMAX_MAX' was not declared in this scope
 intmax_t i = INTMAX_MAX;
  ^
~~~

See here the whole context of the stdint.h test:

~~~
configure:8818: checking whether stdint.h conforms to C99
configure:8987: x86_64-w64-mingw32-g++ -c -g -O2  conftest.cpp >&5
conftest.cpp:66:2: error: #error "WCHAR_MIN, WCHAR_MAX not defined in 
"
 #error "WCHAR_MIN, WCHAR_MAX not defined in "
  ^
conftest.cpp:100:50: error: size of array 'b1' is negative
 typedef int b1[(unsigned char) -1 != 255 ? 1 : -1];
  ^
conftest.cpp:111:31: error: 'INT8_C' was not declared in this scope
 int_least8_t c1 = INT8_C (0x7f);
   ^
conftest.cpp:112:22: error: 'INT_LEAST8_MAX' was not declared in this scope
 int_least8_t c1max = INT_LEAST8_MAX;
  ^
conftest.cpp:113:22: error: 'INT_LEAST8_MIN' was not declared in this scope
 int_least8_t c1min = INT_LEAST8_MIN;
  ^
conftest.cpp:114:35: error: 'INT16_C' was not declared in this scope
 int_least16_t c2 = INT16_C (0x7fff);
   ^
conftest.cpp:115:23: error: 'INT_LEAST16_MAX' was not declared in this scope
 int_least16_t c2max = INT_LEAST16_MAX;
   ^
conftest.cpp:116:23: error: 'INT_LEAST16_MIN' was not declared in this scope
 int_least16_t c2min = INT_LEAST16_MIN;
   ^
conftest.cpp:117:39: error: 'INT32_C' was not declared in this scope
 int_least32_t c3 = INT32_C (0x7fff);
   ^
conftest.cpp:118:23: error: 'INT_LEAST32_MAX' was not declared in this scope
 int_least32_t c3max = INT_LEAST32_MAX;
   ^
conftest.cpp:119:23: error: 'INT_LEAST32_MIN' was not declared in this scope
 int_least32_t c3min = INT_LEAST32_MIN;
   ^
conftest.cpp:120:47: error: 'INT64_C' was not declared in this scope
 int_least64_t c4 = INT64_C (0x7fff);
   ^
conftest.cpp:121:23: error: 'INT_LEAST64_MAX' was not declared in this scope
 int_least64_t c4max = INT_LEAST64_MAX;
   ^
conftest.cpp:122:23: error: 'INT_LEAST64_MIN' was not declared in this scope
 int_least64_t c4min = INT_LEAST64_MIN;
   ^
conftest.cpp:123:33: error: 'UINT8_C' was not declared in this scope
 uint_least8_t d1 = UINT8_C (0xff);
 ^
conftest.cpp:124:23: error: 'UINT_LEAST8_MAX' was not declared in this scope
 uint_least8_t d1max = UINT_LEAST8_MAX;
   ^
conftest.cpp:125:37: error: 'UINT16_C' was not declared in this scope
 uint_least16_t d2 = UINT16_C (0x);
 ^
conftest.cpp:126:24: error: 'UINT_LEAST16_MAX' was not declared in this scope
 uint_least16_t d2max = UINT_LEAST16_MAX;
^
conftest.cpp:127:41: error: 'UINT32_C' was not declared in this scope
 uint_least32_t d3 = UINT32_C (0x);
 ^
conftest.cpp:128:24: error: 'UINT_LEAST32_MAX' was not declared in this scope
 uint_least32_t d3max = UINT_LEAST32_MAX;
^
conftest.cpp:129:49: error: 'UINT64_C' was not declared in this scope
 uint_least64_t d4 = UINT64_C (0x);
 ^
conftest.cpp:130:24: error: 'UINT_LEAST64_MAX' was not declared in this scope
 uint_least64_t d4max = UINT_LEAST64_MAX;
^
conftest.cpp:131:18: error: 'INT_FAST8_MAX' was not declared in this scope
 int_fast8_t e1 = INT_FAST8_MAX;
  ^
conftest.cpp:132:21: error: 'INT_FAST8_MIN' was not declared in this scope
 int_fast8_t e1min = INT_FAST8_MIN;
 ^
conftest.cpp:133:19: error: 'INT_FAST16_MAX' was not declared in this scope
 int_fast16_t e2 = INT_FAST16_MAX;
   ^
conftest.cpp:134:22: error: 'INT_FAST16_MIN' was not declared in this scope
 int_fast16_t e2min = INT_FAST16_MIN;
  ^
conftest.cpp:135:19: error: 'INT_FAST32_MAX' was not declared in this scope
 int_fast32_t e3 = INT_FAST32_MAX;
   ^
conftest.cpp:136:22: error: 'INT_FAST32_MIN' was not declared in this scope
 int_fast32_t e3min = INT_FAST32_MIN;
  ^
conftest.cpp:137:19: error: 'INT_FAST64_MAX' was not declared in this scope
 int_fast64_t e4 = INT_FAST64_MAX;
   ^
conftest.cpp:138:22: error: 'INT_FAST64_MIN' 

Re: stdint.h, C++ and __STDC_LIMIT_MACROS

2015-11-02 Thread Pedro Alves
On 11/02/2015 10:36 AM, Pedro Alves wrote:

> $ grep -rn gl_cv_header_working_stdint_h
> config.cache:628:gl_cv_header_working_stdint_h=${gl_cv_header_working_stdint_h=no}
> config.log:39493:gl_cv_header_working_stdint_h=no
> 
> But, I don't get a replacement:
> 
> $ find . -name stdint.h
> $
> 
> Any hints on where I should be looking next?

Hmm, I looked for how headers end up or not generated, and found out how that
makes it to the Makefile, and noticed that the stdint.h generation in my 
Makefile
was commented out.  Turns out my Makefile was stale, even after having done (I
believe) several config.status --recheck last night.  Today I
re-ran "config.status", and lo, I get a replacement stdint.h.

Sorry for the false alarm.

Thanks,
Pedro Alves




[PATCH] Re: stdint.h, C++ and __STDC_LIMIT_MACROS

2015-11-02 Thread Pedro Alves
On 11/02/2015 11:03 AM, Pedro Alves wrote:
> On 11/02/2015 10:36 AM, Pedro Alves wrote:
> 
>> $ grep -rn gl_cv_header_working_stdint_h
>> config.cache:628:gl_cv_header_working_stdint_h=${gl_cv_header_working_stdint_h=no}
>> config.log:39493:gl_cv_header_working_stdint_h=no
>>
>> But, I don't get a replacement:
>>
>> $ find . -name stdint.h
>> $
>>
>> Any hints on where I should be looking next?
> 
> Hmm, I looked for how headers end up or not generated, and found out how that
> makes it to the Makefile, and noticed that the stdint.h generation in my 
> Makefile
> was commented out.  Turns out my Makefile was stale, even after having done (I
> believe) several config.status --recheck last night.  Today I
> re-ran "config.status", and lo, I get a replacement stdint.h.
> 
> Sorry for the false alarm.

Alright, and now with the stdint.h replacement, I tripped on
a real problem.  E.g.:

../../src/gdb/dcache.c: In function 'dcache_block* dcache_alloc(DCACHE*, 
CORE_ADDR)':
../../src/gdb/dcache.c:387:27: error: cast from 'dcache_block*' to 
'splay_tree_value {aka long unsigned int}' loses precision [-fpermissive]
(splay_tree_value) db);
   ^

splay_tree_value is a typedef for uintptr_t.  And gnulib's stdint.h
replacement typedef that to "unsigned long":

~~~
/* 7.18.1.4. Integer types capable of holding object pointers */

#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
~~~

which is not appropriate for mingw/64-bit, which is LLP64.

Given that mingw's stdint.h is good enough if one defines
__STDC_CONSTANT_MACROS / __STDC_LIMIT_MACROS, seems like the best fix
would be to make it so that the only thing the gnulib replacement
does is define __STDC_..._MACROS and include_next mingw's stdint.h,
nothing else.  See patch below.  What do you think?

>From 1fb3ed739c8e03e2f1459b033b4fe57cfd562dd8 Mon Sep 17 00:00:00 2001
From: Pedro Alves 
Date: Mon, 2 Nov 2015 14:52:18 +
Subject: [PATCH] stdint: detect good enough pre-C++11 stdint.h in C++ mode

When gnulib is configured in C++ mode for a system with a working C99
implementation of stdint.h that predates C++11, gnulib ends up
substituing stdint.h anyway.  This works on most targets, but on e.g.,
64-bit MinGW, it doesn't, as gnulib's substitute assumes LP64, while
MinGW is LLP64:

~~~
/* 7.18.1.4. Integer types capable of holding object pointers */

#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
~~~

Instead of trying to detect the right types, detect
good-enough-pre-C++11 stdint.h and in such case make the substitute
stdint.h just wrap the system's stdint.h with
__STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined.

* lib/stdint.in.h: Skip defining replacement header contents if
@HAVE_PRE_CXX11_STDINT_H@, indicating the system's stdint.h is
good enough and just needs __STDC_CONSTANT_MACROS /
__STDC_LIMIT_MACROS defined in C++.
* m4/stdint.m4 (gl_STDINT_H): Always define __STDC_CONSTANT_MACROS
/ __STDC_LIMIT_MACROS while checking whether the system stdint.h
is good.  If it is good, check whether it works without those
macros defined.  Then if it doesn't work, generate a replacement
header that just defines those macros and includes the system
stdint.h.
* modules/stdint (Makefile.am): Substitute
@HAVE_PRE_CXX11_STDINT_H@.
---
 lib/stdint.in.h |  4 +++-
 m4/stdint.m4| 33 +++--
 modules/stdint  |  1 +
 3 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index f46bbf3..fecb5e1 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -76,7 +76,9 @@
 # @INCLUDE_NEXT@ @NEXT_STDINT_H@
 #endif
 
-#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined 
_GL_JUST_INCLUDE_SYSTEM_STDINT_H
+#if (! defined _@GUARD_PREFIX@_STDINT_H\
+ && ! (defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H\
+  || @HAVE_PRE_CXX11_STDINT_H@))
 #define _@GUARD_PREFIX@_STDINT_H
 
 /*  defines some of the stdint.h types as well, on glibc,
diff --git a/m4/stdint.m4 b/m4/stdint.m4
index 4011a49..4b98596 100644
--- a/m4/stdint.m4
+++ b/m4/stdint.m4
@@ -1,4 +1,4 @@
-# stdint.m4 serial 43
+# stdint.m4 serial 44
 dnl Copyright (C) 2001-2015 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -70,6 +70,8 @@ AC_DEFUN_ONCE([gl_STDINT_H],
AC_COMPILE_IFELSE([
  AC_LANG_PROGRAM([[
 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
+#define __STDC_CONSTANT_MACROS 1
+#define __STDC_LIMIT_MACROS 1
 #include 
 /* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in .  */
 #if !(defined WCHAR_MIN && defined WCHAR_MAX)
@@ -218,6 +220

Is it possible / easy to build a shared library of a selection of modules?

2015-11-02 Thread Jimi Damon

Hi,

I saw this message posted back in 2011 but I've never seen anyone post a 
solution to it.


I would like to build libgnu.so and use it in my project. The reason for 
this is because I use strictly a CMake build and it would be much easier 
to link in this library instead of trying to recode my project using 
autoconf.


I am able to select the linked list module just fine, but there doesn't 
seem to be a configure or ./gnulib-tool option that allows me

to enable the generation of a libgnu.so .

Any ideas how one can do this effortlessly using either a configure / 
make / gnulib-tool step ?


Thanks




--
Jimi Damon
ACCES I/O Products, Inc. 
Linux Engineer
jda...@accesio.com 
(858) 550-7320 x3015

ACCES I/O Logo
10623 Roselle Street San Diego CA 92121-1506 


--
WARNING - This e-mail or its attachments may contain controlled technical 
data or controlled technology within the definition of the International 
Traffic in Arms Regulations (ITAR) or Export Administration Regulations 
(EAR), and are subject to the export control laws of the U.S. Government. 
Transfer of this data or technology by any means to a foreign person, 
whether in the United States or abroad, without an export license or other 
approval from the U.S. Government, is prohibited. The information contained 
in this document is CONFIDENTIAL and property of ACCES I/O Products, Inc. 
Any unauthorized review, use, disclosure or distribution is prohibited 
without express written consent of ACCES I/O Products, Inc. If you are not 
the intended recipient, please contact the sender and destroy all copies of 
the original message and enclosed attachments.


Re: [PATCH] Re: stdint.h, C++ and __STDC_LIMIT_MACROS

2015-11-02 Thread Paul Eggert

Pedro Alves wrote:

Instead of trying to detect the right types, detect
good-enough-pre-C++11 stdint.h and in such case make the substitute
stdint.h just wrap the system's stdint.h with
__STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined.


Instead, how about just adding the necessary #defines for 
__STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS to config.h if they are needed to fix 
the bug?  Then we can leave stdint.h alone (perhaps not even build stdint.h at all).