LANG-1717: support RISC-V in ArchUtils (#1128)
* LANG-1717: support RISC-V in ArchUtils Add RISC-V support to ArchUtils and its dependency class, Processor. * Add missing Javadoc since tags --------- Co-authored-by: Gary Gregory <garydgregory@users.noreply.github.com>
This commit is contained in:
parent
c1181d9e2f
commit
4cff6633e9
|
@ -96,6 +96,8 @@ public class ArchUtils {
|
|||
init_PPC_32Bit();
|
||||
init_PPC_64Bit();
|
||||
init_Aarch_64Bit();
|
||||
init_RISCV_32Bit();
|
||||
init_RISCV_64Bit();
|
||||
}
|
||||
|
||||
private static void init_Aarch_64Bit() {
|
||||
|
@ -118,6 +120,14 @@ public class ArchUtils {
|
|||
addProcessors(new Processor(Processor.Arch.BIT_64, Processor.Type.PPC), "ppc64", "power64", "powerpc64", "power_pc64", "power_rs64");
|
||||
}
|
||||
|
||||
private static void init_RISCV_32Bit() {
|
||||
addProcessors(new Processor(Processor.Arch.BIT_32, Processor.Type.RISCV), "riscv32");
|
||||
}
|
||||
|
||||
private static void init_RISCV_64Bit() {
|
||||
addProcessors(new Processor(Processor.Arch.BIT_64, Processor.Type.RISCV), "riscv64");
|
||||
}
|
||||
|
||||
private static void init_X86_32Bit() {
|
||||
addProcessors(new Processor(Processor.Arch.BIT_32, Processor.Type.X86), "x86", "i386", "i486", "i586", "i686", "pentium");
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ public class Processor {
|
|||
* <li>x86</li>
|
||||
* <li>ia64</li>
|
||||
* <li>PPC</li>
|
||||
* <li>RISCV</li>
|
||||
* <li>Unknown</li>
|
||||
* </ul>
|
||||
*/
|
||||
|
@ -106,6 +107,13 @@ public class Processor {
|
|||
*/
|
||||
PPC("PPC"),
|
||||
|
||||
/**
|
||||
* RISC-V architecture.
|
||||
*
|
||||
* @since 3.14.0
|
||||
*/
|
||||
RISCV("RISC-V"),
|
||||
|
||||
/**
|
||||
* Unknown architecture.
|
||||
*/
|
||||
|
@ -225,6 +233,16 @@ public class Processor {
|
|||
return Type.X86 == type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if {@link Processor} is type of RISC-V.
|
||||
*
|
||||
* @return {@code true}. if {@link Processor} is {@link Type#RISCV}, else {@code false}.
|
||||
* @since 3.14.0
|
||||
*/
|
||||
public boolean isRISCV() {
|
||||
return Type.RISCV == type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
|
|
@ -40,6 +40,8 @@ public class ArchUtilsTest extends AbstractLangTest {
|
|||
private static final String X86 = "x86";
|
||||
private static final String X86_64 = "x86_64";
|
||||
private static final String AARCH_64 = "aarch64";
|
||||
private static final String RISCV_64 = "riscv64";
|
||||
private static final String RISCV_32 = "riscv32";
|
||||
|
||||
private void assertEqualsArchNotNull(final Processor.Arch arch, final Processor processor) {
|
||||
assertNotNull(arch);
|
||||
|
@ -100,6 +102,14 @@ public class ArchUtilsTest extends AbstractLangTest {
|
|||
processor = ArchUtils.getProcessor(AARCH_64);
|
||||
assertEqualsTypeNotNull(Processor.Type.AARCH_64, processor);
|
||||
assertTrue(processor.isAarch64());
|
||||
|
||||
processor = ArchUtils.getProcessor(RISCV_32);
|
||||
assertEqualsTypeNotNull(Processor.Type.RISCV, processor);
|
||||
assertTrue(processor.isRISCV());
|
||||
|
||||
processor = ArchUtils.getProcessor(RISCV_64);
|
||||
assertEqualsTypeNotNull(Processor.Type.RISCV, processor);
|
||||
assertTrue(processor.isRISCV());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -134,6 +144,10 @@ public class ArchUtilsTest extends AbstractLangTest {
|
|||
assertEqualsArchNotNull(Processor.Arch.BIT_32, processor);
|
||||
processor.is32Bit();
|
||||
|
||||
processor = ArchUtils.getProcessor(RISCV_32);
|
||||
assertEqualsArchNotNull(Processor.Arch.BIT_32, processor);
|
||||
assertTrue(processor.is32Bit());
|
||||
|
||||
processor = ArchUtils.getProcessor(X86_64);
|
||||
assertNotEqualsArchNotNull(Processor.Arch.BIT_32, processor);
|
||||
assertFalse(processor.is32Bit());
|
||||
|
@ -145,6 +159,10 @@ public class ArchUtilsTest extends AbstractLangTest {
|
|||
processor = ArchUtils.getProcessor(IA64);
|
||||
assertNotEqualsArchNotNull(Processor.Arch.BIT_32, processor);
|
||||
assertFalse(processor.is32Bit());
|
||||
|
||||
processor = ArchUtils.getProcessor(RISCV_64);
|
||||
assertNotEqualsArchNotNull(Processor.Arch.BIT_32, processor);
|
||||
assertFalse(processor.is32Bit());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -161,6 +179,10 @@ public class ArchUtilsTest extends AbstractLangTest {
|
|||
assertEqualsArchNotNull(Processor.Arch.BIT_64, processor);
|
||||
assertTrue(processor.is64Bit());
|
||||
|
||||
processor = ArchUtils.getProcessor(RISCV_64);
|
||||
assertEqualsArchNotNull(Processor.Arch.BIT_64, processor);
|
||||
assertTrue(processor.is64Bit());
|
||||
|
||||
processor = ArchUtils.getProcessor(X86);
|
||||
assertNotEqualsArchNotNull(Processor.Arch.BIT_64, processor);
|
||||
assertFalse(processor.is64Bit());
|
||||
|
@ -173,6 +195,10 @@ public class ArchUtilsTest extends AbstractLangTest {
|
|||
assertNotEqualsArchNotNull(Processor.Arch.BIT_64, processor);
|
||||
assertFalse(processor.is64Bit());
|
||||
|
||||
processor = ArchUtils.getProcessor(RISCV_32);
|
||||
assertNotEqualsArchNotNull(Processor.Arch.BIT_64, processor);
|
||||
assertFalse(processor.is64Bit());
|
||||
|
||||
processor = ArchUtils.getProcessor(AARCH_64);
|
||||
assertEqualsArchNotNull(Processor.Arch.BIT_64, processor);
|
||||
assertNotEqualsArchNotNull(Processor.Arch.BIT_32, processor);
|
||||
|
|
Loading…
Reference in New Issue