1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * ASSERTION: Test network byte-ordering routines.
29  */
30 
31 #include <sys/isa_defs.h>
32 
33 BEGIN
34 {
35 	before[0] = 0x1122LL;
36 	before[1] = 0x11223344LL;
37 	before[2] = 0x1122334455667788LL;
38 
39 #ifdef _LITTLE_ENDIAN
40 	after[0] = 0x2211LL;
41 	after[1] = 0x44332211LL;
42 	after[2] = 0x8877665544332211LL;
43 #else
44 	after[0] = 0x1122LL;
45 	after[1] = 0x11223344LL;
46 	after[2] = 0x1122334455667788LL;
47 #endif
48 }
49 
50 BEGIN
51 /after[0] != htons(before[0])/
52 {
53 	printf("%x rather than %x", htons(before[0]), after[0]);
54 	exit(1);
55 }
56 
57 BEGIN
58 /after[0] != ntohs(before[0])/
59 {
60 	printf("%x rather than %x", ntohs(before[0]), after[0]);
61 	exit(1);
62 }
63 
64 BEGIN
65 /after[1] != htonl(before[1])/
66 {
67 	printf("%x rather than %x", htonl(before[1]), after[1]);
68 	exit(1);
69 }
70 
71 BEGIN
72 /after[1] != ntohl(before[1])/
73 {
74 	printf("%x rather than %x", ntohl(before[1]), after[1]);
75 	exit(1);
76 }
77 
78 BEGIN
79 /after[2] != htonll(before[2])/
80 {
81 	printf("%x rather than %x", htonll(before[2]), after[2]);
82 	exit(1);
83 }
84 
85 BEGIN
86 /after[2] != ntohll(before[2])/
87 {
88 	printf("%x rather than %x", ntohll(before[2]), after[2]);
89 	exit(1);
90 }
91 
92 BEGIN
93 {
94 	exit(0);
95 }
96