offset.h revision 70e5a7403f0e0a3bd292b8287c5fed5772c15270
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson/*
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
75c0816e8295e180f4bc7f10db3d0d880383bc1cMark Andrews * Copyright (C) 2000, 2001 Internet Software Consortium.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein *
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson * Permission to use, copy, modify, and/or distribute this software for any
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson * purpose with or without fee is hereby granted, provided that the above
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson * copyright notice and this permission notice appear in all copies.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein *
8a66318e41ed14c5a88130e8c362610e8faa2121Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
8a66318e41ed14c5a88130e8c362610e8faa2121Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
8a66318e41ed14c5a88130e8c362610e8faa2121Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
8a66318e41ed14c5a88130e8c362610e8faa2121Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
8a66318e41ed14c5a88130e8c362610e8faa2121Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
8a66318e41ed14c5a88130e8c362610e8faa2121Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
ddccd5811feff696ba460dabfb666ce61040f545Andreas Gustafsson */
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein/* $Id: offset.h,v 1.6 2007/06/19 23:47:20 tbox Exp $ */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#ifndef ISC_OFFSET_H
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#define ISC_OFFSET_H 1
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein/*
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * File offsets are operating-system dependent.
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#include <limits.h> /* Required for CHAR_BIT. */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#include <sys/types.h>
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeintypedef _off_t isc_offset_t;
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein/*
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * POSIX says "Additionally, blkcnt_t and off_t are extended signed integral
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * types", so the maximum value is all 1s except for the high bit.
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews * This definition is more complex than it really needs to be because it was
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews * crafted to keep both the SunOS 5.6 and the HP/UX 11 compilers quiet about
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * integer overflow. For example, though this is equivalent to just left
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews * shifting 1 to the high bit and then inverting the bits, the SunOS compiler
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews * is unhappy about shifting a positive "1" to negative in a signed integer.
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews */
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews#define ISC_OFFSET_MAXIMUM \
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews (~(((off_t)-1 >> (sizeof(off_t) * CHAR_BIT - 1)) \
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews << (sizeof(off_t) * CHAR_BIT - 1)))
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#endif /* ISC_OFFSET_H */
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews