| Kenny Root | 18092dd | 2010-11-24 12:56:06 -0800 | [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 __LIB_UTILS_COMPAT_H | 
|  | 18 | #define __LIB_UTILS_COMPAT_H | 
|  | 19 |  | 
|  | 20 | #include <unistd.h> | 
|  | 21 |  | 
|  | 22 | /* Compatibility definitions for non-Linux (i.e., BSD-based) hosts. */ | 
|  | 23 | #ifndef HAVE_OFF64_T | 
|  | 24 | #if _FILE_OFFSET_BITS < 64 | 
|  | 25 | #error "_FILE_OFFSET_BITS < 64; large files are not supported on this platform" | 
|  | 26 | #endif /* _FILE_OFFSET_BITS < 64 */ | 
|  | 27 |  | 
|  | 28 | typedef off_t off64_t; | 
|  | 29 |  | 
|  | 30 | static inline off64_t lseek64(int fd, off64_t offset, int whence) { | 
|  | 31 | return lseek(fd, offset, whence); | 
|  | 32 | } | 
|  | 33 |  | 
|  | 34 | #ifdef HAVE_PREAD | 
|  | 35 | static inline ssize_t pread64(int fd, void* buf, size_t nbytes, off64_t offset) { | 
|  | 36 | return pread(fd, buf, nbytes, offset); | 
|  | 37 | } | 
|  | 38 | #endif | 
|  | 39 |  | 
|  | 40 | #endif /* !HAVE_OFF64_T */ | 
|  | 41 |  | 
|  | 42 | #endif /* __LIB_UTILS_COMPAT_H */ |