1 // clang-format off
2 /*
3 * Copyright (C) 2010-2017 ARM Limited. All rights reserved.
4 *
5 * Copyright (C) 2008 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20 #ifndef GRALLOC_HELPER_H_
21 #define GRALLOC_HELPER_H_
22
23 #include <sys/mman.h>
24 #include <sys/user.h>
25 #include "utils/log.h"
26
27 #ifndef AWAR
28 #define AWAR(fmt, args...) \
29 __android_log_print(ANDROID_LOG_WARN, "[Gralloc-Warning]", "%s:%d " fmt, __func__, __LINE__, ##args)
30 #endif
31 #ifndef AINF
32 #define AINF(fmt, args...) __android_log_print(ANDROID_LOG_INFO, "[Gralloc]", fmt, ##args)
33 #endif
34 #ifndef AERR
35 #define AERR(fmt, args...) \
36 __android_log_print(ANDROID_LOG_ERROR, "[Gralloc-ERROR]", "%s:%d " fmt, __func__, __LINE__, ##args)
37 #endif
38 #ifndef AERR_IF
39 #define AERR_IF(eq, fmt, args...) \
40 if ((eq)) \
41 AERR(fmt, args)
42 #endif
43
44 #define GRALLOC_ALIGN(value, base) (((value) + ((base)-1)) & ~((base)-1))
45
46 #define GRALLOC_UNUSED(x) ((void)x)
47
round_up_to_page_size(size_t x)48 static inline size_t round_up_to_page_size(size_t x)
49 {
50 const size_t page_size = getpagesize();
51 return (x + (page_size - 1)) & ~(page_size - 1);
52 }
53
54 #endif /* GRALLOC_HELPER_H_ */
55 // clang-format on
56