src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/macho/MachOByteBuffer.java
author iveresov
Fri, 17 Aug 2018 13:20:53 -0700
changeset 51436 091c0d22e735
parent 47216 71c04702a3d5
child 52910 583fd71c47d6
permissions -rw-r--r--
8206992: Update Graal Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
     1
/*
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
     4
 *
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
     8
 *
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    13
 * accompanied this code).
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    14
 *
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    18
 *
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    21
 * questions.
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    22
 */
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    23
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 47216
diff changeset
    24
091c0d22e735 8206992: Update Graal
iveresov
parents: 47216
diff changeset
    25
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    26
package jdk.tools.jaotc.binformat.macho;
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    27
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    28
import java.nio.ByteBuffer;
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    29
import java.nio.ByteOrder;
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    30
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46260
diff changeset
    31
final class MachOByteBuffer {
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    32
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46260
diff changeset
    33
    static ByteBuffer allocate(int size) {
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    34
        ByteBuffer buf = ByteBuffer.allocate(size);
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46260
diff changeset
    35
        if (MachOTargetInfo.getMachOEndian() == MachO.mach_header_64.CPU_SUBTYPE_LITTLE_ENDIAN) {
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    36
            buf.order(ByteOrder.LITTLE_ENDIAN);
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46260
diff changeset
    37
        } else {
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    38
            buf.order(ByteOrder.BIG_ENDIAN);
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46260
diff changeset
    39
        }
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    40
        return (buf);
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    41
    }
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    42
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
diff changeset
    43
}