public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Define __intmax_t, __uintmax_t in bits/types.h
@ 2016-12-21 13:17 Joseph Myers
  2016-12-30 12:43 ` Ping " Joseph Myers
  2016-12-30 12:59 ` Florian Weimer
  0 siblings, 2 replies; 3+ messages in thread
From: Joseph Myers @ 2016-12-21 13:17 UTC (permalink / raw)
  To: libc-alpha

TS 18661-1 defines *fromfp* functions, which are declared in math.h
and whose return types are intmax_t and uintmax_t, without allowing
math.h to define those typedefs.  (This is similar to e.g. ISO C
declaring vprintf in stdio.h without allowing that header to define
va_list.)  Thus, math.h needs to access those typedefs under internal
names.

This patch accordingly arranges for bits/types.h (which defines only
internal names, not public *_t typedefs) to define __intmax_t and
__uintmax_t.  stdint.h is made to use bits/types.h and define intmax_t
and uintmax_t using __intmax_t and __uintmax_t, to avoid duplication
of information.  (It would be reasonable to define more of the types
in stdint.h - and in sys/types.h, where it duplicates such types -
using information already available in bits/types.h.)  The idea is
that the subsequent addition of fromfp functions would then make
math.h include bits/types.h and use __intmax_t and __uintmax_t as the
return types of those functions.

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).

2016-12-21  Joseph Myers  <joseph@codesourcery.com>

	* bits/types.h (__intmax_t): New typedef.
	(__uintmax_t): Likewise.
	* sysdeps/generic/stdint.h: Include <bits/types.h>.
	(intmax_t): Define using __intmax_t.
	(uintmax_t): Define using __uintmax_t.

diff --git a/bits/types.h b/bits/types.h
index 01753bd..45b99fd 100644
--- a/bits/types.h
+++ b/bits/types.h
@@ -56,6 +56,17 @@ __extension__ typedef long long int __quad_t;
 __extension__ typedef unsigned long long int __u_quad_t;
 #endif
 
+/* Largest integral types.  */
+#if __WORDSIZE == 64
+typedef long int		__intmax_t;
+typedef unsigned long int	__uintmax_t;
+#else
+__extension__
+typedef long long int		__intmax_t;
+__extension__
+typedef unsigned long long int	__uintmax_t;
+#endif
+
 
 /* The machine-dependent file <bits/typesizes.h> defines __*_T_TYPE
    macros for each of the OS types we define below.  The definitions
diff --git a/sysdeps/generic/stdint.h b/sysdeps/generic/stdint.h
index 8e4347c..4db6e1c 100644
--- a/sysdeps/generic/stdint.h
+++ b/sysdeps/generic/stdint.h
@@ -24,6 +24,7 @@
 
 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
 #include <bits/libc-header-start.h>
+#include <bits/types.h>
 #include <bits/wchar.h>
 #include <bits/wordsize.h>
 
@@ -131,15 +132,8 @@ typedef unsigned int		uintptr_t;
 
 
 /* Largest integral types.  */
-#if __WORDSIZE == 64
-typedef long int		intmax_t;
-typedef unsigned long int	uintmax_t;
-#else
-__extension__
-typedef long long int		intmax_t;
-__extension__
-typedef unsigned long long int	uintmax_t;
-#endif
+typedef __intmax_t		intmax_t;
+typedef __uintmax_t		uintmax_t;
 
 
 # if __WORDSIZE == 64

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Ping Re: Define __intmax_t, __uintmax_t in bits/types.h
  2016-12-21 13:17 Define __intmax_t, __uintmax_t in bits/types.h Joseph Myers
@ 2016-12-30 12:43 ` Joseph Myers
  2016-12-30 12:59 ` Florian Weimer
  1 sibling, 0 replies; 3+ messages in thread
From: Joseph Myers @ 2016-12-30 12:43 UTC (permalink / raw)
  To: libc-alpha

Ping.  This patch 
<https://sourceware.org/ml/libc-alpha/2016-12/msg00802.html> is pending 
review.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Define __intmax_t, __uintmax_t in bits/types.h
  2016-12-21 13:17 Define __intmax_t, __uintmax_t in bits/types.h Joseph Myers
  2016-12-30 12:43 ` Ping " Joseph Myers
@ 2016-12-30 12:59 ` Florian Weimer
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Weimer @ 2016-12-30 12:59 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

On 12/21/2016 02:17 PM, Joseph Myers wrote:
> diff --git a/bits/types.h b/bits/types.h
> index 01753bd..45b99fd 100644
> --- a/bits/types.h
> +++ b/bits/types.h
> @@ -56,6 +56,17 @@ __extension__ typedef long long int __quad_t;
>  __extension__ typedef unsigned long long int __u_quad_t;
>  #endif
>
> +/* Largest integral types.  */
> +#if __WORDSIZE == 64
> +typedef long int		__intmax_t;
> +typedef unsigned long int	__uintmax_t;
> +#else
> +__extension__
> +typedef long long int		__intmax_t;
> +__extension__
> +typedef unsigned long long int	__uintmax_t;
> +#endif

I wouldn't put __extension__ on its own line for consistency with the 
other declarations in that file.

Otherwise, looks good to me.

Thanks,
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-30 12:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-21 13:17 Define __intmax_t, __uintmax_t in bits/types.h Joseph Myers
2016-12-30 12:43 ` Ping " Joseph Myers
2016-12-30 12:59 ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).