1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#pragma	ident	"@(#)tst.ptrincop.d	1.1	06/08/28 SMI"
28
29/*
30 * ASSERTION:
31 *	Verify increment/decrement operator using pointers
32 *
33 * SECTION: Types, Operators, and Expressions/Increment and Decrement Operators
34 *
35 */
36
37#pragma D option quiet
38
39
40#if !defined(__APPLE__)
41BEGIN
42{
43	ptr_orig = &`kmem_flags;
44	ptr_pos = &`kmem_flags+1;
45	ptr_neg = &`kmem_flags-1;
46
47	ptr_pos_before = ++ptr_orig;
48	ptr_orig = &`kmem_flags;
49	ptr_neg_before = --ptr_orig;
50
51	ptr_orig = &`kmem_flags;
52	ptr_pos_after = ptr_orig++;
53	ptr_orig = &`kmem_flags;
54	ptr_neg_after = ptr_orig--;
55	ptr_orig = &`kmem_flags;
56
57}
58#else
59BEGIN
60{
61	ptr_orig = &`max_ncpus;
62	ptr_pos = &`max_ncpus+1;
63	ptr_neg = &`max_ncpus-1;
64
65	ptr_pos_before = ++ptr_orig;
66	ptr_orig = &`max_ncpus;
67	ptr_neg_before = --ptr_orig;
68
69	ptr_orig = &`max_ncpus;
70	ptr_pos_after = ptr_orig++;
71	ptr_orig = &`max_ncpus;
72	ptr_neg_after = ptr_orig--;
73	ptr_orig = &`max_ncpus;
74
75}
76#endif /* __APPLE__ */
77
78tick-1
79/ptr_pos_before  == ptr_pos && ptr_neg_before == ptr_neg &&
80	ptr_pos_after == ptr_orig && ptr_pos_after == ptr_orig/
81{
82	exit(0);
83}
84
85
86tick-1
87/ptr_pos_before  != ptr_pos || ptr_neg_before != ptr_neg ||
88	ptr_pos_after != ptr_orig || ptr_pos_after != ptr_orig/
89{
90	exit(1);
91}
92
93