Coverage Report

Created: 2026-11-10 14:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
include/prism/compiler/align.h
Line
Count
Source
1
/**
2
 * @file compiler/align.h
3
 */
4
#ifndef PRISM_COMPILER_ALIGN_H
5
#define PRISM_COMPILER_ALIGN_H
6
7
/**
8
 * Compiler-agnostic macros for specifying alignment of types and variables.
9
 */
10
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L /* C11 or later */
11
    /** Specify alignment for a type or variable. */
12
    #define PRISM_ALIGNAS _Alignas
13
14
    /** Get the alignment requirement of a type. */
15
2.52M
    #define PRISM_ALIGNOF _Alignof
16
#elif defined(__GNUC__) || defined(__clang__)
17
    /** Specify alignment for a type or variable. */
18
    #define PRISM_ALIGNAS(size) __attribute__((aligned(size)))
19
20
    /** Get the alignment requirement of a type. */
21
    #define PRISM_ALIGNOF(type) __alignof__(type)
22
#elif defined(_MSC_VER)
23
    /** Specify alignment for a type or variable. */
24
    #define PRISM_ALIGNAS(size) __declspec(align(size))
25
26
    /** Get the alignment requirement of a type. */
27
    #define PRISM_ALIGNOF(type) __alignof(type)
28
#else
29
    /** Void because this platform does not support specifying alignment. */
30
    #define PRISM_ALIGNAS(size)
31
32
    /** Fallback to sizeof as alignment requirement of a type. */
33
    #define PRISM_ALIGNOF(type) sizeof(type)
34
#endif
35
36
#endif