1178476Sjb/*
2178476Sjb * CDDL HEADER START
3178476Sjb *
4178476Sjb * The contents of this file are subject to the terms of the
5178476Sjb * Common Development and Distribution License (the "License").
6178476Sjb * You may not use this file except in compliance with the License.
7178476Sjb *
8178476Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9178476Sjb * or http://www.opensolaris.org/os/licensing.
10178476Sjb * See the License for the specific language governing permissions
11178476Sjb * and limitations under the License.
12178476Sjb *
13178476Sjb * When distributing Covered Code, include this CDDL HEADER in each
14178476Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15178476Sjb * If applicable, add the following below this CDDL HEADER, with the
16178476Sjb * fields enclosed by brackets "[]" replaced with your own identifying
17178476Sjb * information: Portions Copyright [yyyy] [name of copyright owner]
18178476Sjb *
19178476Sjb * CDDL HEADER END
20178476Sjb */
21178476Sjb
22178476Sjb/*
23178476Sjb * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24178476Sjb * Use is subject to license terms.
25178476Sjb */
26178476Sjb
27178476Sjb#pragma ident	"%Z%%M%	%I%	%E% SMI"
28178476Sjb
29178476Sjb/*
30178476Sjb * ASSERTION: sizeof returns the size in bytes of any D expression or data
31178476Sjb * type.
32178476Sjb *
33178476Sjb * SECTION: Structs and Unions/Member Sizes and Offsets
34178476Sjb */
35178476Sjb#pragma D option quiet
36178476Sjb
37178476Sjbchar new_char;
38178476Sjbshort new_short;
39178476Sjbint new_int;
40178476Sjblong new_long;
41178476Sjblong long new_long_long;
42178476Sjbint8_t new_int8;
43178476Sjbint16_t new_int16;
44178476Sjbint32_t new_int32;
45178476Sjbint64_t new_int64;
46178476Sjbintptr_t new_intptr;
47178476Sjbuint8_t new_uint8;
48178476Sjbuint16_t new_uint16;
49178476Sjbuint32_t new_uint32;
50178476Sjbuint64_t new_uint64;
51178476Sjbuintptr_t new_uintptr;
52178476Sjb
53178476Sjb/*
54178476Sjbfloat new_float;
55178476Sjbdouble new_double;
56178476Sjblong double new_long_double;
57178476Sjb
58178476Sjbstring new_string;
59178476Sjb*/
60178476Sjb
61178476Sjbstruct record {
62178476Sjb	char ch;
63178476Sjb	int in;
64178476Sjb} new_struct;
65178476Sjb
66178476Sjbstruct {
67178476Sjb	char ch;
68178476Sjb	int in;
69178476Sjb} anon_struct;
70178476Sjb
71178476Sjbunion record {
72178476Sjb     char ch;
73178476Sjb     int in;
74178476Sjb} new_union;
75178476Sjb
76178476Sjbunion {
77178476Sjb     char ch;
78178476Sjb     int in;
79178476Sjb} anon_union;
80178476Sjb
81178476Sjbenum colors {
82178476Sjb	RED,
83178476Sjb	GREEN,
84178476Sjb	BLUE
85178476Sjb} new_enum;
86178476Sjb
87178476Sjb
88178476Sjbint *pointer;
89178476Sjb
90178476SjbBEGIN
91178476Sjb{
92178476Sjb	printf("sizeof (new_char): %d\n", sizeof (new_char));
93178476Sjb	printf("sizeof (new_short): %d\n", sizeof (new_short));
94178476Sjb	printf("sizeof (new_int): %d\n", sizeof (new_int));
95178476Sjb	printf("sizeof (new_long): %d\n", sizeof (new_long));
96178476Sjb	printf("sizeof (new_long_long): %d\n", sizeof (new_long_long));
97178476Sjb	printf("sizeof (new_int8): %d\n", sizeof (new_int8));
98178476Sjb	printf("sizeof (new_int16): %d\n", sizeof (new_int16));
99178476Sjb	printf("sizeof (new_int32): %d\n", sizeof (new_int32));
100178476Sjb	printf("sizeof (new_int64): %d\n", sizeof (new_int64));
101178476Sjb	printf("sizeof (pointer): %d\n", sizeof (pointer));
102178476Sjb	printf("sizeof (intptr_t): %d\n", sizeof (intptr_t));
103178476Sjb	printf("sizeof (new_struct): %d\n", sizeof (new_struct));
104178476Sjb	printf("sizeof (anon_struct): %d\n", sizeof (anon_struct));
105178476Sjb	printf("sizeof (new_union): %d\n", sizeof (new_union));
106178476Sjb	printf("sizeof (anon_union): %d\n", sizeof (anon_union));
107178476Sjb	printf("sizeof (new_enum): %d\n", sizeof (new_enum));
108178476Sjb	exit(0);
109178476Sjb}
110178476Sjb
111178476SjbEND
112178476Sjb/(1 != sizeof (new_char)) || (2 != sizeof (new_short)) ||
113178476Sjb    (4 != sizeof (new_int)) ||
114178476Sjb    ((4 != sizeof (new_long)) && (8 != sizeof (new_long))) ||
115178476Sjb    (8 != sizeof (new_long_long)) ||
116178476Sjb    (1 != sizeof (new_int8)) || (2 != sizeof (new_int16)) ||
117178476Sjb    (4 != sizeof (new_int32)) || (8 != sizeof (new_int64)) ||
118178476Sjb    (sizeof (pointer) != sizeof (new_intptr)) || (8 != sizeof (new_struct)) ||
119178476Sjb    (4 != sizeof (new_union)) || (4 != sizeof (new_enum))/
120178476Sjb{
121178476Sjb	exit(1);
122178476Sjb}
123