[SERVER-38595] atomic_word.h, typedefs are misleading, nonportable, noncompliant Created: 13/Dec/18  Updated: 29/Oct/23  Resolved: 07/Jan/19

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.1.7

Type: Bug Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Dev Tools 2018-12-31, Dev Tools 2019-01-14
Participants:

 Description   

In a few places, the header uses identifiers with leading underscore and capital letter, which are reserved.

https://github.com/mongodb/mongo/blob/63e43f1bb47f7bddf3dc37ad03a2bbee6d2a9423/src/mongo/platform/atomic_word.h

_ATOMIC_WORD_DECLARE(AtomicUInt32, unsigned);
_ATOMIC_WORD_DECLARE(AtomicUInt64, unsigned long long);
_ATOMIC_WORD_DECLARE(AtomicInt32, int);
_ATOMIC_WORD_DECLARE(AtomicInt64, long long);
_ATOMIC_WORD_DECLARE(AtomicBool, bool);

People think AtomicInt32 wraps int32_t and it doesn't.
This is benign for the AtomicInt32 case, because it's easy to believe that and still be right because 'int32_t' is 'int'.
But for the 64-bit cases, you'll be wrong sometimes. e.g. std::int64_t is long on Linux. It's only long long on Windows.

Also we don't need the _ATOMIC_WORD_DECLARE structure.
All it's doing is providing static asserts that could be inside the AtomicWord class.



 Comments   
Comment by Billy Donahue [ 07/Jan/19 ]

typedefs removed by https://github.com/mongodb/mongo/commit/11bb071e91461b1f8e40b9b15ddf

Comment by Githook User [ 07/Jan/19 ]

Author:

{'username': 'BillyDonahue', 'email': 'billy.donahue@mongodb.com', 'name': 'Billy Donahue'}

Message: SERVER-38595 remove AtomicWord aliases
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/c54018da6d4374924a4cf93236364bfad51b0b35

Comment by Billy Donahue [ 21/Dec/18 ]

The macros would be eliminated by
https://mongodbcr.appspot.com/245700001/

The integer rank problems would still remain though.

Generated at Thu Feb 08 04:49:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.