Author: mturk Date: Thu Apr 23 07:31:12 2009 New Revision: 767830 URL: http://svn.apache.org/viewvc?rev=767830&view=rev Log: Add skeleton Platfom class
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java (with props) commons/sandbox/runtime/trunk/src/main/native/include/acr_platform.h (with props) commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c (with props) commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c (with props) commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c (with props) commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c (with props) commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c (with props) Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java?rev=767830&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java Thu Apr 23 07:31:12 2009 @@ -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. + */ + +package org.apache.commons.runtime; + +/** + * Running Platform version info. + * + * @since Runtime 1.0 + * + */ +public final class Platform { + + private Platform() + { + // No class instance + } + + /* + * Get Platform integer property value. + * @see APR_PLAT_* in acr_platform.h file. + */ + private static native int intProp(int what); + + static { + SIZEOF_INT = intProp(0); + SIZEOF_LONG = intProp(1); + SIZEOF_SIZE_T = intProp(2); + SIZEOF_POINTER = intProp(3); + SIZEOF_WCHAR = intProp(4); + DATA_MODEL = intProp(5); + MAX_PATH = intProp(6); + } + + /** + * Size of the native platform {...@code int} type in bytes. + */ + public static final int SIZEOF_INT; + + /** + * Size of the native platform {...@code long} type in bytes. + */ + public static final int SIZEOF_LONG; + + /** + * Size of the native platform {...@code size_t} type in bytes. + */ + public static final int SIZEOF_SIZE_T; + + /** + * Size of the native platform {...@code pointer} type in bytes. + */ + public static final int SIZEOF_POINTER; + + /** + * Size of the native platform {...@code size_t} type in bytes. + */ + public static final int SIZEOF_WCHAR; + + + /** + * Platfrom data model (@code 32} or {...@code 64} bits. + */ + public static final int DATA_MODEL; + + /** + * Maximum {...@code file} path length this platfrom supports. + */ + public static final int MAX_PATH; + +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=767830&r1=767829&r2=767830&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Thu Apr 23 07:31:12 2009 @@ -81,24 +81,28 @@ $(SRCDIR)/os/unix/file.$(OBJ) \ $(SRCDIR)/os/unix/main.$(OBJ) \ $(SRCDIR)/os/unix/uuid.$(OBJ) \ + $(SRCDIR)/os/linux/platform.$(OBJ) \ $(SRCDIR)/os/linux/os.$(OBJ) SOLARIS_OBJS= \ $(SRCDIR)/os/unix/file.$(OBJ) \ $(SRCDIR)/os/unix/main.$(OBJ) \ $(SRCDIR)/os/unix/uuid.$(OBJ) \ + $(SRCDIR)/os/solaris/platform.$(OBJ) \ $(SRCDIR)/os/solaris/os.$(OBJ) DARWIN_OBJS= \ $(SRCDIR)/os/unix/file.$(OBJ) \ $(SRCDIR)/os/unix/main.$(OBJ) \ $(SRCDIR)/os/unix/uuid.$(OBJ) \ + $(SRCDIR)/os/darwin/platform.$(OBJ) \ $(SRCDIR)/os/darwin/os.$(OBJ) HPUX_OBJS= \ $(SRCDIR)/os/unix/file.$(OBJ) \ $(SRCDIR)/os/unix/main.$(OBJ) \ $(SRCDIR)/os/unix/uuid.$(OBJ) \ + $(SRCDIR)/os/hpux/platform.$(OBJ) \ $(SRCDIR)/os/hpux/os.$(OBJ) TEST_OBJS= \ Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=767830&r1=767829&r2=767830&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Thu Apr 23 07:31:12 2009 @@ -74,6 +74,7 @@ WINDOWS_OBJS= \ $(SRCDIR)/os/win32/file.$(OBJ) \ $(SRCDIR)/os/win32/main.$(OBJ) \ + $(SRCDIR)/os/win32/platform.$(OBJ) \ $(SRCDIR)/os/win32/os.$(OBJ) \ $(SRCDIR)/os/win32/syslog.$(OBJ) \ $(SRCDIR)/os/win32/uuid.$(OBJ) \ Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_platform.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_platform.h?rev=767830&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/include/acr_platform.h (added) +++ commons/sandbox/runtime/trunk/src/main/native/include/acr_platform.h Thu Apr 23 07:31:12 2009 @@ -0,0 +1,46 @@ +/* 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_PLATFORM_H +#define _ACR_PLATFORM_H + +#include "acr.h" +#include <jni.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file acr_platform.h + * @brief + * + * ACR platform private structures + * + */ +#define ACR_PLAT_SIZEOF_INT 0 +#define ACR_PLAT_SIZEOF_LONG 1 +#define ACR_PLAT_SIZEOF_SIZE_T 2 +#define ACR_PLAT_SIZEOF_POINTER 3 +#define ACR_PLAT_SIZEOF_WCHAR 4 +#define ACR_PLAT_DATA_MODEL 5 +#define ACR_PLAT_PATH_MAX 6 + +#ifdef __cplusplus +} +#endif + +#endif /* _ACR_PLATFORM_H */ Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_platform.h ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c?rev=767830&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c Thu Apr 23 07:31:12 2009 @@ -0,0 +1,60 @@ +/* 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 "acr_arch.h" +#include "acr_string.h" +#include "acr_platform.h" + +static const char unknown[] = "unknown"; + +ACR_JNI_EXPORT_DECLARE(jint, Platform, intProp)(ACR_JNISTDARGS, jint what) +{ + UNREFERENCED_STDARGS; + + switch (what) { + case ACR_PLAT_SIZEOF_INT: + return sizeof(int); + break; + case ACR_PLAT_SIZEOF_LONG: + return sizeof(long); + break; + case ACR_PLAT_SIZEOF_SIZE_T: + return sizeof(size_t); + break; + case ACR_PLAT_SIZEOF_POINTER: + return sizeof(void *); + break; + case ACR_PLAT_SIZEOF_WCHAR: + return sizeof(wchar_t); + break; + case ACR_PLAT_DATA_MODEL: +#if CC_SIZEOF_VOIDP == 8 + return 64; +#else + return 32; +#endif + break; + case ACR_PLAT_PATH_MAX: + return PATH_MAX; + break; + default: + break; + } + + return -1; +} Propchange: commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c?rev=767830&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c Thu Apr 23 07:31:12 2009 @@ -0,0 +1,60 @@ +/* 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 "acr_arch.h" +#include "acr_string.h" +#include "acr_platform.h" + +static const char unknown[] = "unknown"; + +ACR_JNI_EXPORT_DECLARE(jint, Platform, intProp)(ACR_JNISTDARGS, jint what) +{ + UNREFERENCED_STDARGS; + + switch (what) { + case ACR_PLAT_SIZEOF_INT: + return sizeof(int); + break; + case ACR_PLAT_SIZEOF_LONG: + return sizeof(long); + break; + case ACR_PLAT_SIZEOF_SIZE_T: + return sizeof(size_t); + break; + case ACR_PLAT_SIZEOF_POINTER: + return sizeof(void *); + break; + case ACR_PLAT_SIZEOF_WCHAR: + return sizeof(wchar_t); + break; + case ACR_PLAT_DATA_MODEL: +#if CC_SIZEOF_VOIDP == 8 + return 64; +#else + return 32; +#endif + break; + case ACR_PLAT_PATH_MAX: + return PATH_MAX; + break; + default: + break; + } + + return -1; +} Propchange: commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c?rev=767830&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c Thu Apr 23 07:31:12 2009 @@ -0,0 +1,60 @@ +/* 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 "acr_arch.h" +#include "acr_string.h" +#include "acr_platform.h" + +static const char unknown[] = "unknown"; + +ACR_JNI_EXPORT_DECLARE(jint, Platform, intProp)(ACR_JNISTDARGS, jint what) +{ + UNREFERENCED_STDARGS; + + switch (what) { + case ACR_PLAT_SIZEOF_INT: + return sizeof(int); + break; + case ACR_PLAT_SIZEOF_LONG: + return sizeof(long); + break; + case ACR_PLAT_SIZEOF_SIZE_T: + return sizeof(size_t); + break; + case ACR_PLAT_SIZEOF_POINTER: + return sizeof(void *); + break; + case ACR_PLAT_SIZEOF_WCHAR: + return sizeof(wchar_t); + break; + case ACR_PLAT_DATA_MODEL: +#if CC_SIZEOF_VOIDP == 8 + return 64; +#else + return 32; +#endif + break; + case ACR_PLAT_PATH_MAX: + return PATH_MAX; + break; + default: + break; + } + + return -1; +} Propchange: commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c?rev=767830&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c Thu Apr 23 07:31:12 2009 @@ -0,0 +1,60 @@ +/* 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 "acr_arch.h" +#include "acr_string.h" +#include "acr_platform.h" + +static const char unknown[] = "unknown"; + +ACR_JNI_EXPORT_DECLARE(jint, Platform, intProp)(ACR_JNISTDARGS, jint what) +{ + UNREFERENCED_STDARGS; + + switch (what) { + case ACR_PLAT_SIZEOF_INT: + return sizeof(int); + break; + case ACR_PLAT_SIZEOF_LONG: + return sizeof(long); + break; + case ACR_PLAT_SIZEOF_SIZE_T: + return sizeof(size_t); + break; + case ACR_PLAT_SIZEOF_POINTER: + return sizeof(void *); + break; + case ACR_PLAT_SIZEOF_WCHAR: + return sizeof(wchar_t); + break; + case ACR_PLAT_DATA_MODEL: +#if CC_SIZEOF_VOIDP == 8 + return 64; +#else + return 32; +#endif + break; + case ACR_PLAT_PATH_MAX: + return PATH_MAX; + break; + default: + break; + } + + return -1; +} Propchange: commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c?rev=767830&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Thu Apr 23 07:31:12 2009 @@ -0,0 +1,60 @@ +/* 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 "acr_arch.h" +#include "acr_string.h" +#include "acr_platform.h" + +static const char unknown[] = "unknown"; + +ACR_JNI_EXPORT_DECLARE(jint, Platform, intProp)(ACR_JNISTDARGS, jint what) +{ + UNREFERENCED_STDARGS; + + switch (what) { + case ACR_PLAT_SIZEOF_INT: + return sizeof(int); + break; + case ACR_PLAT_SIZEOF_LONG: + return sizeof(long); + break; + case ACR_PLAT_SIZEOF_SIZE_T: + return sizeof(size_t); + break; + case ACR_PLAT_SIZEOF_POINTER: + return sizeof(void *); + break; + case ACR_PLAT_SIZEOF_WCHAR: + return sizeof(wchar_t); + break; + case ACR_PLAT_DATA_MODEL: +#if CC_SIZEOF_VOIDP == 8 + return 64; +#else + return 32; +#endif + break; + case ACR_PLAT_PATH_MAX: + return MAX_PATH - 1; + break; + default: + break; + } + + return -1; +} Propchange: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java?rev=767830&r1=767829&r2=767830&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java (original) +++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java Thu Apr 23 07:31:12 2009 @@ -72,6 +72,11 @@ System.out.println("Is Devel " + Version.IS_DEVELOPMENT); System.out.println("Build at " + Version.BUILDMARK); + System.out.println(); + System.out.println("Platform:"); + System.out.println("Int size " + Platform.SIZEOF_INT); + System.out.println("Max path " + Platform.MAX_PATH); + } }