Author: "A. Maitland Bottoms" <bottoms@debian.org>
Description: remove buggy Avx tests
 Test causes seqfault on some AMD processors, and there's more than
 one way to SIMD these days, so do not let lack of AVX hold us back.
 Fixes segfault on AMD Phenom(tm) II X6 1045T Processor.

--- a/src/fdmdv2_main.h
+++ b/src/fdmdv2_main.h
@@ -647,9 +647,6 @@
         int        vk_rx_pause;
         int        vk_repeats, vk_repeat_counter;
         float      vk_rx_time;
-
-        void       checkAvxSupport();
-        bool       isAvxPresent;
 };
 
 void txRxProcessing();
--- a/src/fdmdv2_main.cpp
+++ b/src/fdmdv2_main.cpp
@@ -316,12 +316,6 @@
 
     wxGetApp().m_serialport = new Serialport();
 
-    // Check for AVX support in the processor.  If it's not present, 2020 won't be processed
-    // fast enough
-    checkAvxSupport();
-    if(!isAvxPresent)
-        m_rb2020->Disable();
-
     tools->AppendSeparator();
     wxMenuItem* m_menuItemToolsConfigDelete;
     m_menuItemToolsConfigDelete = new wxMenuItem(tools, wxID_ANY, wxString(_("&Restore defaults")) , wxT("Delete config file/keys and restore defaults"), wxITEM_NORMAL);
@@ -583,7 +577,7 @@
         m_rb2400b->SetValue(1);
     if (mode == 7)
         m_rbHorusBinary->SetValue(1);
-    if (mode == 8 && isAvxPresent)
+    if (mode == 8)
         m_rb2020->SetValue(1);
     pConfig->SetPath(wxT("/"));
 
@@ -2706,7 +2700,7 @@
             m_textInterleaverSync->SetLabel("");
             g_modemInbufferSize = (int)(FRAME_DURATION * horus_get_Fs(g_horus));
         }
-        if (m_rb2020->GetValue() && isAvxPresent) {
+        if (m_rb2020->GetValue()) {
             g_mode = FREEDV_MODE_2020;
             g_Nc = 31;                         /* TODO: be nice if we didn't have to hard code this, maybe API call? */
             m_panelScatter->setNc(g_Nc);
@@ -2932,8 +2926,7 @@
         m_rb800xa->Enable();
         m_rb2400b->Enable();
         m_rbHorusBinary->Enable();
-        if(isAvxPresent)
-            m_rb2020->Enable();
+	m_rb2020->Enable();
         if (m_rbPlugIn != NULL)
             m_rbPlugIn->Enable();
            
@@ -4490,63 +4483,6 @@
     }
 }
 
-//
-// checkAvxSupport
-//
-// Tests the underlying platform for AVX support.  2020 needs AVX support to run
-// in real-time, and old processors do not offer AVX support
-//
-#if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86)
-
-void __cpuid(int* cpuinfo, int info)
-{
-    __asm__ __volatile__(
-        "xchg %%ebx, %%edi;"
-        "cpuid;"
-        "xchg %%ebx, %%edi;"
-        :"=a" (cpuinfo[0]), "=D" (cpuinfo[1]), "=c" (cpuinfo[2]), "=d" (cpuinfo[3])
-        :"0" (info)
-    );
-}
-
-// These methods are defined for Windows but must be created otherwise
-unsigned long long __xgetbv(unsigned int index)
-{
-    unsigned int eax, edx;
-    __asm__ __volatile__(
-        "xgetbv;"
-        : "=a" (eax), "=d"(edx)
-        : "c" (index)
-    );
-    return ((unsigned long long)edx << 32) | eax;
-}
-
-void MainFrame::checkAvxSupport(void)
-{
-
-    int cpuinfo[4];
-    __cpuid(cpuinfo, 1);
-
-    bool avxSupported = false;
-
-    avxSupported = cpuinfo[2] & (1 << 28) || false;
-    bool osxsaveSupported = cpuinfo[2] & (1 << 27) || false;
-    if (osxsaveSupported && avxSupported)
-    {
-        // _XCR_XFEATURE_ENABLED_MASK = 0
-        unsigned long long xcrFeatureMask = __xgetbv(0);
-        avxSupported = (xcrFeatureMask & 0x6) == 0x6;
-    }
-
-    isAvxPresent = avxSupported;
-}
-#else
-void MainFrame::checkAvxSupport(void)
-{
-    isAvxPresent = false;
-}
-#endif
-
 #ifdef __UDP_SUPPORT__
 
 //----------------------------------------------------------------
