You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/07/03 08:39:36 UTC
svn commit: r790804 -
/commons/sandbox/runtime/trunk/src/main/native/shared/dbb.c
Author: mturk
Date: Fri Jul 3 06:39:35 2009
New Revision: 790804
URL: http://svn.apache.org/viewvc?rev=790804&view=rev
Log:
Readd dbb.c as DirectBuffer implementation
Added:
commons/sandbox/runtime/trunk/src/main/native/shared/dbb.c (with props)
Added: commons/sandbox/runtime/trunk/src/main/native/shared/dbb.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/dbb.c?rev=790804&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/dbb.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/dbb.c Fri Jul 3 06:39:35 2009
@@ -0,0 +1,107 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ *
+ * @author Mladen Turk
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_clazz.h"
+#include "acr_memory.h"
+#include "acr_pointer.h"
+#include "acr_vm.h"
+
+#define ACR_WANT_MEMPROTECT
+#include "acr_error.h"
+
+/**
+ * DirectByteBuffer utilities
+ */
+/**
+ * Pointer class utilities
+ */
+#if CC_SIZEOF_VOIDP == 8
+#define ACR_DBB_EXPORT_DECLARE(RT, FN) \
+ JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_DirectBuffer64_##FN
+
+J_DECLARE_CLAZZ = {
+ NULL,
+ NULL,
+ ACR_CLASS_PATH "DirectBuffer64"
+};
+
+J_DECLARE_M_ID(0000) = {
+ NULL,
+ "<init>",
+ "(JJJ)V"
+};
+
+#else
+#define ACR_DBB_EXPORT_DECLARE(RT, FN) \
+ JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_DirectBuffer32_##FN
+
+J_DECLARE_CLAZZ = {
+ NULL,
+ NULL,
+ ACR_CLASS_PATH "DirectBuffer32"
+};
+
+J_DECLARE_M_ID(0000) = {
+ NULL,
+ "<init>",
+ "(III)V"
+};
+
+#endif
+
+ACR_CLASS_LDEF(DirectBuffer)
+{
+ int rv;
+
+ if ((rv = ACR_LoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
+ return rv;
+ J_LOAD_METHOD(0000);
+
+ return ACR_SUCCESS;
+}
+
+ACR_CLASS_UDEF(DirectBuffer)
+{
+ ACR_UnloadClass(_E, &_clazzn);
+}
+
+ACR_DECLARE(jobjectArray) ACR_NewDirectBufferArray(JNIEnv *_E, jsize len)
+{
+ if (_clazzn.i)
+ return (*_E)->NewObjectArray(_E, len, _clazzn.i, NULL);
+ else
+ return NULL;
+}
+
+ACR_DECLARE(jobject) ACR_DirectBufferCreate(JNIEnv *_E, void *p, size_t len,
+ acr_pointer_cleanup_fn_t *cb)
+{
+ if (_clazzn.i && J4MID(0000))
+ return (*_E)->NewObject(_E, _clazzn.i, J4MID(0000),
+ P2N(p), P2N(cb), (acr_ptr_t)len);
+ else {
+ ACR_SET_OS_ERROR(ACR_ECLASSNOTFOUND);
+ return NULL;
+ }
+}
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/shared/dbb.c
------------------------------------------------------------------------------
svn:eol-style = native