drm/fourcc: introduce DRM_FOURCC_STANDALONE guard
Subsystems (2)
PATCH 1/1 drm/fourcc: introduce DRM_FOURCC_STANDALONE guard
Currently, the drm_fourcc.h header depends on drm.h for __u32 and __u64. At the same time drm.h pulls a lot of unneeded symbols.
Add new guard DRM_FOURCC_STANDALONE, which when set will use local declaration of said symbols.
When used on linux - this is a trivial but only when building in strict c99 mode. One is welcome to ignore the warning, silence it or use c11. If neither of the three is an option, then do _not_ set the new guard.
---
As mentioned before - there's little point in having yet another header since keeping those in sync has been a PITA in the past.
--- include/uapi/drm/drm_fourcc.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
include/uapi/drm/drm_fourcc.h +19 -0
@@ -24,7 +24,26 @@ #ifndef DRM_FOURCC_H #define DRM_FOURCC_H +/* + * Define DRM_FOURCC_STANDALONE you're interested only FOURCC and do not want + * to pull drm.h into your application. + */ +#ifdef DRM_FOURCC_STANDALONE +#if defined(__linux__) + +#include <linux/types.h> + +#else /* One of the BSDs */ + +#include <stdint.h> +typedef uint32_t __u32; +typedef uint64_t __u64; + +#endif /* __linux __ */ + +#else #include "drm.h" +#endif /* DRM_FOURCC_STANDALONE */ #if defined(__cplusplus) extern "C" {
Signature · 6 lines
2.30.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 54 lines · Emil Velikov
Currently, the
drm_fourcc.hheader depends ondrm.hfor__u32and__u64. At the same timedrm.hpulls a lot of unneeded symbols.Add new guard
DRM_FOURCC_STANDALONE, which when set will use local declaration of said symbols.When used on linux - this is a trivial but only when building in strict c99 mode. One is welcome to ignore the warning, silence it or use c11. If neither of the three is an option, then do _not_ set the new guard.
Cc James Park <[email protected]>Cc Pekka Paalanen <[email protected]>Cc Simon Ser <[email protected]>Signed-off-by Emil Velikov <[email protected]>---
As mentioned before - there's little point in having yet another header since keeping those in sync has been a PITA in the past.--- include/uapi/drm/drm_fourcc.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)include/uapi/drm/drm_fourcc.h +19
-1@@ -24,7 +24,26 @@ #ifndef DRM_FOURCC_H #define DRM_FOURCC_H +/* + * Define DRM_FOURCC_STANDALONE you're interested only FOURCC and do not want + * to pull drm.h into your application. + */ +#ifdef DRM_FOURCC_STANDALONE +#if defined(__linux__) + +#include <linux/types.h> + +#else /* One of the BSDs */ + +#include <stdint.h> +typedef uint32_t __u32; +typedef uint64_t __u64; + +#endif /* __linux __ */ + +#else #include "drm.h" +#endif /* DRM_FOURCC_STANDALONE */ #if defined(__cplusplus) extern "C" { --
Quoted 2 lines
2.30.0
One of my earlier solutions similarly would have forced people to deal with duplicate typedefs, and we arrived at the current solution because we didn't want to burden anyone with that. I feel like having the extra include-guarded file is the lesser of evils. If it helps the patch go through, then I'd drop my preference but I really think the current solution is better.
- James
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 53 lines · James Park
Quoted 51 lines · Emil Velikov
Currently, the
drm_fourcc.hheader depends ondrm.hfor__u32and__u64. At the same timedrm.hpulls a lot of unneeded symbols.Add new guard
DRM_FOURCC_STANDALONE, which when set will use local declaration of said symbols.When used on linux - this is a trivial but only when building in strict c99 mode. One is welcome to ignore the warning, silence it or use c11. If neither of the three is an option, then do _not_ set the new guard.
Cc James Park <[email protected]>Cc Pekka Paalanen <[email protected]>Cc Simon Ser <[email protected]>Signed-off-by Emil Velikov <[email protected]>---
As mentioned before - there's little point in having yet another header since keeping those in sync has been a PITA in the past.--- include/uapi/drm/drm_fourcc.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)include/uapi/drm/drm_fourcc.h +19
-0@@ -24,7 +24,26 @@#ifndef DRM_FOURCC_H #define DRM_FOURCC_H +/* +* Define DRM_FOURCC_STANDALONE you're interested only FOURCC and do not want +* to pull drm.h into your application. +*/ +#ifdef DRM_FOURCC_STANDALONE +#if defined(__linux__) + +#include <linux/types.h> + +#else /* One of the BSDs */ + +#include <stdint.h> +typedef uint32_t __u32 ; +typedef uint64_t __u64 ; + +#endif /* __linux __ */ + +#else #include "drm.h" +#endif /* DRM_FOURCC_STANDALONE */
Quoted 9 lines
Quoted 5 lines
include/uapi/drm/drm_fourcc.h +0
-1#if defined(__cplusplus)extern "C" { --2.30.0
One of my earlier solutions similarly would have forced people to deal with duplicate typedefs, and we arrived at the current solution because we didn't want to burden anyone with that.
As summed in the commit message the burden is only applicable when all of the following are set:
- non-linux
- force DRM_FOURCC_STANDALONE
- c99 -pedantic
Even then, we're talking about a compilation warning. So yeah - let's keep things short and sweet.
Side note: AFAICT MSVC will not trigger a warning so your logs should be clean.
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 77 lines · Emil Velikov
Quoted 2 lines · James Park
On Tue, Feb 2, 2021 at 2:47 PM Emil Velikov <[email protected]>
Quoted 2 lines · wrote:
Quoted 2 lines
Currently, the
drm_fourcc.hheader depends ondrm.hfor__u32and
__u64.Quoted 6 lines
Quoted 6 lines
At the same time
drm.hpulls a lot of unneeded symbols.Add new guard
DRM_FOURCC_STANDALONE, which when set will use local declaration of said symbols.When used on linux - this is a trivial but only when building in
strict c99
Quoted 1 line
Quoted 1 line
mode. One is welcome to ignore the warning, silence it or use c11. If
neither
Quoted 13 lines
Quoted 13 lines
of the three is an option, then do _not_ set the new guard.
Cc James Park <[email protected]>Cc Pekka Paalanen <[email protected]>Cc Simon Ser <[email protected]>Signed-off-by Emil Velikov <[email protected]>---
As mentioned before - there's little point in having yet another header since keeping those in sync has been a PITA in the past.--- include/uapi/drm/drm_fourcc.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0
b/include/uapi/drm/drm_fourcc.hQuoted 9 lines
include/uapi/drm/drm_fourcc.h line 28
Quoted 9 lines
index
6f0628eb13a6..c1522902f6c9100644include/uapi/drm/drm_fourcc.h +2
-0@@ -24,7 +24,26 @@#ifndef DRM_FOURCC_H #define DRM_FOURCC_H +/* +* Define DRM_FOURCC_STANDALONE you're interested only FOURCC and do not want
Quoted 19 lines
Quoted 19 lines
include/uapi/drm/drm_fourcc.h +17
-0+* to pull drm.h into your application. +*/ +#ifdef DRM_FOURCC_STANDALONE +#if defined(__linux__) + +#include <linux/types.h> + +#else /* One of the BSDs */ + +#include <stdint.h> +typedef uint32_t __u32 ; +typedef uint64_t __u64 ; + +#endif /* __linux __ */ + +#else #include "drm.h" +#endif /* DRM_FOURCC_STANDALONE */ Quoted 9 lines
Quoted 5 lines
include/uapi/drm/drm_fourcc.h +0
-1#if defined(__cplusplus)extern "C" { --2.30.0
One of my earlier solutions similarly would have forced people to deal with duplicate typedefs, and we arrived at the current solution because we didn't want to burden anyone with that.
As summed in the commit message the burden is only applicable when all of the following are set:
- non-linux
- forceDRM_FOURCC_STANDALONE
- c99 -pedantic
Quoted 8 lines
Even then, we're talking about a compilation warning. So yeah - let's keep things short and sweet.
Side note: AFAICT MSVC will not trigger a warning so your logs should be clean.
-Emil
I'm having trouble reading your commit message, this sentence in
particular: "When used on linux - this is a trivial but only when building in strict c99 mode."
This asymmetric copy/paste grosses me out so much. I don't think a patch like this should be opinionated about someone's build settings. Am I alone? Doesn't this bother anyone else?
- James
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines · Emil Velikov
As summed in the commit message the burden is only applicable when all of the following are set:
- non-linux
- forceDRM_FOURCC_STANDALONE
- c99 -pedanticEven then, we're talking about a compilation warning. So yeah - let's keep things short and sweet.
Sorry, I don't think this is acceptable. Regardless of your personal preference some projects have -Werror -pendantic, and we shouldn't make them fail the build because of a libdrm header.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 5 lines · On Wednesday, February 3rd, 2021 at 1:56 AM, Emil Velikov…
As summed in the commit message the burden is only applicable when all of the following are set:
- non-linux
- forceDRM_FOURCC_STANDALONE
- c99 -pedantic
Oh, and FWIW, this is not a theoretical situation at all. All of these conditions happen to be true on my compositor. It has FreeBSD CI, -Werror, and will use DRM_FOURCC_STANDALONE when available.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 9 lines · Simon Ser
Quoted 5 lines · On Wednesday, February 3rd, 2021 at 1:56 AM, Emil Velikov…
As summed in the commit message the burden is only applicable when all of the following are set:
- non-linux
- forceDRM_FOURCC_STANDALONE
- c99 -pedantic
Quoted 3 lines
Oh, and FWIW, this is not a theoretical situation at all. All of these conditions happen to be true on my compositor. It has FreeBSD CI, -Werror, and will use
DRM_FOURCC_STANDALONEwhen available.
There are ways to disable [1] or silence [2] this - are you intentionally ignoring them?
Or the goal here is to 'fix' the kernel for a very uncommon non-linux use-case?
-Emil
[1] pragma GCC diagnostic warning "-Wpedantic"
[2] pragma GCC diagnostic ignored or -std=c11
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 10 lines · Emil Velikov
Quoted 9 lines · Simon Ser
Quoted 5 lines · On Wednesday, February 3rd, 2021 at 1:56 AM, Emil Velikov…
As summed in the commit message the burden is only applicable when all of the following are set:
- non-linux
- forceDRM_FOURCC_STANDALONE
- c99 -pedantic
Quoted 6 lines
Quoted 3 lines
Oh, and FWIW, this is not a theoretical situation at all. All of these conditions happen to be true on my compositor. It has FreeBSD CI, -Werror, and will use
DRM_FOURCC_STANDALONEwhen available.There are ways to disable [1] or silence [2] this - are you intentionally ignoring them?
We have a policy against pragma. However we already use -std=c11, so in fact wouldn't be affected by this change.
Quoted 1 line
Or the goal here is to 'fix' the kernel for a very uncommon non-linux use-case?
If the kernel doesn't care about non-Linux, why is there an #ifdef __linux__ in the first place?
Quoted 2 lines
[1] pragma GCC diagnostic warning "-Wpedantic"
[2] pragma GCC diagnostic ignored or -std=c11
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 17 lines · Simon Ser
Quoted 14 lines · Emil Velikov
Quoted 12 lines · Simon Ser
Quoted 5 lines · On Wednesday, February 3rd, 2021 at 1:56 AM, Emil Velikov…
As summed in the commit message the burden is only applicable when all of the following are set:
- non-linux
- forceDRM_FOURCC_STANDALONE
- c99 -pedanticOh, and FWIW, this is not a theoretical situation at all. All of these conditions happen to be true on my compositor. It has FreeBSD CI, -Werror, and will use
DRM_FOURCC_STANDALONEwhen available.
Quoted 6 lines
Quoted 2 lines
There are ways to disable [1] or silence [2] this - are you intentionally ignoring them?
We have a policy against pragma. However we already use -std=c11, so in fact wouldn't be affected by this change.
No issue then, great. Let's merge this trivial solution and move on to other things.
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 2 lines · Emil Velikov
No issue then, great. Let's merge this trivial solution and move on to other things.
Just because one compositor isn't affected isn't an excuse for the kernel to force its users to use a specific C standard.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines · Simon Ser
Quoted 2 lines · Emil Velikov
No issue then, great. Let's merge this trivial solution and move on to other things.
Just because one compositor isn't affected isn't an excuse for the kernel to force its users to use a specific C standard.
As said before, there are multiple ways to handle this _without_ introducing yet another UAPI header. I don't see why you're dismissing all of them, can you elaborate?
Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 3 lines · Emil Velikov
As said before, there are multiple ways to handle this without introducing yet another UAPI header. I don't see why you're dismissing all of them, can you elaborate?
Because I hate it when I have to adjust my compiler flags because of some third-party header.
Can you explain what were the past issues with introducing a new header?
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Apologies for anything I've said so far that has been harsh. I'd like this discussion to be civil.
I'm not sure if Simon is still on board with a patch given his thumbs up to Erik's comment on the Mesa merge request (which I responded to), but I would also like to know why adding another header file is problematic. I would prefer to keep the definitions deduplicated and make the code robust even for edge cases unless there's a good reason not to. Avoiding an extra file doesn't seem like a good enough reason to me, but I also don't have to maintain codebases that rely on these headers, so maybe there's something I'm overlooking.
Thanks,
James
Quoted 7 lines · Simon Ser
Quoted 3 lines · Emil Velikov
As said before, there are multiple ways to handle this without introducing yet another UAPI header. I don't see why you're dismissing all of them, can you elaborate?
Quoted 5 lines
Because I hate it when I have to adjust my compiler flags because of some third-party header.
Can you explain what were the past issues with introducing a new header?
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 13 lines · James Park
Apologies for anything I've said so far that has been harsh. I'd like this discussion to be civil.
I'm not sure if Simon is still on board with a patch given his thumbs up to Erik's comment on the Mesa merge request (which I responded to), but I would also like to know why adding another header file is problematic. I would prefer to keep the definitions deduplicated and make the code robust even for edge cases unless there's a good reason not to. Avoiding an extra file doesn't seem like a good enough reason to me, but I also don't have to maintain codebases that rely on these headers, so maybe there's something I'm overlooking.
Quoted 16 lines
Thanks,
JamesQuoted 12 lines · Simon Ser
Quoted 3 lines · Emil Velikov
As said before, there are multiple ways to handle this without introducing yet another UAPI header. I don't see why you're dismissing all of them, can you elaborate?
Because I hate it when I have to adjust my compiler flags because of some third-party header.
Can you explain what were the past issues with introducing a new header?
And sorry for top-posting. Gmail habits.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 10 lines · Simon Ser
Quoted 3 lines · Emil Velikov
As said before, there are multiple ways to handle this without introducing yet another UAPI header. I don't see why you're dismissing all of them, can you elaborate?
Because I hate it when I have to adjust my compiler flags because of some third-party header.
Mentioned it over IRC, but adding here for posterity:
I think it's perfectly normal to be unhappy, angry, etc but please mention that upfront so that we know what we're working with.
In this case, one gets to deal with the warning, if they _explicitly_ opts-in. That said, v2 should be warnings free in virtually any permutation.
Quoted 2 lines
Can you explain what were the past issues with introducing a new header?
Few that come to mind:
- distros shipping partial header set
- mixing headers, be that any of:
- distros shipping kernel headers, as well as libdrm
- system libdrm and local - be that imported or installed to /usr/local/
A bigger annoyance that just came to mind - having the same header name/guard within your project as the one introduced.
So while it may seem like bikeshed, there are many subtle ways where things can go bad :-\
HTH
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel