unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Re: Missing size_t declaration in UAPI
       [not found] ` <04EB5627-FD42-4397-995B-FDF051CFCFB5@brauner.io>
@ 2019-11-09 11:52   ` Elichai Turkel
  2019-11-09 12:15     ` Elichai Turkel
  2019-11-09 12:27     ` Florian Weimer
  0 siblings, 2 replies; 4+ messages in thread
From: Elichai Turkel @ 2019-11-09 11:52 UTC (permalink / raw)
  To: Christian Brauner; +Cc: linux-api, libc-alpha

Hi,
I'm proposing to move `linux/tools/include/nolibc/nolibc.h` to the
UAPI interface.
It would then be included in `linux/types.h`
Would love feedback before I work on a patch.

Thanks.
Elichai.

On Fri, Nov 8, 2019 at 11:43 PM Christian Brauner <christian@brauner.io> wrote:
>
> On November 8, 2019 10:25:09 PM GMT+01:00, Elichai Turkel <elichai.turkel@gmail.com> wrote:
>>
>> Hi,
>> Currently compiling the following program fails:
>> ```
>> #include "linux/signal.h"
>> void main(void){}
>> ```
>> Because of `./asm/signal.h:127:2: error: unknown type name ‘size_t’`.
>>
>> I tried patching with `#include <stddef.h>` but there's a local file
>> with the same name overriding the include.
>>
>> How can this be fixed? the `drm` headers seems to work with `uint_*`.
>>
>> Right now the `linux/signal.h` header isn't usable without wrapping it
>> with another header to include/define size_t.
>>
>> Thanks,
>> Elichai.
>
>
> I think it might make sense to always cc the libc mailing list too for these things.



-- 
PGP: 5607C93B5F86650C

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

* Re: Missing size_t declaration in UAPI
  2019-11-09 11:52   ` Missing size_t declaration in UAPI Elichai Turkel
@ 2019-11-09 12:15     ` Elichai Turkel
  2019-11-09 12:27     ` Florian Weimer
  1 sibling, 0 replies; 4+ messages in thread
From: Elichai Turkel @ 2019-11-09 12:15 UTC (permalink / raw)
  To: Christian Brauner; +Cc: linux-api, libc-alpha

After further reading into `nolibc.h` I think not all of it should be
in UAPI (specifically the syscalls wrappers don't).
I think it should be split and both the ASM declarations and the
types(i.e. size_t) should be in UAPI

On Sat, Nov 9, 2019 at 1:52 PM Elichai Turkel <elichai.turkel@gmail.com> wrote:
>
> Hi,
> I'm proposing to move `linux/tools/include/nolibc/nolibc.h` to the
> UAPI interface.
> It would then be included in `linux/types.h`
> Would love feedback before I work on a patch.
>
> Thanks.
> Elichai.
>
> On Fri, Nov 8, 2019 at 11:43 PM Christian Brauner <christian@brauner.io> wrote:
> >
> > On November 8, 2019 10:25:09 PM GMT+01:00, Elichai Turkel <elichai.turkel@gmail.com> wrote:
> >>
> >> Hi,
> >> Currently compiling the following program fails:
> >> ```
> >> #include "linux/signal.h"
> >> void main(void){}
> >> ```
> >> Because of `./asm/signal.h:127:2: error: unknown type name ‘size_t’`.
> >>
> >> I tried patching with `#include <stddef.h>` but there's a local file
> >> with the same name overriding the include.
> >>
> >> How can this be fixed? the `drm` headers seems to work with `uint_*`.
> >>
> >> Right now the `linux/signal.h` header isn't usable without wrapping it
> >> with another header to include/define size_t.
> >>
> >> Thanks,
> >> Elichai.
> >
> >
> > I think it might make sense to always cc the libc mailing list too for these things.
>
>
>
> --
> PGP: 5607C93B5F86650C



-- 
PGP: 5607C93B5F86650C

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

