C++ Logo

std-discussion

Advanced search

Re: Guaranteed size of binary semaphore?

From: Jens Maurer <Jens.Maurer_at_[hidden]>
Date: Thu, 31 Mar 2022 20:19:10 +0200
On 31/03/2022 20.00, KL via Std-Discussion wrote:
> Hi,
>
> I measured the size of a binary semaphore.
> https://en.cppreference.com/w/cpp/thread/counting_semaphore
>
> I found 4 bytes, the size of an int32_t on a 64 bit system.
>
> I need your confirmation that this size won't vary in the future and that it is not implementation defined.

The size of any type is implementation-defined.

> I rely on that inside a mmap structure that won't be touched later. Arch: amd64.

Some implementations make an effort to remain ABI-compatible as they evolve,
which includes keeping the size of library-defined classes the same.
However, that's entirely at the discretion of the implementation.

Please contact the vendor of your implementation if you seek any such guarantees.

Jens

Received on 2022-03-31 18:19:13