util_md.h revision 0
0N/A/*
2362N/A * Copyright 1998-2005 Sun Microsystems, Inc. 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
0N/A * published by the Free Software Foundation. Sun designates this
0N/A * particular file as subject to the "Classpath" exception as provided
0N/A * by Sun 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,
2362N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2362N/A *
2362N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
0N/A * have any questions.
0N/A */
0N/A
0N/A#ifndef JDWP_UTIL_MD_H
0N/A#define JDWP_UTIL_MD_H
0N/A
0N/A#include <limits.h>
0N/A#include <sys/types.h>
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
0N/A