0N/A/*
2362N/A * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#ifndef JDWP_UTIL_MD_H
0N/A#define JDWP_UTIL_MD_H
0N/A
502N/A#include <stddef.h>
502N/A#include <stdint.h> /* To get uintptr_t */
502N/A
0N/A#include <limits.h>
0N/A#include <sys/types.h>
4632N/A#ifdef _ALLBSD_SOURCE
4632N/A#include <machine/endian.h>
4632N/A#elif __linux__
4632N/A#include <endian.h>
4632N/A#endif
0N/A
0N/A#ifdef _LP64
0N/Atypedef unsigned long UNSIGNED_JLONG;
0N/Atypedef unsigned int UNSIGNED_JINT;
0N/A#else /* _LP64 */
0N/Atypedef unsigned long long UNSIGNED_JLONG;
0N/Atypedef unsigned long UNSIGNED_JINT;
0N/A#endif /* _LP64 */
0N/A
0N/A#ifndef MAXPATHLEN
0N/A#define MAXPATHLEN PATH_MAX
0N/A#endif
0N/A
0N/A/* On little endian machines, convert java big endian numbers. */
0N/A
0N/A#if defined(_LITTLE_ENDIAN)
0N/A
0N/A#define HOST_TO_JAVA_CHAR(x) (((x & 0xff) << 8) | ((x >> 8) & (0xff)))
0N/A#define HOST_TO_JAVA_SHORT(x) (((x & 0xff) << 8) | ((x >> 8) & (0xff)))
0N/A#define HOST_TO_JAVA_INT(x) \
0N/A ((x << 24) | \
0N/A ((x & 0x0000ff00) << 8) | \
0N/A ((x & 0x00ff0000) >> 8) | \
0N/A (((UNSIGNED_JINT)(x & 0xff000000)) >> 24))
0N/A#define HOST_TO_JAVA_LONG(x) \
0N/A ((x << 56) | \
0N/A ((x & 0x000000000000ff00) << 40) | \
0N/A ((x & 0x0000000000ff0000) << 24) | \
0N/A ((x & 0x00000000ff000000) << 8) | \
0N/A ((x & 0x000000ff00000000) >> 8) | \
0N/A ((x & 0x0000ff0000000000) >> 24) | \
0N/A ((x & 0x00ff000000000000) >> 40) | \
0N/A (((UNSIGNED_JLONG)(x & 0xff00000000000000)) >> 56))
0N/A#define HOST_TO_JAVA_FLOAT(x) stream_encodeFloat(x)
0N/A#define HOST_TO_JAVA_DOUBLE(x) stream_encodeDouble(x)
0N/A
0N/A#else
0N/A
0N/A#define HOST_TO_JAVA_CHAR(x) (x)
0N/A#define HOST_TO_JAVA_SHORT(x) (x)
0N/A#define HOST_TO_JAVA_INT(x) (x)
0N/A#define HOST_TO_JAVA_LONG(x) (x)
0N/A#define HOST_TO_JAVA_FLOAT(x) (x)
0N/A#define HOST_TO_JAVA_DOUBLE(x) (x)
0N/A
0N/A#endif
0N/A
0N/A#define JAVA_TO_HOST_CHAR(x) HOST_TO_JAVA_CHAR(x)
0N/A#define JAVA_TO_HOST_SHORT(x) HOST_TO_JAVA_SHORT(x)
0N/A#define JAVA_TO_HOST_INT(x) HOST_TO_JAVA_INT(x)
0N/A#define JAVA_TO_HOST_LONG(x) HOST_TO_JAVA_LONG(x)
0N/A#define JAVA_TO_HOST_FLOAT(x) HOST_TO_JAVA_FLOAT(x)
0N/A#define JAVA_TO_HOST_DOUBLE(x) HOST_TO_JAVA_DOUBLE(x)
0N/A
0N/A#endif