* [PATCH 4/4] fix a minor bug for the definition of WINT_MIN
@ 2014-11-25 14:50 Jens Gustedt
2014-12-02 18:06 ` Rich Felker
0 siblings, 1 reply; 7+ messages in thread
From: Jens Gustedt @ 2014-11-25 14:50 UTC (permalink / raw)
To: musl
This must be an unsigned value.
---
include/stdint.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/stdint.h b/include/stdint.h
index 8b91163..8b81ca0 100644
--- a/include/stdint.h
+++ b/include/stdint.h
@@ -78,7 +78,7 @@ typedef uint64_t uint_least64_t;
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX
-#define WINT_MIN 0
+#define WINT_MIN (+_UINTEGER_C(uint32_t, 0))
#define WINT_MAX UINT32_MAX
#if L'\0'-1 > 0
--
1.9.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 4/4] fix a minor bug for the definition of WINT_MIN
2014-11-25 14:50 [PATCH 4/4] fix a minor bug for the definition of WINT_MIN Jens Gustedt
@ 2014-12-02 18:06 ` Rich Felker
2014-12-02 19:23 ` Jens Gustedt
0 siblings, 1 reply; 7+ messages in thread
From: Rich Felker @ 2014-12-02 18:06 UTC (permalink / raw)
To: musl
On Tue, Nov 25, 2014 at 03:50:17PM +0100, Jens Gustedt wrote:
> This must be an unsigned value.
> ---
> include/stdint.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/stdint.h b/include/stdint.h
> index 8b91163..8b81ca0 100644
> --- a/include/stdint.h
> +++ b/include/stdint.h
> @@ -78,7 +78,7 @@ typedef uint64_t uint_least64_t;
> #define INTMAX_MAX INT64_MAX
> #define UINTMAX_MAX UINT64_MAX
>
> -#define WINT_MIN 0
> +#define WINT_MIN (+_UINTEGER_C(uint32_t, 0))
> #define WINT_MAX UINT32_MAX
Indeed, but 0U would be a much nicer way of writing it.
Also I'm wondering why I have wint_t in the arch-specific
alltypes.h.in files if stdint.h is assuming the type is
unsigned/32-bit, and it actually is for all archs. Perhaps we should
move it into the shared part of alltypes.h.in?
Rich
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 4/4] fix a minor bug for the definition of WINT_MIN
2014-12-02 18:06 ` Rich Felker
@ 2014-12-02 19:23 ` Jens Gustedt
2014-12-02 19:47 ` Rich Felker
0 siblings, 1 reply; 7+ messages in thread
From: Jens Gustedt @ 2014-12-02 19:23 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 1445 bytes --]
Am Dienstag, den 02.12.2014, 13:06 -0500 schrieb Rich Felker:
> On Tue, Nov 25, 2014 at 03:50:17PM +0100, Jens Gustedt wrote:
> > This must be an unsigned value.
> > ---
> > include/stdint.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/stdint.h b/include/stdint.h
> > index 8b91163..8b81ca0 100644
> > --- a/include/stdint.h
> > +++ b/include/stdint.h
> > @@ -78,7 +78,7 @@ typedef uint64_t uint_least64_t;
> > #define INTMAX_MAX INT64_MAX
> > #define UINTMAX_MAX UINT64_MAX
> >
> > -#define WINT_MIN 0
> > +#define WINT_MIN (+_UINTEGER_C(uint32_t, 0))
> > #define WINT_MAX UINT32_MAX
>
> Indeed, but 0U would be a much nicer way of writing it.
But this would be wrong on platforms with 16 bit int, no?
> Also I'm wondering why I have wint_t in the arch-specific
> alltypes.h.in files if stdint.h is assuming the type is
> unsigned/32-bit, and it actually is for all archs. Perhaps we should
> move it into the shared part of alltypes.h.in?
don't we have archs with 16 bit int?
but right, even then we could move it up and define it as uint32_t
Jens
--
:: INRIA Nancy Grand Est ::: AlGorille ::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536 ::
:: :::::::::::::::::::::: gsm France : +33 651400183 ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 4/4] fix a minor bug for the definition of WINT_MIN
2014-12-02 19:23 ` Jens Gustedt
@ 2014-12-02 19:47 ` Rich Felker
2014-12-02 21:42 ` Jens Gustedt
0 siblings, 1 reply; 7+ messages in thread
From: Rich Felker @ 2014-12-02 19:47 UTC (permalink / raw)
To: musl
On Tue, Dec 02, 2014 at 08:23:18PM +0100, Jens Gustedt wrote:
> Am Dienstag, den 02.12.2014, 13:06 -0500 schrieb Rich Felker:
> > On Tue, Nov 25, 2014 at 03:50:17PM +0100, Jens Gustedt wrote:
> > > This must be an unsigned value.
> > > ---
> > > include/stdint.h | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/include/stdint.h b/include/stdint.h
> > > index 8b91163..8b81ca0 100644
> > > --- a/include/stdint.h
> > > +++ b/include/stdint.h
> > > @@ -78,7 +78,7 @@ typedef uint64_t uint_least64_t;
> > > #define INTMAX_MAX INT64_MAX
> > > #define UINTMAX_MAX UINT64_MAX
> > >
> > > -#define WINT_MIN 0
> > > +#define WINT_MIN (+_UINTEGER_C(uint32_t, 0))
> > > #define WINT_MAX UINT32_MAX
> >
> > Indeed, but 0U would be a much nicer way of writing it.
>
> But this would be wrong on platforms with 16 bit int, no?
POSIX requires int to be at least 32 bits.
> > Also I'm wondering why I have wint_t in the arch-specific
> > alltypes.h.in files if stdint.h is assuming the type is
> > unsigned/32-bit, and it actually is for all archs. Perhaps we should
> > move it into the shared part of alltypes.h.in?
>
> don't we have archs with 16 bit int?
No. And we don't have archs with int > 32 bits either because too much
would break with no practical benefits. (For example, uint32_t would
be smaller than int and thus would be subject to default promotions,
UB on overflow, etc. and there would be no way to get either a 16-bit
type or a 32-bit type without extended integer types.)
> but right, even then we could move it up and define it as uint32_t
That would not work directly, as wint_t is exposed in places that
don't expose uint32_t.
Rich
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 4/4] fix a minor bug for the definition of WINT_MIN
2014-12-02 19:47 ` Rich Felker
@ 2014-12-02 21:42 ` Jens Gustedt
2014-12-02 21:56 ` Rich Felker
0 siblings, 1 reply; 7+ messages in thread
From: Jens Gustedt @ 2014-12-02 21:42 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 1887 bytes --]
Am Dienstag, den 02.12.2014, 14:47 -0500 schrieb Rich Felker:
> On Tue, Dec 02, 2014 at 08:23:18PM +0100, Jens Gustedt wrote:
> > > Indeed, but 0U would be a much nicer way of writing it.
> >
> > But this would be wrong on platforms with 16 bit int, no?
>
> POSIX requires int to be at least 32 bits.
ah right, and since we heavily rely on linux we don't assume that we
will ever run on a non-POSIX platform
> > > Also I'm wondering why I have wint_t in the arch-specific
> > > alltypes.h.in files if stdint.h is assuming the type is
> > > unsigned/32-bit, and it actually is for all archs. Perhaps we should
> > > move it into the shared part of alltypes.h.in?
> >
> > don't we have archs with 16 bit int?
>
> No. And we don't have archs with int > 32 bits either because too much
> would break with no practical benefits. (For example, uint32_t would
> be smaller than int and thus would be subject to default promotions,
> UB on overflow, etc. and there would be no way to get either a 16-bit
> type or a 32-bit type without extended integer types.)
>
> > but right, even then we could move it up and define it as uint32_t
>
> That would not work directly, as wint_t is exposed in places that
> don't expose uint32_t.
So that's probably the reason why it is burried in the arch specific
stuff. So I see two solutions
- have it as I did, be symmetric, and burry it in the arch specific
files
- have it in one place, but then bluntly use unsigned, UINT_MAX and 0U
I have no personal preference for any of that.
Jens
--
:: INRIA Nancy Grand Est ::: AlGorille ::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536 ::
:: :::::::::::::::::::::: gsm France : +33 651400183 ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 4/4] fix a minor bug for the definition of WINT_MIN
2014-12-02 21:42 ` Jens Gustedt
@ 2014-12-02 21:56 ` Rich Felker
2014-12-03 10:24 ` Jens Gustedt
0 siblings, 1 reply; 7+ messages in thread
From: Rich Felker @ 2014-12-02 21:56 UTC (permalink / raw)
To: musl
On Tue, Dec 02, 2014 at 10:42:57PM +0100, Jens Gustedt wrote:
> Am Dienstag, den 02.12.2014, 14:47 -0500 schrieb Rich Felker:
> > On Tue, Dec 02, 2014 at 08:23:18PM +0100, Jens Gustedt wrote:
> > > > Indeed, but 0U would be a much nicer way of writing it.
> > >
> > > But this would be wrong on platforms with 16 bit int, no?
> >
> > POSIX requires int to be at least 32 bits.
>
> ah right, and since we heavily rely on linux we don't assume that we
> will ever run on a non-POSIX platform
>
> > > > Also I'm wondering why I have wint_t in the arch-specific
> > > > alltypes.h.in files if stdint.h is assuming the type is
> > > > unsigned/32-bit, and it actually is for all archs. Perhaps we should
> > > > move it into the shared part of alltypes.h.in?
> > >
> > > don't we have archs with 16 bit int?
> >
> > No. And we don't have archs with int > 32 bits either because too much
> > would break with no practical benefits. (For example, uint32_t would
> > be smaller than int and thus would be subject to default promotions,
> > UB on overflow, etc. and there would be no way to get either a 16-bit
> > type or a 32-bit type without extended integer types.)
> >
> > > but right, even then we could move it up and define it as uint32_t
> >
> > That would not work directly, as wint_t is exposed in places that
> > don't expose uint32_t.
>
> So that's probably the reason why it is burried in the arch specific
> stuff. So I see two solutions
>
> - have it as I did, be symmetric, and burry it in the arch specific
> files
>
> - have it in one place, but then bluntly use unsigned, UINT_MAX and 0U
>
> I have no personal preference for any of that.
One simple definition that seems to work and naturally gets the types
right:
#define WINT_MAX 0xffffffffu
#define WINT_MIN (WINT_MAX-WINT_MAX)
Note that UINT_MAX isn't available in stdint.h; this was probably the
original motivation for using UINT32_MAX. But spelling it out as
0xffffffffu explicitly works just as well.
Rich
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 4/4] fix a minor bug for the definition of WINT_MIN
2014-12-02 21:56 ` Rich Felker
@ 2014-12-03 10:24 ` Jens Gustedt
0 siblings, 0 replies; 7+ messages in thread
From: Jens Gustedt @ 2014-12-03 10:24 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 1151 bytes --]
Am Dienstag, den 02.12.2014, 16:56 -0500 schrieb Rich Felker:
> On Tue, Dec 02, 2014 at 10:42:57PM +0100, Jens Gustedt wrote:
> > So that's probably the reason why it is burried in the arch specific
> > stuff. So I see two solutions
> >
> > - have it as I did, be symmetric, and burry it in the arch specific
> > files
> >
> > - have it in one place, but then bluntly use unsigned, UINT_MAX and 0U
> >
> > I have no personal preference for any of that.
>
> One simple definition that seems to work and naturally gets the types
> right:
>
> #define WINT_MAX 0xffffffffu
> #define WINT_MIN (WINT_MAX-WINT_MAX)
>
> Note that UINT_MAX isn't available in stdint.h; this was probably the
> original motivation for using UINT32_MAX. But spelling it out as
> 0xffffffffu explicitly works just as well.
perfect
Jens
--
:: INRIA Nancy Grand Est ::: AlGorille ::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536 ::
:: :::::::::::::::::::::: gsm France : +33 651400183 ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-12-03 10:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-25 14:50 [PATCH 4/4] fix a minor bug for the definition of WINT_MIN Jens Gustedt
2014-12-02 18:06 ` Rich Felker
2014-12-02 19:23 ` Jens Gustedt
2014-12-02 19:47 ` Rich Felker
2014-12-02 21:42 ` Jens Gustedt
2014-12-02 21:56 ` Rich Felker
2014-12-03 10:24 ` Jens Gustedt
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).