* Re: Missing size_t declaration in UAPI
  2019-11-09 11:52   ` Missing size_t declaration in UAPI Elichai Turkel
  2019-11-09 12:15     ` Elichai Turkel
@ 2019-11-09 12:27     ` Florian Weimer
       [not found]       ` <CALN7hC+QS=PJLvtH4k8paVae6PzLdAQJXyU64gUxXu-ULMKvng@mail.gmail.com>
  1 sibling, 1 reply; 4+ messages in thread
From: Florian Weimer @ 2019-11-09 12:27 UTC (permalink / raw)
  To: Elichai Turkel; +Cc: Christian Brauner, linux-api, libc-alpha

* Elichai Turkel:

> I'm proposing to move `linux/tools/include/nolibc/nolibc.h` to the
> UAPI interface.
> It would then be included in `linux/types.h`
> Would love feedback before I work on a patch.

I do not think nolibc.h is a good starting point.  The header is
pretty much incompatible with everything, including multiple
translation units that include it, so including it from
<linux/types.h> will not work.

>>> Currently compiling the following program fails:
>>> ```
>>> #include "linux/signal.h"
>>> void main(void){}
>>> ```
>>> Because of `./asm/signal.h:127:2: error: unknown type name ‘size_t’`.
>>>
>>> I tried patching with `#include <stddef.h>` but there's a local file
>>> with the same name overriding the include.

<stddef.h> is expected to be provided by the compiler. It's probably
easier to fix your build environment.

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

* Re: Missing size_t declaration in UAPI
       [not found]         ` <87sgmv5s8l.fsf@mid.deneb.enyo.de>
@ 2020-01-29 11:41           ` Elichai Turkel
  0 siblings, 0 replies; 4+ messages in thread
From: Elichai Turkel @ 2020-01-29 11:41 UTC (permalink / raw)
  To: linux-api; +Cc: libc-alpha

Hi, I want to continue that discussion
I see three options to resolve this:
1. Add `#include <stddef.h>` in every header that uses `size_t` (patch
provided).
2. Add `#include <stddef.h>` to `asm-generic/posix_types.h` and make
sure every header that uses `size_t` will include that.
3. Replace all usages of `size_t` with `__kernel_size_t`.

Included a patch for the first option but if people prefer I'll
provide patches for the rest.
I never contributed code to linux so feedback on your thoughts and the
process are more than welcome :)

