Blame src/lzo_ptr.c

Packit Service 5195f2
/* lzo_ptr.c -- low-level pointer constructs
Packit Service 5195f2
Packit Service 5195f2
   This file is part of the LZO real-time data compression library.
Packit Service 5195f2
Packit Service 5195f2
   Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
Packit Service 5195f2
   All Rights Reserved.
Packit Service 5195f2
Packit Service 5195f2
   The LZO library is free software; you can redistribute it and/or
Packit Service 5195f2
   modify it under the terms of the GNU General Public License as
Packit Service 5195f2
   published by the Free Software Foundation; either version 2 of
Packit Service 5195f2
   the License, or (at your option) any later version.
Packit Service 5195f2
Packit Service 5195f2
   The LZO library is distributed in the hope that it will be useful,
Packit Service 5195f2
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 5195f2
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 5195f2
   GNU General Public License for more details.
Packit Service 5195f2
Packit Service 5195f2
   You should have received a copy of the GNU General Public License
Packit Service 5195f2
   along with the LZO library; see the file COPYING.
Packit Service 5195f2
   If not, write to the Free Software Foundation, Inc.,
Packit Service 5195f2
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit Service 5195f2
Packit Service 5195f2
   Markus F.X.J. Oberhumer
Packit Service 5195f2
   <markus@oberhumer.com>
Packit Service 5195f2
   http://www.oberhumer.com/opensource/lzo/
Packit Service 5195f2
 */
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
#include "lzo_conf.h"
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
/***********************************************************************
Packit Service 5195f2
//
Packit Service 5195f2
************************************************************************/
Packit Service 5195f2
Packit Service 5195f2
LZO_PUBLIC(lzo_uintptr_t)
Packit Service 5195f2
__lzo_ptr_linear(const lzo_voidp ptr)
Packit Service 5195f2
{
Packit Service 5195f2
    lzo_uintptr_t p;
Packit Service 5195f2
Packit Service 5195f2
#if (LZO_ARCH_I086)
Packit Service 5195f2
#error "LZO_ARCH_I086 is unsupported"
Packit Service 5195f2
#elif (LZO_MM_PVP)
Packit Service 5195f2
#error "LZO_MM_PVP is unsupported"
Packit Service 5195f2
#else
Packit Service 5195f2
    p = (lzo_uintptr_t) PTR_LINEAR(ptr);
Packit Service 5195f2
#endif
Packit Service 5195f2
Packit Service 5195f2
    return p;
Packit Service 5195f2
}
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
/***********************************************************************
Packit Service 5195f2
//
Packit Service 5195f2
************************************************************************/
Packit Service 5195f2
Packit Service 5195f2
LZO_PUBLIC(unsigned)
Packit Service 5195f2
__lzo_align_gap(const lzo_voidp ptr, lzo_uint size)
Packit Service 5195f2
{
Packit Service 5195f2
#if (__LZO_UINTPTR_T_IS_POINTER)
Packit Service 5195f2
#error "__LZO_UINTPTR_T_IS_POINTER is unsupported"
Packit Service 5195f2
#else
Packit Service 5195f2
    lzo_uintptr_t p, n;
Packit Service 5195f2
    p = __lzo_ptr_linear(ptr);
Packit Service 5195f2
    n = (((p + size - 1) / size) * size) - p;
Packit Service 5195f2
#endif
Packit Service 5195f2
Packit Service 5195f2
    assert(size > 0);
Packit Service 5195f2
    assert((long)n >= 0);
Packit Service 5195f2
    assert(n <= size);
Packit Service 5195f2
    return (unsigned)n;
Packit Service 5195f2
}
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
/*
Packit Service 5195f2
vi:ts=4:et
Packit Service 5195f2
*/