All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Florian Weimer <fweimer@redhat.com>
Cc: linux-api@vger.kernel.org, ltp@lists.linux.it, libc-alpha@sourceware.org
Subject: Re: asm-generic/int-ll64.h wrongly used on x86_64?
Date: Fri, 19 Nov 2021 14:53:10 +0100	[thread overview]
Message-ID: <YZesRs3/tyZY12BN@yuki> (raw)
In-Reply-To: <877dd4cmsw.fsf@oldenburg.str.redhat.com>

Hi!
> The correct format depends on whether you use struct statx from the
> glibc headers or the Linux UAPI headers.  glibc uses uint64_t, Linux
> uses __u64.  uint64_t in glibc prefers unsigned long if the type is
> 64-bit, Linux uses unsigned long long unconditionally.
> 
> One solution is to use %ju and cast to (uintmax_t).  Other cast-based
> approaches are possible as well.
> 
> I'm not happy with the situation because those casts reduce type safety
> and may suppress relevant compiler warnings.

I still do not get why can't the kernel __u64 match the uint64_t at
least in userspace. It should be as easy as:

diff --git a/include/uapi/asm-generic/types.h b/include/uapi/asm-generic/types.h
index dfaa50d99d8f..3c9a1fc5d5c3 100644
--- a/include/uapi/asm-generic/types.h
+++ b/include/uapi/asm-generic/types.h
@@ -2,8 +2,12 @@
 #ifndef _ASM_GENERIC_TYPES_H
 #define _ASM_GENERIC_TYPES_H
 /*
- * int-ll64 is used everywhere now.
+ * int-ll64 is used everywhere in kernel now.
  */
-#include <asm-generic/int-ll64.h>
+#if __BITS_PER_LONG == 64 && !__KERNEL__
+# include <asm-generic/int-l64.h>
+#else
+# include <asm-generic/int-ll64.h>
+#if

 #endif /* _ASM_GENERIC_TYPES_H */


-- 
Cyril Hrubis
chrubis@suse.cz

WARNING: multiple messages have this Message-ID (diff)
From: Cyril Hrubis <chrubis@suse.cz>
To: Florian Weimer <fweimer@redhat.com>
Cc: linux-api@vger.kernel.org, libc-alpha@sourceware.org, ltp@lists.linux.it
Subject: Re: [LTP] asm-generic/int-ll64.h wrongly used on x86_64?
Date: Fri, 19 Nov 2021 14:53:10 +0100	[thread overview]
Message-ID: <YZesRs3/tyZY12BN@yuki> (raw)
In-Reply-To: <877dd4cmsw.fsf@oldenburg.str.redhat.com>

Hi!
> The correct format depends on whether you use struct statx from the
> glibc headers or the Linux UAPI headers.  glibc uses uint64_t, Linux
> uses __u64.  uint64_t in glibc prefers unsigned long if the type is
> 64-bit, Linux uses unsigned long long unconditionally.
> 
> One solution is to use %ju and cast to (uintmax_t).  Other cast-based
> approaches are possible as well.
> 
> I'm not happy with the situation because those casts reduce type safety
> and may suppress relevant compiler warnings.

I still do not get why can't the kernel __u64 match the uint64_t at
least in userspace. It should be as easy as:

diff --git a/include/uapi/asm-generic/types.h b/include/uapi/asm-generic/types.h
index dfaa50d99d8f..3c9a1fc5d5c3 100644
--- a/include/uapi/asm-generic/types.h
+++ b/include/uapi/asm-generic/types.h
@@ -2,8 +2,12 @@
 #ifndef _ASM_GENERIC_TYPES_H
 #define _ASM_GENERIC_TYPES_H
 /*
- * int-ll64 is used everywhere now.
+ * int-ll64 is used everywhere in kernel now.
  */
-#include <asm-generic/int-ll64.h>
+#if __BITS_PER_LONG == 64 && !__KERNEL__
+# include <asm-generic/int-l64.h>
+#else
+# include <asm-generic/int-ll64.h>
+#if

 #endif /* _ASM_GENERIC_TYPES_H */


-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2021-11-19 13:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19 12:38 asm-generic/int-ll64.h wrongly used on x86_64? Cyril Hrubis
2021-11-19 12:38 ` [LTP] " Cyril Hrubis
2021-11-19 13:11 ` Florian Weimer
2021-11-19 13:11   ` [LTP] " Florian Weimer
2021-11-19 13:53   ` Cyril Hrubis [this message]
2021-11-19 13:53     ` Cyril Hrubis

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=YZesRs3/tyZY12BN@yuki \
    --to=chrubis@suse.cz \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-api@vger.kernel.org \
    --cc=ltp@lists.linux.it \
    /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.