Blame src/lzo_ptr.h

Packit 679830
/* lzo_ptr.h -- low-level pointer constructs
Packit 679830
Packit 679830
   This file is part of the LZO real-time data compression library.
Packit 679830
Packit 679830
   Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
Packit 679830
   All Rights Reserved.
Packit 679830
Packit 679830
   The LZO library is free software; you can redistribute it and/or
Packit 679830
   modify it under the terms of the GNU General Public License as
Packit 679830
   published by the Free Software Foundation; either version 2 of
Packit 679830
   the License, or (at your option) any later version.
Packit 679830
Packit 679830
   The LZO library is distributed in the hope that it will be useful,
Packit 679830
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 679830
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 679830
   GNU General Public License for more details.
Packit 679830
Packit 679830
   You should have received a copy of the GNU General Public License
Packit 679830
   along with the LZO library; see the file COPYING.
Packit 679830
   If not, write to the Free Software Foundation, Inc.,
Packit 679830
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit 679830
Packit 679830
   Markus F.X.J. Oberhumer
Packit 679830
   <markus@oberhumer.com>
Packit 679830
   http://www.oberhumer.com/opensource/lzo/
Packit 679830
 */
Packit 679830
Packit 679830
Packit 679830
/* WARNING: this file should *not* be used by applications. It is
Packit 679830
   part of the implementation of the library and is subject
Packit 679830
   to change.
Packit 679830
 */
Packit 679830
Packit 679830
Packit 679830
#ifndef __LZO_PTR_H
Packit 679830
#define __LZO_PTR_H 1
Packit 679830
Packit 679830
#ifdef __cplusplus
Packit 679830
extern "C" {
Packit 679830
#endif
Packit 679830
Packit 679830
Packit 679830
/***********************************************************************
Packit 679830
//
Packit 679830
************************************************************************/
Packit 679830
Packit 679830
/* Always use the safe (=integral) version for pointer-comparisons.
Packit 679830
 * The compiler should optimize away the additional casts anyway.
Packit 679830
 *
Packit 679830
 * Note that this only works if the representation and ordering
Packit 679830
 * of the pointer and the integral is the same (at bit level).
Packit 679830
 */
Packit 679830
Packit 679830
#if (LZO_ARCH_I086)
Packit 679830
#error "LZO_ARCH_I086 is unsupported"
Packit 679830
#elif (LZO_MM_PVP)
Packit 679830
#error "LZO_MM_PVP is unsupported"
Packit 679830
#else
Packit 679830
#define PTR(a)              ((lzo_uintptr_t) (a))
Packit 679830
#define PTR_LINEAR(a)       PTR(a)
Packit 679830
#define PTR_ALIGNED_4(a)    ((PTR_LINEAR(a) & 3) == 0)
Packit 679830
#define PTR_ALIGNED_8(a)    ((PTR_LINEAR(a) & 7) == 0)
Packit 679830
#define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0)
Packit 679830
#define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0)
Packit 679830
#endif
Packit 679830
Packit 679830
#define PTR_LT(a,b)         (PTR(a) < PTR(b))
Packit 679830
#define PTR_GE(a,b)         (PTR(a) >= PTR(b))
Packit 679830
#define PTR_DIFF(a,b)       (PTR(a) - PTR(b))
Packit 679830
#define pd(a,b)             ((lzo_uint) ((a)-(b)))
Packit 679830
Packit 679830
Packit 679830
LZO_EXTERN(lzo_uintptr_t)
Packit 679830
__lzo_ptr_linear(const lzo_voidp ptr);
Packit 679830
Packit 679830
Packit 679830
typedef union
Packit 679830
{
Packit 679830
    char            a_char;
Packit 679830
    unsigned char   a_uchar;
Packit 679830
    short           a_short;
Packit 679830
    unsigned short  a_ushort;
Packit 679830
    int             a_int;
Packit 679830
    unsigned int    a_uint;
Packit 679830
    long            a_long;
Packit 679830
    unsigned long   a_ulong;
Packit 679830
    lzo_int         a_lzo_int;
Packit 679830
    lzo_uint        a_lzo_uint;
Packit 679830
    lzo_xint        a_lzo_xint;
Packit 679830
    lzo_int16_t     a_lzo_int16_t;
Packit 679830
    lzo_uint16_t    a_lzo_uint16_t;
Packit 679830
    lzo_int32_t     a_lzo_int32_t;
Packit 679830
    lzo_uint32_t    a_lzo_uint32_t;
Packit 679830
#if defined(lzo_uint64_t)
Packit 679830
    lzo_int64_t     a_lzo_int64_t;
Packit 679830
    lzo_uint64_t    a_lzo_uint64_t;
Packit 679830
#endif
Packit 679830
    size_t          a_size_t;
Packit 679830
    ptrdiff_t       a_ptrdiff_t;
Packit 679830
    lzo_uintptr_t   a_lzo_uintptr_t;
Packit 679830
    void *          a_void_p;
Packit 679830
    char *          a_char_p;
Packit 679830
    unsigned char * a_uchar_p;
Packit 679830
    const void *          a_c_void_p;
Packit 679830
    const char *          a_c_char_p;
Packit 679830
    const unsigned char * a_c_uchar_p;
Packit 679830
    lzo_voidp       a_lzo_voidp;
Packit 679830
    lzo_bytep       a_lzo_bytep;
Packit 679830
    const lzo_voidp a_c_lzo_voidp;
Packit 679830
    const lzo_bytep a_c_lzo_bytep;
Packit 679830
}
Packit 679830
lzo_full_align_t;
Packit 679830
Packit 679830
Packit 679830
Packit 679830
#ifdef __cplusplus
Packit 679830
} /* extern "C" */
Packit 679830
#endif
Packit 679830
Packit 679830
#endif /* already included */
Packit 679830
Packit 679830
/*
Packit 679830
vi:ts=4:et
Packit 679830
*/
Packit 679830