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