aboutsummaryrefslogtreecommitdiffstats
path: root/cpu_mode_x86.c
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2014-01-02 21:55:13 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2014-01-02 21:55:13 +0100
commita31630e0d5b9880c716d9004ef4154396ba41ebc (patch)
treeaebbd3b132e5f2dd31bc34750ccded2378fc687a /cpu_mode_x86.c
parent9aaac5be9db5e1537badc65242412ef14c5096e3 (diff)
downloadka9q-fec-a31630e0d5b9880c716d9004ef4154396ba41ebc.tar.gz
ka9q-fec-a31630e0d5b9880c716d9004ef4154396ba41ebc.tar.bz2
ka9q-fec-a31630e0d5b9880c716d9004ef4154396ba41ebc.zip
Extract fec-3.0.1
Diffstat (limited to 'cpu_mode_x86.c')
-rw-r--r--cpu_mode_x86.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/cpu_mode_x86.c b/cpu_mode_x86.c
new file mode 100644
index 0000000..322018e
--- /dev/null
+++ b/cpu_mode_x86.c
@@ -0,0 +1,33 @@
+/* Determine CPU support for SIMD
+ * Copyright 2004 Phil Karn, KA9Q
+ */
+#include <stdio.h>
+#include "fec.h"
+
+/* Various SIMD instruction set names */
+char *Cpu_modes[] = {"Unknown","Portable C","x86 Multi Media Extensions (MMX)",
+ "x86 Streaming SIMD Extensions (SSE)",
+ "x86 Streaming SIMD Extensions 2 (SSE2)",
+ "PowerPC G4/G5 Altivec/Velocity Engine"};
+
+enum cpu_mode Cpu_mode;
+
+void find_cpu_mode(void){
+
+ int f;
+ if(Cpu_mode != UNKNOWN)
+ return;
+
+ /* Figure out what kind of CPU we have */
+ f = cpu_features();
+ if(f & (1<<26)){ /* SSE2 is present */
+ Cpu_mode = SSE2;
+ } else if(f & (1<<25)){ /* SSE is present */
+ Cpu_mode = SSE;
+ } else if(f & (1<<23)){ /* MMX is present */
+ Cpu_mode = MMX;
+ } else { /* No SIMD at all */
+ Cpu_mode = PORT;
+ }
+ fprintf(stderr,"SIMD CPU detect: %s\n",Cpu_modes[Cpu_mode]);
+}