Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
pyatomic_gcc.h620 linesDownload Raw Back to cpython
1// This is the implementation of Python atomic operations using GCC's built-in2// functions that match the C+11 memory model. This implementation is preferred3// for GCC compatible compilers, such as Clang. These functions are available4// in GCC 4.8+ without needing to compile with --std=c11 or --std=gnu11.5 6#ifndef Py_ATOMIC_GCC_H7#  error "this header file must not be included directly"8#endif9 10 11// --- _Py_atomic_add --------------------------------------------------------12 13static inline int14_Py_atomic_add_int(int *obj, int value)15{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); }16 17static inline int8_t18_Py_atomic_add_int8(int8_t *obj, int8_t value)19{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); }20 21static inline int16_t22_Py_atomic_add_int16(int16_t *obj, int16_t value)23{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); }24 25static inline int32_t26_Py_atomic_add_int32(int32_t *obj, int32_t value)27{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); }28 29static inline int64_t30_Py_atomic_add_int64(int64_t *obj, int64_t value)31{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); }32 33static inline intptr_t34_Py_atomic_add_intptr(intptr_t *obj, intptr_t value)35{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); }36 37static inline unsigned int38_Py_atomic_add_uint(unsigned int *obj, unsigned int value)39{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); }40 41static inline uint8_t42_Py_atomic_add_uint8(uint8_t *obj, uint8_t value)43{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); }44 45static inline uint16_t46_Py_atomic_add_uint16(uint16_t *obj, uint16_t value)47{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); }48 49static inline uint32_t50_Py_atomic_add_uint32(uint32_t *obj, uint32_t value)51{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); }52 53static inline uint64_t54_Py_atomic_add_uint64(uint64_t *obj, uint64_t value)55{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); }56 57static inline uintptr_t58_Py_atomic_add_uintptr(uintptr_t *obj, uintptr_t value)59{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); }60 61static inline Py_ssize_t62_Py_atomic_add_ssize(Py_ssize_t *obj, Py_ssize_t value)63{ return __atomic_fetch_add(obj, value, __ATOMIC_SEQ_CST); }64 65 66// --- _Py_atomic_compare_exchange -------------------------------------------67 68static inline int69_Py_atomic_compare_exchange_int(int *obj, int *expected, int desired)70{ return __atomic_compare_exchange_n(obj, expected, desired, 0,71                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }72 73static inline int74_Py_atomic_compare_exchange_int8(int8_t *obj, int8_t *expected, int8_t desired)75{ return __atomic_compare_exchange_n(obj, expected, desired, 0,76                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }77 78static inline int79_Py_atomic_compare_exchange_int16(int16_t *obj, int16_t *expected, int16_t desired)80{ return __atomic_compare_exchange_n(obj, expected, desired, 0,81                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }82 83static inline int84_Py_atomic_compare_exchange_int32(int32_t *obj, int32_t *expected, int32_t desired)85{ return __atomic_compare_exchange_n(obj, expected, desired, 0,86                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }87 88static inline int89_Py_atomic_compare_exchange_int64(int64_t *obj, int64_t *expected, int64_t desired)90{ return __atomic_compare_exchange_n(obj, expected, desired, 0,91                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }92 93static inline int94_Py_atomic_compare_exchange_intptr(intptr_t *obj, intptr_t *expected, intptr_t desired)95{ return __atomic_compare_exchange_n(obj, expected, desired, 0,96                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }97 98static inline int99_Py_atomic_compare_exchange_uint(unsigned int *obj, unsigned int *expected, unsigned int desired)100{ return __atomic_compare_exchange_n(obj, expected, desired, 0,101                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }102 103static inline int104_Py_atomic_compare_exchange_uint8(uint8_t *obj, uint8_t *expected, uint8_t desired)105{ return __atomic_compare_exchange_n(obj, expected, desired, 0,106                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }107 108static inline int109_Py_atomic_compare_exchange_uint16(uint16_t *obj, uint16_t *expected, uint16_t desired)110{ return __atomic_compare_exchange_n(obj, expected, desired, 0,111                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }112 113static inline int114_Py_atomic_compare_exchange_uint32(uint32_t *obj, uint32_t *expected, uint32_t desired)115{ return __atomic_compare_exchange_n(obj, expected, desired, 0,116                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }117 118static inline int119_Py_atomic_compare_exchange_uint64(uint64_t *obj, uint64_t *expected, uint64_t desired)120{ return __atomic_compare_exchange_n(obj, expected, desired, 0,121                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }122 123static inline int124_Py_atomic_compare_exchange_uintptr(uintptr_t *obj, uintptr_t *expected, uintptr_t desired)125{ return __atomic_compare_exchange_n(obj, expected, desired, 0,126                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }127 128static inline int129_Py_atomic_compare_exchange_ssize(Py_ssize_t *obj, Py_ssize_t *expected, Py_ssize_t desired)130{ return __atomic_compare_exchange_n(obj, expected, desired, 0,131                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }132 133static inline int134_Py_atomic_compare_exchange_ptr(void *obj, void *expected, void *desired)135{ return __atomic_compare_exchange_n((void **)obj, (void **)expected, desired, 0,136                                     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }137 138 139// --- _Py_atomic_exchange ---------------------------------------------------140 141static inline int142_Py_atomic_exchange_int(int *obj, int value)143{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); }144 145static inline int8_t146_Py_atomic_exchange_int8(int8_t *obj, int8_t value)147{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); }148 149static inline int16_t150_Py_atomic_exchange_int16(int16_t *obj, int16_t value)151{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); }152 153static inline int32_t154_Py_atomic_exchange_int32(int32_t *obj, int32_t value)155{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); }156 157static inline int64_t158_Py_atomic_exchange_int64(int64_t *obj, int64_t value)159{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); }160 161static inline intptr_t162_Py_atomic_exchange_intptr(intptr_t *obj, intptr_t value)163{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); }164 165static inline unsigned int166_Py_atomic_exchange_uint(unsigned int *obj, unsigned int value)167{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); }168 169static inline uint8_t170_Py_atomic_exchange_uint8(uint8_t *obj, uint8_t value)171{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); }172 173static inline uint16_t174_Py_atomic_exchange_uint16(uint16_t *obj, uint16_t value)175{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); }176 177static inline uint32_t178_Py_atomic_exchange_uint32(uint32_t *obj, uint32_t value)179{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); }180 181static inline uint64_t182_Py_atomic_exchange_uint64(uint64_t *obj, uint64_t value)183{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); }184 185static inline uintptr_t186_Py_atomic_exchange_uintptr(uintptr_t *obj, uintptr_t value)187{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); }188 189static inline Py_ssize_t190_Py_atomic_exchange_ssize(Py_ssize_t *obj, Py_ssize_t value)191{ return __atomic_exchange_n(obj, value, __ATOMIC_SEQ_CST); }192 193static inline void *194_Py_atomic_exchange_ptr(void *obj, void *value)195{ return __atomic_exchange_n((void **)obj, value, __ATOMIC_SEQ_CST); }196 197 198// --- _Py_atomic_and --------------------------------------------------------199 200static inline uint8_t201_Py_atomic_and_uint8(uint8_t *obj, uint8_t value)202{ return __atomic_fetch_and(obj, value, __ATOMIC_SEQ_CST); }203 204static inline uint16_t205_Py_atomic_and_uint16(uint16_t *obj, uint16_t value)206{ return __atomic_fetch_and(obj, value, __ATOMIC_SEQ_CST); }207 208static inline uint32_t209_Py_atomic_and_uint32(uint32_t *obj, uint32_t value)210{ return __atomic_fetch_and(obj, value, __ATOMIC_SEQ_CST); }211 212static inline uint64_t213_Py_atomic_and_uint64(uint64_t *obj, uint64_t value)214{ return __atomic_fetch_and(obj, value, __ATOMIC_SEQ_CST); }215 216static inline uintptr_t217_Py_atomic_and_uintptr(uintptr_t *obj, uintptr_t value)218{ return __atomic_fetch_and(obj, value, __ATOMIC_SEQ_CST); }219 220 221// --- _Py_atomic_or ---------------------------------------------------------222 223static inline uint8_t224_Py_atomic_or_uint8(uint8_t *obj, uint8_t value)225{ return __atomic_fetch_or(obj, value, __ATOMIC_SEQ_CST); }226 227static inline uint16_t228_Py_atomic_or_uint16(uint16_t *obj, uint16_t value)229{ return __atomic_fetch_or(obj, value, __ATOMIC_SEQ_CST); }230 231static inline uint32_t232_Py_atomic_or_uint32(uint32_t *obj, uint32_t value)233{ return __atomic_fetch_or(obj, value, __ATOMIC_SEQ_CST); }234 235static inline uint64_t236_Py_atomic_or_uint64(uint64_t *obj, uint64_t value)237{ return __atomic_fetch_or(obj, value, __ATOMIC_SEQ_CST); }238 239static inline uintptr_t240_Py_atomic_or_uintptr(uintptr_t *obj, uintptr_t value)241{ return __atomic_fetch_or(obj, value, __ATOMIC_SEQ_CST); }242 243 244// --- _Py_atomic_load -------------------------------------------------------245 246static inline int247_Py_atomic_load_int(const int *obj)248{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); }249 250static inline int8_t251_Py_atomic_load_int8(const int8_t *obj)252{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); }253 254static inline int16_t255_Py_atomic_load_int16(const int16_t *obj)256{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); }257 258static inline int32_t259_Py_atomic_load_int32(const int32_t *obj)260{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); }261 262static inline int64_t263_Py_atomic_load_int64(const int64_t *obj)264{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); }265 266static inline intptr_t267_Py_atomic_load_intptr(const intptr_t *obj)268{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); }269 270static inline uint8_t271_Py_atomic_load_uint8(const uint8_t *obj)272{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); }273 274static inline uint16_t275_Py_atomic_load_uint16(const uint16_t *obj)276{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); }277 278static inline uint32_t279_Py_atomic_load_uint32(const uint32_t *obj)280{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); }281 282static inline uint64_t283_Py_atomic_load_uint64(const uint64_t *obj)284{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); }285 286static inline uintptr_t287_Py_atomic_load_uintptr(const uintptr_t *obj)288{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); }289 290static inline unsigned int291_Py_atomic_load_uint(const unsigned int *obj)292{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); }293 294static inline Py_ssize_t295_Py_atomic_load_ssize(const Py_ssize_t *obj)296{ return __atomic_load_n(obj, __ATOMIC_SEQ_CST); }297 298static inline void *299_Py_atomic_load_ptr(const void *obj)300{ return (void *)__atomic_load_n((void * const *)obj, __ATOMIC_SEQ_CST); }301 302 303// --- _Py_atomic_load_relaxed -----------------------------------------------304 305static inline int306_Py_atomic_load_int_relaxed(const int *obj)307{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }308 309static inline char310_Py_atomic_load_char_relaxed(const char *obj)311{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }312 313static inline unsigned char314_Py_atomic_load_uchar_relaxed(const unsigned char *obj)315{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }316 317static inline short318_Py_atomic_load_short_relaxed(const short *obj)319{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }320 321static inline unsigned short322_Py_atomic_load_ushort_relaxed(const unsigned short *obj)323{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }324 325static inline long326_Py_atomic_load_long_relaxed(const long *obj)327{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }328 329static inline float330_Py_atomic_load_float_relaxed(const float *obj)331{ float ret; __atomic_load(obj, &ret, __ATOMIC_RELAXED); return ret; }332 333static inline double334_Py_atomic_load_double_relaxed(const double *obj)335{ double ret; __atomic_load(obj, &ret, __ATOMIC_RELAXED); return ret; }336 337static inline int8_t338_Py_atomic_load_int8_relaxed(const int8_t *obj)339{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }340 341static inline int16_t342_Py_atomic_load_int16_relaxed(const int16_t *obj)343{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }344 345static inline int32_t346_Py_atomic_load_int32_relaxed(const int32_t *obj)347{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }348 349static inline int64_t350_Py_atomic_load_int64_relaxed(const int64_t *obj)351{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }352 353static inline intptr_t354_Py_atomic_load_intptr_relaxed(const intptr_t *obj)355{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }356 357static inline uint8_t358_Py_atomic_load_uint8_relaxed(const uint8_t *obj)359{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }360 361static inline uint16_t362_Py_atomic_load_uint16_relaxed(const uint16_t *obj)363{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }364 365static inline uint32_t366_Py_atomic_load_uint32_relaxed(const uint32_t *obj)367{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }368 369static inline uint64_t370_Py_atomic_load_uint64_relaxed(const uint64_t *obj)371{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }372 373static inline uintptr_t374_Py_atomic_load_uintptr_relaxed(const uintptr_t *obj)375{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }376 377static inline unsigned int378_Py_atomic_load_uint_relaxed(const unsigned int *obj)379{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }380 381static inline Py_ssize_t382_Py_atomic_load_ssize_relaxed(const Py_ssize_t *obj)383{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }384 385static inline void *386_Py_atomic_load_ptr_relaxed(const void *obj)387{ return (void *)__atomic_load_n((void * const *)obj, __ATOMIC_RELAXED); }388 389static inline unsigned long long390_Py_atomic_load_ullong_relaxed(const unsigned long long *obj)391{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }392 393static inline long long394_Py_atomic_load_llong_relaxed(const long long *obj)395{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }396 397 398// --- _Py_atomic_store ------------------------------------------------------399 400static inline void401_Py_atomic_store_int(int *obj, int value)402{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); }403 404static inline void405_Py_atomic_store_int8(int8_t *obj, int8_t value)406{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); }407 408static inline void409_Py_atomic_store_int16(int16_t *obj, int16_t value)410{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); }411 412static inline void413_Py_atomic_store_int32(int32_t *obj, int32_t value)414{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); }415 416static inline void417_Py_atomic_store_int64(int64_t *obj, int64_t value)418{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); }419 420static inline void421_Py_atomic_store_intptr(intptr_t *obj, intptr_t value)422{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); }423 424static inline void425_Py_atomic_store_uint8(uint8_t *obj, uint8_t value)426{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); }427 428static inline void429_Py_atomic_store_uint16(uint16_t *obj, uint16_t value)430{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); }431 432static inline void433_Py_atomic_store_uint32(uint32_t *obj, uint32_t value)434{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); }435 436static inline void437_Py_atomic_store_uint64(uint64_t *obj, uint64_t value)438{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); }439 440static inline void441_Py_atomic_store_uintptr(uintptr_t *obj, uintptr_t value)442{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); }443 444static inline void445_Py_atomic_store_uint(unsigned int *obj, unsigned int value)446{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); }447 448static inline void449_Py_atomic_store_ptr(void *obj, void *value)450{ __atomic_store_n((void **)obj, value, __ATOMIC_SEQ_CST); }451 452static inline void453_Py_atomic_store_ssize(Py_ssize_t *obj, Py_ssize_t value)454{ __atomic_store_n(obj, value, __ATOMIC_SEQ_CST); }455 456 457// --- _Py_atomic_store_relaxed ----------------------------------------------458 459static inline void460_Py_atomic_store_int_relaxed(int *obj, int value)461{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }462 463static inline void464_Py_atomic_store_int8_relaxed(int8_t *obj, int8_t value)465{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }466 467static inline void468_Py_atomic_store_int16_relaxed(int16_t *obj, int16_t value)469{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }470 471static inline void472_Py_atomic_store_int32_relaxed(int32_t *obj, int32_t value)473{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }474 475static inline void476_Py_atomic_store_int64_relaxed(int64_t *obj, int64_t value)477{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }478 479static inline void480_Py_atomic_store_intptr_relaxed(intptr_t *obj, intptr_t value)481{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }482 483static inline void484_Py_atomic_store_uint8_relaxed(uint8_t *obj, uint8_t value)485{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }486 487static inline void488_Py_atomic_store_uint16_relaxed(uint16_t *obj, uint16_t value)489{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }490 491static inline void492_Py_atomic_store_uint32_relaxed(uint32_t *obj, uint32_t value)493{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }494 495static inline void496_Py_atomic_store_uint64_relaxed(uint64_t *obj, uint64_t value)497{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }498 499static inline void500_Py_atomic_store_uintptr_relaxed(uintptr_t *obj, uintptr_t value)501{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }502 503static inline void504_Py_atomic_store_uint_relaxed(unsigned int *obj, unsigned int value)505{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }506 507static inline void508_Py_atomic_store_ptr_relaxed(void *obj, void *value)509{ __atomic_store_n((void **)obj, value, __ATOMIC_RELAXED); }510 511static inline void512_Py_atomic_store_ssize_relaxed(Py_ssize_t *obj, Py_ssize_t value)513{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }514 515static inline void516_Py_atomic_store_ullong_relaxed(unsigned long long *obj,517                                unsigned long long value)518{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }519 520static inline void521_Py_atomic_store_char_relaxed(char *obj, char value)522{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }523 524static inline void525_Py_atomic_store_uchar_relaxed(unsigned char *obj, unsigned char value)526{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }527 528static inline void529_Py_atomic_store_short_relaxed(short *obj, short value)530{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }531 532static inline void533_Py_atomic_store_ushort_relaxed(unsigned short *obj, unsigned short value)534{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }535 536static inline void537_Py_atomic_store_long_relaxed(long *obj, long value)538{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }539 540static inline void541_Py_atomic_store_float_relaxed(float *obj, float value)542{ __atomic_store(obj, &value, __ATOMIC_RELAXED); }543 544static inline void545_Py_atomic_store_double_relaxed(double *obj, double value)546{ __atomic_store(obj, &value, __ATOMIC_RELAXED); }547 548static inline void549_Py_atomic_store_llong_relaxed(long long *obj, long long value)550{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }551 552 553// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------554 555static inline void *556_Py_atomic_load_ptr_acquire(const void *obj)557{ return (void *)__atomic_load_n((void * const *)obj, __ATOMIC_ACQUIRE); }558 559static inline uintptr_t560_Py_atomic_load_uintptr_acquire(const uintptr_t *obj)561{ return (uintptr_t)__atomic_load_n(obj, __ATOMIC_ACQUIRE); }562 563static inline void564_Py_atomic_store_ptr_release(void *obj, void *value)565{ __atomic_store_n((void **)obj, value, __ATOMIC_RELEASE); }566 567static inline void568_Py_atomic_store_uintptr_release(uintptr_t *obj, uintptr_t value)569{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); }570 571static inline void572_Py_atomic_store_int_release(int *obj, int value)573{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); }574 575static inline void576_Py_atomic_store_ssize_release(Py_ssize_t *obj, Py_ssize_t value)577{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); }578 579static inline void580_Py_atomic_store_uint_release(unsigned int *obj, unsigned int value)581{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); }582 583static inline int584_Py_atomic_load_int_acquire(const int *obj)585{ return __atomic_load_n(obj, __ATOMIC_ACQUIRE); }586 587static inline void588_Py_atomic_store_uint32_release(uint32_t *obj, uint32_t value)589{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); }590 591static inline void592_Py_atomic_store_uint64_release(uint64_t *obj, uint64_t value)593{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); }594 595static inline uint64_t596_Py_atomic_load_uint64_acquire(const uint64_t *obj)597{ return __atomic_load_n(obj, __ATOMIC_ACQUIRE); }598 599static inline uint32_t600_Py_atomic_load_uint32_acquire(const uint32_t *obj)601{ return __atomic_load_n(obj, __ATOMIC_ACQUIRE); }602 603static inline Py_ssize_t604_Py_atomic_load_ssize_acquire(const Py_ssize_t *obj)605{ return __atomic_load_n(obj, __ATOMIC_ACQUIRE); }606 607// --- _Py_atomic_fence ------------------------------------------------------608 609static inline void610_Py_atomic_fence_seq_cst(void)611{ __atomic_thread_fence(__ATOMIC_SEQ_CST); }612 613 static inline void614_Py_atomic_fence_acquire(void)615{ __atomic_thread_fence(__ATOMIC_ACQUIRE); }616 617 static inline void618_Py_atomic_fence_release(void)619{ __atomic_thread_fence(__ATOMIC_RELEASE); }620 
codekingpro/portable-devtools · Team Ai