MFlamer
MFlamer

Reputation: 2440

gcc atomics supported types

This is a quote from the recent gcc manual regarding the types supported for atomic operations.

The four non-arithmetic functions (load, store, exchange, and compare exchange) all have a generic version as well. This generic version works on any data type. If the data type size maps to one of the integral sizes that may have lock free support, the generic version utilizes the lock free built-in function. Otherwise an external call is left to be resolved at run time. This external call is the same format with the addition of a ‘size_t’ parameter inserted as the first parameter indicating the size of the object being pointed to. All objects must be the same size.

The original document is here gcc 4.8.1. I assume that the hardware can only perform atomic operations on simple 32, 64 and occasionaly 128bit types. So, what happens with these generic versions of the functions that take a pointer? Only the access to the pointer can actually be atomic, right?

An additional related question is how do these atomics work in a language like java where everything is boxed? What is accessed atomically, the value or the reference?

Upvotes: 0

Views: 145

Answers (1)

user1969104
user1969104

Reputation: 2420

It is mentioned that for the generic types lock is used.

Upvotes: 1

Related Questions