Alex James has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/36249 )
Change subject: commonlib: Use __builtin_offsetof with supported compilers ......................................................................
commonlib: Use __builtin_offsetof with supported compilers
Use __builtin_offsetof (which is treated as a constant expression) with Clang & GCC. This also allows check_member to work with Clang.
Signed-off-by: Alex James theracermaster@gmail.com Change-Id: I8b5cb4110c13ee42114ecf65932d7f1e5636210e --- M src/commonlib/include/commonlib/helpers.h 1 file changed, 3 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/36249/1
diff --git a/src/commonlib/include/commonlib/helpers.h b/src/commonlib/include/commonlib/helpers.h index 4429ea4..b5e08b4 100644 --- a/src/commonlib/include/commonlib/helpers.h +++ b/src/commonlib/include/commonlib/helpers.h @@ -107,17 +107,15 @@ #define MHz (1000 * KHz) #define GHz (1000 * MHz)
-#ifndef offsetof +#ifdef __ROMCC__ #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#else +#define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER) #endif
-#if !defined(__clang__) #define check_member(structure, member, offset) _Static_assert( \ offsetof(struct structure, member) == offset, \ "`struct " #structure "` offset for `" #member "` is not " #offset) -#else -#define check_member(structure, member, offset) -#endif
/** * container_of - cast a member of a structure out to the containing structure
Hello build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36249
to look at the new patch set (#2).
Change subject: commonlib: Use __builtin_offsetof with supported compilers ......................................................................
commonlib: Use __builtin_offsetof with supported compilers
Use __builtin_offsetof (which is treated as a constant expression) with Clang & GCC. This also allows check_member to work with Clang.
Signed-off-by: Alex James theracermaster@gmail.com Change-Id: I8b5cb4110c13ee42114ecf65932d7f1e5636210e --- M src/commonlib/include/commonlib/helpers.h 1 file changed, 4 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/36249/2
Jacob Garber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36249 )
Change subject: commonlib: Use __builtin_offsetof with supported compilers ......................................................................
Patch Set 2: Code-Review+1
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36249 )
Change subject: commonlib: Use __builtin_offsetof with supported compilers ......................................................................
Patch Set 2: Code-Review+1
(1 comment)
https://review.coreboot.org/c/coreboot/+/36249/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/36249/2//COMMIT_MSG@10 PS2, Line 10: Clang What version?
Hello Jacob Garber, Paul Menzel, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36249
to look at the new patch set (#3).
Change subject: commonlib: Use __builtin_offsetof with supported compilers ......................................................................
commonlib: Use __builtin_offsetof with supported compilers
Use __builtin_offsetof (which is treated as a constant expression) with Clang & GCC. This also allows check_member to work with Clang 9.
Signed-off-by: Alex James theracermaster@gmail.com Change-Id: I8b5cb4110c13ee42114ecf65932d7f1e5636210e --- M src/commonlib/include/commonlib/helpers.h 1 file changed, 4 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/36249/3
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36249 )
Change subject: commonlib: Use __builtin_offsetof with supported compilers ......................................................................
Patch Set 4: Code-Review+2
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36249 )
Change subject: commonlib: Use __builtin_offsetof with supported compilers ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/36249/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/36249/2//COMMIT_MSG@10 PS2, Line 10: Clang
What version?
Done
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/36249 )
Change subject: commonlib: Use __builtin_offsetof with supported compilers ......................................................................
commonlib: Use __builtin_offsetof with supported compilers
Use __builtin_offsetof (which is treated as a constant expression) with Clang & GCC. This also allows check_member to work with Clang 9.
Signed-off-by: Alex James theracermaster@gmail.com Change-Id: I8b5cb4110c13ee42114ecf65932d7f1e5636210e Reviewed-on: https://review.coreboot.org/c/coreboot/+/36249 Reviewed-by: Aaron Durbin adurbin@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/commonlib/include/commonlib/helpers.h 1 file changed, 4 insertions(+), 4 deletions(-)
Approvals: build bot (Jenkins): Verified Aaron Durbin: Looks good to me, approved
diff --git a/src/commonlib/include/commonlib/helpers.h b/src/commonlib/include/commonlib/helpers.h index f3b71d7..ca3b3c5 100644 --- a/src/commonlib/include/commonlib/helpers.h +++ b/src/commonlib/include/commonlib/helpers.h @@ -108,16 +108,16 @@ #define GHz (1000 * MHz)
#ifndef offsetof +#ifdef __ROMCC__ #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#else +#define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER) +#endif #endif
-#if !defined(__clang__) #define check_member(structure, member, offset) _Static_assert( \ offsetof(struct structure, member) == offset, \ "`struct " #structure "` offset for `" #member "` is not " #offset) -#else -#define check_member(structure, member, offset) -#endif
/** * container_of - cast a member of a structure out to the containing structure