diff options
author | Sven Gothel <[email protected]> | 2011-07-17 16:34:39 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-07-17 16:34:39 +0200 |
commit | f733203dfbd034a6b1aa3eb2cd616437c982c435 (patch) | |
tree | 4ace71d4b129870b02f962b714c9dce9f83bc294 /src/java/com/jogamp/common/util/IOUtil.java | |
parent | ad3dc39ccfddb007c3e91acf454f804573969419 (diff) |
GlueGen proper size / alignment of primitive and compound types usage [1/2] - Preparation.
Currently GlueGen fails for type long (size) and some alignments (see package.html).
- The size and alignment values shall be queried at runtime.
- Compound alignment needs to follow the described natural alignment (also @runtime).
-
- Build
- add Linux Arm7 (EABI)
- junit test
- added compound/struct tests, pointing out the shortcomings of current impl.
- package.html
- Added alignment documentation
- remove intptr.cfg
- add GluGen types int8_t, int16_t, uint8_t, uint16_t
- move MachineDescription* into runtime
- Platform
- has runtime MachineDescription
- moved size, .. to MachineDescription
- use enums for OSType, CPUArch and CPUType defined by os.name/os.arch,
triggering exception if os/arch is not supported.
This avoids Java String comparison and conscious os/arch detection.
- MachineDescription:
- compile time instances MachineDescription32Bits, MachineDescription64Bits
- runtime queried instance MachineDescriptionRuntime
- correct size, alignment, page size, ..
Diffstat (limited to 'src/java/com/jogamp/common/util/IOUtil.java')
-rw-r--r-- | src/java/com/jogamp/common/util/IOUtil.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index b2d9ed4..5b00fb4 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -42,6 +42,7 @@ import java.net.URLConnection; import java.nio.ByteBuffer; import com.jogamp.common.nio.Buffers; +import com.jogamp.common.os.MachineDescription; import com.jogamp.common.os.Platform; public class IOUtil { @@ -81,7 +82,7 @@ public class IOUtil { * number of bytes written is returned. */ public static int copyStream2Stream(InputStream in, OutputStream out, int totalNumBytes) throws IOException { - final byte[] buf = new byte[Platform.getPageSize()]; + final byte[] buf = new byte[Platform.getMachineDescription().pageSizeInBytes()]; int numBytes = 0; while (true) { int count; @@ -137,16 +138,16 @@ public class IOUtil { if( !(stream instanceof BufferedInputStream) ) { stream = new BufferedInputStream(stream); } - int totalRead = 0; int avail = stream.available(); - ByteBuffer data = Buffers.newDirectByteBuffer( Platform.getPageAlignedSize(avail) ); - byte[] chunk = new byte[Platform.getPageSize()]; - int chunk2Read = Math.min(Platform.getPageSize(), avail); + final MachineDescription machine = Platform.getMachineDescription(); + ByteBuffer data = Buffers.newDirectByteBuffer( machine.pageAlignedSize(avail) ); + byte[] chunk = new byte[machine.pageSizeInBytes()]; + int chunk2Read = Math.min(machine.pageSizeInBytes(), avail); int numRead = 0; do { if (avail > data.remaining()) { - final ByteBuffer newData = Buffers.newDirectByteBuffer( - Platform.getPageAlignedSize(data.position() + avail) ); + final ByteBuffer newData = Buffers.newDirectByteBuffer( + machine.pageAlignedSize(data.position() + avail) ); newData.put(data); data = newData; } @@ -154,10 +155,9 @@ public class IOUtil { numRead = stream.read(chunk, 0, chunk2Read); if (numRead >= 0) { data.put(chunk, 0, numRead); - totalRead += numRead; } avail = stream.available(); - chunk2Read = Math.min(Platform.getPageSize(), avail); + chunk2Read = Math.min(machine.pageSizeInBytes(), avail); } while (avail > 0 && numRead >= 0); data.flip(); |