| Colin Cross | 28fa5bc | 2012-05-20 13:28:05 -0700 | [diff] [blame] | 1 | /* | 
|  | 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 |  | 
|  | 36 | typedef unsigned long long u64; | 
|  | 37 | typedef signed long long s64; | 
|  | 38 | typedef unsigned int u32; | 
|  | 39 | typedef unsigned short int u16; | 
|  | 40 | typedef unsigned char u8; | 
|  | 41 |  | 
|  | 42 | #define DIV_ROUND_UP(x, y) (((x) + (y) - 1)/(y)) | 
|  | 43 | #define ALIGN(x, y) ((y) * DIV_ROUND_UP((x), (y))) | 
| Colin Cross | bdc6d39 | 2012-05-02 15:18:22 -0700 | [diff] [blame] | 44 | #define ALIGN_DOWN(x, y) ((y) * ((x) / (y))) | 
| Colin Cross | 28fa5bc | 2012-05-20 13:28:05 -0700 | [diff] [blame] | 45 |  | 
|  | 46 | #define error(fmt, args...) do { fprintf(stderr, "error: %s: " fmt "\n", __func__, ## args); } while (0) | 
|  | 47 | #define error_errno(s, args...) error(s ": %s", ##args, strerror(errno)) | 
|  | 48 |  | 
|  | 49 | #endif |