Author: mturk Date: Mon Apr 18 10:30:18 2011 New Revision: 1094468 URL: http://svn.apache.org/viewvc?rev=1094468&view=rev Log: Add experimental AIX os code
Added: commons/sandbox/runtime/trunk/src/main/native/os/aix/os.c (with props) Added: commons/sandbox/runtime/trunk/src/main/native/os/aix/os.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/aix/os.c?rev=1094468&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/aix/os.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/os/aix/os.c Mon Apr 18 10:30:18 2011 @@ -0,0 +1,84 @@ +/* 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> + +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_AIX; +} + +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("aix"); +} + +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) +{ + if (_sys_done == 0) + return CSTR_TO_JSTRING(_sys_buf.release); + else + return CSTR_TO_JSTRING(_unknown); +} + +ACR_JNI_EXPORT(jstring, Os, getVersion)(JNI_STDARGS) +{ + if (_sys_done == 0) + return CSTR_TO_JSTRING(_sys_buf.version); + else + return CSTR_TO_JSTRING(_unknown); +} Propchange: commons/sandbox/runtime/trunk/src/main/native/os/aix/os.c ------------------------------------------------------------------------------ svn:eol-style = native