465
466 private native void copySwapMemory0(Object srcBase, long srcOffset,
467 Object destBase, long destOffset,
468 long bytes, long elemSize);
469
470
471 /**
472 * Copies all elements from one block of memory to another block,
473 * *unconditionally* byte swapping the elements on the fly.
474 *
475 * <p>This method determines each block's base address by means of two parameters,
476 * and so it provides (in effect) a <em>double-register</em> addressing mode,
477 * as discussed in {@link #getInt(Object,long)}. When the object reference is null,
478 * the offset supplies an absolute base address.
479 *
480 * @since 9
481 */
482 public void copySwapMemory(Object srcBase, long srcOffset,
483 Object destBase, long destOffset,
484 long bytes, long elemSize) {
485 if (bytes < 0 || srcOffset < 0 || destOffset < 0) {
486 throw new IllegalArgumentException();
487 }
488 if (elemSize != 2 && elemSize != 4 && elemSize != 8) {
489 throw new IllegalArgumentException();
490 }
491 if (bytes % elemSize != 0) {
492 throw new IllegalArgumentException();
493 }
494 if ((srcBase == null && srcOffset == 0) ||
495 (destBase == null && destOffset == 0)) {
496 throw new NullPointerException();
497 }
498
499 // Must be off-heap, or primitive heap arrays
500 if ((srcBase != null && !isPrimitiveArray(srcBase.getClass())) ||
501 (destBase != null && !isPrimitiveArray(destBase.getClass()))) {
502 throw new IllegalArgumentException();
503 }
504
505 // Sanity check size and offsets on 32-bit platforms. Most
506 // significant 32 bits must be zero.
507 if (ADDRESS_SIZE == 4 &&
508 (bytes >>> 32 != 0 || srcOffset >>> 32 != 0 || destOffset >>> 32 != 0)) {
509 throw new IllegalArgumentException();
510 }
511
512 if (bytes == 0) {
513 return;
514 }
515
516 copySwapMemory0(srcBase, srcOffset, destBase, destOffset, bytes, elemSize);
517 }
518
519 /**
520 * Copies all elements from one block of memory to another block, byte swapping the
521 * elements on the fly.
|
465
466 private native void copySwapMemory0(Object srcBase, long srcOffset,
467 Object destBase, long destOffset,
468 long bytes, long elemSize);
469
470
471 /**
472 * Copies all elements from one block of memory to another block,
473 * *unconditionally* byte swapping the elements on the fly.
474 *
475 * <p>This method determines each block's base address by means of two parameters,
476 * and so it provides (in effect) a <em>double-register</em> addressing mode,
477 * as discussed in {@link #getInt(Object,long)}. When the object reference is null,
478 * the offset supplies an absolute base address.
479 *
480 * @since 9
481 */
482 public void copySwapMemory(Object srcBase, long srcOffset,
483 Object destBase, long destOffset,
484 long bytes, long elemSize) {
485 if (bytes < 0) {
486 throw new IllegalArgumentException();
487 }
488 if (elemSize != 2 && elemSize != 4 && elemSize != 8) {
489 throw new IllegalArgumentException();
490 }
491 if (bytes % elemSize != 0) {
492 throw new IllegalArgumentException();
493 }
494 if ((srcBase == null && srcOffset == 0) ||
495 (destBase == null && destOffset == 0)) {
496 throw new NullPointerException();
497 }
498
499 // Must be off-heap, or primitive heap arrays
500 if (srcBase != null && (srcOffset < 0 || !isPrimitiveArray(srcBase.getClass()))) {
501 throw new IllegalArgumentException();
502 }
503 if (destBase != null && (destOffset < 0 || !isPrimitiveArray(destBase.getClass()))) {
504 throw new IllegalArgumentException();
505 }
506
507 // Sanity check size and offsets on 32-bit platforms. Most
508 // significant 32 bits must be zero.
509 if (ADDRESS_SIZE == 4 &&
510 (bytes >>> 32 != 0 || srcOffset >>> 32 != 0 || destOffset >>> 32 != 0)) {
511 throw new IllegalArgumentException();
512 }
513
514 if (bytes == 0) {
515 return;
516 }
517
518 copySwapMemory0(srcBase, srcOffset, destBase, destOffset, bytes, elemSize);
519 }
520
521 /**
522 * Copies all elements from one block of memory to another block, byte swapping the
523 * elements on the fly.
|