blob: 276d7867d552e275cd3a374849e1f7bc8a2d9c2d [file] [log] [blame]
Rom Lemarchandca107952013-11-22 15:26:48 -08001/*
2 * Copyright (C) 2013 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#include <cstddef>
Rom Lemarchandca107952013-11-22 15:26:48 -080018#include <hardware/hardware.h>
19#include <hardware/sensors.h>
20#include <hardware/fb.h>
21#include <hardware/hwcomposer.h>
22#include <hardware/gralloc.h>
23#include <hardware/consumerir.h>
24#include <hardware/camera_common.h>
25#include <hardware/camera3.h>
26
27#define GET_PADDING(align, size) (((align) - ((size) % (align))) % (align))
28
29#define CHECK_LAST_MEMBER(type, member) \
30do { \
31static constexpr size_t calc_size = offsetof(type, member) + sizeof(((type *)0)->member); \
32static_assert(sizeof(type) == calc_size + GET_PADDING(alignof(type), calc_size), \
33"" #member " is not the last element of " #type); \
34} while (0)
35
36void CheckSizes(void) {
37 //Types defined in hardware.h
38 CHECK_LAST_MEMBER(hw_module_t, reserved);
39 CHECK_LAST_MEMBER(hw_device_t, close);
40
41 //Types defined in sensors.h
42 CHECK_LAST_MEMBER(sensors_vec_t, reserved);
43 CHECK_LAST_MEMBER(sensors_event_t, reserved1);
44 CHECK_LAST_MEMBER(struct sensor_t, reserved);
45 CHECK_LAST_MEMBER(sensors_poll_device_1_t, reserved_procs);
46
47 //Types defined in fb.h
48 CHECK_LAST_MEMBER(framebuffer_device_t, reserved_proc);
49
50 //Types defined in hwcomposer.h
51 CHECK_LAST_MEMBER(hwc_layer_1_t, reserved);
52 CHECK_LAST_MEMBER(hwc_composer_device_1_t, reserved_proc);
53
54 //Types defined in gralloc.h
55 CHECK_LAST_MEMBER(gralloc_module_t, reserved_proc);
56 CHECK_LAST_MEMBER(alloc_device_t, reserved_proc);
57
58 //Types defined in consumerir.h
59 CHECK_LAST_MEMBER(consumerir_device_t, reserved);
60
61 //Types defined in camera_common.h
62 CHECK_LAST_MEMBER(vendor_tag_ops_t, reserved);
63 CHECK_LAST_MEMBER(camera_module_t, reserved);
64
65 //Types defined in camera3.h
66 CHECK_LAST_MEMBER(camera3_device_ops_t, reserved);
67}
68