summaryrefslogtreecommitdiffstats
path: root/src/corelib/arch
diff options
context:
space:
mode:
authorAurelien Jarno <aurelien@aurel32.net>2013-11-10 23:20:46 +0100
committerThiago Macieira <thiago.macieira@intel.com>2014-06-27 03:19:02 +0200
commit60b6b28c213a420ee40e254ff1823876098e0a04 (patch)
treec8ed53a71164bc66755cc72134417895651c43d1 /src/corelib/arch
parentdd91f8d46dbdf62cc276bc204425c4ae106d913e (diff)
Support MIPS atomic on pre-MIPS32 architectures
The atomic functions on MIPS are based on the sync opcode with an immediate argument, which is something introduced in the MIPS32 instruction set. This prevent to use Qt on pre-MIPS32 CPU, like the Loongson 2 CPU. However some of the pre-MIPS32 CPUs interprets the sync opcode with and immediate argument as a sync opcode without argument (which is a stronger ordering than with the argument), and for the others the kernel emulates it. It is therefore fine to use the current MIPS atomic functions on pre-MIPS32 CPU. This patch allows that by temporarily changing the instruction set to MIPS32 around the sync instruction, so that binutils doesn't choke on it. Change-Id: I9cc984bd55b5f172736ce9e638a6f4e271b79fe7 Reviewed-by: Lisandro Damián Nicanor Pérez Meyer <perezmeyer@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/arch')
-rw-r--r--src/corelib/arch/qatomic_mips.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/corelib/arch/qatomic_mips.h b/src/corelib/arch/qatomic_mips.h
index 463612212b..7bfe16a450 100644
--- a/src/corelib/arch/qatomic_mips.h
+++ b/src/corelib/arch/qatomic_mips.h
@@ -110,13 +110,19 @@ template <typename T> struct QAtomicOps : QBasicAtomicOps<sizeof(T)>
template <int size> template <typename T> inline
void QBasicAtomicOps<size>::acquireMemoryFence(const T &) Q_DECL_NOTHROW
{
- asm volatile ("sync 0x11" ::: "memory");
+ asm volatile (".set push\n"
+ ".set mips32\n"
+ "sync 0x11\n"
+ ".set pop\n" ::: "memory");
}
template <int size> template <typename T> inline
void QBasicAtomicOps<size>::releaseMemoryFence(const T &) Q_DECL_NOTHROW
{
- asm volatile ("sync 0x12" ::: "memory");
+ asm volatile (".set push\n"
+ ".set mips32\n"
+ "sync 0x11\n"
+ ".set pop\n" ::: "memory");
}
template <int size> template <typename T> inline