Skip to content

Commit

Permalink
Merge pull request #132 from jcharaoui/add-mipsel-arch
Browse files Browse the repository at this point in the history
Add support for MIPS 32-bit little-endian architecture
  • Loading branch information
headius committed Dec 7, 2022
2 parents ca5b77f + c257560 commit 37aa891
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
5 changes: 5 additions & 0 deletions build.xml
Expand Up @@ -83,6 +83,11 @@
<os arch="loongarch64"/>
</or>
</condition>
<condition property="platform.cpu" value="mipsel">
<or>
<os arch="mipsel"/>
</or>
</condition>
<condition property="platform.cpu" value="mips64">
<or>
<os arch="mips64"/>
Expand Down
11 changes: 7 additions & 4 deletions jni/jffi/Foreign.c
Expand Up @@ -274,11 +274,14 @@ Java_com_kenai_jffi_Foreign_unregisterNatives(JNIEnv *env, jobject self, jclass
#elif defined(__ia64__) || defined(__ia64)
# define CPU "ia64"

#elif defined(__mips__) || defined(__mips) || defined(__mips64)
# if defined (__mips64)
#elif defined(__mips64)
# if BYTE_ORDER == LITTLE_ENDIAN
# define CPU "mips64el"
# else
# define CPU "mips"
# endif

#elif defined (__mips__) || defined (__mips)
# if BYTE_ORDER == LITTLE_ENDIAN
# define CPU "mipsel"
# endif

#elif defined(__s390__)
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/kenai/jffi/Platform.java
Expand Up @@ -106,7 +106,9 @@ public enum CPU {
AARCH64(64),
/** LOONGARCH64 */
LOONGARCH64(64),
/** MIPS64EL */
/** MIPSEL */
MIPSEL(32),
/** MIPS64EL */
MIPS64EL(64),
/** Unknown CPU */
UNKNOWN(64);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/kenai/jffi/internal/StubLoader.java
Expand Up @@ -161,6 +161,8 @@ public enum CPU {
AARCH64,
/** LOONGARCH64 */
LOONGARCH64,
/** MIPS 32-bit little endian */
MIPSEL,
/** MIPS 64-bit little endian */
MIPS64EL,
/** Unknown CPU */
Expand Down Expand Up @@ -231,6 +233,8 @@ private static CPU determineCPU() {
return CPU.AARCH64;
} else if (Util.equalsIgnoreCase("loongarch64", archString, LOCALE)) {
return CPU.LOONGARCH64;
} else if (Util.equalsIgnoreCase("mipsel", archString, LOCALE)) {
return CPU.MIPSEL;
} else if (Util.equalsIgnoreCase("mips64", archString, LOCALE) || Util.equalsIgnoreCase("mips64el", archString, LOCALE)) {
return CPU.MIPS64EL;

Expand Down
5 changes: 3 additions & 2 deletions src/test/java/com/kenai/jffi/NumberTest.java
Expand Up @@ -264,8 +264,9 @@ private void returnF128HighPrecision(InvokerType type) {
Assume.assumeFalse("Apple Silicon does not support 80-bit long double",
Platform.getPlatform().getOS() == Platform.OS.DARWIN &&
Platform.getPlatform().getCPU() == Platform.CPU.AARCH64);
Assume.assumeFalse("32-bit ARM does not support 80-bit long double",
Platform.getPlatform().getCPU() == Platform.CPU.ARM);
Assume.assumeFalse("32-bit ARM and MIPSel do not support 80-bit long double",
Platform.getPlatform().getCPU() == Platform.CPU.ARM ||
Platform.getPlatform().getCPU() == Platform.CPU.MIPSEL);
LibNumberTest lib = UnitHelper.loadTestLibrary(LibNumberTest.class, type);
BigDecimal param = new BigDecimal("1.234567890123456789");
BigDecimal result = lib.ret_f128(param);
Expand Down

0 comments on commit 37aa891

Please sign in to comment.