blob: 9741c336438e03fae643690543a6df05090b4d17 [file] [log] [blame]
Roman Stratiienkoe3983342021-02-15 15:41:53 +02001// 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>
Roman Stratiienkod21071f2021-03-09 21:56:50 +020024#include <sys/user.h>
25#include "utils/log.h"
Roman Stratiienkoe3983342021-02-15 15:41:53 +020026
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
48static inline size_t round_up_to_page_size(size_t x)
49{
Vilas Bhatb9ae5902024-03-27 18:17:45 +000050 const size_t page_size = getpagesize();
51 return (x + (page_size - 1)) & ~(page_size - 1);
Roman Stratiienkoe3983342021-02-15 15:41:53 +020052}
53
54#endif /* GRALLOC_HELPER_H_ */
55// clang-format on