57 |
|
|
58 |
/* FIXME these are defined in gnu_java_nio_channels_FileChannelImpl |
/* FIXME these are defined in gnu_java_nio_channels_FileChannelImpl |
59 |
too; should be someplace common. */ |
too; should be someplace common. */ |
60 |
#define ALIGN_DOWN(p,s) ((p) - ((p) % (s))) |
#define ALIGN_DOWN(p,s) ((jpointer)(p) - ((jpointer)(p) % (s))) |
61 |
#define ALIGN_UP(p,s) ((p) + ((s) - ((p) % (s)))) |
#define ALIGN_UP(p,s) ((jpointer)(p) + ((s) - ((jpointer)(p) % (s)))) |
62 |
|
|
63 |
/** |
/** |
64 |
* Returns the memory page size of this platform. |
* Returns the memory page size of this platform. |
97 |
const long pagesize = get_pagesize (); |
const long pagesize = get_pagesize (); |
98 |
jfieldID MappedByteBufferImpl_address; |
jfieldID MappedByteBufferImpl_address; |
99 |
jfieldID MappedByteBufferImpl_size; |
jfieldID MappedByteBufferImpl_size; |
|
jfieldID RawData_data; |
|
100 |
jobject MappedByteBufferImpl_address_value = NULL; |
jobject MappedByteBufferImpl_address_value = NULL; |
101 |
|
|
102 |
*address = NULL; |
*address = NULL; |
122 |
return; |
return; |
123 |
} |
} |
124 |
|
|
|
#if (SIZEOF_VOID_P == 4) |
|
|
RawData_data = |
|
|
(*env)->GetFieldID (env, (*env)->GetObjectClass (env, MappedByteBufferImpl_address_value), |
|
|
"data", "I"); |
|
125 |
*address = (void *) |
*address = (void *) |
126 |
ALIGN_DOWN ((*env)->GetIntField (env, MappedByteBufferImpl_address_value, |
ALIGN_DOWN (JCL_GetRawData (env, MappedByteBufferImpl_address_value), pagesize); |
|
RawData_data), pagesize); |
|
|
#elif (SIZEOF_VOID_P == 8) |
|
|
RawData_data = |
|
|
(*env)->GetFieldID (env, (*env)->GetObjectClass (env, MappedByteBufferImpl_address_value), |
|
|
"data", "J"); |
|
|
*address = (void *) |
|
|
ALIGN_DOWN ((*env)->GetLongField (env, MappedByteBufferImpl_address_value, |
|
|
RawData_data), pagesize); |
|
|
#endif /* SIZEOF_VOID_P */ |
|
|
|
|
127 |
*size = (size_t) |
*size = (size_t) |
128 |
ALIGN_UP ((*env)->GetIntField (env, this, MappedByteBufferImpl_size), |
ALIGN_UP ((*env)->GetIntField (env, this, MappedByteBufferImpl_size), |
129 |
pagesize); |
pagesize); |