```
diff --git a/include/uapi/linux/agpgart.h b/include/uapi/linux/agpgart.h
index f52510451..9630abcb8 100644
--- a/include/uapi/linux/agpgart.h
+++ b/include/uapi/linux/agpgart.h
@@ -52,7 +52,7 @@

 #ifndef __KERNEL__
 #include <linux/types.h>
-#include <stdlib.h>
+#include <stddef.h>

 struct agp_version {
  __u16 major;
diff --git a/include/uapi/linux/arcfb.h b/include/uapi/linux/arcfb.h
index 7a9008b36..f7018f92b 100644
--- a/include/uapi/linux/arcfb.h
+++ b/include/uapi/linux/arcfb.h
@@ -2,6 +2,10 @@
 #ifndef __LINUX_ARCFB_H__
 #define __LINUX_ARCFB_H__

+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
+
 #define FBIO_WAITEVENT _IO('F', 0x88)
 #define FBIO_GETCONTROL2 _IOR('F', 0x89, size_t)

diff --git a/include/uapi/linux/coda.h b/include/uapi/linux/coda.h
index aa34c2dca..1b909ef35 100644
--- a/include/uapi/linux/coda.h
+++ b/include/uapi/linux/coda.h
@@ -97,6 +97,7 @@ typedef unsigned long long u_quad_t;
 #include <linux/time.h>
 #define cdev_t u_quad_t
 #ifndef __KERNEL__
+#include <stddef.h>
 #if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
 #define _UQUAD_T_ 1
 typedef unsigned long long u_quad_t;
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 379a612f8..edd20ca84 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -15,6 +15,7 @@
 #include <linux/types.h>
 #ifndef __KERNEL__
 #include <linux/fscrypt.h>
+#include <stddef.h>
 #endif

 /* Use of MS_* flags within the kernel is restricted to core mount(2) code. */
diff --git a/include/uapi/linux/fsmap.h b/include/uapi/linux/fsmap.h
index 91fd519a3..521c2f650 100644
--- a/include/uapi/linux/fsmap.h
+++ b/include/uapi/linux/fsmap.h
@@ -10,6 +10,9 @@
 #define _LINUX_FSMAP_H

 #include <linux/types.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif

 /*
  * Structure for FS_IOC_GETFSMAP.
diff --git a/include/uapi/linux/i8k.h b/include/uapi/linux/i8k.h
index 268e6268f..91c478cca 100644
--- a/include/uapi/linux/i8k.h
+++ b/include/uapi/linux/i8k.h
@@ -18,6 +18,10 @@
 #ifndef _LINUX_I8K_H
 #define _LINUX_I8K_H

+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
+
 #define I8K_PROC "/proc/i8k"
 #define I8K_PROC_FMT "1.0"

diff --git a/include/uapi/linux/if_pppox.h b/include/uapi/linux/if_pppox.h
index e7a693c28..1b3ebaab1 100644
--- a/include/uapi/linux/if_pppox.h
+++ b/include/uapi/linux/if_pppox.h
@@ -28,6 +28,10 @@
 #include <linux/in.h>
 #include <linux/in6.h>

+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
+
 /* For user-space programs to pick up these definitions
  * which they wouldn't get otherwise without defining __KERNEL__
  */
diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h
index 05669c87a..5873e22f8 100644
--- a/include/uapi/linux/kexec.h
+++ b/include/uapi/linux/kexec.h
@@ -8,6 +8,9 @@
  */

 #include <linux/types.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif

 /* kexec flags for different usage scenarios */
 #define KEXEC_ON_CRASH 0x00000001
@@ -47,6 +50,7 @@
 #define KEXEC_SEGMENT_MAX 16

 #ifndef __KERNEL__
+#include <stddef.h>
 /*
  * This structure is used to hold the arguments that are used when
  * loading  kernel binaries.
diff --git a/include/uapi/linux/matroxfb.h b/include/uapi/linux/matroxfb.h
index 23e025b7e..50fd2453a 100644
--- a/include/uapi/linux/matroxfb.h
+++ b/include/uapi/linux/matroxfb.h
@@ -7,6 +7,10 @@
 #include <linux/videodev2.h>
 #include <linux/fb.h>

+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
+
 struct matroxioc_output_mode {
  __u32 output; /* which output */
 #define MATROXFB_OUTPUT_PRIMARY 0x0000
diff --git a/include/uapi/linux/nfc.h b/include/uapi/linux/nfc.h
index f6e3c8c9c..491607e9b 100644
--- a/include/uapi/linux/nfc.h
+++ b/include/uapi/linux/nfc.h
@@ -23,6 +23,9 @@

 #include <linux/types.h>
 #include <linux/socket.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif

 #define NFC_GENL_NAME "nfc"
 #define NFC_GENL_VERSION 1
diff --git a/include/uapi/linux/omapfb.h b/include/uapi/linux/omapfb.h
index 44f43af4c..21a4803bf 100644
--- a/include/uapi/linux/omapfb.h
+++ b/include/uapi/linux/omapfb.h
@@ -28,6 +28,9 @@
 #include <linux/fb.h>
 #include <linux/ioctl.h>
 #include <linux/types.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif

 /* IOCTL commands. */

diff --git a/include/uapi/linux/pmu.h b/include/uapi/linux/pmu.h
index f2fc1bd80..1664bdd3c 100644
--- a/include/uapi/linux/pmu.h
+++ b/include/uapi/linux/pmu.h
@@ -122,6 +122,9 @@ enum {
  * Ioctl commands for the /dev/pmu device
  */
 #include <linux/ioctl.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif

 /* no param */
 #define PMU_IOC_SLEEP _IO('B', 0)
diff --git a/include/uapi/linux/radeonfb.h b/include/uapi/linux/radeonfb.h
index 86eafb805..428a99482 100644
--- a/include/uapi/linux/radeonfb.h
+++ b/include/uapi/linux/radeonfb.h
@@ -4,6 +4,9 @@

 #include <asm/ioctl.h>
 #include <linux/types.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif

 #define ATY_RADEON_LCD_ON 0x00000001
 #define ATY_RADEON_CRT_ON 0x00000002
diff --git a/include/uapi/linux/reiserfs_xattr.h
b/include/uapi/linux/reiserfs_xattr.h
index 28f10842f..f121bc88a 100644
--- a/include/uapi/linux/reiserfs_xattr.h
+++ b/include/uapi/linux/reiserfs_xattr.h
@@ -7,6 +7,9 @@
 #define _LINUX_REISERFS_XATTR_H

 #include <linux/types.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif

 /* Magic value in header */
 #define REISERFS_XATTR_MAGIC 0x52465841 /* "RFXA" */
diff --git a/include/uapi/linux/seg6_iptunnel.h
b/include/uapi/linux/seg6_iptunnel.h
index 09fb608a3..b4debe869 100644
--- a/include/uapi/linux/seg6_iptunnel.h
+++ b/include/uapi/linux/seg6_iptunnel.h
@@ -16,6 +16,9 @@
 #define _UAPI_LINUX_SEG6_IPTUNNEL_H

 #include <linux/seg6.h> /* For struct ipv6_sr_hdr. */
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif

 enum {
  SEG6_IPTUNNEL_UNSPEC,
diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
index 87aa2a6d9..f56befb69 100644
--- a/include/uapi/linux/sysctl.h
+++ b/include/uapi/linux/sysctl.h
@@ -26,6 +26,9 @@
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/compiler.h>
+#ifndef __KERNEL__
+#include <stddef.h>
+#endif

 #define CTL_MAXNAME 10 /* how many path components do we allow in a
    call to sysctl?   In other words, what is
diff --git a/include/uapi/xen/privcmd.h b/include/uapi/xen/privcmd.h
index d20295560..51cf59019 100644
--- a/include/uapi/xen/privcmd.h
+++ b/include/uapi/xen/privcmd.h
@@ -38,6 +38,10 @@
 #include <linux/compiler.h>
 #include <xen/interface/xen.h>

+#ifndef __KERNEL__
+#include <stddef.h>
+#endif
+
 struct privcmd_hypercall {
  __u64 op;
  __u64 arg[5];
```


