Mercurial > code
view pack.h @ 137:97c9c20535e2
Just fix a -Wextra warning
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 26 Mar 2012 10:46:32 +0200 |
parents | 07800b7af208 |
children | a6a7cd08be72 |
line wrap: on
line source
/* * pack.h -- endian dependant binary file reader * * Copyright (c) 2011, 2012, David Demelier <markand@malikania.fr> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _PACK_H_ #define _PACK_H_ #include <stdarg.h> #ifdef __cplusplus extern "C" { #endif /* * Endian detection based on SDL_endian.h */ #undef PACK_HOST_BYTEORDER #define PACK_LE 1234 #define PACK_BE 4321 #if defined(__hppa__) || \ defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ (defined(__MIPS__) && defined(__MISPEB__)) || \ defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ defined(__sparc__) # define PACK_HOST_BYTEORDER PACK_BE #else # define PACK_HOST_BYTEORDER PACK_LE #endif #define pack_swap16(x) \ ((((x) >> 8) & 0x00FFL) | (((x) << 8) & 0xFF00L)) #define pack_swap32(x) ((((x) >> 24) & 0x000000FFL) \ | (((x) >> 8) & 0x0000FF00L) \ | (((x) << 8) & 0x00FF0000L) \ | (((x) << 24) & 0xFF000000L)) #define pack_swap64(x) (((uint64_t) \ ((uint32_t) pack_swap32((uint32_t) (((x) << 32) >> 32))) << 32) \ | (uint32_t) pack_swap32((uint32_t) ((x) >> 32))) int pack_write(int, const char *, const char *, ...); int pack_vwrite(int, const char *, const char *, va_list); int pack_fwrite(int, FILE *, const char *, ...); int pack_vfwrite(int, FILE *, const char *, va_list); int pack_read(int, const char *, const char *, ...); int pack_vread(int, const char *, const char *, va_list); int pack_fread(int, FILE *, const char *, ...); int pack_vfread(int, FILE *, const char *, va_list); #ifdef __cplusplus } #endif #endif /* _PACK_H_ */