__PREFIX_BEGIN__
//-----------------------------------------------------------------------------
// Copyright © 2004 - Philip Howard - All rights reserved
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//-----------------------------------------------------------------------------
// package	libh/byte
// homepage	http://libh.slashusr.org/
//-----------------------------------------------------------------------------
// author	Philip Howard
// email	libh at ipal dot org
// homepage	http://phil.ipal.org/
//-----------------------------------------------------------------------------
// This file is best viewed using a fixed spaced font such as Courier
// and in a display at least 120 columns wide.
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// file		byte.h
//-----------------------------------------------------------------------------
#ifndef __BYTE_H__
#define __BYTE_H__

#include <stdint.h>

__PREFIX_END__

__DEFINE_BEGIN__
//-----------------------------------------------------------------------------
// Define structures that unions a character array over various common types.
// Architectural byte order issues will apply here.
//-----------------------------------------------------------------------------
struct bytes_short {
    union {
	signed short		svalue				;
	unsigned short		uvalue				;
	unsigned char		bytes	[sizeof (short)]	;
    };
};
typedef struct bytes_short bytes_short;

struct bytes_int16 {
    union {
	int16_t			svalue				;
	uint16_t		uvalue				;
	unsigned char		bytes	[sizeof (int16_t)]	;
    };
};
typedef struct bytes_int bytes_int16;

struct bytes_int {
    union {
	signed int		svalue				;
	unsigned int		uvalue				;
	unsigned char		bytes	[sizeof (int)]		;
    };
};
typedef struct bytes_int bytes_int;

struct bytes_int32 {
    union {
	int32_t			svalue				;
	uint32_t		uvalue				;
	unsigned char		bytes	[sizeof (int32_t)]	;
    };
};
typedef struct bytes_int bytes_int32;

struct bytes_long {
    union {
	signed long		svalue				;
	unsigned long		uvalue				;
	unsigned char		bytes	[sizeof (long)]		;
    };
};
typedef struct bytes_long bytes_long;

struct bytes_int64 {
    union {
	int64_t			svalue				;
	uint64_t		uvalue				;
	unsigned char		bytes	[sizeof (int64_t)]	;
    };
};
typedef struct bytes_int bytes_int64;

struct bytes_long_long {
    union {
	signed long long	svalue				;
	unsigned long long	uvalue				;
	unsigned char		bytes	[sizeof (long long)]	;
    };
};
typedef struct bytes_long_long bytes_long_long;

struct bytes_float {
    union {
	float			value				;
	unsigned char		bytes	[sizeof (float)]	;
    };
};
typedef struct bytes_float bytes_float;

struct bytes_double {
    union {
	double			value				;
	unsigned char		bytes	[sizeof (double)]	;
    };
};
typedef struct bytes_double bytes_double;

struct bytes_long_double {
    union {
	long double		value				;
	unsigned char		bytes	[sizeof (long double)]	;
    };
};
typedef struct bytes_long_double bytes_long_double;

struct bytes_pointer {
    union {
	void *			value				;
	intptr_t		svalue				;
	uintptr_t		uvalue				;
	unsigned char		bytes	[sizeof (void *)]	;
    };
};
typedef struct bytes_pointer bytes_pointer;

__DEFINE_END__

__SUFFIX_BEGIN__
#endif /* __BYTE_H__ */
__SUFFIX_END__

