[libc-commits] [PATCH] D135408: [libc] fix futex type

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Oct 6 15:06:30 PDT 2022


michaelrj created this revision.
michaelrj added reviewers: sivachandra, lntue.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added projects: libc-project, All.
michaelrj requested review of this revision.

Previously the futex type was defined in terms of unsigned int, now it's
uint32, which is more portable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135408

Files:
  libc/include/llvm-libc-types/__futex_word.h


Index: libc/include/llvm-libc-types/__futex_word.h
===================================================================
--- libc/include/llvm-libc-types/__futex_word.h
+++ libc/include/llvm-libc-types/__futex_word.h
@@ -10,16 +10,11 @@
 #define __LLVM_LIBC_TYPES_FUTEX_WORD_H__
 
 typedef struct {
-#if defined(__unix__) && (defined(__x86_64__) || defined(__aarch64__))
   // Futex word should be aligned appropriately to allow target atomic
   // instructions. This declaration mimics the internal setup.
-  _Alignas(sizeof(unsigned int) > _Alignof(unsigned int)
-               ? sizeof(unsigned int)
-               : _Alignof(unsigned int)) unsigned int __word;
-  _Static_assert(sizeof(unsigned int) == 4, "Unexpected size of unsigned int.");
-#else
-#error "A type to represent a futex word is not available for the target arch."
-#endif
+  _Alignas(sizeof(__UINT32_TYPE__) > _Alignof(__UINT32_TYPE__)
+               ? sizeof(__UINT32_TYPE__)
+               : _Alignof(__UINT32_TYPE__)) __UINT32_TYPE__ __word;
 } __futex_word;
 
 #endif // __LLVM_LIBC_TYPES_FUTEX_WORD_H__


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135408.465893.patch
Type: text/x-patch
Size: 1081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20221006/2d3eb1e4/attachment.bin>


More information about the libc-commits mailing list