1/* lzo_ptr.c -- low-level pointer constructs 2 3 This file is part of the LZO real-time data compression library. 4 5 Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer 6 All Rights Reserved. 7 8 The LZO library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License as 10 published by the Free Software Foundation; either version 2 of 11 the License, or (at your option) any later version. 12 13 The LZO library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with the LZO library; see the file COPYING. 20 If not, write to the Free Software Foundation, Inc., 21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 23 Markus F.X.J. Oberhumer 24 <markus@oberhumer.com> 25 http://www.oberhumer.com/opensource/lzo/ 26 */ 27 28 29#include "lzo_conf.h" 30 31 32/*********************************************************************** 33// 34************************************************************************/ 35 36LZO_PUBLIC(lzo_uintptr_t) 37__lzo_ptr_linear(const lzo_voidp ptr) 38{ 39 lzo_uintptr_t p; 40 41#if (LZO_ARCH_I086) 42#error "LZO_ARCH_I086 is unsupported" 43#elif (LZO_MM_PVP) 44#error "LZO_MM_PVP is unsupported" 45#else 46 p = (lzo_uintptr_t) PTR_LINEAR(ptr); 47#endif 48 49 return p; 50} 51 52 53/*********************************************************************** 54// 55************************************************************************/ 56 57LZO_PUBLIC(unsigned) 58__lzo_align_gap(const lzo_voidp ptr, lzo_uint size) 59{ 60#if (__LZO_UINTPTR_T_IS_POINTER) 61#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" 62#else 63 lzo_uintptr_t p, n; 64 p = __lzo_ptr_linear(ptr); 65 n = (((p + size - 1) / size) * size) - p; 66#endif 67 68 assert(size > 0); 69 assert((long)n >= 0); 70 assert(n <= size); 71 return (unsigned)n; 72} 73 74 75 76/* 77vi:ts=4:et 78*/ 79