xref: /illumos-gate/usr/src/tools/protocmp/arch.c (revision 578978f135d3d5007cd4590ec41afed45e52044b)
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 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #include <stdio.h>
28 #include <string.h>
29 
30 #include "list.h"
31 
32 int
33 assign_arch(const char *architecture)
34 {
35 	int	arch = 0;
36 
37 #if defined(__sparc)
38 	if (strcmp(architecture, "sparc") == 0)
39 		arch = P_SPARC;
40 	else if (strcmp(architecture, "ISA") == 0)
41 		arch = P_SPARC;
42 	else if (strcmp(architecture, "all") == 0)
43 		arch = P_SPARC;
44 	else if (strcmp(architecture, "sparc.sun4") == 0)
45 		arch = P_SUN4;
46 	else if (strcmp(architecture, "sparc.sun4c") == 0)
47 		arch = P_SUN4c;
48 	else if (strcmp(architecture, "sparc.sun4u") == 0)
49 		arch = P_SUN4u;
50 	else if (strcmp(architecture, "sparc.sun4d") == 0)
51 		arch = P_SUN4d;
52 	else if (strcmp(architecture, "sparc.sun4e") == 0)
53 		arch = P_SUN4e;
54 	else if (strcmp(architecture, "sparc.sun4m") == 0)
55 		arch = P_SUN4m;
56 	else if (strcmp(architecture, "sparc.sun4v") == 0)
57 		arch = P_SUN4v;
58 #elif defined(__i386)
59 	if (strcmp(architecture, "i386") == 0)
60 		arch = P_I386;
61 	else if (strcmp(architecture, "ISA") == 0)
62 		arch = P_I386;
63 	else if (strcmp(architecture, "all") == 0)
64 		arch = P_I386;
65 	else if (strcmp(architecture, "i386.i86pc") == 0)
66 		arch = P_I86PC;
67 #elif defined(__ppc)
68 	if (strcmp(architecture, "ppc") == 0)
69 		arch = P_PPC;
70 	else if (strcmp(architecture, "ISA") == 0)
71 		arch = P_PPC;
72 	else if (strcmp(architecture, "all") == 0)
73 		arch = P_PPC;
74 	else if (strcmp(architecture, "ppc.prep") == 0)
75 		arch = P_PREP;
76 #else
77 #error "Unknown instruction set"
78 #endif
79 
80 	return (arch);
81 }
82