• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #include <system/window.h>
19 #include <hardware/hardware.h>
20 #include <hardware/sensors.h>
21 #include <hardware/fb.h>
22 #include <hardware/hwcomposer.h>
23 #include <hardware/gralloc.h>
24 #include <hardware/consumerir.h>
25 #include <hardware/camera_common.h>
26 #include <hardware/camera3.h>
27 
28 template<size_t> static constexpr size_t CheckSizeHelper(size_t, size_t);
29 
CheckSizeHelper(size_t size32,size_t)30 template<> constexpr size_t CheckSizeHelper<4>(size_t size32, size_t /* size64 */) {
31     return size32;
32 }
33 
CheckSizeHelper(size_t,size_t size64)34 template<> constexpr size_t CheckSizeHelper<8>(size_t /* size32 */, size_t size64) {
35     return size64;
36 }
37 
CheckTypeSize()38 template<typename T, size_t size32, size_t size64> static void CheckTypeSize() {
39     const size_t mySize = CheckSizeHelper<sizeof(void *)>(size32, size64);
40 
41     static_assert(sizeof(T) == mySize, "struct is the wrong size");
42 }
43 
CheckSizes(void)44 void CheckSizes(void) {
45     //Types defined in hardware.h
46     CheckTypeSize<hw_module_t, 128, 248>();
47     CheckTypeSize<hw_device_t, 64, 120>();
48 
49     //Types defined in sensors.h
50     CheckTypeSize<sensors_vec_t, 16, 16>();
51     CheckTypeSize<sensors_event_t, 104, 104>();
52     CheckTypeSize<struct sensor_t, 68, 104>();
53     CheckTypeSize<sensors_poll_device_1_t, 116, 224>();
54 
55     //Types defined in fb.h
56     CheckTypeSize<framebuffer_device_t, 184, 288>();
57 
58     //Types defined in hwcomposer.h
59     CheckTypeSize<hwc_layer_1_t, 96, 120>();
60     CheckTypeSize<hwc_composer_device_1_t, 116, 224>();
61 
62     //Types defined in gralloc.h
63     CheckTypeSize<gralloc_module_t, 176, 344>();
64     CheckTypeSize<alloc_device_t, 104, 200>();
65 
66     //Types defined in consumerir.h
67     CheckTypeSize<consumerir_device_t, 96, 184>();
68 
69     //Types defined in camera_common.h
70     CheckTypeSize<vendor_tag_ops_t, 52, 104>();
71     CheckTypeSize<camera_module_t, 176, 344>();
72 
73     //Types defined in camera3.h
74     CheckTypeSize<camera3_device_ops_t, 64, 128>();
75 }
76 
77