summaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java')
-rw-r--r--src/java/jogamp/common/os/elf/IOUtils.java23
-rw-r--r--src/java/jogamp/common/os/elf/SectionArmAttributes.java7
2 files changed, 12 insertions, 18 deletions
diff --git a/src/java/jogamp/common/os/elf/IOUtils.java b/src/java/jogamp/common/os/elf/IOUtils.java
index 8c7bfd1..08bbaa1 100644
--- a/src/java/jogamp/common/os/elf/IOUtils.java
+++ b/src/java/jogamp/common/os/elf/IOUtils.java
@@ -29,18 +29,19 @@ package jogamp.common.os.elf;
import java.io.IOException;
import java.io.RandomAccessFile;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
+
+import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.Bitstream;
class IOUtils {
- static final long MAX_INT_VALUE = ( (long) Integer.MAX_VALUE & 0xffffffffL ) ;
+ static final long MAX_INT_VALUE = ( Integer.MAX_VALUE & 0xffffffffL ) ;
static String toHexString(int i) { return "0x"+Integer.toHexString(i); }
static String toHexString(long i) { return "0x"+Long.toHexString(i); }
static int shortToInt(short s) {
- return (int)s & 0x0000ffff;
+ return s & 0x0000ffff;
}
static int long2Int(final long v) {
@@ -50,12 +51,6 @@ class IOUtils {
return (int)v;
}
- static void checkBounds(final byte[] sb, final int offset, final int remaining) {
- if( offset + remaining > sb.length ) {
- throw new IndexOutOfBoundsException("Buffer of size "+sb.length+" cannot hold offset "+offset+" + remaining "+remaining);
- }
- }
-
static void readBytes(final RandomAccessFile in, final byte[] out, final int offset, final int len)
throws IOException, IllegalArgumentException
{
@@ -80,9 +75,7 @@ class IOUtils {
}
static int readInt32(final byte[] in, final int offset) {
- checkBounds(in, offset, 4);
- final ByteBuffer b = ByteBuffer.wrap(in, offset, 4).order(ByteOrder.nativeOrder());
- return b.asIntBuffer().get(0);
+ return Bitstream.readInt32(!Platform.isLittleEndian(), in, offset);
}
/**
@@ -95,7 +88,7 @@ class IOUtils {
* @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>.
*/
static String getString(final byte[] sb, final int offset, final int remaining, int[] offset_post) throws IndexOutOfBoundsException {
- checkBounds(sb, offset, remaining);
+ Bitstream.checkBounds(sb, offset, remaining);
int strlen = 0;
for(; strlen < remaining && sb[strlen + offset] != 0; strlen++) { }
final String s = 0 < strlen ? new String(sb, offset, strlen) : "" ;
@@ -114,7 +107,7 @@ class IOUtils {
* @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>.
*/
static int getStringCount(final byte[] sb, int offset, final int remaining) throws IndexOutOfBoundsException {
- checkBounds(sb, offset, remaining);
+ Bitstream.checkBounds(sb, offset, remaining);
int strnum=0;
for(int i=0; i < remaining; i++) {
for(; i < remaining && sb[i + offset] != 0; i++) { }
diff --git a/src/java/jogamp/common/os/elf/SectionArmAttributes.java b/src/java/jogamp/common/os/elf/SectionArmAttributes.java
index 249b2e3..db6710a 100644
--- a/src/java/jogamp/common/os/elf/SectionArmAttributes.java
+++ b/src/java/jogamp/common/os/elf/SectionArmAttributes.java
@@ -1,13 +1,14 @@
package jogamp.common.os.elf;
import static jogamp.common.os.elf.IOUtils.toHexString;
-import static jogamp.common.os.elf.IOUtils.checkBounds;
import static jogamp.common.os.elf.IOUtils.readUInt32;
import static jogamp.common.os.elf.IOUtils.getString;
import java.util.ArrayList;
import java.util.List;
+import com.jogamp.common.util.Bitstream;
+
/**
* ARM EABI attributes within section header {@link SectionHeader#SHT_ARM_ATTRIBUTES}.
* <p>
@@ -215,7 +216,7 @@ public class SectionArmAttributes extends Section {
* @throws IllegalArgumentException if section parsing failed, i.e. incompatible version or data.
*/
static List<VendorAttributes> parse(final byte[] in, final int offset, final int remaining) throws IndexOutOfBoundsException, IllegalArgumentException {
- checkBounds(in, offset, remaining);
+ Bitstream.checkBounds(in, offset, remaining);
int i = offset;
if( FORMAT_VERSION_A != in[ i ] ) {
throw new IllegalArgumentException("ShArmAttr: Not version A, but: "+toHexString(in[i]));
@@ -268,7 +269,7 @@ public class SectionArmAttributes extends Section {
* @throws IllegalArgumentException if section parsing failed, i.e. incompatible version or data.
*/
static void parseSub(final byte[] in, final int offset, final int remaining, int[] offset_post, List<Attribute> attributes) throws IndexOutOfBoundsException, IllegalArgumentException {
- checkBounds(in, offset, remaining);
+ Bitstream.checkBounds(in, offset, remaining);
// Starts w/ sub-section Tag
int i = offset;