1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2025 Oxide Computer Company 14 */ 15 16 /* 17 * This embeds type information with anonymous structures and unions and passes 18 * it to a function which allows the pid provider to get at it with various 19 * forms of the print() action in tst.anon.ksh. 20 */ 21 22 #include <stdio.h> 23 #include <string.h> 24 25 struct elves { 26 int feanor; 27 struct { 28 int fingolfin; 29 }; 30 union { 31 int maedhros; 32 int fingon; 33 struct { 34 int aredhel; 35 union { 36 int turgon; 37 struct { 38 int tuor; 39 int idril; 40 struct { 41 union { 42 int earendil; 43 int elwing; 44 }; 45 int silmaril; 46 }; 47 }; 48 union { 49 int maeglin; 50 int morgoth; 51 union { 52 int balrog; 53 int gondolin; 54 int glorfindel; 55 int ecthelion; 56 }; 57 }; 58 }; 59 }; 60 }; 61 struct { 62 int elrond; 63 int elros; 64 }; 65 }; 66 67 void mandos(struct elves * elves)68mandos(struct elves *elves) 69 { 70 (void) fprintf(stderr, "%x\n", elves->feanor); 71 } 72 73 int main(void)74main(void) 75 { 76 struct elves elves; 77 (void) memset(&elves, 0, sizeof (elves)); 78 elves.feanor = 0x1497; 79 elves.fingolfin = 0x467; 80 elves.maedhros = 0x587; 81 elves.turgon = 0x510; 82 elves.idril = 0x525; 83 elves.earendil = 0x7777; 84 elves.silmaril = 0x9999; 85 elves.elrond = 0x3021; 86 elves.elros = 0x442; 87 88 mandos(&elves); 89 }; 90