xref: /aosp_15_r20/external/libcxx/include/cstddef (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===--------------------------- cstddef ----------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CSTDDEF
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_CSTDDEF
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker/*
15*58b9f456SAndroid Build Coastguard Worker    cstddef synopsis
16*58b9f456SAndroid Build Coastguard Worker
17*58b9f456SAndroid Build Coastguard WorkerMacros:
18*58b9f456SAndroid Build Coastguard Worker
19*58b9f456SAndroid Build Coastguard Worker    offsetof(type,member-designator)
20*58b9f456SAndroid Build Coastguard Worker    NULL
21*58b9f456SAndroid Build Coastguard Worker
22*58b9f456SAndroid Build Coastguard Workernamespace std
23*58b9f456SAndroid Build Coastguard Worker{
24*58b9f456SAndroid Build Coastguard Worker
25*58b9f456SAndroid Build Coastguard WorkerTypes:
26*58b9f456SAndroid Build Coastguard Worker
27*58b9f456SAndroid Build Coastguard Worker    ptrdiff_t
28*58b9f456SAndroid Build Coastguard Worker    size_t
29*58b9f456SAndroid Build Coastguard Worker    max_align_t
30*58b9f456SAndroid Build Coastguard Worker    nullptr_t
31*58b9f456SAndroid Build Coastguard Worker    byte // C++17
32*58b9f456SAndroid Build Coastguard Worker
33*58b9f456SAndroid Build Coastguard Worker}  // std
34*58b9f456SAndroid Build Coastguard Worker
35*58b9f456SAndroid Build Coastguard Worker*/
36*58b9f456SAndroid Build Coastguard Worker
37*58b9f456SAndroid Build Coastguard Worker#include <__config>
38*58b9f456SAndroid Build Coastguard Worker#include <version>
39*58b9f456SAndroid Build Coastguard Worker
40*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
41*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
42*58b9f456SAndroid Build Coastguard Worker#endif
43*58b9f456SAndroid Build Coastguard Worker
44*58b9f456SAndroid Build Coastguard Worker// Don't include our own <stddef.h>; we don't want to declare ::nullptr_t.
45*58b9f456SAndroid Build Coastguard Worker#include_next <stddef.h>
46*58b9f456SAndroid Build Coastguard Worker#include <__nullptr>
47*58b9f456SAndroid Build Coastguard Worker
48*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
49*58b9f456SAndroid Build Coastguard Worker
50*58b9f456SAndroid Build Coastguard Workerusing ::ptrdiff_t;
51*58b9f456SAndroid Build Coastguard Workerusing ::size_t;
52*58b9f456SAndroid Build Coastguard Worker
53*58b9f456SAndroid Build Coastguard Worker#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
54*58b9f456SAndroid Build Coastguard Worker    defined(__DEFINED_max_align_t) || defined(__NetBSD__)
55*58b9f456SAndroid Build Coastguard Worker// Re-use the compiler's <stddef.h> max_align_t where possible.
56*58b9f456SAndroid Build Coastguard Workerusing ::max_align_t;
57*58b9f456SAndroid Build Coastguard Worker#else
58*58b9f456SAndroid Build Coastguard Workertypedef long double max_align_t;
59*58b9f456SAndroid Build Coastguard Worker#endif
60*58b9f456SAndroid Build Coastguard Worker
61*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
62*58b9f456SAndroid Build Coastguard Worker
63*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
64*58b9f456SAndroid Build Coastguard Workernamespace std  // purposefully not versioned
65*58b9f456SAndroid Build Coastguard Worker{
66*58b9f456SAndroid Build Coastguard Workerenum class byte : unsigned char {};
67*58b9f456SAndroid Build Coastguard Worker
68*58b9f456SAndroid Build Coastguard Workerconstexpr byte  operator| (byte  __lhs, byte __rhs) noexcept
69*58b9f456SAndroid Build Coastguard Worker{
70*58b9f456SAndroid Build Coastguard Worker    return static_cast<byte>(
71*58b9f456SAndroid Build Coastguard Worker      static_cast<unsigned char>(
72*58b9f456SAndroid Build Coastguard Worker         static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)
73*58b9f456SAndroid Build Coastguard Worker    ));
74*58b9f456SAndroid Build Coastguard Worker}
75*58b9f456SAndroid Build Coastguard Worker
76*58b9f456SAndroid Build Coastguard Workerconstexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
77*58b9f456SAndroid Build Coastguard Worker{ return __lhs = __lhs | __rhs; }
78*58b9f456SAndroid Build Coastguard Worker
79*58b9f456SAndroid Build Coastguard Workerconstexpr byte  operator& (byte  __lhs, byte __rhs) noexcept
80*58b9f456SAndroid Build Coastguard Worker{
81*58b9f456SAndroid Build Coastguard Worker    return static_cast<byte>(
82*58b9f456SAndroid Build Coastguard Worker      static_cast<unsigned char>(
83*58b9f456SAndroid Build Coastguard Worker         static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)
84*58b9f456SAndroid Build Coastguard Worker    ));
85*58b9f456SAndroid Build Coastguard Worker}
86*58b9f456SAndroid Build Coastguard Worker
87*58b9f456SAndroid Build Coastguard Workerconstexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
88*58b9f456SAndroid Build Coastguard Worker{ return __lhs = __lhs & __rhs; }
89*58b9f456SAndroid Build Coastguard Worker
90*58b9f456SAndroid Build Coastguard Workerconstexpr byte  operator^ (byte  __lhs, byte __rhs) noexcept
91*58b9f456SAndroid Build Coastguard Worker{
92*58b9f456SAndroid Build Coastguard Worker    return static_cast<byte>(
93*58b9f456SAndroid Build Coastguard Worker      static_cast<unsigned char>(
94*58b9f456SAndroid Build Coastguard Worker         static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)
95*58b9f456SAndroid Build Coastguard Worker    ));
96*58b9f456SAndroid Build Coastguard Worker}
97*58b9f456SAndroid Build Coastguard Worker
98*58b9f456SAndroid Build Coastguard Workerconstexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
99*58b9f456SAndroid Build Coastguard Worker{ return __lhs = __lhs ^ __rhs; }
100*58b9f456SAndroid Build Coastguard Worker
101*58b9f456SAndroid Build Coastguard Workerconstexpr byte  operator~ (byte __b) noexcept
102*58b9f456SAndroid Build Coastguard Worker{
103*58b9f456SAndroid Build Coastguard Worker    return static_cast<byte>(
104*58b9f456SAndroid Build Coastguard Worker      static_cast<unsigned char>(
105*58b9f456SAndroid Build Coastguard Worker        ~static_cast<unsigned int>(__b)
106*58b9f456SAndroid Build Coastguard Worker    ));
107*58b9f456SAndroid Build Coastguard Worker}
108*58b9f456SAndroid Build Coastguard Worker
109*58b9f456SAndroid Build Coastguard Worker}
110*58b9f456SAndroid Build Coastguard Worker
111*58b9f456SAndroid Build Coastguard Worker#include <type_traits>  // rest of byte
112*58b9f456SAndroid Build Coastguard Worker#endif
113*58b9f456SAndroid Build Coastguard Worker
114*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CSTDDEF
115