1 /* ucl_ptr.c -- low-level pointer constructs
3 This file is part of the UCL data compression library.
5 Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
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.
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.
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.
23 Markus F.X.J. Oberhumer
24 <markus@oberhumer.com>
25 http://www.oberhumer.com/opensource/ucl/
32 /***********************************************************************
34 ************************************************************************/
37 __ucl_ptr_linear(const ucl_voidp ptr
)
41 #if defined(__UCL_DOS16) || defined(__UCL_WIN16)
42 p
= (((ucl_ptr_t
)(_FP_SEG(ptr
))) << (16 - __UCL_HShift
)) + (_FP_OFF(ptr
));
51 /***********************************************************************
53 ************************************************************************/
56 __ucl_align_gap(const ucl_voidp ptr
, ucl_uint size
)
62 p
= __ucl_ptr_linear(ptr
);
63 s
= (ucl_ptr_t
) (size
- 1);
65 assert((size
& (size
- 1)) == 0);
66 n
= ((p
+ s
) & ~s
) - p
;
68 n
= (((p
+ s
) / size
) * size
) - p
;