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/04/08 13:07:16 UTC
svn commit: r763181 - in /commons/sandbox/runtime/trunk/src/main/native:
configure include/acr.h os/darwin/os.c os/linux/os.c os/solaris/os.c
Author: mturk
Date: Wed Apr 8 11:07:16 2009
New Revision: 763181
URL: http://svn.apache.org/viewvc?rev=763181&view=rev
Log:
Add Mac os.c
Added:
commons/sandbox/runtime/trunk/src/main/native/os/darwin/os.c (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/configure
commons/sandbox/runtime/trunk/src/main/native/include/acr.h
commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c
commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c
Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=763181&r1=763180&r2=763181&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Wed Apr 8 11:07:16 2009
@@ -268,9 +268,9 @@
r="`uname -r | sed 's/\.//g'`"
varadds cppopts "-DDARWIN=$r"
varadds ccflags "-fPIC -O3 -g"
- varadds ldflags "-lrt -lpthread -ldl"
- varadds shflags "-shared -fPIC -Wl,-soname -Wl,lib$name$so"
+ varadds ldflags "-lpthread -ldl"
if $has_jni ; then so=".jnilib"; else so=".dynlib"; fi
+ varadds shflags "-dynamiclib -flat_namespace -undefined suppress -fPIC -Wl,-dylib_install_name -Wl,lib$name$so"
;;
solaris-cc )
r="`uname -r | sed 's/5.//'`"
@@ -361,7 +361,7 @@
echo "No shared library support!"
exit 1
fi
- rm -f $test.* $test >/dev/null 2>&1 || true
+ rm -rf $test.* $test >/dev/null 2>&1 || true
fi
have_include()
@@ -381,7 +381,7 @@
echo 0
fi
fi
- rm -f $test.* $test *.pdb >/dev/null 2>&1 || true
+ rm -rf $test.* $test *.pdb >/dev/null 2>&1 || true
}
test_csizeof()
@@ -399,7 +399,7 @@
else
echo 0
fi
- rm -f $test.* $test *.pdb >/dev/null 2>&1 || true
+ rm -rf $test.* $test *.pdb >/dev/null 2>&1 || true
}
# Generate configuration header file
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr.h?rev=763181&r1=763180&r2=763181&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr.h Wed Apr 8 11:07:16 2009
@@ -120,11 +120,14 @@
typedef ssize_t acr_ssize_t;
typedef long long acr_int64_t;
typedef unsigned long long acr_uint64_t;
+if CC_SIZEOF_OFF64_T
typedef off64_t acr_off_t;
+#else
+typedef int64_t acr_off_t;
+#endif
typedef socklen_t acr_socklen_t;
#endif
-
#if CC_SIZEOF_VOIDP == 8
typedef acr_uint64_t acr_ptr_t;
#else
Added: commons/sandbox/runtime/trunk/src/main/native/os/darwin/os.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/os.c?rev=763181&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/os.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/os.c Wed Apr 8 11:07:16 2009
@@ -0,0 +1,109 @@
+/* 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 <sys/utsname.h>
+#include <sys/sysctl.h>
+
+#define MAXSIZESYSSTRING 256
+
+ACR_JNI_EXPORT_DECLARE(jboolean, OS, is)(ACR_JNISTDARGS, jint type)
+{
+ UNREFERENCED_STDARGS;
+ if ((type & ACR_OS_UNIX) == ACR_OS_UNIX)
+ return JNI_TRUE;
+ else if (type == ACR_OS_LINUX)
+ return JNI_TRUE;
+ else
+ return JNI_FALSE;
+}
+
+ACR_JNI_EXPORT_DECLARE(jint, OS, type)(ACR_JNISTDARGS)
+{
+ UNREFERENCED_STDARGS;
+ return 5;
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getSysname)(ACR_JNISTDARGS)
+{
+ struct utsname sys;
+ if (!uname(&sys))
+ return CSTR_TO_JSTRING(sys.sysname);
+ else
+ return NULL;
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getVersion)(ACR_JNISTDARGS)
+{
+ struct utsname sys;
+ if (!uname(&sys))
+ return CSTR_TO_JSTRING(sys.version);
+ else
+ return NULL;
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getRelease)(ACR_JNISTDARGS)
+{
+ struct utsname sys;
+ if (!uname(&sys))
+ return CSTR_TO_JSTRING(sys.release);
+ else
+ return NULL;
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getMachine)(ACR_JNISTDARGS)
+{
+ struct utsname sys;
+ if (!uname(&sys))
+ return CSTR_TO_JSTRING(sys.machine);
+ else
+ return NULL;
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getNodename)(ACR_JNISTDARGS)
+{
+ struct utsname sys;
+ if (!uname(&sys))
+ return CSTR_TO_JSTRING(sys.nodename);
+ else
+ return NULL;
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getProcessor)(ACR_JNISTDARGS)
+{
+ char string[MAXSIZESYSSTRING];
+ size_t s = sizeof(string);
+ int mib[] = { CTL_HW, HW_MACHINE_ARCH };
+
+ if (sysctl(mib, 2, s, &s, 0, 0) < 0)
+ return NULL;
+ else
+ return CSTR_TO_JSTRING(string);
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getHardwarePlatform)(ACR_JNISTDARGS)
+{
+ char string[MAXSIZESYSSTRING];
+ size_t s = sizeof(string);
+ int mib[] = { CTL_HW, HW_MODEL };
+
+ if (sysctl(mib, 2, s, &s, 0, 0) < 0)
+ return NULL;
+ else
+ return CSTR_TO_JSTRING(string);
+}
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/os/darwin/os.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c?rev=763181&r1=763180&r2=763181&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c Wed Apr 8 11:07:16 2009
@@ -18,6 +18,10 @@
#include "acr_private.h"
#include <sys/utsname.h>
+#define MAXSIZESYSSTRING 256
+
+static const char unknown[] = "unknown";
+
ACR_JNI_EXPORT_DECLARE(jboolean, OS, is)(ACR_JNISTDARGS, jint type)
{
UNREFERENCED_STDARGS;
@@ -79,3 +83,14 @@
else
return NULL;
}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getProcessor)(ACR_JNISTDARGS)
+{
+ return CSTR_TO_JSTRING(unknown);
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getHardwarePlatform)(ACR_JNISTDARGS)
+{
+ return CSTR_TO_JSTRING(unknown);
+}
+
Modified: commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c?rev=763181&r1=763180&r2=763181&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c Wed Apr 8 11:07:16 2009
@@ -19,7 +19,7 @@
#include <sys/systeminfo.h>
-#define MAXSIZESYSSTRING 80
+#define MAXSIZESYSSTRING 256
ACR_JNI_EXPORT_DECLARE(jboolean, OS, is)(ACR_JNISTDARGS, jint type)
{
@@ -73,3 +73,21 @@
else
return CSTR_TO_JSTRING(string);
}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getProcessor)(ACR_JNISTDARGS)
+{
+ char string[MAXSIZESYSSTRING];
+ if (sysinfo(SI_ARCHITECTURE, string, sizeof(string)) < 0)
+ return NULL;
+ else
+ return CSTR_TO_JSTRING(string);
+}
+
+ACR_JNI_EXPORT_DECLARE(jstring, OS, getHardwarePlatform)(ACR_JNISTDARGS)
+{
+ char string[MAXSIZESYSSTRING];
+ if (sysinfo(SI_PLATFORM, string, sizeof(string)) < 0)
+ return NULL;
+ else
+ return CSTR_TO_JSTRING(string);
+}