blob: c92ae72fe2c2d72bb94de77083500b48e8bba9ed [file] [log] [blame]
Michael Forster82c02d32022-05-20 21:47:33 -07001// Part of the Crubit project, under the Apache License v2.0 with LLVM
2// Exceptions. See /LICENSE for license information.
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
Lukasz Anforowicz19e057d2022-10-28 12:03:23 -07005// Automatically @generated Rust bindings for the following C++ target:
Michael Forster82c02d32022-05-20 21:47:33 -07006// //rs_bindings_from_cc/test/golden:bitfields_cc
Devin Jeanpierre6ed0f602023-03-01 17:22:54 -08007// Features: experimental, supported
Lukasz Anforowicz19e057d2022-10-28 12:03:23 -07008
Devin Jeanpierre43356432023-01-13 12:39:02 -08009#![rustfmt::skip]
Googlere842bf42023-04-24 06:03:47 -070010#![feature(
11 custom_inner_attributes,
12 impl_trait_in_assoc_type,
13 negative_impls,
14 type_alias_impl_trait
15)]
Lukasz Anforowicz16889da2022-10-06 13:37:48 -070016#![allow(stable_features)]
Googler61afe912023-03-03 13:59:15 -080017#![no_std]
Lukasz Anforowicz4bb78a72023-03-06 14:10:37 -080018#![allow(improper_ctypes)]
Michael Forster82c02d32022-05-20 21:47:33 -070019#![allow(non_camel_case_types)]
20#![allow(non_snake_case)]
21#![allow(non_upper_case_globals)]
22#![deny(warnings)]
23
Michael Forster82c02d32022-05-20 21:47:33 -070024// Part of the Crubit project, under the Apache License v2.0 with LLVM
25// Exceptions. See /LICENSE for license information.
26// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
27
Devin Jeanpierrecd5ebf32022-07-08 05:31:55 -070028#[::ctor::recursively_pinned]
Michael Forster82c02d32022-05-20 21:47:33 -070029#[repr(C, align(4))]
30pub struct WithBitfields {
31 // f1 : 2 bits
Googlerbed0a2a2023-03-01 11:53:43 -080032 __bitfields0: [::core::mem::MaybeUninit<u8>; 1],
Lukasz Anforowicz460e4272023-05-18 16:11:46 -070033 pub f2: ::core::ffi::c_int,
Michael Forster82c02d32022-05-20 21:47:33 -070034 // f3 : 4 bits
35 // f4 : 8 bits
36 // : 45 bits
Googlerbed0a2a2023-03-01 11:53:43 -080037 __bitfields2: [::core::mem::MaybeUninit<u8>; 10],
Lukasz Anforowicz460e4272023-05-18 16:11:46 -070038 pub f5: ::core::ffi::c_int,
Michael Forster82c02d32022-05-20 21:47:33 -070039 // f6 : 23 bits
Googlerbed0a2a2023-03-01 11:53:43 -080040 __bitfields4: [::core::mem::MaybeUninit<u8>; 3],
Devin Jeanpierre851a6412023-04-13 14:38:14 -070041 /// Reason for representing this field as a blob of bytes:
42 /// `[[no_unique_address]]` attribute was present.
Googlerbed0a2a2023-03-01 11:53:43 -080043 pub(crate) f7: [::core::mem::MaybeUninit<u8>; 1],
Michael Forster82c02d32022-05-20 21:47:33 -070044 // f8 : 2 bits
Googlerbed0a2a2023-03-01 11:53:43 -080045 __bitfields6: [::core::mem::MaybeUninit<u8>; 1],
Michael Forster82c02d32022-05-20 21:47:33 -070046}
47forward_declare::unsafe_define!(forward_declare::symbol!("WithBitfields"), crate::WithBitfields);
48impl WithBitfields {
49 pub fn f7(&self) -> &u8 {
50 unsafe { &*(&self.f7 as *const _ as *const u8) }
51 }
52}
53
Devin Jeanpierrecd5ebf32022-07-08 05:31:55 -070054impl ::ctor::CtorNew<()> for WithBitfields {
55 type CtorType = impl ::ctor::Ctor<Output = Self>;
Devin Jeanpierre56413252022-06-02 18:48:24 -070056 #[inline(always)]
57 fn ctor_new(args: ()) -> Self::CtorType {
58 let () = args;
Devin Jeanpierre93927e82022-08-01 14:05:54 -070059 unsafe {
Googlerbed0a2a2023-03-01 11:53:43 -080060 ::ctor::FnCtor::new(
61 move |dest: ::core::pin::Pin<&mut ::core::mem::MaybeUninit<Self>>| {
62 crate::detail::__rust_thunk___ZN13WithBitfieldsC1Ev(
63 ::core::pin::Pin::into_inner_unchecked(dest),
64 );
65 },
66 )
Devin Jeanpierre93927e82022-08-01 14:05:54 -070067 }
Devin Jeanpierre56413252022-06-02 18:48:24 -070068 }
69}
Michael Forster82c02d32022-05-20 21:47:33 -070070
Felipe de A. Mello Pereira6f3cf162023-01-16 00:48:25 -080071impl<'b> ::ctor::CtorNew<&'b Self> for WithBitfields {
Devin Jeanpierre83cb2dc2022-07-15 01:50:28 -070072 type CtorType = impl ::ctor::Ctor<Output = Self> + ::ctor::Captures<'b>;
Devin Jeanpierre56413252022-06-02 18:48:24 -070073 #[inline(always)]
Felipe de A. Mello Pereira6f3cf162023-01-16 00:48:25 -080074 fn ctor_new(args: &'b Self) -> Self::CtorType {
Devin Jeanpierre56413252022-06-02 18:48:24 -070075 let __param_0 = args;
Devin Jeanpierre93927e82022-08-01 14:05:54 -070076 unsafe {
Googlerbed0a2a2023-03-01 11:53:43 -080077 ::ctor::FnCtor::new(
78 move |dest: ::core::pin::Pin<&mut ::core::mem::MaybeUninit<Self>>| {
79 crate::detail::__rust_thunk___ZN13WithBitfieldsC1ERKS_(
80 ::core::pin::Pin::into_inner_unchecked(dest),
81 __param_0,
82 );
83 },
84 )
Devin Jeanpierre93927e82022-08-01 14:05:54 -070085 }
Devin Jeanpierre56413252022-06-02 18:48:24 -070086 }
87}
Felipe de A. Mello Pereira6f3cf162023-01-16 00:48:25 -080088impl<'b> ::ctor::CtorNew<(&'b Self,)> for WithBitfields {
Devin Jeanpierre83cb2dc2022-07-15 01:50:28 -070089 type CtorType = impl ::ctor::Ctor<Output = Self> + ::ctor::Captures<'b>;
Devin Jeanpierre56413252022-06-02 18:48:24 -070090 #[inline(always)]
Felipe de A. Mello Pereira6f3cf162023-01-16 00:48:25 -080091 fn ctor_new(args: (&'b Self,)) -> Self::CtorType {
Devin Jeanpierre56413252022-06-02 18:48:24 -070092 let (arg,) = args;
Felipe de A. Mello Pereira6f3cf162023-01-16 00:48:25 -080093 <Self as ::ctor::CtorNew<&'b Self>>::ctor_new(arg)
Devin Jeanpierre56413252022-06-02 18:48:24 -070094 }
95}
Michael Forster82c02d32022-05-20 21:47:33 -070096
Felipe de A. Mello Pereira6f3cf162023-01-16 00:48:25 -080097impl<'b> ::ctor::CtorNew<::ctor::RvalueReference<'b, Self>> for WithBitfields {
Devin Jeanpierre83cb2dc2022-07-15 01:50:28 -070098 type CtorType = impl ::ctor::Ctor<Output = Self> + ::ctor::Captures<'b>;
Devin Jeanpierre56413252022-06-02 18:48:24 -070099 #[inline(always)]
Felipe de A. Mello Pereira6f3cf162023-01-16 00:48:25 -0800100 fn ctor_new(args: ::ctor::RvalueReference<'b, Self>) -> Self::CtorType {
Devin Jeanpierre56413252022-06-02 18:48:24 -0700101 let __param_0 = args;
Devin Jeanpierre93927e82022-08-01 14:05:54 -0700102 unsafe {
Googlerbed0a2a2023-03-01 11:53:43 -0800103 ::ctor::FnCtor::new(
104 move |dest: ::core::pin::Pin<&mut ::core::mem::MaybeUninit<Self>>| {
105 crate::detail::__rust_thunk___ZN13WithBitfieldsC1EOS_(
106 ::core::pin::Pin::into_inner_unchecked(dest),
107 __param_0,
108 );
109 },
110 )
Devin Jeanpierre93927e82022-08-01 14:05:54 -0700111 }
Devin Jeanpierre56413252022-06-02 18:48:24 -0700112 }
113}
Felipe de A. Mello Pereira6f3cf162023-01-16 00:48:25 -0800114impl<'b> ::ctor::CtorNew<(::ctor::RvalueReference<'b, Self>,)> for WithBitfields {
Devin Jeanpierre83cb2dc2022-07-15 01:50:28 -0700115 type CtorType = impl ::ctor::Ctor<Output = Self> + ::ctor::Captures<'b>;
Devin Jeanpierre56413252022-06-02 18:48:24 -0700116 #[inline(always)]
Felipe de A. Mello Pereira6f3cf162023-01-16 00:48:25 -0800117 fn ctor_new(args: (::ctor::RvalueReference<'b, Self>,)) -> Self::CtorType {
Devin Jeanpierre56413252022-06-02 18:48:24 -0700118 let (arg,) = args;
Felipe de A. Mello Pereira6f3cf162023-01-16 00:48:25 -0800119 <Self as ::ctor::CtorNew<::ctor::RvalueReference<'b, Self>>>::ctor_new(arg)
Devin Jeanpierre56413252022-06-02 18:48:24 -0700120 }
121}
Michael Forster82c02d32022-05-20 21:47:33 -0700122
Felipe de A. Mello Pereira5b9ad752023-01-11 01:03:23 -0800123impl<'b> ::ctor::Assign<&'b Self> for WithBitfields {
Devin Jeanpierre9ced4ef2022-06-08 12:39:10 -0700124 #[inline(always)]
Googlerbed0a2a2023-03-01 11:53:43 -0800125 fn assign<'a>(self: ::core::pin::Pin<&'a mut Self>, __param_0: &'b Self) {
Devin Jeanpierre9ced4ef2022-06-08 12:39:10 -0700126 unsafe {
127 crate::detail::__rust_thunk___ZN13WithBitfieldsaSERKS_(self, __param_0);
128 }
129 }
130}
Michael Forster82c02d32022-05-20 21:47:33 -0700131
Felipe de A. Mello Pereira6f3cf162023-01-16 00:48:25 -0800132impl<'b> ::ctor::Assign<::ctor::RvalueReference<'b, Self>> for WithBitfields {
Devin Jeanpierre9ced4ef2022-06-08 12:39:10 -0700133 #[inline(always)]
134 fn assign<'a>(
Googlerbed0a2a2023-03-01 11:53:43 -0800135 self: ::core::pin::Pin<&'a mut Self>,
Felipe de A. Mello Pereira6f3cf162023-01-16 00:48:25 -0800136 __param_0: ::ctor::RvalueReference<'b, Self>,
Devin Jeanpierre9ced4ef2022-06-08 12:39:10 -0700137 ) {
138 unsafe {
139 crate::detail::__rust_thunk___ZN13WithBitfieldsaSEOS_(self, __param_0);
140 }
141 }
142}
Michael Forster82c02d32022-05-20 21:47:33 -0700143
Lukasz Anforowiczcc638f92023-05-26 11:39:04 -0700144/// This is a regression test for b/283835873 where the alignment of the
145/// generated struct was wrong/missing.
146#[::ctor::recursively_pinned]
147#[repr(C, align(4))]
148pub struct AlignmentRegressionTest {
149 // code_point : 31 bits
150 // status : 1 bits
151 __bitfields0: [::core::mem::MaybeUninit<u8>; 4],
152}
153forward_declare::unsafe_define!(
154 forward_declare::symbol!("AlignmentRegressionTest"),
155 crate::AlignmentRegressionTest
156);
157
158impl ::ctor::CtorNew<()> for AlignmentRegressionTest {
159 type CtorType = impl ::ctor::Ctor<Output = Self>;
160 #[inline(always)]
161 fn ctor_new(args: ()) -> Self::CtorType {
162 let () = args;
163 unsafe {
164 ::ctor::FnCtor::new(
165 move |dest: ::core::pin::Pin<&mut ::core::mem::MaybeUninit<Self>>| {
166 crate::detail::__rust_thunk___ZN23AlignmentRegressionTestC1Ev(
167 ::core::pin::Pin::into_inner_unchecked(dest),
168 );
169 },
170 )
171 }
172 }
173}
174
175impl<'b> ::ctor::CtorNew<&'b Self> for AlignmentRegressionTest {
176 type CtorType = impl ::ctor::Ctor<Output = Self> + ::ctor::Captures<'b>;
177 #[inline(always)]
178 fn ctor_new(args: &'b Self) -> Self::CtorType {
179 let __param_0 = args;
180 unsafe {
181 ::ctor::FnCtor::new(
182 move |dest: ::core::pin::Pin<&mut ::core::mem::MaybeUninit<Self>>| {
183 crate::detail::__rust_thunk___ZN23AlignmentRegressionTestC1ERKS_(
184 ::core::pin::Pin::into_inner_unchecked(dest),
185 __param_0,
186 );
187 },
188 )
189 }
190 }
191}
192impl<'b> ::ctor::CtorNew<(&'b Self,)> for AlignmentRegressionTest {
193 type CtorType = impl ::ctor::Ctor<Output = Self> + ::ctor::Captures<'b>;
194 #[inline(always)]
195 fn ctor_new(args: (&'b Self,)) -> Self::CtorType {
196 let (arg,) = args;
197 <Self as ::ctor::CtorNew<&'b Self>>::ctor_new(arg)
198 }
199}
200
201impl<'b> ::ctor::CtorNew<::ctor::RvalueReference<'b, Self>> for AlignmentRegressionTest {
202 type CtorType = impl ::ctor::Ctor<Output = Self> + ::ctor::Captures<'b>;
203 #[inline(always)]
204 fn ctor_new(args: ::ctor::RvalueReference<'b, Self>) -> Self::CtorType {
205 let __param_0 = args;
206 unsafe {
207 ::ctor::FnCtor::new(
208 move |dest: ::core::pin::Pin<&mut ::core::mem::MaybeUninit<Self>>| {
209 crate::detail::__rust_thunk___ZN23AlignmentRegressionTestC1EOS_(
210 ::core::pin::Pin::into_inner_unchecked(dest),
211 __param_0,
212 );
213 },
214 )
215 }
216 }
217}
218impl<'b> ::ctor::CtorNew<(::ctor::RvalueReference<'b, Self>,)> for AlignmentRegressionTest {
219 type CtorType = impl ::ctor::Ctor<Output = Self> + ::ctor::Captures<'b>;
220 #[inline(always)]
221 fn ctor_new(args: (::ctor::RvalueReference<'b, Self>,)) -> Self::CtorType {
222 let (arg,) = args;
223 <Self as ::ctor::CtorNew<::ctor::RvalueReference<'b, Self>>>::ctor_new(arg)
224 }
225}
226
227impl<'b> ::ctor::Assign<&'b Self> for AlignmentRegressionTest {
228 #[inline(always)]
229 fn assign<'a>(self: ::core::pin::Pin<&'a mut Self>, __param_0: &'b Self) {
230 unsafe {
231 crate::detail::__rust_thunk___ZN23AlignmentRegressionTestaSERKS_(self, __param_0);
232 }
233 }
234}
235
236impl<'b> ::ctor::Assign<::ctor::RvalueReference<'b, Self>> for AlignmentRegressionTest {
237 #[inline(always)]
238 fn assign<'a>(
239 self: ::core::pin::Pin<&'a mut Self>,
240 __param_0: ::ctor::RvalueReference<'b, Self>,
241 ) {
242 unsafe {
243 crate::detail::__rust_thunk___ZN23AlignmentRegressionTestaSEOS_(self, __param_0);
244 }
245 }
246}
247
248// Error while generating bindings for item 'AlignmentRegressionTest::(unnamed enum at ./rs_bindings_from_cc/test/golden/bitfields.h:26:3)':
249// Unnamed enums are not supported yet
250
Michael Forster82c02d32022-05-20 21:47:33 -0700251// CRUBIT_RS_BINDINGS_FROM_CC_TEST_GOLDEN_BITFIELDS_H_
252
Devin Jeanpierre56413252022-06-02 18:48:24 -0700253mod detail {
254 #[allow(unused_imports)]
255 use super::*;
256 extern "C" {
257 pub(crate) fn __rust_thunk___ZN13WithBitfieldsC1Ev<'a>(
Googlerbed0a2a2023-03-01 11:53:43 -0800258 __this: &'a mut ::core::mem::MaybeUninit<crate::WithBitfields>,
Devin Jeanpierre56413252022-06-02 18:48:24 -0700259 );
260 pub(crate) fn __rust_thunk___ZN13WithBitfieldsC1ERKS_<'a, 'b>(
Googlerbed0a2a2023-03-01 11:53:43 -0800261 __this: &'a mut ::core::mem::MaybeUninit<crate::WithBitfields>,
Devin Jeanpierre56413252022-06-02 18:48:24 -0700262 __param_0: &'b crate::WithBitfields,
263 );
264 pub(crate) fn __rust_thunk___ZN13WithBitfieldsC1EOS_<'a, 'b>(
Googlerbed0a2a2023-03-01 11:53:43 -0800265 __this: &'a mut ::core::mem::MaybeUninit<crate::WithBitfields>,
Devin Jeanpierrecd5ebf32022-07-08 05:31:55 -0700266 __param_0: ::ctor::RvalueReference<'b, crate::WithBitfields>,
Devin Jeanpierre56413252022-06-02 18:48:24 -0700267 );
Devin Jeanpierre9ced4ef2022-06-08 12:39:10 -0700268 pub(crate) fn __rust_thunk___ZN13WithBitfieldsaSERKS_<'a, 'b>(
Googlerbed0a2a2023-03-01 11:53:43 -0800269 __this: ::core::pin::Pin<&'a mut crate::WithBitfields>,
Devin Jeanpierre9ced4ef2022-06-08 12:39:10 -0700270 __param_0: &'b crate::WithBitfields,
Googlerbed0a2a2023-03-01 11:53:43 -0800271 ) -> ::core::pin::Pin<&'a mut crate::WithBitfields>;
Devin Jeanpierre9ced4ef2022-06-08 12:39:10 -0700272 pub(crate) fn __rust_thunk___ZN13WithBitfieldsaSEOS_<'a, 'b>(
Googlerbed0a2a2023-03-01 11:53:43 -0800273 __this: ::core::pin::Pin<&'a mut crate::WithBitfields>,
Devin Jeanpierrecd5ebf32022-07-08 05:31:55 -0700274 __param_0: ::ctor::RvalueReference<'b, crate::WithBitfields>,
Googlerbed0a2a2023-03-01 11:53:43 -0800275 ) -> ::core::pin::Pin<&'a mut crate::WithBitfields>;
Lukasz Anforowiczcc638f92023-05-26 11:39:04 -0700276 pub(crate) fn __rust_thunk___ZN23AlignmentRegressionTestC1Ev<'a>(
277 __this: &'a mut ::core::mem::MaybeUninit<crate::AlignmentRegressionTest>,
278 );
279 pub(crate) fn __rust_thunk___ZN23AlignmentRegressionTestC1ERKS_<'a, 'b>(
280 __this: &'a mut ::core::mem::MaybeUninit<crate::AlignmentRegressionTest>,
281 __param_0: &'b crate::AlignmentRegressionTest,
282 );
283 pub(crate) fn __rust_thunk___ZN23AlignmentRegressionTestC1EOS_<'a, 'b>(
284 __this: &'a mut ::core::mem::MaybeUninit<crate::AlignmentRegressionTest>,
285 __param_0: ::ctor::RvalueReference<'b, crate::AlignmentRegressionTest>,
286 );
287 pub(crate) fn __rust_thunk___ZN23AlignmentRegressionTestaSERKS_<'a, 'b>(
288 __this: ::core::pin::Pin<&'a mut crate::AlignmentRegressionTest>,
289 __param_0: &'b crate::AlignmentRegressionTest,
290 ) -> ::core::pin::Pin<&'a mut crate::AlignmentRegressionTest>;
291 pub(crate) fn __rust_thunk___ZN23AlignmentRegressionTestaSEOS_<'a, 'b>(
292 __this: ::core::pin::Pin<&'a mut crate::AlignmentRegressionTest>,
293 __param_0: ::ctor::RvalueReference<'b, crate::AlignmentRegressionTest>,
294 ) -> ::core::pin::Pin<&'a mut crate::AlignmentRegressionTest>;
Devin Jeanpierre56413252022-06-02 18:48:24 -0700295 }
296}
297
Googlerbed0a2a2023-03-01 11:53:43 -0800298const _: () = assert!(::core::mem::size_of::<Option<&i32>>() == ::core::mem::size_of::<&i32>());
Michael Forster82c02d32022-05-20 21:47:33 -0700299
Googlerbed0a2a2023-03-01 11:53:43 -0800300const _: () = assert!(::core::mem::size_of::<crate::WithBitfields>() == 32);
301const _: () = assert!(::core::mem::align_of::<crate::WithBitfields>() == 4);
Michael Forster82c02d32022-05-20 21:47:33 -0700302const _: () = {
Googler9e3ef6d2023-05-05 08:09:23 -0700303 static_assertions::assert_not_impl_any!(crate::WithBitfields:Copy);
Michael Forster82c02d32022-05-20 21:47:33 -0700304};
305const _: () = {
Googler9e3ef6d2023-05-05 08:09:23 -0700306 static_assertions::assert_not_impl_any!(crate::WithBitfields:Drop);
Michael Forster82c02d32022-05-20 21:47:33 -0700307};
Lukasz Anforowiczed94b242022-09-07 11:47:58 -0700308const _: () = assert!(memoffset::offset_of!(crate::WithBitfields, f2) == 4);
309const _: () = assert!(memoffset::offset_of!(crate::WithBitfields, f5) == 20);
310const _: () = assert!(memoffset::offset_of!(crate::WithBitfields, f7) == 27);
Lukasz Anforowiczcc638f92023-05-26 11:39:04 -0700311
312const _: () = assert!(::core::mem::size_of::<crate::AlignmentRegressionTest>() == 4);
313const _: () = assert!(::core::mem::align_of::<crate::AlignmentRegressionTest>() == 4);
314const _: () = {
315 static_assertions::assert_not_impl_any!(crate::AlignmentRegressionTest:Copy);
316};
317const _: () = {
318 static_assertions::assert_not_impl_any!(crate::AlignmentRegressionTest:Drop);
319};