-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
various fixups for atomic operation APIs #22915
various fixups for atomic operation APIs #22915
Conversation
All checks are passing now. checkpatch (informational only, not a failure)
Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
@andrewboie given your comment (#22887 (comment)) should then |
I think you can add "fixes #22887" to the description. |
fd382ce
to
b399ffd
Compare
atomic_t is currently a signed integer. using uintptr_t would convert it to an unsigned value, which I do not want to do in this PR. |
Is a long guaranteed to be the same size as a pointer? AFAIK it is only guaranteed to be 32 bits or more. |
I used one of zephyr's derived types in zephyr/types.h. I did not typedef atomic_t to long. slong_t / ulong_t are defined as being able to hold a pointer. They are that header's version of uintptr_t / intptr_t |
We can't make atomic_t be an architecture-dependent size. Users need to be able to store known quantities in it. And on a practical level: 64 bit platforms need to be able to make atomic updates to 32 bit ints too. |
What do you suggest we do? |
I don't see that we have much choice. Apps want a consistent data type for atomic operations (e.g lock counts) that isn't architecture-dependent. But they also want to be able to store a pointer/address in them. I think having a separate "atomic_addr_t" (which on 32 bit systems would just be implemented as a atomic_t) is reasonable enough. And I take no position on signed/unsigned. From my perspective it's perfectly OK to have it be any integer type and let the applications cast as needed. The feature being provided is about the memory underneath the type, not the bytes themselves. |
What about the original suggestion:
|
Yeah, you guys have convinced me ... updated PR in a bit |
The variable needs to be an atomic_t, and in one case it was being incremented outside of an atomic_inc/atomic_add. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
In some cases this was a bool, in some cases an integer value of 1 or 0. Standardize on bool. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
b399ffd
to
a66292c
Compare
Updated PR ... adds atomic_ptr_* APIs for cas, get, set, clear. |
a66292c
to
5ffe510
Compare
The existing APIs are insufficient on 64-bit systems as atomic_t is 32-bits wide. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
5ffe510
to
8c91ad5
Compare
Fixes: #22887