blob: 9137805f78cc1e78e3a040de5db1947f8dacda2f [file] [log] [blame]
Colin Cross28fa5bc2012-05-20 13:28:05 -07001/*
2 * Copyright (C) 2010 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#ifndef _LIBSPARSE_SPARSE_DEFS_
18#define _LIBSPARSE_SPARSE_DEFS_
19
20#include <errno.h>
21#include <stdio.h>
22
23#define __le64 u64
24#define __le32 u32
25#define __le16 u16
26
27#define __be64 u64
28#define __be32 u32
29#define __be16 u16
30
31#define __u64 u64
32#define __u32 u32
33#define __u16 u16
34#define __u8 u8
35
36typedef unsigned long long u64;
37typedef signed long long s64;
38typedef unsigned int u32;
39typedef unsigned short int u16;
40typedef unsigned char u8;
41
Jerry Zhang7b444f02018-06-12 16:42:09 -070042#define DIV_ROUND_UP(x, y) (((x) + (y)-1) / (y))
43#define ALIGN(x, y) ((y)*DIV_ROUND_UP((x), (y)))
Colin Crossbdc6d392012-05-02 15:18:22 -070044#define ALIGN_DOWN(x, y) ((y) * ((x) / (y)))
Colin Cross28fa5bc2012-05-20 13:28:05 -070045
Jerry Zhang7b444f02018-06-12 16:42:09 -070046#define error(fmt, args...) \
47 do { \
48 fprintf(stderr, "error: %s: " fmt "\n", __func__, ##args); \
49 } while (0)
Colin Cross28fa5bc2012-05-20 13:28:05 -070050#define error_errno(s, args...) error(s ": %s", ##args, strerror(errno))
51
52#endif