1*9512fe85Sahl /* 2*9512fe85Sahl * CDDL HEADER START 3*9512fe85Sahl * 4*9512fe85Sahl * The contents of this file are subject to the terms of the 5*9512fe85Sahl * Common Development and Distribution License (the "License"). 6*9512fe85Sahl * You may not use this file except in compliance with the License. 7*9512fe85Sahl * 8*9512fe85Sahl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*9512fe85Sahl * or http://www.opensolaris.org/os/licensing. 10*9512fe85Sahl * See the License for the specific language governing permissions 11*9512fe85Sahl * and limitations under the License. 12*9512fe85Sahl * 13*9512fe85Sahl * When distributing Covered Code, include this CDDL HEADER in each 14*9512fe85Sahl * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*9512fe85Sahl * If applicable, add the following below this CDDL HEADER, with the 16*9512fe85Sahl * fields enclosed by brackets "[]" replaced with your own identifying 17*9512fe85Sahl * information: Portions Copyright [yyyy] [name of copyright owner] 18*9512fe85Sahl * 19*9512fe85Sahl * CDDL HEADER END 20*9512fe85Sahl */ 21*9512fe85Sahl 22*9512fe85Sahl /* 23*9512fe85Sahl * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24*9512fe85Sahl * Use is subject to license terms. 25*9512fe85Sahl */ 26*9512fe85Sahl 27*9512fe85Sahl /* 28*9512fe85Sahl * ASSERTION: sizeof returns the size in bytes of any D expression or data 29*9512fe85Sahl * type. 30*9512fe85Sahl * 31*9512fe85Sahl * SECTION: Structs and Unions/Member Sizes and Offsets 32*9512fe85Sahl */ 33*9512fe85Sahl #pragma D option quiet 34*9512fe85Sahl 35*9512fe85Sahl char new_char; 36*9512fe85Sahl short new_short; 37*9512fe85Sahl int new_int; 38*9512fe85Sahl long new_long; 39*9512fe85Sahl long long new_long_long; 40*9512fe85Sahl int8_t new_int8; 41*9512fe85Sahl int16_t new_int16; 42*9512fe85Sahl int32_t new_int32; 43*9512fe85Sahl int64_t new_int64; 44*9512fe85Sahl intptr_t new_intptr; 45*9512fe85Sahl uint8_t new_uint8; 46*9512fe85Sahl uint16_t new_uint16; 47*9512fe85Sahl uint32_t new_uint32; 48*9512fe85Sahl uint64_t new_uint64; 49*9512fe85Sahl uintptr_t new_uintptr; 50*9512fe85Sahl 51*9512fe85Sahl /* 52*9512fe85Sahl float new_float; 53*9512fe85Sahl double new_double; 54*9512fe85Sahl long double new_long_double; 55*9512fe85Sahl 56*9512fe85Sahl string new_string; 57*9512fe85Sahl */ 58*9512fe85Sahl 59*9512fe85Sahl struct record { 60*9512fe85Sahl char ch; 61*9512fe85Sahl int in; 62*9512fe85Sahl } new_struct; 63*9512fe85Sahl 64*9512fe85Sahl struct { 65*9512fe85Sahl char ch; 66*9512fe85Sahl int in; 67*9512fe85Sahl } anon_struct; 68*9512fe85Sahl 69*9512fe85Sahl union record { 70*9512fe85Sahl char ch; 71*9512fe85Sahl int in; 72*9512fe85Sahl } new_union; 73*9512fe85Sahl 74*9512fe85Sahl union { 75*9512fe85Sahl char ch; 76*9512fe85Sahl int in; 77*9512fe85Sahl } anon_union; 78*9512fe85Sahl 79*9512fe85Sahl enum colors { 80*9512fe85Sahl RED, 81*9512fe85Sahl GREEN, 82*9512fe85Sahl BLUE 83*9512fe85Sahl } new_enum; 84*9512fe85Sahl 85*9512fe85Sahl 86*9512fe85Sahl int *pointer; 87*9512fe85Sahl 88*9512fe85Sahl BEGIN 89*9512fe85Sahl { 90*9512fe85Sahl printf("sizeof (new_char): %d\n", sizeof (new_char)); 91*9512fe85Sahl printf("sizeof (new_short): %d\n", sizeof (new_short)); 92*9512fe85Sahl printf("sizeof (new_int): %d\n", sizeof (new_int)); 93*9512fe85Sahl printf("sizeof (new_long): %d\n", sizeof (new_long)); 94*9512fe85Sahl printf("sizeof (new_long_long): %d\n", sizeof (new_long_long)); 95*9512fe85Sahl printf("sizeof (new_int8): %d\n", sizeof (new_int8)); 96*9512fe85Sahl printf("sizeof (new_int16): %d\n", sizeof (new_int16)); 97*9512fe85Sahl printf("sizeof (new_int32): %d\n", sizeof (new_int32)); 98*9512fe85Sahl printf("sizeof (new_int64): %d\n", sizeof (new_int64)); 99*9512fe85Sahl printf("sizeof (pointer): %d\n", sizeof (pointer)); 100*9512fe85Sahl printf("sizeof (intptr_t): %d\n", sizeof (intptr_t)); 101*9512fe85Sahl printf("sizeof (new_struct): %d\n", sizeof (new_struct)); 102*9512fe85Sahl printf("sizeof (anon_struct): %d\n", sizeof (anon_struct)); 103*9512fe85Sahl printf("sizeof (new_union): %d\n", sizeof (new_union)); 104*9512fe85Sahl printf("sizeof (anon_union): %d\n", sizeof (anon_union)); 105*9512fe85Sahl printf("sizeof (new_enum): %d\n", sizeof (new_enum)); 106*9512fe85Sahl exit(0); 107*9512fe85Sahl } 108*9512fe85Sahl 109*9512fe85Sahl END 110*9512fe85Sahl /(1 != sizeof (new_char)) || (2 != sizeof (new_short)) || 111*9512fe85Sahl (4 != sizeof (new_int)) || 112*9512fe85Sahl ((4 != sizeof (new_long)) && (8 != sizeof (new_long))) || 113*9512fe85Sahl (8 != sizeof (new_long_long)) || 114*9512fe85Sahl (1 != sizeof (new_int8)) || (2 != sizeof (new_int16)) || 115*9512fe85Sahl (4 != sizeof (new_int32)) || (8 != sizeof (new_int64)) || 116*9512fe85Sahl (sizeof (pointer) != sizeof (new_intptr)) || (8 != sizeof (new_struct)) || 117*9512fe85Sahl (4 != sizeof (new_union)) || (4 != sizeof (new_enum))/ 118*9512fe85Sahl { 119*9512fe85Sahl exit(1); 120*9512fe85Sahl } 121