xref: /illumos-gate/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d (revision 48edc7cf07b5dccc3ad84bf2dafe4150bd666d60)
1 /*
2  * CDDL HEADER START
3  *
4  * This file and its contents are supplied under the terms of the
5  * Common Development and Distribution License ("CDDL"), version 1.0.
6  * You may only use this file in accordance with the terms of version
7  * 1.0 of the CDDL.
8  *
9  * A full copy of the text of the CDDL should have accompanied this
10  * source.  A copy of the CDDL is also available via the Internet at
11  * http://www.illumos.org/license/CDDL.
12  *
13  * CDDL HEADER END
14  */
15 
16 /*
17  * Copyright (c) 2012 by Delphix. All rights reserved.
18  */
19 
20 /*
21  * Test execution-time casting between integer types of different size.
22  */
23 
24 #pragma D option quiet
25 
26 int64_t x;
27 
28 BEGIN
29 {
30 	z = 0xfff0;
31 
32 	x = (int32_t)(int16_t)z;
33 	printf("%16x %20d %20u\n", x, x, x);
34 	x = (int32_t)(uint16_t)z;
35 	printf("%16x %20d %20u\n", x, x, x);
36 	x = (uint32_t)(int16_t)z;
37 	printf("%16x %20d %20u\n", x, x, x);
38 	x = (uint32_t)(uint16_t)z;
39 	printf("%16x %20d %20u\n", x, x, x);
40 	printf("\n");
41 
42 	x = (int16_t)(int32_t)z;
43 	printf("%16x %20d %20u\n", x, x, x);
44 	x = (int16_t)(uint32_t)z;
45 	printf("%16x %20d %20u\n", x, x, x);
46 	x = (uint16_t)(int32_t)z;
47 	printf("%16x %20d %20u\n", x, x, x);
48 	x = (uint16_t)(uint32_t)z;
49 	printf("%16x %20d %20u\n", x, x, x);
50 
51 	exit(0);
52 }
53