On Sun, Nov 10, 2019 at 11:36 PM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> * Elichai Turkel:
>
> >>>> <stddef.h> is expected to be provided by the compiler. It's probably
> >>>> easier to fix your build environment.
> >
> > `<stddef.h>` is obviously *provided* by the compiler. but it's still
> > need to be *included*.
> > so maybe I'm going too far and we just need to include `<stddef.h>` in
> > `linux/types.h`.
>
> Yes, that should work.  <linux/types.h> obviously must be compatible
> with <stddef.h>.



-- 
PGP: 5607C93B5F86650C

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

end of thread, other threads:[~2020-01-29 11:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CALN7hCJRe1uL6pd+VwgzDt=5giMVjvX+YpF28f5qbLOVCZf4GQ@mail.gmail.com>
     [not found] ` <04EB5627-FD42-4397-995B-FDF051CFCFB5@brauner.io>
2019-11-09 11:52   ` Missing size_t declaration in UAPI Elichai Turkel
2019-11-09 12:15     ` Elichai Turkel
2019-11-09 12:27     ` Florian Weimer
     [not found]       ` <CALN7hC+QS=PJLvtH4k8paVae6PzLdAQJXyU64gUxXu-ULMKvng@mail.gmail.com>
     [not found]         ` <87sgmv5s8l.fsf@mid.deneb.enyo.de>
2020-01-29 11:41           ` Elichai Turkel

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).