1258945Sroberto/*
2258945Sroberto * Copyright (C) 2004, 2007  Internet Systems Consortium, Inc. ("ISC")
3258945Sroberto * Copyright (C) 2000, 2001  Internet Software Consortium.
4258945Sroberto *
5258945Sroberto * Permission to use, copy, modify, and/or distribute this software for any
6258945Sroberto * purpose with or without fee is hereby granted, provided that the above
7258945Sroberto * copyright notice and this permission notice appear in all copies.
8258945Sroberto *
9258945Sroberto * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10258945Sroberto * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11258945Sroberto * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12258945Sroberto * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13258945Sroberto * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14258945Sroberto * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15258945Sroberto * PERFORMANCE OF THIS SOFTWARE.
16258945Sroberto */
17258945Sroberto
18258945Sroberto/* $Id: offset.h,v 1.6 2007/06/19 23:47:20 tbox Exp $ */
19258945Sroberto
20258945Sroberto#ifndef ISC_OFFSET_H
21258945Sroberto#define ISC_OFFSET_H 1
22258945Sroberto
23258945Sroberto/*
24258945Sroberto * File offsets are operating-system dependent.
25258945Sroberto */
26258945Sroberto#include <limits.h>             /* Required for CHAR_BIT. */
27258945Sroberto#include <sys/types.h>
28258945Sroberto
29258945Srobertotypedef _off_t isc_offset_t;
30258945Sroberto
31258945Sroberto/*
32258945Sroberto * POSIX says "Additionally, blkcnt_t and off_t are extended signed integral
33258945Sroberto * types", so the maximum value is all 1s except for the high bit.
34258945Sroberto * This definition is more complex than it really needs to be because it was
35258945Sroberto * crafted to keep both the SunOS 5.6 and the HP/UX 11 compilers quiet about
36258945Sroberto * integer overflow.  For example, though this is equivalent to just left
37258945Sroberto * shifting 1 to the high bit and then inverting the bits, the SunOS compiler
38258945Sroberto * is unhappy about shifting a positive "1" to negative in a signed integer.
39258945Sroberto */
40258945Sroberto#define ISC_OFFSET_MAXIMUM \
41258945Sroberto	(~(((off_t)-1 >> (sizeof(off_t) * CHAR_BIT - 1)) \
42258945Sroberto		      << (sizeof(off_t) * CHAR_BIT - 1)))
43258945Sroberto
44258945Sroberto#endif /* ISC_OFFSET_H */
45