Daily bump.
[official-gcc.git] / libjava / java / nio / natVMDirectByteBufferImpl.cc
blob3119fdea3e6a7abbab294b22ba9bbcf352d113e8
1 // natDirectByteBufferImpl.cc
3 /* Copyright (C) 2003, 2004 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 details. */
11 #include <config.h>
13 #include <gcj/cni.h>
14 #include <jvm.h>
16 #include <stdlib.h>
18 #include <gnu/gcj/RawData.h>
19 #include <java/nio/VMDirectByteBuffer.h>
21 using gnu::gcj::RawData;
23 RawData*
24 java::nio::VMDirectByteBuffer::allocate (jint capacity)
26 return reinterpret_cast<gnu::gcj::RawData*> (::malloc (capacity));
29 void
30 java::nio::VMDirectByteBuffer::free (gnu::gcj::RawData* address)
32 ::free (reinterpret_cast<void*> (address));
35 jbyte
36 java::nio::VMDirectByteBuffer::get (RawData* address, jint index)
38 jbyte* pointer = reinterpret_cast<jbyte*> (address) + index;
39 return *pointer;
42 void
43 java::nio::VMDirectByteBuffer::get (RawData* address, jint index,
44 jbyteArray dst, jint offset, jint length)
46 jbyte* src = reinterpret_cast<jbyte*> (address) + index;
47 memcpy (elements (dst) + offset, src, length);
50 void
51 java::nio::VMDirectByteBuffer::put (gnu::gcj::RawData* address,
52 jint index, jbyte value)
54 jbyte* pointer = reinterpret_cast<jbyte*> (address) + index;
55 *pointer = value;
58 RawData*
59 java::nio::VMDirectByteBuffer::adjustAddress (RawData* address, jint offset)
61 jbyte* start = reinterpret_cast<jbyte*> (address) + offset;
62 return reinterpret_cast<RawData*>(start);
65 void
66 java::nio::VMDirectByteBuffer::shiftDown (RawData* address, jint dst_offset,
67 jint src_offset, jint count)
69 jbyte* dst = reinterpret_cast<jbyte*> (address) + dst_offset;
70 jbyte* src = reinterpret_cast<jbyte*> (address) + src_offset;
71 ::memmove(dst, src, count);