Subversion Repositories QNX 8.QNX8 IFS tool

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /* ucl_ptr.h -- low-level pointer constructs
  2.  
  3.    This file is part of the UCL data compression library.
  4.  
  5.    Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
  6.    All Rights Reserved.
  7.  
  8.    The UCL 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 UCL 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 UCL library; see the file COPYING.
  20.    If not, write to the Free Software Foundation, Inc.,
  21.    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22.  
  23.    Markus F.X.J. Oberhumer
  24.    <markus@oberhumer.com>
  25.    http://www.oberhumer.com/opensource/ucl/
  26.  */
  27.  
  28.  
  29. /* WARNING: this file should *not* be used by applications. It is
  30.    part of the implementation of the library and is subject
  31.    to change.
  32.  */
  33.  
  34.  
  35. #ifndef __UCL_PTR_H
  36. #define __UCL_PTR_H
  37.  
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41.  
  42.  
  43. /***********************************************************************
  44. // Integral types
  45. ************************************************************************/
  46.  
  47. #if !defined(ucl_uintptr_t)
  48. #  define ucl_uintptr_t     acc_uintptr_t
  49. #endif
  50.  
  51.  
  52. /***********************************************************************
  53. //
  54. ************************************************************************/
  55.  
  56. /* Always use the safe (=integral) version for pointer-comparisions.
  57.  * The compiler should optimize away the additional casts anyway.
  58.  *
  59.  * Note that this only works if the representation and ordering
  60.  * of the pointer and the integral is the same (at bit level).
  61.  *
  62.  * Most 16-bit compilers have their own view about pointers -
  63.  * fortunately they don't care about comparing pointers
  64.  * that are pointing to Nirvana.
  65.  */
  66.  
  67. #if (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16)
  68. #define PTR(a)              ((ucl_bytep) (a))
  69. /* only need the low bits of the pointer -> offset is ok */
  70. #define PTR_ALIGNED_4(a)    ((ACC_FP_OFF(a) & 3) == 0)
  71. #define PTR_ALIGNED2_4(a,b) (((ACC_FP_OFF(a) | ACC_FP_OFF(b)) & 3) == 0)
  72. #else
  73. #define PTR(a)              ((ucl_uintptr_t) (a))
  74. #define PTR_LINEAR(a)       PTR(a)
  75. #define PTR_ALIGNED_4(a)    ((PTR_LINEAR(a) & 3) == 0)
  76. #define PTR_ALIGNED_8(a)    ((PTR_LINEAR(a) & 7) == 0)
  77. #define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0)
  78. #define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0)
  79. #endif
  80.  
  81. #define PTR_LT(a,b)         (PTR(a) < PTR(b))
  82. #define PTR_GE(a,b)         (PTR(a) >= PTR(b))
  83.  
  84.  
  85. UCL_EXTERN(ucl_uintptr_t)
  86. __ucl_ptr_linear(const ucl_voidp ptr);
  87.  
  88.  
  89. typedef union
  90. {
  91.     char            a_char;
  92.     unsigned char   a_uchar;
  93.     short           a_short;
  94.     unsigned short  a_ushort;
  95.     int             a_int;
  96.     unsigned int    a_uint;
  97.     long            a_long;
  98.     unsigned long   a_ulong;
  99.     ucl_int         a_ucl_int;
  100.     ucl_uint        a_ucl_uint;
  101.     ucl_int32       a_ucl_int32;
  102.     ucl_uint32      a_ucl_uint32;
  103.     ptrdiff_t       a_ptrdiff_t;
  104.     ucl_uintptr_t   a_ucl_uintptr_t;
  105.     ucl_voidp       a_ucl_voidp;
  106.     void *          a_void_p;
  107.     ucl_bytep       a_ucl_bytep;
  108.     ucl_bytepp      a_ucl_bytepp;
  109.     ucl_uintp       a_ucl_uintp;
  110.     ucl_uint *      a_ucl_uint_p;
  111.     ucl_uint32p     a_ucl_uint32p;
  112.     ucl_uint32 *    a_ucl_uint32_p;
  113.     unsigned char * a_uchar_p;
  114.     char *          a_char_p;
  115. }
  116. ucl_align_t;
  117.  
  118.  
  119.  
  120. #ifdef __cplusplus
  121. } /* extern "C" */
  122. #endif
  123.  
  124. #endif /* already included */
  125.  
  126. /*
  127. vi:ts=4:et
  128. */
  129.  
  130.