atomic operation on variable

Hi everyone,
How can i perform atomic operation of 64 bit variable on 32 bit system? this variable can be used anywhere like thread,signal handler and main routine. is there any way to do 64 bit variable atomic operation on 32bit system?


If you have a modern C++ compiler, you can just use std::atomic<std::uint64_t>
As these variables are normally stored in RAM, you don't need a 64bit architecture to create a 64 bit variable, as Cubbie mentioned, you can use std::atomic to declare any type of variable as atomic. also don't forget to include atomic header.
I am using c compiler, i am not able to see any such atomic header file. how can declare atomic variable?
C has the header file <stdatomic.h>, but it's not as widely supported yet. Check your compiler and your OS documentation for atomic operations.
But <stdatomic.h> is added in C11 standard, but most compilers till now they have not updated. Here i have two doubts.

1) if compiler will support atomic operation,is atomic variable whatever i will declare can be of different size. like int64. whatever i saw on internet search, when ever declaring any variable as atomic, it will take it as int (which is 32bit wide). then how can int64 should be declare as atomic operation?

2) suppose, for old compiler version using C99 standard, which does not have any provision for atomic operation. is there any function exist to make operation as atomic one?

pre-C11 atomic operations are non-standard, so it doesn't matter what version of C does your compiler support. For example, GCC has two sets of atomic operations:
Topic archived. No new replies allowed.