Author: mturk Date: Wed Apr 8 06:58:03 2009 New Revision: 763123 URL: http://svn.apache.org/viewvc?rev=763123&view=rev Log: Add unix paltfor, common for all posix variants
Added: commons/sandbox/runtime/trunk/src/main/native/os/unix/ commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c (with props) Added: commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c?rev=763123&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c Wed Apr 8 06:58:03 2009 @@ -0,0 +1,67 @@ +/* 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. + */ + +#include "acr.h" +#include "acr_private.h" + +#include <pthread.h> + +/** + * Posix main + * + */ + +static JavaVM *acr_pvm = NULL; +static pthread_key_t acr_thread_key; + +typedef struct acr_thread_local_t { + JNIEnv *env; + int attached; +} acr_thread_local_t; + +static void acr_thread_key_destructor(void *data) +{ + acr_thread_local_t *t = (acr_thread_local_t *)data; + + /* Destructor will be called only if data is + * not NULL + */ + if (t->attached) { + (*acr_pvm)->DetachCurrentThread(acr_pvm); + } + free(t); +} + +/* Called by the JVM when ACR is loaded */ +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) +{ + JNIEnv *env; + void *epp; + + UNREFERENCED(reserved); + if ((*vm)->GetEnv(vm, (void **)&epp, JNI_VERSION_1_4)) { + return JNI_ERR; + } + acr_pvm = vm; + if (pthread_key_create(&acr_thread_key, acr_thread_key_destructor)) { + + return JNI_ERR; + } + env = epp; + + + return JNI_VERSION_1_4; +} Propchange: commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c ------------------------------------------------------------------------------ svn:eol-style = native