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