Subversion Repositories QNX 8.QNX8 IFS tool

Rev

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

  1. /* ucl_ptr.c -- 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. #include "ucl_conf.h"
  30.  
  31.  
  32. /***********************************************************************
  33. //
  34. ************************************************************************/
  35.  
  36. UCL_PUBLIC(ucl_uintptr_t)
  37. __ucl_ptr_linear(const ucl_voidp ptr)
  38. {
  39.     ucl_uintptr_t p;
  40.  
  41. #if (ACC_OS_DOS16 || ACC_OS_OS216 || ACC_OS_WIN16)
  42.     p = (((ucl_uintptr_t)(ACC_FP_SEG(ptr))) << (16 - ACC_MM_AHSHIFT)) + (ACC_FP_OFF(ptr));
  43. #else
  44.     p = PTR_LINEAR(ptr);
  45. #endif
  46.  
  47.     return p;
  48. }
  49.  
  50.  
  51. /***********************************************************************
  52. //
  53. ************************************************************************/
  54.  
  55. UCL_PUBLIC(unsigned)
  56. __ucl_align_gap(const ucl_voidp ptr, ucl_uint size)
  57. {
  58.     ucl_uintptr_t p, s, n;
  59.  
  60.     assert(size > 0);
  61.  
  62.     p = __ucl_ptr_linear(ptr);
  63.     s = (ucl_uintptr_t) (size - 1);
  64. #if 0
  65.     assert((size & (size - 1)) == 0);
  66.     n = ((p + s) & ~s) - p;
  67. #else
  68.     n = (((p + s) / size) * size) - p;
  69. #endif
  70.  
  71.     assert((long)n >= 0);
  72.     assert(n <= s);
  73.  
  74.     return (unsigned)n;
  75. }
  76.  
  77.  
  78.  
  79. /*
  80. vi:ts=4:et
  81. */
  82.