core: add Sparc arch
diff --git a/cs.c b/cs.c
index bdacee8..6eac933 100644
--- a/cs.c
+++ b/cs.c
@@ -26,6 +26,7 @@
 extern void Mips_enable(void);
 extern void X86_enable(void);
 extern void PPC_enable(void);
+extern void Sparc_enable(void);
 
 static void archs_enable(void)
 {
@@ -43,12 +44,15 @@
 #ifdef CAPSTONE_HAS_MIPS
 	Mips_enable();
 #endif
-#ifdef CAPSTONE_HAS_X86
-	X86_enable();
-#endif
 #ifdef CAPSTONE_HAS_POWERPC
 	PPC_enable();
 #endif
+#ifdef CAPSTONE_HAS_SPARC
+	Sparc_enable();
+#endif
+#ifdef CAPSTONE_HAS_X86
+	X86_enable();
+#endif
 
 	initialized = true;
 }
@@ -88,7 +92,7 @@
 	if (query == CS_ARCH_ALL)
 		return all_arch == ((1 << CS_ARCH_ARM) | (1 << CS_ARCH_ARM64) |
 				(1 << CS_ARCH_MIPS) | (1 << CS_ARCH_X86) |
-				(1 << CS_ARCH_PPC));
+				(1 << CS_ARCH_PPC) | (1 << CS_ARCH_SPARC));
 
 	if ((unsigned int)query < CS_ARCH_MAX)
 		return all_arch & (1 << query);
@@ -576,6 +580,11 @@
 				if (insn->detail->ppc.operands[i].type == (ppc_op_type)op_type)
 					count++;
 			break;
+		case CS_ARCH_SPARC:
+			for (i = 0; i < insn->detail->sparc.op_count; i++)
+				if (insn->detail->sparc.operands[i].type == (sparc_op_type)op_type)
+					count++;
+			break;
 	}
 
 	return count;
@@ -641,6 +650,14 @@
 					return i;
 			}
 			break;
+		case CS_ARCH_SPARC:
+			for (i = 0; i < insn->detail->sparc.op_count; i++) {
+				if (insn->detail->sparc.operands[i].type == (sparc_op_type)op_type)
+					count++;
+				if (count == post)
+					return i;
+			}
+			break;
 	}
 
 	return -1;