/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <jni.h>
#include "SharedMemory.h"
#include "com_sun_tools_jdi_SharedMemoryConnection.h"
#include "jdwpTransport.h"
#include "shmemBase.h"
#include "sys.h"
/*
* JNI interface to the shared memory transport. These JNI methods
* call the base shared memory support to do the real work.
*
* That is, this is the front-ends interface to our shared memory
* communication code.
*/
/*
* Cached architecture
*/
static int byte_ordering_known;
static int is_big_endian;
/*
* Returns 1 if big endian architecture
*/
static int isBigEndian() {
if (!byte_ordering_known) {
unsigned int i = 0xff000000;
if (((char *)(&i))[0] != 0) {
is_big_endian = 1;
} else {
is_big_endian = 0;
}
byte_ordering_known = 1;
}
return is_big_endian;
}
/*
* Convert to big endian
*/
unsigned int b[4];
if (isBigEndian()) {
return i;
}
b[0] = (i >> 24) & 0xff;
b[1] = (i >> 16) & 0xff;
b[2] = (i >> 8) & 0xff;
b[3] = i & 0xff;
/*
* It doesn't matter that jint is signed as we are or'ing
* and hence end up with the correct bits.
*/
return (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0];
}
/*
* Convert unsigned short to big endian
*/
static unsigned short shortToBigShort(unsigned short s) {
unsigned int b[2];
if (isBigEndian()) {
return s;
}
b[0] = (s >> 8) & 0xff;
b[1] = s & 0xff;
return (b[1] << 8) + b[0];
}
/*
* Create a byte[] from a packet struct. All data in the byte array
* is JDWP packet suitable for wire transmission. That is, all fields,
* and data are in big-endian format as required by the JDWP
* specification.
*/
static jbyteArray
{
/* total packet length is header + data */
return NULL;
}
/* First 4 bytes of packet are the length (in big endian format) */
/* Next 4 bytes are the id field */
/* next byte is the flags */
} else {
}
/* finally the data */
if (data_length > 0) {
return NULL;
}
}
return array;
}
/*
* Fill a packet struct from a byte array. The byte array is a
* JDWP packet suitable for wire transmission. That is, all fields,
* and data are in big-endian format as required by the JDWP
* specification. We thus need to convert the fields from big
* endian to the platform endian.
*
* The jbyteArray provided to this function is assumed to
* of a length than is equal or greater than the length of
* the JDWP packet that is contains.
*/
static void
{
/*
* Get the packet header
*/
/*
* The id field is in big endian (also errorCode field in the case
* of reply packets).
*/
} else {
/* command packet */
}
/*
* The length of the JDWP packet is 11 + data
*/
if (data_length == 0) {
} else {
"Unable to allocate command data buffer");
return;
}
return;
}
}
}
static void
{
}
}
/*
* Class: com_sun_tools_jdi_SharedMemoryConnection
* Method: close0
* Signature: (J)V
*/
{
}
/*
* Class: com_sun_tools_jdi_SharedMemoryConnection
* Method: receiveByte0
* Signature: (J)B
*/
{
jbyte b = 0;
}
return b;
}
/*
* Class: com_sun_tools_jdi_SharedMemoryConnection
* Method: receivePacket0
*/
{
return NULL;
} else {
/* Free the packet even if there was an exception above */
return array;
}
}
/*
* Class: com_sun_tools_jdi_SharedMemoryConnection
* Method: sendByte0
* Signature: (JB)V
*/
{
}
}
/*
* Class: com_sun_tools_jdi_SharedMemoryConnection
* Method: sendPacket0
*/
{
return;
}
}
}