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/08/21 17:54:50 UTC
svn commit: r806614 - in /commons/sandbox/runtime/trunk/src/main/native:
include/acr_io.h os/unix/ios.c os/win32/ios.c
Author: mturk
Date: Fri Aug 21 15:54:50 2009
New Revision: 806614
URL: http://svn.apache.org/viewvc?rev=806614&view=rev
Log:
Add IoClose API
Added:
commons/sandbox/runtime/trunk/src/main/native/include/acr_io.h (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c
Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_io.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_io.h?rev=806614&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_io.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_io.h Fri Aug 21 15:54:50 2009
@@ -0,0 +1,49 @@
+/* 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.
+ */
+
+#ifndef _ACR_IO_H
+#define _ACR_IO_H
+
+#include "acr.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file acr_io.h
+ * @brief
+ *
+ * ACR Common I/O functions
+ *
+ */
+/**
+ * Close the ACR Descriptor handle.
+ * @param env Current JNI environment
+ * @param descriptor Descriptor handle to close.
+ * @return ACR error code on failure. If env is not NULL the IO exception
+ * is thrown in case of failure.
+ * @remark The function calls the descriptor cleanup function.
+ */
+ACR_DECLARE(int) ACR_IoClose(JNIEnv *env, int descriptor);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_IO_H */
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_io.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c?rev=806614&r1=806613&r2=806614&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c Fri Aug 21 15:54:50 2009
@@ -20,6 +20,7 @@
#include "acr_error.h"
#include "acr_memory.h"
#include "acr_descriptor.h"
+#include "acr_io.h"
#include "acr_vm.h"
#include <pthread.h>
@@ -259,7 +260,7 @@
return ACR_EBADF;
if (!__bitmap)
return ACR_ENOMEM;
- if (!IS_INVALID_HANDLE(acr_ioh_tab[i].h) && acr_ioh_tab[i].c) {
+ if (IS_VALID_HANDLE(acr_ioh_tab[i].h) && acr_ioh_tab[i].c) {
/* Run the cleanup */
rc = (*acr_ioh_tab[i].c)(acr_ioh_tab[i].h, acr_ioh_tab[i].type,
acr_ioh_tab[i].flags);
@@ -280,7 +281,7 @@
return;
pthread_mutex_lock(&ios_lock);
for (i = 0; i < acr_ioh_mask; i++) {
- if (!IS_INVALID_HANDLE(acr_ioh_tab[i].h) && acr_ioh_tab[i].c) {
+ if (IS_VALID_HANDLE(acr_ioh_tab[i].h) && acr_ioh_tab[i].c) {
/* Run the cleanups */
(*acr_ioh_tab[i].c)(acr_ioh_tab[i].h, acr_ioh_tab[i].type,
acr_ioh_tab[i].flags);
@@ -295,3 +296,11 @@
pthread_mutex_destroy(&ios_lock);
}
+ACR_DECLARE(int) ACR_IoClose(JNIEnv *_E, int dh)
+{
+ int rc = acr_ioh_close(dh);
+
+ ACR_THROW_IO_IF_ERR(rc);
+ return rc;
+}
+
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c?rev=806614&r1=806613&r2=806614&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c Fri Aug 21 15:54:50 2009
@@ -236,7 +236,7 @@
return ACR_EBADF;
if (!__bitmap)
return ACR_ENOMEM;
- if (!IS_INVALID_HANDLE(acr_ioh_tab[i].h) && acr_ioh_tab[i].c) {
+ if (IS_VALID_HANDLE(acr_ioh_tab[i].h) && acr_ioh_tab[i].c) {
/* Run the cleanup */
rc = (*acr_ioh_tab[i].c)(acr_ioh_tab[i].h, acr_ioh_tab[i].type,
acr_ioh_tab[i].flags);
@@ -257,7 +257,7 @@
return;
EnterCriticalSection(&ios_lock);
for (i = 0; i < acr_ioh_mask; i++) {
- if (!IS_INVALID_HANDLE(acr_ioh_tab[i].h) && acr_ioh_tab[i].c) {
+ if (IS_VALID_HANDLE(acr_ioh_tab[i].h) && acr_ioh_tab[i].c) {
/* Run the cleanups */
(*acr_ioh_tab[i].c)(acr_ioh_tab[i].h, acr_ioh_tab[i].type,
acr_ioh_tab[i].flags);
@@ -272,3 +272,11 @@
}
+ACR_DECLARE(int) ACR_IoClose(JNIEnv *_E, int dh)
+{
+ int rc = acr_ioh_close(dh);
+
+ ACR_THROW_IO_IF_ERR(rc);
+ return rc;
+}
+