155027Smarcel/*-
255027Smarcel * Copyright (c) 1999 Marcel Moolenaar
355027Smarcel * All rights reserved.
455027Smarcel *
555027Smarcel * Redistribution and use in source and binary forms, with or without
655027Smarcel * modification, are permitted provided that the following conditions
755027Smarcel * are met:
855027Smarcel * 1. Redistributions of source code must retain the above copyright
955027Smarcel *    notice, this list of conditions and the following disclaimer
1055027Smarcel *    in this position and unchanged.
1155027Smarcel * 2. Redistributions in binary form must reproduce the above copyright
1255027Smarcel *    notice, this list of conditions and the following disclaimer in the
1355027Smarcel *    documentation and/or other materials provided with the distribution.
1455027Smarcel * 3. The name of the author may not be used to endorse or promote products
1555027Smarcel *    derived from this software without specific prior written permission.
1655027Smarcel *
1755027Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1855027Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1955027Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2055027Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2155027Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2255027Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2355027Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2455027Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2555027Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2655027Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2755027Smarcel *
2855027Smarcel * $FreeBSD$
2955027Smarcel */
3055027Smarcel
3155027Smarcel#ifndef _SYS_ASSYM_H_
3255027Smarcel#define	_SYS_ASSYM_H_
3355027Smarcel
34126891Strhodes#define	ASSYM_BIAS		0x10000	/* avoid zero-length arrays */
3561174Sbde#define	ASSYM_ABS(value)	((value) < 0 ? -((value) + 1) + 1ULL : (value))
3655027Smarcel
37126891Strhodes#define	ASSYM(name, value)						      \
38126891Strhodeschar name ## sign[((value) < 0 ? 1 : 0) + ASSYM_BIAS];			      \
39126891Strhodeschar name ## w0[(ASSYM_ABS(value) & 0xFFFFU) + ASSYM_BIAS];		      \
40126891Strhodeschar name ## w1[((ASSYM_ABS(value) & 0xFFFF0000UL) >> 16) + ASSYM_BIAS];      \
41126891Strhodeschar name ## w2[((ASSYM_ABS(value) & 0xFFFF00000000ULL) >> 32) + ASSYM_BIAS]; \
42126891Strhodeschar name ## w3[((ASSYM_ABS(value) & 0xFFFF000000000000ULL) >> 48) + ASSYM_BIAS]
4355027Smarcel
4455027Smarcel#endif /* !_SYS_ASSYM_H_ */
45