From: Masahiro Yamada <yamada.m@jp.panasonic.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 04/10] Use uint64_t for time types
Date: Mon, 22 Dec 2014 19:22:41 +0900 [thread overview]
Message-ID: <20141222192241.FC99.AA925319@jp.panasonic.com> (raw)
In-Reply-To: <CAPnjgZ05fBE3S8YXkwtsrGfubzKtgOFgLKFVQLWmYXiJog_q7w@mail.gmail.com>
Hi Simon,
On Tue, 16 Dec 2014 21:38:34 -0700
Simon Glass <sjg@chromium.org> wrote:
> Hi Masahiro,
>
> On 15 December 2014 at 18:38, Masahiro YAMADA <yamada.m@jp.panasonic.com> wrote:
> >
> > Hi Simon,
> >
> >
> > 2014-12-16 3:38 GMT+09:00 Simon Glass <sjg@chromium.org>:
> > > Hi Masahiro,
> > >
> > > On 15 December 2014 at 09:55, Masahiro YAMADA <yamada.m@jp.panasonic.com> wrote:
> > >> Hi Simon,
> > >>
> > >>
> > >> 2014-10-15 19:38 GMT+09:00 Simon Glass <sjg@chromium.org>:
> > >>> Unfortunately 'unsigned long long' and 'uint64_t' are not necessarily
> > >>> compatible on 64-bit machines. Use the correct typedef instead of
> > >>> writing the supposed type out in full.
> > >>
> > >> I doubt this statement.
> > >>
> > >> I think "unsigned long long" always has 64bit width.
> > >>
> > >> (C specification guarantees that the width of "unsigned long long"
> > >> is greater or equal to 64 bit)
> > >>
> > >> Could you tell me which toolchain violates it?
> > >
> > > Some compilers use 'unsigned long' and some use 'unsigned long long'.
> > > I think that is the core of the problem.
> > >
> > > We don't have a problem with unsigned long long not being at least
> > > 64-bit. I wonder whether some toolchains use 128-bit for this?
> >
> > That is not my point.
> >
> > "unsigned long long" has 64-bit width whether on 32bit compilers
> > or 64bit compilers or whatever.
>
> I think that might be true at least for gcc. But in principle a 64-bit
> machine should use 128-bit for long long.
128-bit variable? Are you kidding?
I am not talking about "in principle" things, but talking
about real compilers.
So, on which compiler do you have problems?
For instance, please?
> >
> >
> > We should always hard-code the definition:
> > typedef unsigned long long uint64_t;
> >
> > That's all. We can always use "%llx" for printing uint64_t or u64.
> > (and this is what U-boot (and Linux) had used until you broke the consistency.)
> >
> >
> > If we include <stdint.h>, you are right. It is the beginning of nightmare.
> > Some compilers use "unsigned long" for uint64_t and some use
> > "unsigned long long"
> > for uint64_t.
> >
> > What did it buy us?
> >
> > You just introduced unreadability by using PRIu64 for printing 64bit
> > width variables.
>
> I have also hit this problem with m68k and one other compiler in
> U-Boot. Is it because these compilers are broken, or something else?
I guess you are mentioning "size_t" problem on m68k.
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/188121/focus=188932
If so, you are already confused.
"size_t" is another problem that should be discussed separetely.
Notice
[1] uint32_t, int32_t, uint64_t, int64_t, uintptr_t are provided by <stdint.h>
[2] PRIx32, PRIx64, PRId32, PRId64 etc. are provided by <inttypes.h>
[3] size_t is provided by <stddef.h>
We are talking about [1] and [2].
And also notice [1] and [2] should be provided by the same compiler to work correctly.
[3] should not be mixed up with [1].
If you are interested in the topic about the conflict between "size_t" type and "%z",
I can introduce you another thread.
But I am not showing that, in case this discussion goes wrong.
Best Regards
Masahiro Yamada
next prev parent reply other threads:[~2014-12-22 10:22 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-15 10:38 [U-Boot] [PATCH 0/10] Provide inttypes.h to avoid 32/64 bit problems with printf() Simon Glass
2014-10-15 10:38 ` [U-Boot] [PATCH 01/10] Provide option to avoid defining a custom version of uintptr_t Simon Glass
2014-10-27 22:20 ` [U-Boot] [U-Boot, " Tom Rini
2014-10-15 10:38 ` [U-Boot] [PATCH 02/10] Add some standard headers external code might need Simon Glass
2014-10-27 22:20 ` [U-Boot] [U-Boot, " Tom Rini
2014-10-28 16:25 ` [U-Boot] [PATCH " Masahiro YAMADA
2014-10-28 16:29 ` Simon Glass
2014-10-28 16:38 ` Masahiro YAMADA
2014-10-28 17:33 ` Simon Glass
2014-10-28 17:46 ` Jeroen Hofstee
2014-10-28 18:24 ` Simon Glass
2014-10-29 14:06 ` Masahiro YAMADA
2014-10-30 1:43 ` Simon Glass
2014-10-30 7:53 ` Masahiro Yamada
2014-10-31 2:43 ` Simon Glass
2014-10-15 10:38 ` [U-Boot] [PATCH 03/10] ext4: Use inttypes for printf() string Simon Glass
2014-10-27 22:20 ` [U-Boot] [U-Boot,03/10] " Tom Rini
2014-10-15 10:38 ` [U-Boot] [PATCH 04/10] Use uint64_t for time types Simon Glass
2014-10-27 22:20 ` [U-Boot] [U-Boot,04/10] " Tom Rini
2014-12-15 16:55 ` [U-Boot] [PATCH 04/10] " Masahiro YAMADA
2014-12-15 18:38 ` Simon Glass
2014-12-16 1:38 ` Masahiro YAMADA
2014-12-17 4:38 ` Simon Glass
2014-12-22 10:22 ` Masahiro Yamada [this message]
2014-10-15 10:38 ` [U-Boot] [PATCH 05/10] Use uint64_t instead of u64 in put_dec() Simon Glass
2014-10-27 22:20 ` [U-Boot] [U-Boot, " Tom Rini
2014-10-15 10:38 ` [U-Boot] [PATCH 06/10] Tidy up data sizes and function comment in display_options Simon Glass
2014-10-27 22:20 ` [U-Boot] [U-Boot, " Tom Rini
2014-10-15 10:38 ` [U-Boot] [PATCH 07/10] x86: Use correct printf() format string for uintptr_t Simon Glass
2014-10-27 22:20 ` [U-Boot] [U-Boot, " Tom Rini
2014-10-15 10:38 ` [U-Boot] [PATCH 08/10] scsi: " Simon Glass
2014-10-27 22:20 ` [U-Boot] [U-Boot, " Tom Rini
2014-12-15 18:32 ` [U-Boot] [PATCH " Masahiro YAMADA
2014-10-15 10:38 ` [U-Boot] [PATCH 09/10] usb: " Simon Glass
2014-10-27 22:20 ` [U-Boot] [U-Boot, " Tom Rini
2014-10-15 10:38 ` [U-Boot] [PATCH 10/10] test: Add a simple test to detected warnings with uint64_t, uintptr_t Simon Glass
2014-10-27 22:20 ` [U-Boot] [U-Boot, " Tom Rini
2014-10-24 1:03 ` [U-Boot] [PATCH 0/10] Provide inttypes.h to avoid 32/64 bit problems with printf() Simon Glass
2014-10-24 7:19 ` Jeroen Hofstee
2014-10-24 17:06 ` Jeroen Hofstee
2014-10-24 17:18 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141222192241.FC99.AA925319@jp.panasonic.com \
--to=yamada.m@jp.panasonic.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.