xref: /freebsd-src/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.hton.d (revision f8ac9d32d3233e8956a6a220ed9c108d0036cd8f)
12be1a816SJohn Birrell /*
22be1a816SJohn Birrell  * CDDL HEADER START
32be1a816SJohn Birrell  *
42be1a816SJohn Birrell  * The contents of this file are subject to the terms of the
52be1a816SJohn Birrell  * Common Development and Distribution License (the "License").
62be1a816SJohn Birrell  * You may not use this file except in compliance with the License.
72be1a816SJohn Birrell  *
82be1a816SJohn Birrell  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92be1a816SJohn Birrell  * or http://www.opensolaris.org/os/licensing.
102be1a816SJohn Birrell  * See the License for the specific language governing permissions
112be1a816SJohn Birrell  * and limitations under the License.
122be1a816SJohn Birrell  *
132be1a816SJohn Birrell  * When distributing Covered Code, include this CDDL HEADER in each
142be1a816SJohn Birrell  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152be1a816SJohn Birrell  * If applicable, add the following below this CDDL HEADER, with the
162be1a816SJohn Birrell  * fields enclosed by brackets "[]" replaced with your own identifying
172be1a816SJohn Birrell  * information: Portions Copyright [yyyy] [name of copyright owner]
182be1a816SJohn Birrell  *
192be1a816SJohn Birrell  * CDDL HEADER END
202be1a816SJohn Birrell  */
212be1a816SJohn Birrell 
222be1a816SJohn Birrell /*
232be1a816SJohn Birrell  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
242be1a816SJohn Birrell  * Use is subject to license terms.
252be1a816SJohn Birrell  */
262be1a816SJohn Birrell 
272be1a816SJohn Birrell #pragma ident	"%Z%%M%	%I%	%E% SMI"
282be1a816SJohn Birrell 
292be1a816SJohn Birrell /*
302be1a816SJohn Birrell  * ASSERTION: Test network byte-ordering routines.
312be1a816SJohn Birrell  */
322be1a816SJohn Birrell 
33*f8ac9d32SJohn Birrell #if defined(__amd64__) || defined(__i386__)
34*f8ac9d32SJohn Birrell #define _LITTLE_ENDIAN
35*f8ac9d32SJohn Birrell #endif
362be1a816SJohn Birrell 
372be1a816SJohn Birrell BEGIN
382be1a816SJohn Birrell {
392be1a816SJohn Birrell 	before[0] = 0x1122LL;
402be1a816SJohn Birrell 	before[1] = 0x11223344LL;
412be1a816SJohn Birrell 	before[2] = 0x1122334455667788LL;
422be1a816SJohn Birrell 
432be1a816SJohn Birrell #ifdef _LITTLE_ENDIAN
442be1a816SJohn Birrell 	after[0] = 0x2211LL;
452be1a816SJohn Birrell 	after[1] = 0x44332211LL;
462be1a816SJohn Birrell 	after[2] = 0x8877665544332211LL;
472be1a816SJohn Birrell #else
482be1a816SJohn Birrell 	after[0] = 0x1122LL;
492be1a816SJohn Birrell 	after[1] = 0x11223344LL;
502be1a816SJohn Birrell 	after[2] = 0x1122334455667788LL;
512be1a816SJohn Birrell #endif
522be1a816SJohn Birrell }
532be1a816SJohn Birrell 
542be1a816SJohn Birrell BEGIN
552be1a816SJohn Birrell /after[0] != htons(before[0])/
562be1a816SJohn Birrell {
572be1a816SJohn Birrell 	printf("%x rather than %x", htons(before[0]), after[0]);
582be1a816SJohn Birrell 	exit(1);
592be1a816SJohn Birrell }
602be1a816SJohn Birrell 
612be1a816SJohn Birrell BEGIN
622be1a816SJohn Birrell /after[0] != ntohs(before[0])/
632be1a816SJohn Birrell {
642be1a816SJohn Birrell 	printf("%x rather than %x", ntohs(before[0]), after[0]);
652be1a816SJohn Birrell 	exit(1);
662be1a816SJohn Birrell }
672be1a816SJohn Birrell 
682be1a816SJohn Birrell BEGIN
692be1a816SJohn Birrell /after[1] != htonl(before[1])/
702be1a816SJohn Birrell {
712be1a816SJohn Birrell 	printf("%x rather than %x", htonl(before[1]), after[1]);
722be1a816SJohn Birrell 	exit(1);
732be1a816SJohn Birrell }
742be1a816SJohn Birrell 
752be1a816SJohn Birrell BEGIN
762be1a816SJohn Birrell /after[1] != ntohl(before[1])/
772be1a816SJohn Birrell {
782be1a816SJohn Birrell 	printf("%x rather than %x", ntohl(before[1]), after[1]);
792be1a816SJohn Birrell 	exit(1);
802be1a816SJohn Birrell }
812be1a816SJohn Birrell 
822be1a816SJohn Birrell BEGIN
832be1a816SJohn Birrell /after[2] != htonll(before[2])/
842be1a816SJohn Birrell {
852be1a816SJohn Birrell 	printf("%x rather than %x", htonll(before[2]), after[2]);
862be1a816SJohn Birrell 	exit(1);
872be1a816SJohn Birrell }
882be1a816SJohn Birrell 
892be1a816SJohn Birrell BEGIN
902be1a816SJohn Birrell /after[2] != ntohll(before[2])/
912be1a816SJohn Birrell {
922be1a816SJohn Birrell 	printf("%x rather than %x", ntohll(before[2]), after[2]);
932be1a816SJohn Birrell 	exit(1);
942be1a816SJohn Birrell }
952be1a816SJohn Birrell 
962be1a816SJohn Birrell BEGIN
972be1a816SJohn Birrell {
982be1a816SJohn Birrell 	exit(0);
992be1a816SJohn Birrell }
100