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