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 2011/04/18 13:47:16 UTC
svn commit: r1094502 -
/commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c
Author: mturk
Date: Mon Apr 18 11:47:16 2011
New Revision: 1094502
URL: http://svn.apache.org/viewvc?rev=1094502&view=rev
Log:
Add Solaris os
Added:
commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c (with props)
Added: 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=1094502&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c Mon Apr 18 11:47:16 2011
@@ -0,0 +1,89 @@
+/* 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/jniapi.h"
+#include "acr/string.h"
+#include <sys/utsname.h>
+
+#define MAXSIZESYSSTRING 256
+#include <sys/utsname.h>
+
+static int _sys_done = -1;
+static struct utsname _sys_buf;
+static int _sys_ncpu = 0;
+static const char _unknown[] = "unknown";
+
+ACR_JNI_EXPORT(jint, Os, getType)(JNI_STDARGS)
+{
+ UNREFERENCED_STDARGS;
+ return ACR_OS_SOLARIS;
+}
+
+ACR_JNI_EXPORT(jint, Os, getNumCpu)(JNI_STDARGS)
+{
+ UNREFERENCED_STDARGS;
+ if (_sys_ncpu == 0) {
+ long nc = sysconf(_SC_NPROCESSORS_CONF);
+ if (nc == -1)
+ _sys_ncpu = 1;
+ else
+ _sys_ncpu = (int)nc;
+ }
+ return _sys_ncpu;
+}
+
+ACR_JNI_EXPORT(jint, Os, init)(JNI_STDARGS)
+{
+ UNREFERENCED_STDARGS;
+ if (_sys_done == 0)
+ return 0;
+ _sys_done = uname(&_sys_buf);
+ if (_sys_done)
+ return errno;
+ else
+ return 0;
+}
+
+ACR_JNI_EXPORT(jstring, Os, getSysname)(JNI_STDARGS)
+{
+ return CSTR_TO_JSTRING("solaris");
+}
+
+ACR_JNI_EXPORT(jstring, Os, getNodename)(JNI_STDARGS)
+{
+ if (_sys_done == 0)
+ return CSTR_TO_JSTRING(_sys_buf.nodename);
+ else
+ return CSTR_TO_JSTRING(_unknown);
+}
+
+ACR_JNI_EXPORT(jstring, Os, getRelease)(JNI_STDARGS)
+{
+ char buf[MAXSIZESYSSTRING];
+ if (sysinfo(SI_RELEASE, buf, sizeof(buf)) < 0)
+ return CSTR_TO_JSTRING(_unknown);
+ else
+ return CSTR_TO_JSTRING(buf);
+}
+
+ACR_JNI_EXPORT(jstring, Os, getVersion)(JNI_STDARGS)
+{
+ char buf[MAXSIZESYSSTRING];
+ if (sysinfo(SI_VERSION, buf, sizeof(buf)) < 0)
+ return CSTR_TO_JSTRING(_unknown);
+ else
+ return CSTR_TO_JSTRING(buf);
+}
Propchange: commons/sandbox/runtime/trunk/src/main/native/os/solaris/os.c
------------------------------------------------------------------------------
svn:eol-style = native