security: Use macros from compiler.h instead of gcc specific attributes
PATCH 1/1 security: Use macros from compiler.h instead of gcc specific attributes
NOTE: Please ignore the earlier similar emails. I apologize sincerely for the mistake.
To increase compiler portability there is <linux/compiler.h> which provides convenience macros for various gcc constructs. Eg: __weak for __attribute__((weak)).
I've taken up the job of cleaning these attributes all over the kernel. Currently my patches for cleanup of all files under /kernel, /block and /mm are already done and in the linux 3.15 tree.
In the following patch I've replaced all aforementioned instances under the /security directory in the kernel source.
Gideon Israel Dsouza (1):
security: Used macros from compiler.h instead of __attribute__((...))
security/selinux/include/security.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
1.9.3
PATCH 1/1 security: Used macros from compiler.h instead of __attribute__((...))
To increase compiler portability there is <linux/compiler.h> which provides convenience macros for various gcc constructs. Eg: __packed for __attribute__((packed)).
This patch is part of a large task I've taken to clean the gcc specific attributes and use the the macros instead.
--- security/selinux/include/security.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
security/selinux/include/security.h +2 -1
@@ -8,6 +8,7 @@#ifndef _SELINUX_SECURITY_H_#define _SELINUX_SECURITY_H_ +#include <linux/compiler.h> #include <linux/dcache.h> #include <linux/magic.h> #include <linux/types.h>
@@ -220,7 +221,7 @@ struct selinux_kernel_status {/* * The version > 0 supports above members. */ -} __attribute__((packed)); +} __packed;extern void selinux_status_update_setenforce (int enforcing);extern void selinux_status_update_policyload (int seqno);
Signature · 1 line
1.9.3
Paul Moore
maintainerRe: [PATCH 1/1] security: Used macros from compiler.h instead of __attribute__((...))
Quoted 7 lines · Gideon Israel Dsouza
To increase compiler portability there is <
linux/compiler.h> which provides convenience macros for various gcc constructs. Eg:__packedfor __attribute__((packed)).This patch is part of a large task I've taken to clean the gcc specific attributes and use the the macros instead.
Quoted 6 lines
Signed-off-by Gideon Israel Dsouza <[email protected]>--- security/selinux/include/security.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)From what I can tell this should still work with both the LLVM and Intel
compilers, is that correct?
Quoted 21 lines
(quoted diff) +0
-0
b/security/selinux/include/security.hindex ce7852c..ff19bcc 100644security/selinux/include/security.h +2
-1@@ -8,6 +8,7 @@#ifndef _SELINUX_SECURITY_H_#define _SELINUX_SECURITY_H_ +#include <linux/compiler.h> #include <linux/dcache.h> #include <linux/magic.h> #include <linux/types.h> @@ -220,7 +221,7 @@ struct selinux_kernel_status {/* * The version > 0 supports above members. */ -} __attribute__((packed)); +} __packed;extern void selinux_status_update_setenforce (int enforcing);extern void selinux_status_update_policyload (int seqno);
Signature · 2 lines
paul moore www.paul-moore.com
Re: [PATCH 1/1] security: Used macros from compiler.h instead of __attribute__((...))
Quoted 8 lines · Paul Moore
Quoted 7 lines · Gideon Israel Dsouza
To increase compiler portability there is <
linux/compiler.h> which provides convenience macros for various gcc constructs. Eg:__packedfor __attribute__((packed)).This patch is part of a large task I've taken to clean the gcc specific attributes and use the the macros instead.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Gideon Israel Dsouza <[email protected]>--- security/selinux/include/security.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)From what I can tell this should still work with both the LLVM and Intel compilers, is that correct?
That's the idea of the compiler-agnostic attribute macros.
Interestingly, only include/linux/compiler-gcc.h defines __packed.
As it's already in heavy use, I can only assume both LLVM and the Intel compilers handle both "__packed" (without a special definition) and the gcc-specific "__attribute__((packed))".
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Paul Moore
maintainerRe: [PATCH 1/1] security: Used macros from compiler.h instead of __attribute__((...))
Quoted 12 lines · Geert Uytterhoeven
Quoted 11 lines · Paul Moore
Quoted 10 lines · Gideon Israel Dsouza
To increase compiler portability there is <
linux/compiler.h> which provides convenience macros for various gcc constructs. Eg:__packedfor __attribute__((packed)).This patch is part of a large task I've taken to clean the gcc specific attributes and use the the macros instead.
Signed-off-by Gideon Israel Dsouza <[email protected]>---
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
security/selinux/include/security.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)From what I can tell this should still work with both the LLVM and Intel compilers, is that correct?
That's the idea of the compiler-agnostic attribute macros.
I just wanted to make sure as I personally only really use gcc and don't pretend to be up on all the details regarding other compilers.
Quoted 3 lines
Interestingly, only
include/linux/compiler-gcc.hdefines__packed.From what I could tell by looking at the code, the other compilers all define
__GNUC__ so they get the __packed macro as part of the gcc configuration. I believe the LLVM and Intel compilers would only need to redefine __packed if they wanted/needed a different definition.
Quoted 3 lines
As it's already in heavy use, I can only assume both LLVM and the Intel compilers handle both "
__packed" (without a special definition) and the gcc-specific "__attribute__((packed))".
Yep, seems reasonable. I'll go ahead and apply the patch.
Signature · 2 lines
paul moore www.paul-moore.com
Re: [PATCH 1/1] security: Used macros from compiler.h instead of __attribute__((...))
Hey Paul and Geert,
Sorry I didn't response quick enough, I was out of town on a trip. Just got back.
Didn't even think of LLVM honestly but that is an excellent point and I'll try compiling with it.
Paul, thanks for applying my patch.
Regards,
Gideon
Quoted 41 lines · Paul Moore
Quoted 12 lines · Geert Uytterhoeven
Quoted 11 lines · Paul Moore
Quoted 10 lines · Gideon Israel Dsouza
To increase compiler portability there is <
linux/compiler.h> which provides convenience macros for various gcc constructs. Eg:__packedfor __attribute__((packed)).This patch is part of a large task I've taken to clean the gcc specific attributes and use the the macros instead.
Signed-off-by Gideon Israel Dsouza <[email protected]>---
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
security/selinux/include/security.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)From what I can tell this should still work with both the LLVM and Intel compilers, is that correct?
That's the idea of the compiler-agnostic attribute macros.
I just wanted to make sure as I personally only really use gcc and don't pretend to be up on all the details regarding other compilers.
Quoted 1 line
Interestingly, only
include/linux/compiler-gcc.hdefines__packed.From what I could tell by looking at the code, the other compilers all define
__GNUC__so they get the__packedmacro as part of the gcc configuration. I believe the LLVM and Intel compilers would only need to redefine__packedif they wanted/needed a different definition.Quoted 3 lines
As it's already in heavy use, I can only assume both LLVM and the Intel compilers handle both "
__packed" (without a special definition) and the gcc-specific "__attribute__((packed))".Yep, seems reasonable. I'll go ahead and apply the patch.
--
paul moore
www.paul-moore.com