mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-22 17:45:48 -05:00
Strict aliasing.
This commit is contained in:
parent
25cffee789
commit
836796fff4
@ -9,8 +9,6 @@ project(sdrangelove)
|
|||||||
set(CMAKE_BUILD_TYPE "Release")
|
set(CMAKE_BUILD_TYPE "Release")
|
||||||
#set(CMAKE_BUILD_TYPE "ReleaseWithDebugInfo")
|
#set(CMAKE_BUILD_TYPE "ReleaseWithDebugInfo")
|
||||||
#set(CMAKE_BUILD_TYPE "Debug")
|
#set(CMAKE_BUILD_TYPE "Debug")
|
||||||
add_definitions(-Wall -fno-strict-aliasing)
|
|
||||||
|
|
||||||
|
|
||||||
set(QT_USE_QTOPENGL TRUE)
|
set(QT_USE_QTOPENGL TRUE)
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
@ -99,7 +97,7 @@ set(sdrbase_SOURCES
|
|||||||
|
|
||||||
sdrbase/util/message.cpp
|
sdrbase/util/message.cpp
|
||||||
sdrbase/util/messagequeue.cpp
|
sdrbase/util/messagequeue.cpp
|
||||||
sdrbase/util/miniz.cpp
|
#sdrbase/util/miniz.cpp
|
||||||
sdrbase/util/simpleserializer.cpp
|
sdrbase/util/simpleserializer.cpp
|
||||||
sdrbase/util/spinlock.cpp
|
sdrbase/util/spinlock.cpp
|
||||||
)
|
)
|
||||||
@ -170,7 +168,7 @@ set(sdrbase_HEADERS
|
|||||||
include/util/export.h
|
include/util/export.h
|
||||||
include/util/message.h
|
include/util/message.h
|
||||||
include/util/messagequeue.h
|
include/util/messagequeue.h
|
||||||
include/util/miniz.h
|
#include/util/miniz.h
|
||||||
include/util/simpleserializer.h
|
include/util/simpleserializer.h
|
||||||
include/util/spinlock.h
|
include/util/spinlock.h
|
||||||
)
|
)
|
||||||
@ -265,8 +263,9 @@ if(MSVC)
|
|||||||
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
|
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
|
||||||
add_definitions (/D "_CRT_SECURE_NO_WARNINGS")
|
add_definitions (/D "_CRT_SECURE_NO_WARNINGS")
|
||||||
else()
|
else()
|
||||||
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse2" )
|
#set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse2" )
|
||||||
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse2" )
|
#set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse2" )
|
||||||
|
add_definitions(-msse2 -Wall)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
project(samplesource)
|
project(samplesource)
|
||||||
|
|
||||||
find_package(LibUSB)
|
find_package(LibUSB)
|
||||||
find_package(LibOsmoSDR)
|
#find_package(LibOsmoSDR)
|
||||||
|
|
||||||
add_subdirectory(gnuradio)
|
add_subdirectory(gnuradio)
|
||||||
|
|
||||||
|
@ -339,8 +339,8 @@ void MainWindow::updateStatus()
|
|||||||
m_engineRunning->setColor(Qt::gray);
|
m_engineRunning->setColor(Qt::gray);
|
||||||
m_engineError->setColor(Qt::gray);
|
m_engineError->setColor(Qt::gray);
|
||||||
statusBar()->clearMessage();
|
statusBar()->clearMessage();
|
||||||
if(m_startOsmoSDRUpdateAfterStop)
|
//if(m_startOsmoSDRUpdateAfterStop)
|
||||||
on_actionOsmoSDR_Firmware_Upgrade_triggered();
|
// on_actionOsmoSDR_Firmware_Upgrade_triggered();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DSPEngine::StRunning:
|
case DSPEngine::StRunning:
|
||||||
@ -355,8 +355,8 @@ void MainWindow::updateStatus()
|
|||||||
m_engineRunning->setColor(Qt::gray);
|
m_engineRunning->setColor(Qt::gray);
|
||||||
m_engineError->setColor(Qt::red);
|
m_engineError->setColor(Qt::red);
|
||||||
statusBar()->showMessage(tr("Error: %1").arg(m_dspEngine->errorMessage()));
|
statusBar()->showMessage(tr("Error: %1").arg(m_dspEngine->errorMessage()));
|
||||||
if(m_startOsmoSDRUpdateAfterStop)
|
//if(m_startOsmoSDRUpdateAfterStop)
|
||||||
on_actionOsmoSDR_Firmware_Upgrade_triggered();
|
// on_actionOsmoSDR_Firmware_Upgrade_triggered();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_lastEngineState = state;
|
m_lastEngineState = state;
|
||||||
@ -401,6 +401,7 @@ void MainWindow::on_action_View_Fullscreen_toggled(bool checked)
|
|||||||
|
|
||||||
void MainWindow::on_actionOsmoSDR_Firmware_Upgrade_triggered()
|
void MainWindow::on_actionOsmoSDR_Firmware_Upgrade_triggered()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
DSPEngine::State engineState = m_dspEngine->state();
|
DSPEngine::State engineState = m_dspEngine->state();
|
||||||
if((engineState != DSPEngine::StIdle) && (engineState != DSPEngine::StError)) {
|
if((engineState != DSPEngine::StIdle) && (engineState != DSPEngine::StError)) {
|
||||||
m_startOsmoSDRUpdateAfterStop = true;
|
m_startOsmoSDRUpdateAfterStop = true;
|
||||||
@ -412,6 +413,7 @@ void MainWindow::on_actionOsmoSDR_Firmware_Upgrade_triggered()
|
|||||||
OsmoSDRUpgrade osmoSDRUpgrade;
|
OsmoSDRUpgrade osmoSDRUpgrade;
|
||||||
osmoSDRUpgrade.exec();
|
osmoSDRUpgrade.exec();
|
||||||
*/
|
*/
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_presetSave_clicked()
|
void MainWindow::on_presetSave_clicked()
|
||||||
|
@ -50,15 +50,9 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&File</string>
|
<string>&File</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="action_Exit"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QMenu" name="menu_Options">
|
|
||||||
<property name="title">
|
|
||||||
<string>&Options</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="actionOsmoSDR_Firmware_Upgrade"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="action_Preferences"/>
|
<addaction name="action_Preferences"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="action_Exit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menu_Acquisition">
|
<widget class="QMenu" name="menu_Acquisition">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@ -79,9 +73,9 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Help</string>
|
<string>&Help</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="action_Open_Website"/>
|
<!--addaction name="action_Open_Website"/>
|
||||||
<addaction name="action_Check_for_Update"/>
|
<addaction name="action_Check_for_Update"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/-->
|
||||||
<addaction name="action_Loaded_Plugins"/>
|
<addaction name="action_Loaded_Plugins"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="action_About"/>
|
<addaction name="action_About"/>
|
||||||
@ -100,7 +94,7 @@
|
|||||||
<addaction name="menu_View"/>
|
<addaction name="menu_View"/>
|
||||||
<addaction name="menu_Acquisition"/>
|
<addaction name="menu_Acquisition"/>
|
||||||
<addaction name="menu_Channels"/>
|
<addaction name="menu_Channels"/>
|
||||||
<addaction name="menu_Options"/>
|
<!--addaction name="menu_Options"/-->
|
||||||
<addaction name="menu_Window"/>
|
<addaction name="menu_Window"/>
|
||||||
<addaction name="menu_Help"/>
|
<addaction name="menu_Help"/>
|
||||||
</widget>
|
</widget>
|
||||||
@ -371,11 +365,11 @@
|
|||||||
<string>F11</string>
|
<string>F11</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionOsmoSDR_Firmware_Upgrade">
|
<!--action name="actionOsmoSDR_Firmware_Upgrade">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>OsmoSDR &Firmware Upgrade...</string>
|
<string>OsmoSDR &Firmware Upgrade...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action-->
|
||||||
<action name="action_Oscilloscope">
|
<action name="action_Oscilloscope">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -407,16 +401,16 @@
|
|||||||
<string>&Preferences...</string>
|
<string>&Preferences...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_Demod_NFM">
|
<!--action name="action_Demod_NFM">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>N&FM</string>
|
<string>N&FM</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="action_Tetra">
|
<action name="action_Demod_SSB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Tetra</string>
|
<string>&SSB</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action-->
|
||||||
<action name="action_Loaded_Plugins">
|
<action name="action_Loaded_Plugins">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Loaded &Plugins...</string>
|
<string>Loaded &Plugins...</string>
|
||||||
|
@ -165,8 +165,14 @@ void SimpleSerializer::writeU64(quint32 id, quint64 value)
|
|||||||
m_data.push_back((char)((value >> (i * 8)) & 0xff));
|
m_data.push_back((char)((value >> (i * 8)) & 0xff));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
union floatasint {
|
||||||
|
quint32 u;
|
||||||
|
float f;
|
||||||
|
};
|
||||||
|
|
||||||
void SimpleSerializer::writeFloat(quint32 id, float value)
|
void SimpleSerializer::writeFloat(quint32 id, float value)
|
||||||
{
|
{
|
||||||
|
union floatasint tmp;
|
||||||
if(id == 0) {
|
if(id == 0) {
|
||||||
qCritical("SimpleSerializer: ID 0 is not allowed");
|
qCritical("SimpleSerializer: ID 0 is not allowed");
|
||||||
return;
|
return;
|
||||||
@ -175,15 +181,21 @@ void SimpleSerializer::writeFloat(quint32 id, float value)
|
|||||||
if(!writeTag(TFloat, id, 4))
|
if(!writeTag(TFloat, id, 4))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
quint32 tmp = *((quint32*)&value);
|
tmp.f = value;
|
||||||
m_data.push_back((char)((tmp >> 24) & 0xff));
|
m_data.push_back((char)((tmp.u >> 24) & 0xff));
|
||||||
m_data.push_back((char)((tmp >> 16) & 0xff));
|
m_data.push_back((char)((tmp.u >> 16) & 0xff));
|
||||||
m_data.push_back((char)((tmp >> 8) & 0xff));
|
m_data.push_back((char)((tmp.u >> 8) & 0xff));
|
||||||
m_data.push_back((char)(tmp & 0xff));
|
m_data.push_back((char)(tmp.u & 0xff));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
union doubleasint {
|
||||||
|
quint64 u;
|
||||||
|
double d;
|
||||||
|
};
|
||||||
|
|
||||||
void SimpleSerializer::writeDouble(quint32 id, double value)
|
void SimpleSerializer::writeDouble(quint32 id, double value)
|
||||||
{
|
{
|
||||||
|
union doubleasint tmp;
|
||||||
if(id == 0) {
|
if(id == 0) {
|
||||||
qCritical("SimpleSerializer: ID 0 is not allowed");
|
qCritical("SimpleSerializer: ID 0 is not allowed");
|
||||||
return;
|
return;
|
||||||
@ -192,15 +204,15 @@ void SimpleSerializer::writeDouble(quint32 id, double value)
|
|||||||
if(!writeTag(TDouble, id, 8))
|
if(!writeTag(TDouble, id, 8))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
quint64 tmp = *((quint64*)&value);
|
tmp.d = value;
|
||||||
m_data.push_back((char)((tmp >> 56) & 0xff));
|
m_data.push_back((char)((tmp.u >> 56) & 0xff));
|
||||||
m_data.push_back((char)((tmp >> 48) & 0xff));
|
m_data.push_back((char)((tmp.u >> 48) & 0xff));
|
||||||
m_data.push_back((char)((tmp >> 40) & 0xff));
|
m_data.push_back((char)((tmp.u >> 40) & 0xff));
|
||||||
m_data.push_back((char)((tmp >> 32) & 0xff));
|
m_data.push_back((char)((tmp.u >> 32) & 0xff));
|
||||||
m_data.push_back((char)((tmp >> 24) & 0xff));
|
m_data.push_back((char)((tmp.u >> 24) & 0xff));
|
||||||
m_data.push_back((char)((tmp >> 16) & 0xff));
|
m_data.push_back((char)((tmp.u >> 16) & 0xff));
|
||||||
m_data.push_back((char)((tmp >> 8) & 0xff));
|
m_data.push_back((char)((tmp.u >> 8) & 0xff));
|
||||||
m_data.push_back((char)(tmp & 0xff));
|
m_data.push_back((char)(tmp.u & 0xff));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleSerializer::writeBool(quint32 id, bool value)
|
void SimpleSerializer::writeBool(quint32 id, bool value)
|
||||||
@ -414,7 +426,7 @@ returnDefault:
|
|||||||
bool SimpleDeserializer::readFloat(quint32 id, float* result, float def) const
|
bool SimpleDeserializer::readFloat(quint32 id, float* result, float def) const
|
||||||
{
|
{
|
||||||
uint readOfs;
|
uint readOfs;
|
||||||
quint32 tmp;
|
union floatasint tmp;
|
||||||
Elements::const_iterator it = m_elements.constFind(id);
|
Elements::const_iterator it = m_elements.constFind(id);
|
||||||
if(it == m_elements.constEnd())
|
if(it == m_elements.constEnd())
|
||||||
goto returnDefault;
|
goto returnDefault;
|
||||||
@ -424,10 +436,10 @@ bool SimpleDeserializer::readFloat(quint32 id, float* result, float def) const
|
|||||||
goto returnDefault;
|
goto returnDefault;
|
||||||
|
|
||||||
readOfs = it->ofs;
|
readOfs = it->ofs;
|
||||||
tmp = 0;
|
tmp.u = 0;
|
||||||
for(int i = 0; i < 4; i++)
|
for(int i = 0; i < 4; i++)
|
||||||
tmp = (tmp << 8) | readByte(&readOfs);
|
tmp.u = (tmp.u << 8) | readByte(&readOfs);
|
||||||
*result = *((float*)&tmp);
|
*result = tmp.f;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
returnDefault:
|
returnDefault:
|
||||||
@ -438,7 +450,7 @@ returnDefault:
|
|||||||
bool SimpleDeserializer::readDouble(quint32 id, double* result, double def) const
|
bool SimpleDeserializer::readDouble(quint32 id, double* result, double def) const
|
||||||
{
|
{
|
||||||
uint readOfs;
|
uint readOfs;
|
||||||
quint64 tmp;
|
union doubleasint tmp;
|
||||||
Elements::const_iterator it = m_elements.constFind(id);
|
Elements::const_iterator it = m_elements.constFind(id);
|
||||||
if(it == m_elements.constEnd())
|
if(it == m_elements.constEnd())
|
||||||
goto returnDefault;
|
goto returnDefault;
|
||||||
@ -448,10 +460,10 @@ bool SimpleDeserializer::readDouble(quint32 id, double* result, double def) cons
|
|||||||
goto returnDefault;
|
goto returnDefault;
|
||||||
|
|
||||||
readOfs = it->ofs;
|
readOfs = it->ofs;
|
||||||
tmp = 0;
|
tmp.u = 0;
|
||||||
for(int i = 0; i < 8; i++)
|
for(int i = 0; i < 8; i++)
|
||||||
tmp = (tmp << 8) | readByte(&readOfs);
|
tmp.u = (tmp.u << 8) | readByte(&readOfs);
|
||||||
*result = *((double*)&tmp);
|
*result = tmp.d;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
returnDefault:
|
returnDefault:
|
||||||
@ -459,11 +471,21 @@ returnDefault:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
union real4asint {
|
||||||
|
quint32 u;
|
||||||
|
Real r;
|
||||||
|
};
|
||||||
|
|
||||||
|
union real8asint {
|
||||||
|
quint64 u;
|
||||||
|
Real r;
|
||||||
|
};
|
||||||
|
|
||||||
bool SimpleDeserializer::readReal(quint32 id, Real* result, Real def) const
|
bool SimpleDeserializer::readReal(quint32 id, Real* result, Real def) const
|
||||||
{
|
{
|
||||||
if(sizeof(Real) == 4) {
|
if(sizeof(Real) == 4) {
|
||||||
uint readOfs;
|
uint readOfs;
|
||||||
quint32 tmp;
|
union real4asint tmp;
|
||||||
Elements::const_iterator it = m_elements.constFind(id);
|
Elements::const_iterator it = m_elements.constFind(id);
|
||||||
if(it == m_elements.constEnd())
|
if(it == m_elements.constEnd())
|
||||||
goto returnDefault32;
|
goto returnDefault32;
|
||||||
@ -473,10 +495,10 @@ bool SimpleDeserializer::readReal(quint32 id, Real* result, Real def) const
|
|||||||
goto returnDefault32;
|
goto returnDefault32;
|
||||||
|
|
||||||
readOfs = it->ofs;
|
readOfs = it->ofs;
|
||||||
tmp = 0;
|
tmp.u = 0;
|
||||||
for(int i = 0; i < 4; i++)
|
for(int i = 0; i < 4; i++)
|
||||||
tmp = (tmp << 8) | readByte(&readOfs);
|
tmp.u = (tmp.u << 8) | readByte(&readOfs);
|
||||||
*result = *((Real*)&tmp);
|
*result = tmp.r;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
returnDefault32:
|
returnDefault32:
|
||||||
@ -484,7 +506,7 @@ bool SimpleDeserializer::readReal(quint32 id, Real* result, Real def) const
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
uint readOfs;
|
uint readOfs;
|
||||||
quint64 tmp;
|
union real8asint tmp;
|
||||||
Elements::const_iterator it = m_elements.constFind(id);
|
Elements::const_iterator it = m_elements.constFind(id);
|
||||||
if(it == m_elements.constEnd())
|
if(it == m_elements.constEnd())
|
||||||
goto returnDefault64;
|
goto returnDefault64;
|
||||||
@ -494,10 +516,10 @@ bool SimpleDeserializer::readReal(quint32 id, Real* result, Real def) const
|
|||||||
goto returnDefault64;
|
goto returnDefault64;
|
||||||
|
|
||||||
readOfs = it->ofs;
|
readOfs = it->ofs;
|
||||||
tmp = 0;
|
tmp.u = 0;
|
||||||
for(int i = 0; i < 8; i++)
|
for(int i = 0; i < 8; i++)
|
||||||
tmp = (tmp << 8) | readByte(&readOfs);
|
tmp.u = (tmp.u << 8) | readByte(&readOfs);
|
||||||
*result = *((Real*)&tmp);
|
*result = tmp.r;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
returnDefault64:
|
returnDefault64:
|
||||||
|
Loading…
Reference in New Issue
Block a user