svn commit: r806431 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar: ArArchiveEntry.java ArArchiveInputStream.java

2009-08-21 Thread bodewig
Author: bodewig
Date: Fri Aug 21 07:05:07 2009
New Revision: 806431

URL: http://svn.apache.org/viewvc?rev=806431view=rev
Log:
ar stores permissions as octal numbers, output stream does write them 
correctly, input stream was reading them as decimal

Modified:

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java

commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java?rev=806431r1=806430r2=806431view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java
 Fri Aug 21 07:05:07 2009
@@ -110,7 +110,7 @@
 public ArArchiveEntry(File inputFile, String entryName) {
 // TODO sort out mode
 this(entryName, inputFile.isFile() ? inputFile.length() : 0,
- 0, 0, 0, inputFile.lastModified() / 1000);
+ 0, 0, DEFAULT_MODE, inputFile.lastModified() / 1000);
 }
 
 public long getSize() {

Modified: 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java?rev=806431r1=806430r2=806431view=diff
==
--- 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
 (original)
+++ 
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
 Fri Aug 21 07:05:07 2009
@@ -143,7 +143,7 @@
 temp = temp.substring(0, temp.length() - 1);
 }
 currentEntry = new ArArchiveEntry(temp, asLong(length), asInt(userid),
-  asInt(groupid), asInt(filemode),
+  asInt(groupid), asInt(filemode, 8),
   asLong(lastmodified));
 return currentEntry;
 }
@@ -153,7 +153,11 @@
 }
 
 private int asInt(byte[] input) {
-return Integer.parseInt(new String(input).trim());
+return asInt(input, 10);
+}
+
+private int asInt(byte[] input, int base) {
+return Integer.parseInt(new String(input).trim(), base);
 }
 
 /*




svn commit: r806434 - in /commons/sandbox/runtime/trunk/src: main/native/include/ main/native/os/unix/ main/native/test/ test/org/apache/commons/runtime/

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 07:28:51 2009
New Revision: 806434

URL: http://svn.apache.org/viewvc?rev=806434view=rev
Log:
Add SysV mutex implementation

Added:
commons/sandbox/runtime/trunk/src/main/native/os/unix/smutex.c   (with 
props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/include/acr_procmutex.h
commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c
commons/sandbox/runtime/trunk/src/main/native/test/testcase.c

commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_procmutex.h
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_procmutex.h?rev=806434r1=806433r2=806434view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_procmutex.h 
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_procmutex.h Fri 
Aug 21 07:28:51 2009
@@ -32,6 +32,11 @@
  */
 
 /**
+ * Any value will do
+ */
+#define ACR_MTX_MAGIC   0xC2303964
+
+/**
  * Private, platform-specific data struture representing a mutex.
  */
 typedef struct acr_pmutex_t acr_pmutex_t;

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c?rev=806434r1=806433r2=806434view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c Fri Aug 21 
07:28:51 2009
@@ -14,6 +14,10 @@
  * limitations under the License.
  */
 
+/*
+ * Posix semaphore implementation.
+ */
+
 #include acr.h
 #include acr_private.h
 #include acr_arch.h
@@ -92,7 +96,7 @@
 *p = '_';
 }
 do {
-m-sem = sem_open(m-name, O_CREAT | O_EXCL, 0666, 1);
+m-sem = sem_open(m-name, O_CREAT | O_EXCL, 0660, 1);
 if (m-sem == (sem_t *)SEM_FAILED) {
 if (rc)
 goto finally;

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c?rev=806434r1=806433r2=806434view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c Fri Aug 21 
07:28:51 2009
@@ -14,6 +14,10 @@
  * limitations under the License.
  */
 
+/*
+ * Posix semaphore implementation
+ */
+
 #include acr.h
 #include acr_private.h
 #include acr_arch.h
@@ -93,7 +97,7 @@
 *p = '_';
 }
 do {
-s-sem = sem_open(s-name, O_CREAT | O_EXCL, 0666, value);
+s-sem = sem_open(s-name, O_CREAT | O_EXCL, 0660, value);
 if (s-sem == (sem_t *)SEM_FAILED) {
 if (rc)
 goto finally;

Added: commons/sandbox/runtime/trunk/src/main/native/os/unix/smutex.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/smutex.c?rev=806434view=auto
==
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/smutex.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/smutex.c Fri Aug 21 
07:28:51 2009
@@ -0,0 +1,532 @@
+/* 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.
+ */
+
+/*
+ * System V semaphore implementation.
+ * Although Linux manual says that Posix semaphores have better API,
+ * they don't provide a simple way for setting the permissions once after
+ * they are created.
+ */
+
+#include acr.h
+#include acr_private.h
+#include acr_arch.h
+#include acr_clazz.h
+#include acr_error.h
+#include acr_memory.h
+#include acr_string.h
+#include acr_descriptor.h
+#include acr_pointer.h
+#include acr_procmutex.h
+
+#include sys/ipc.h
+#include sys/sem.h
+#include sys/file.h
+
+J_DECLARE_CLAZZ = {
+NULL,
+NULL,
+ACR_CLASS_PATH Mutex
+};
+

svn commit: r806439 - /commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 07:52:34 2009
New Revision: 806439

URL: http://svn.apache.org/viewvc?rev=806439view=rev
Log:
Few comments on Darwin muteses

Modified:
commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c?rev=806439r1=806438r2=806439view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c Fri Aug 21 
07:52:34 2009
@@ -14,6 +14,13 @@
  * limitations under the License.
  */
 
+/* File lock based mutex implementation.
+ * XXX: Darwin uses posix semaphores so they could
+ *  probably be used for mutexes as well.
+ *  Of course they don't have a descent API for
+ *  setting the permissions afterwards.
+ */
+
 #include acr.h
 #include acr_private.h
 #include acr_arch.h
@@ -67,7 +74,7 @@
 }
 if (m-filedes  0)
 close(m-filedes);
-if (m-fname) { 
+if (m-fname) {
 unlink(m-fname);
 free(m-fname);
 }
@@ -99,7 +106,7 @@
 if (m-anon)
 m-filedes = mkstemp(m-fname);
 else
-m-filedes = open(m-fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
+m-filedes = open(m-fname, O_CREAT | O_WRONLY | O_EXCL, 0660);
 
 if (m-filedes  0) {
 rc =  ACR_GET_OS_ERROR();
@@ -121,7 +128,7 @@
 }
 
 ACR_DECLARE(int) ACR_ProcMutexAttach(JNIEnv *_E, const acr_pchar_t *fname)
-{
+{
 int rc = 0;
 acr_pmutex_t *m;
 
@@ -162,7 +169,7 @@
 
 if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
 return ACR_EINVAL;
-}
+}
 
 op.l_whence = SEEK_SET;   /* from current point */
 op.l_start  = 0;  /* -- */
@@ -190,7 +197,7 @@
 
 if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
 return ACR_EINVAL;
-}
+}
 op.l_whence = SEEK_SET;   /* from current point */
 op.l_start  = 0;  /* -- */
 op.l_len= 0;  /* until end of file */
@@ -220,7 +227,7 @@
 
 if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
 return ACR_EINVAL;
-}
+}
 
 m-locked   = 0;
 op.l_whence = SEEK_SET;   /* from current point */
@@ -245,7 +252,7 @@
 
 if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
 return ACR_EINVAL;
-}
+}
 if (!(perms  ACR_FPROT_GSETID))
 gid = -1;
 if (fchown(m-filedes, uid, gid)  0) {
@@ -263,6 +270,17 @@
 return acr_ioh_close(mutex);
 }
 
+ACR_DECLARE(int) ACR_ProcMutexRemove(JNIEnv *_E, const acr_pchar_t *filename)
+{
+
+if (unlink(filename)) {
+ACR_THROW_IO_ERROR();
+return ACR_GET_OS_ERROR();
+}
+else
+return ACR_SUCCESS;
+}
+
 ACR_CLASS_LDEF(Mutex)
 {
 int rv;




svn commit: r806443 - /commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 08:01:47 2009
New Revision: 806443

URL: http://svn.apache.org/viewvc?rev=806443view=rev
Log:
Add missing include

Modified:
commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c?rev=806443r1=806442r2=806443view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c Fri Aug 21 
08:01:47 2009
@@ -28,8 +28,8 @@
 #include acr_error.h
 #include acr_memory.h
 #include acr_string.h
+#include acr_file.h
 #include acr_descriptor.h
-#include acr_pointer.h
 #include acr_procmutex.h
 
 #include sys/ipc.h




svn commit: r806446 - /commons/sandbox/runtime/trunk/src/main/native/configure

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 08:04:43 2009
New Revision: 806446

URL: http://svn.apache.org/viewvc?rev=806446view=rev
Log:
Create .jnilib by default on Mac

Modified:
commons/sandbox/runtime/trunk/src/main/native/configure

Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=806446r1=806445r2=806446view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Fri Aug 21 08:04:43 
2009
@@ -83,7 +83,7 @@
 java_home=`echo $JAVA_HOME | tr '\\' '/' 2/dev/null`
 java_pinc=
 has_dso_test=no
-has_jni=no
+has_jni=yes
 has_64_bit=no
 has_test=no
 has_memprotect=no




svn commit: r806450 - in /commons/sandbox/runtime/trunk/src/main/native: configure os/unix/pmutex.c

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 08:25:33 2009
New Revision: 806450

URL: http://svn.apache.org/viewvc?rev=806450view=rev
Log:
Combine posix and sysv mutexes and decide what to use at configure time

Modified:
commons/sandbox/runtime/trunk/src/main/native/configure
commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.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=806450r1=806449r2=806450view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Fri Aug 21 08:25:33 
2009
@@ -89,6 +89,7 @@
 has_memprotect=no
 has_maintainer_mode=no
 has_native_threads=no
+has_sysv_mutex=no
 is_unix=true
 
 has_openssl=no
@@ -539,6 +540,9 @@
 if [ .$has_memprotect = .yes ]; then
 varadds cppopts -DACR_ENABLE_SEH
 fi
+if [ .$has_sysv_mutex = .yes ]; then
+varadds cppopts -DACR_USE_SYSV_MUTEX
+fi
 if [ .$has_test = .yes ]; then
 varadds cppopts -DACR_ENABLE_TEST
 testobjs='$(TEST_OBJS)'

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c?rev=806450r1=806449r2=806450view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c Fri Aug 21 
08:25:33 2009
@@ -28,6 +28,9 @@
 #include acr_descriptor.h
 #include acr_procmutex.h
 
+#include sys/ipc.h
+#include sys/sem.h
+#include sys/file.h
 #include semaphore.h
 
 #ifndef SEM_FAILED
@@ -52,19 +55,404 @@
 
 static volatile unsigned int _mtx_counter = 1;
 
+union semun {
+int val;
+struct semid_ds *buf;
+unsigned short *array;
+};
+
+typedef struct semblock_t {
+acr_uint32_tmagic;   /* Is this our memeory */
+pid_t   creator; /* Creator's process ID*/
+acr_uint32_tvalue;   /* Maximum semaphore value */
+} semblock_t;
+
+
 struct acr_pmutex_t {
-sem_t *sem;
-intlocked;
-char   name[NAME_MAX];
+int locked;
+#if defined(ACR_USE_SYSV_MUTEX)
+int filedes;
+const char *filename;   /* NULL if anonymous */
+#else
+sem_t  *sem;
+charfilename[NAME_MAX];
+#endif
 };
 
+ACR_CLASS_LDEF(Mutex)
+{
+int rv;
+
+if ((rv = ACR_LoadClass(_E, _clazzn, 0)) != ACR_SUCCESS)
+return rv;
+J_LOAD_METHOD();
+
+return ACR_SUCCESS;
+}
+
+ACR_CLASS_UDEF(Mutex)
+{
+ACR_UnloadClass(_E, _clazzn);
+}
+
+#if defined(ACR_USE_SYSV_MUTEX)
+
+static int mutex_owner_cleanup(void *mutex, int type, unsigned int flags)
+{
+if (type == ACR_DT_MUTEX) {
+int rc = ACR_SUCCESS;
+acr_pmutex_t *m = (acr_pmutex_t *)mutex;
+if (m-filedes  0) {
+union semun ick;
+if (m-locked) {
+struct sembuf op;
+/* Unlock our instance */
+op.sem_num = 0;
+op.sem_op  = 1;
+op.sem_flg = SEM_UNDO;
+do {
+rc = semop(m-filedes, op, 1);
+} while (rc  0  errno == EINTR);
+}
+ick.val = 0;
+semctl(m-filedes, 0, IPC_RMID, ick);
+}
+if (m-filename) {
+if (access(m-filename, F_OK)) {
+rc = ACR_SUCCESS;
+}
+else {
+if (unlink(m-filename))
+rc = ACR_GET_OS_ERROR();
+}
+free((void *)(m-filename));
+}
+free(m);
+return rc;
+}
+return ACR_EBADF;
+}
+
+static int mutex_child_cleanup(void *mutex, int type, unsigned int flags)
+{
+if (type == ACR_DT_MUTEX) {
+int rc;
+acr_pmutex_t *m = (acr_pmutex_t *)mutex;
+if (m-filedes  0) {
+if (m-locked) {
+struct sembuf op;
+/* Unlock our instance */
+op.sem_num = 0;
+op.sem_op  = 1;
+op.sem_flg = SEM_UNDO;
+do {
+rc = semop(m-filedes, op, 1);
+} while (rc  0  errno == EINTR);
+}
+}
+free(m);
+return ACR_SUCCESS;
+}
+return ACR_EBADF;
+}
+
+ACR_DECLARE(int) ACR_ProcMutexCreate(JNIEnv *_E, const acr_pchar_t *fname)
+{
+union semun ick;
+int rc = 0;
+acr_pmutex_t *m;
+key_t mkey = IPC_PRIVATE;
+int flags  = IPC_CREAT;
+
+if (fname) {
+size_t nbytes;
+semblock_t hdr;
+int fs, fd = -1;
+
+fd = open(fname, O_WRONLY | O_CREAT | O_EXCL, 0660);
+if (fd  0) {
+rc =  ACR_GET_OS_ERROR();
+ACR_THROW_IO_ERRNO();
+

svn commit: r806454 - /commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 08:31:42 2009
New Revision: 806454

URL: http://svn.apache.org/viewvc?rev=806454view=rev
Log:
Add sysv mutexes for Darwin

Modified:
commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c?rev=806454r1=806453r2=806454view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c Fri Aug 21 
08:31:42 2009
@@ -33,6 +33,7 @@
 #include acr_procmutex.h
 
 #include sys/ipc.h
+#include sys/sem.h
 #include sys/file.h
 
 J_DECLARE_CLAZZ = {
@@ -48,12 +49,362 @@
 };
 
 struct acr_pmutex_t {
-int   filedes;
-int   locked;
-int   anon;
-char *fname;
+int filedes;
+int locked;
+const char *filename;
 };
 
+#if defined(ACR_USE_SYSV_MUTEX)
+
+static int mutex_owner_cleanup(void *mutex, int type, unsigned int flags)
+{
+if (type == ACR_DT_MUTEX) {
+int rc = ACR_SUCCESS;
+acr_pmutex_t *m = (acr_pmutex_t *)mutex;
+if (m-filedes  0) {
+union semun ick;
+if (m-locked) {
+struct sembuf op;
+/* Unlock our instance */
+op.sem_num = 0;
+op.sem_op  = 1;
+op.sem_flg = SEM_UNDO;
+do {
+rc = semop(m-filedes, op, 1);
+} while (rc  0  errno == EINTR);
+}
+ick.val = 0;
+semctl(m-filedes, 0, IPC_RMID, ick);
+}
+if (m-filename) {
+if (access(m-filename, F_OK)) {
+rc = ACR_SUCCESS;
+}
+else {
+if (unlink(m-filename))
+rc = ACR_GET_OS_ERROR();
+}
+free((void *)(m-filename));
+}
+free(m);
+return rc;
+}
+return ACR_EBADF;
+}
+
+static int mutex_child_cleanup(void *mutex, int type, unsigned int flags)
+{
+if (type == ACR_DT_MUTEX) {
+int rc;
+acr_pmutex_t *m = (acr_pmutex_t *)mutex;
+if (m-filedes  0) {
+if (m-locked) {
+struct sembuf op;
+/* Unlock our instance */
+op.sem_num = 0;
+op.sem_op  = 1;
+op.sem_flg = SEM_UNDO;
+do {
+rc = semop(m-filedes, op, 1);
+} while (rc  0  errno == EINTR);
+}
+}
+free(m);
+return ACR_SUCCESS;
+}
+return ACR_EBADF;
+}
+
+ACR_DECLARE(int) ACR_ProcMutexCreate(JNIEnv *_E, const acr_pchar_t *fname)
+{
+union semun ick;
+int rc = 0;
+acr_pmutex_t *m;
+key_t mkey = IPC_PRIVATE;
+int flags  = IPC_CREAT;
+
+if (fname) {
+size_t nbytes;
+semblock_t hdr;
+int fs, fd = -1;
+
+fd = open(fname, O_WRONLY | O_CREAT | O_EXCL, 0660);
+if (fd  0) {
+rc =  ACR_GET_OS_ERROR();
+ACR_THROW_IO_ERRNO();
+return -1;
+}
+mkey = ftok(fname, 1);
+if (mkey == (key_t)-1) {
+rc =  ACR_GET_OS_ERROR();
+close(fd);
+ACR_THROW_IO_IF_ERR(rc);
+return -1;
+}
+/* Write our header to shadow file
+ * Not needed, but might be used in the
+ * future to pass some data along with the mutex
+ */
+nbytes = sizeof(semblock_t);
+hdr.creator = getpid();
+hdr.magic   = ACR_MTX_MAGIC;
+hdr.value   = 1;
+do {
+fs = write(fd,(const void *)hdr, nbytes);
+} while (fs == (acr_size_t)-1  errno == EINTR);
+if (fs == -1) {
+rc = ACR_GET_OS_ERROR();
+close(fd);
+ACR_THROW_IO_IF_ERR(rc);
+return -1;
+}
+close(fd);
+flags |= IPC_EXCL;
+}
+m = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_pmutex_t));
+if (!m)
+return -1;
+if (fname) {
+m-filename = ACR_StrdupA(_E, THROW_FMARK, fname);
+if (!m-filename) {
+rc =  ACR_GET_OS_ERROR();
+free(m);
+ACR_SET_OS_ERROR(rc);
+return -1;
+}
+}
+m-filedes = semget(mkey, 1, flags | 0660);
+
+if (m-filedes  0) {
+if (fname  errno == EEXIST) {
+/* XXX: Should we throw separate exception here?
+ */
+}
+rc =  ACR_GET_OS_ERROR();
+goto finally;
+}
+ick.val = 1;
+if (semctl(m-filedes, 0, SETVAL, ick)  0) {
+rc =  ACR_GET_OS_ERROR();
+goto finally;
+}
+m-locked = 0;
+
+finally:
+if (rc) {
+if (m-filedes  0) {
+ick.val = 0;
+semctl(m-filedes, 0, 

svn commit: r806455 - /commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 08:33:24 2009
New Revision: 806455

URL: http://svn.apache.org/viewvc?rev=806455view=rev
Log:
Add missing private struct

Modified:
commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c?rev=806455r1=806454r2=806455view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c Fri Aug 21 
08:33:24 2009
@@ -54,6 +54,12 @@
 const char *filename;
 };
 
+typedef struct semblock_t {
+acr_uint32_tmagic;   /* Is this our memeory */
+pid_t   creator; /* Creator's process ID*/
+acr_uint32_tvalue;   /* Maximum semaphore value */
+} semblock_t;
+
 #if defined(ACR_USE_SYSV_MUTEX)
 
 static int mutex_owner_cleanup(void *mutex, int type, unsigned int flags)




svn commit: r806467 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/Mutex.java native/os/darwin/pmutex.c native/os/unix/pmutex.c native/os/win32/pmutex.c

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 09:03:25 2009
New Revision: 806467

URL: http://svn.apache.org/viewvc?rev=806467view=rev
Log:
Add Mutex.remove mathod. Usable for platforms that have kernel persistent 
mutexes

Modified:

commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java?rev=806467r1=806466r2=806467view=diff
==
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
 Fri Aug 21 09:03:25 2009
@@ -170,5 +170,28 @@
 }
 }
 
+private static native int remove0(String name)
+throws IOException, SecurityException;
+/**
+ * Remove mutex associated with a {...@code file}.
+ * p
+ * This function is only supported on platforms which support
+ * name-based mutexes.
+ * /p
+ * @param file The abstract file path associated with mutex
+ * object which needs to be removed.
+ */
+public static boolean remove(File file)
+throws IOException, SecurityException
+{
+int rc;
+
+rc = remove0(file.getPath());
+if (rc == Status.OK)
+return true;
+else
+return false;
+}
+
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c?rev=806467r1=806466r2=806467view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c Fri Aug 21 
09:03:25 2009
@@ -749,3 +749,16 @@
 return mtxo;
 }
 
+ACR_JNI_EXPORT_DECLARE(jint, Mutex, remove0)(ACR_JNISTDARGS,
+ jstring name)
+{
+
+int rc = ACR_SUCCESS;
+UNREFERENCED_O;
+
+WITH_CSTR(name) {
+rc = ACR_ProcMutexRemove(_E, J2S(name));
+} END_WITH_CSTR(name);
+return rc;
+}
+

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c?rev=806467r1=806466r2=806467view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c Fri Aug 21 
09:03:25 2009
@@ -79,22 +79,6 @@
 #endif
 };
 
-ACR_CLASS_LDEF(Mutex)
-{
-int rv;
-
-if ((rv = ACR_LoadClass(_E, _clazzn, 0)) != ACR_SUCCESS)
-return rv;
-J_LOAD_METHOD();
-
-return ACR_SUCCESS;
-}
-
-ACR_CLASS_UDEF(Mutex)
-{
-ACR_UnloadClass(_E, _clazzn);
-}
-
 #if defined(ACR_USE_SYSV_MUTEX)
 
 static int mutex_owner_cleanup(void *mutex, int type, unsigned int flags)
@@ -641,6 +625,25 @@
 
 #endif  /* ACR_USE_SYSV_MUTEX */
 
+/* Java API
+ */
+
+ACR_CLASS_LDEF(Mutex)
+{
+int rv;
+
+if ((rv = ACR_LoadClass(_E, _clazzn, 0)) != ACR_SUCCESS)
+return rv;
+J_LOAD_METHOD();
+
+return ACR_SUCCESS;
+}
+
+ACR_CLASS_UDEF(Mutex)
+{
+ACR_UnloadClass(_E, _clazzn);
+}
+
 static int mtx_descriptor_cleanup(ACR_JNISTDARGS,
   acr_descriptor_cb_type_e cm,
   acr_descriptor_cb_t *dp)
@@ -742,3 +745,16 @@
 return mtxo;
 }
 
+ACR_JNI_EXPORT_DECLARE(jint, Mutex, remove0)(ACR_JNISTDARGS,
+ jstring name)
+{
+
+int rc = ACR_SUCCESS;
+UNREFERENCED_O;
+
+WITH_CSTR(name) {
+rc = ACR_ProcMutexRemove(_E, J2S(name));
+} END_WITH_CSTR(name);
+return rc;
+}
+

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c?rev=806467r1=806466r2=806467view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c Fri Aug 21 
09:03:25 2009
@@ -309,3 +309,10 @@
 return mtxo;
 }
 
+ACR_JNI_EXPORT_DECLARE(jint, Mutex, remove0)(ACR_JNISTDARGS,
+ jstring name)
+{
+UNREFERENCED_STDARGS;
+return ACR_ENOTIMPL;
+}
+




svn commit: r806470 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/ native/include/ native/include/arch/windows/ native/os/hpux/ native/os/unix/ native/os/win32/ native/

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 09:15:14 2009
New Revision: 806470

URL: http://svn.apache.org/viewvc?rev=806470view=rev
Log:
Remove trailing tabs. No functional change

Modified:

commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/AbstractPointer.java

commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MbString.java

commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
commons/sandbox/runtime/trunk/src/main/native/include/acr_crypto.h
commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h
commons/sandbox/runtime/trunk/src/main/native/include/acr_shm.h
commons/sandbox/runtime/trunk/src/main/native/include/acr_time.h
commons/sandbox/runtime/trunk/src/main/native/include/acr_xdr.h

commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h

commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
commons/sandbox/runtime/trunk/src/main/native/os/hpux/pshm.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/dirent.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/pshm.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/time.c
commons/sandbox/runtime/trunk/src/main/native/shared/base64.c
commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
commons/sandbox/runtime/trunk/src/main/native/shared/sema.c
commons/sandbox/runtime/trunk/src/main/native/shared/sha1.c
commons/sandbox/runtime/trunk/src/main/native/shared/sha2.c
commons/sandbox/runtime/trunk/src/main/native/shared/shm.c
commons/sandbox/runtime/trunk/src/main/native/shared/xdr.c

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/AbstractPointer.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/AbstractPointer.java?rev=806470r1=806469r2=806470view=diff
==
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/AbstractPointer.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/AbstractPointer.java
 Fri Aug 21 09:15:14 2009
@@ -25,7 +25,7 @@
 abstract class AbstractPointer implements Pointer
 {
 
-   protected boolean ISCONST;
+protected boolean ISCONST;
 /**
  * Create new {...@code null} Pointer instance.
  * p
@@ -42,7 +42,7 @@
  * @see Memory#malloc()
  */
 public static final Pointer createInstance()
-   throws OutOfMemoryError
+throws OutOfMemoryError
 {
 return Memory.malloc();
 }

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MbString.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MbString.java?rev=806470r1=806469r2=806470view=diff
==
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MbString.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/MbString.java
 Fri Aug 21 09:15:14 2009
@@ -381,7 +381,7 @@
 public static final byte[] strdup(MbString src)
 throws NullPointerException
 {
-   byte[] copy = new byte[src.length()];
+byte[] copy = new byte[src.length()];
 System.arraycopy(src.mbstr, 0, copy, 0, src.mblen);
 
 return copy;
@@ -402,8 +402,8 @@
 public static final byte[] strndup(MbString src, int len)
 throws NullPointerException
 {
-   int length  = Math.min(src.length(), len);
-   byte[] copy = new byte[length];
+intlength  = Math.min(src.length(), len);
+byte[] copy = new byte[length];
 System.arraycopy(src.mbstr, 0, copy, 0, length);
 
 return copy;

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java?rev=806470r1=806469r2=806470view=diff
==
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
 Fri Aug 21 09:15:14 2009
@@ -167,7 +167,7 @@
 }
 else {
 throw new ClosedDescriptorException();
-}
+}
 }
 
 private static native int close0(Descriptor shm)
@@ -193,7 +193,7 @@
 }
 else {
 throw new ClosedDescriptorException();
-}
+}
 }
 
  

svn commit: r806475 - /commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 09:28:17 2009
New Revision: 806475

URL: http://svn.apache.org/viewvc?rev=806475view=rev
Log:
throw exception when attaching

Modified:

commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java

Modified: 
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java?rev=806475r1=806474r2=806475view=diff
==
--- 
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java
 Fri Aug 21 09:28:17 2009
@@ -59,11 +59,7 @@
 }
 }
 else {
-try {
-s = test002(0);
-} catch (Throwable t) {
-// Ignore
-}
+s = test002(0);
 }
 if (s  0  owner) {
 // Neither Create or Attach were sussesful




svn commit: r806479 - /commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 09:49:29 2009
New Revision: 806479

URL: http://svn.apache.org/viewvc?rev=806479view=rev
Log:
Do not allow dots in semaphore names as well

Modified:
commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c?rev=806479r1=806478r2=806479view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c Fri Aug 21 
09:49:29 2009
@@ -55,7 +55,7 @@
 struct acr_semaphore_t {
 sem_t *sem;
 intlocked;
-char   name[NAME_MAX];
+char   name[NAME_MAX + 1];
 };
 
 static int semaphore_cleanup(void *sema, int type, unsigned int flags)
@@ -90,10 +90,10 @@
 else {
 if (*name != '/')
 s-name[0] = '/';
-strlcat(s-name, name, NAME_MAX - 2);
+strlcat(s-name, name, NAME_MAX);
 }
 for (p = s-name[1]; *p; p++) {
-if (*p == '/')
+if (*p == '/' || *p == '.')
 *p = '_';
 }
 do {
@@ -150,9 +150,9 @@
 return -1;
 if (*name != '/')
 s-name[0] = '/';
-strlcat(s-name, name, NAME_MAX - 2);
+strlcat(s-name, name, NAME_MAX);
 for (p = s-name[1]; *p; p++) {
-if (*p == '/')
+if (*p == '/' || *p == '.')
 *p = '_';
 }
 
@@ -185,14 +185,18 @@
 
 ACR_DECLARE(int) ACR_SemaphoreRemove(JNIEnv *_E, const acr_pchar_t *sname)
 {
-char name[NAME_MAX] = ;
+char *p;
+char  name[NAME_MAX + 1] = ;
 if (!sname) {
 return ACR_EINVAL;
 }
 if (*sname != '/')
 name[0] = '/';
-strlcat(name, sname, NAME_MAX -2);
-
+strlcat(name, sname, NAME_MAX);
+for (p = name[1]; *p; p++) {
+if (*p == '/' || *p == '.')
+*p = '_';
+}
 return sem_unlink(name);
 }
 




svn commit: r806486 - in /commons/sandbox/runtime/trunk/src: main/native/os/unix/smutex.c test/org/apache/commons/runtime/TestSemaphore.java

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 10:34:21 2009
New Revision: 806486

URL: http://svn.apache.org/viewvc?rev=806486view=rev
Log:
SysV mutex is now combined with Posix mutex in pmutex.c

Removed:
commons/sandbox/runtime/trunk/src/main/native/os/unix/smutex.c
Modified:

commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java

Modified: 
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java?rev=806486r1=806485r2=806486view=diff
==
--- 
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSemaphore.java
 Fri Aug 21 10:34:21 2009
@@ -57,16 +57,15 @@
 } catch (Throwable t) {
 // Ignore
 }
+if (s  0) {
+// Remove and try to Create again
+test006(0);
+s = test001(0);
+}
 }
 else {
 s = test002(0);
 }
-if (s  0  owner) {
-// Neither Create or Attach were sussesful
-// Remove and try Create again
-test006(0);
-s = test001(0);
-}
 assertTrue(Invalid Semaphore, s  0);
 if (owner) {
 // Wait until child attaches




svn commit: r806605 - in /commons/sandbox/runtime/trunk/src/main/native: Makefile.in Makefile.msc.in include/acr_file.h include/acr_filemk.h include/acr_private.h os/unix/temps.c os/win32/temps.c shar

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 15:39:29 2009
New Revision: 806605

URL: http://svn.apache.org/viewvc?rev=806605view=rev
Log:
Add temp file and dir support

Added:
commons/sandbox/runtime/trunk/src/main/native/include/acr_filemk.h   (with 
props)
commons/sandbox/runtime/trunk/src/main/native/os/unix/temps.c   (with props)
commons/sandbox/runtime/trunk/src/main/native/os/win32/temps.c   (with 
props)
commons/sandbox/runtime/trunk/src/main/native/shared/cmnfile.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/main/native/include/acr_file.h
commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h
commons/sandbox/runtime/trunk/src/main/native/shared/fco.c
commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c

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=806605r1=806604r2=806605view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Fri Aug 21 
15:39:29 2009
@@ -79,6 +79,7 @@
 COMMON_OBJS=\
$(SRCDIR)/shared/buildmark.$(OBJ) \
$(SRCDIR)/shared/clazz.$(OBJ) \
+   $(SRCDIR)/shared/cmnfile.$(OBJ) \
$(SRCDIR)/shared/constp.$(OBJ) \
$(SRCDIR)/shared/descriptor.$(OBJ) \
$(SRCDIR)/shared/db.$(OBJ) \
@@ -117,6 +118,7 @@
$(SRCDIR)/os/unix/pshm.$(OBJ) \
$(SRCDIR)/os/unix/signals.$(OBJ) \
$(SRCDIR)/os/unix/syslog.$(OBJ) \
+   $(SRCDIR)/os/unix/temps.$(OBJ) \
$(SRCDIR)/os/unix/time.$(OBJ) \
$(SRCDIR)/os/unix/uuid.$(OBJ) \
$(SRCDIR)/os/unix/uutils.$(OBJ) \
@@ -141,6 +143,7 @@
$(SRCDIR)/os/unix/pshm.$(OBJ) \
$(SRCDIR)/os/unix/signals.$(OBJ) \
$(SRCDIR)/os/unix/syslog.$(OBJ) \
+   $(SRCDIR)/os/unix/temps.$(OBJ) \
$(SRCDIR)/os/unix/time.$(OBJ) \
$(SRCDIR)/os/unix/uuid.$(OBJ) \
$(SRCDIR)/os/unix/uutils.$(OBJ) \
@@ -162,6 +165,7 @@
$(SRCDIR)/os/unix/pshm.$(OBJ) \
$(SRCDIR)/os/unix/signals.$(OBJ) \
$(SRCDIR)/os/unix/syslog.$(OBJ) \
+   $(SRCDIR)/os/unix/temps.$(OBJ) \
$(SRCDIR)/os/unix/time.$(OBJ) \
$(SRCDIR)/os/unix/uuid.$(OBJ) \
$(SRCDIR)/os/unix/uutils.$(OBJ) \
@@ -184,6 +188,7 @@
$(SRCDIR)/os/unix/psema.$(OBJ) \
$(SRCDIR)/os/unix/signals.$(OBJ) \
$(SRCDIR)/os/unix/syslog.$(OBJ) \
+   $(SRCDIR)/os/unix/temps.$(OBJ) \
$(SRCDIR)/os/unix/time.$(OBJ) \
$(SRCDIR)/os/unix/uuid.$(OBJ) \
$(SRCDIR)/os/unix/uutils.$(OBJ) \

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=806605r1=806604r2=806605view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Fri Aug 21 
15:39:29 2009
@@ -70,6 +70,7 @@
 COMMON_OBJS=\
$(SRCDIR)/shared/buildmark.$(OBJ) \
$(SRCDIR)/shared/clazz.$(OBJ) \
+   $(SRCDIR)/shared/cmnfile.$(OBJ) \
$(SRCDIR)/shared/constp.$(OBJ) \
$(SRCDIR)/shared/descriptor.$(OBJ) \
$(SRCDIR)/shared/db.$(OBJ) \
@@ -112,6 +113,7 @@
$(SRCDIR)/os/win32/syslog.$(OBJ) \
$(SRCDIR)/os/win32/group.$(OBJ) \
$(SRCDIR)/os/win32/user.$(OBJ) \
+   $(SRCDIR)/os/win32/temps.$(OBJ) \
$(SRCDIR)/os/win32/time.$(OBJ) \
$(SRCDIR)/os/win32/uuid.$(OBJ) \
$(SRCDIR)/os/win32/variant.$(OBJ) \

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h?rev=806605r1=806604r2=806605view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_file.h Fri Aug 21 
15:39:29 2009
@@ -130,6 +130,17 @@
file lock */
 /** @} */
 
+typedef struct acr_file_t acr_file_t;
+
+struct acr_file_t {
+#if defined (WIN32)
+HANDLE   fd;/* Os file descriptor   */
+#else
+int  fd;
+#endif
+acr_pchar_t *name;  /* Real file name   */
+
+};
 
 /** Get FileType
  * @param env JNI environment to use. If NULL no exception will be thrown
@@ -166,8 +177,15 @@
 ACR_DECLARE(jobject) ACR_IoFileObjectCreate(JNIEnv *_E, const acr_pchar_t 
*fname,
 int ftype);
 
+/** Get Filename from file 

svn commit: r806614 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr_io.h os/unix/ios.c os/win32/ios.c

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 15:54:50 2009
New Revision: 806614

URL: http://svn.apache.org/viewvc?rev=806614view=rev
Log:
Add IoClose API

Added:
commons/sandbox/runtime/trunk/src/main/native/include/acr_io.h   (with 
props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c

Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_io.h
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_io.h?rev=806614view=auto
==
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_io.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_io.h Fri Aug 21 
15:54:50 2009
@@ -0,0 +1,49 @@
+/* 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_IO_H
+#define _ACR_IO_H
+
+#include acr.h
+
+#ifdef __cplusplus
+extern C {
+#endif
+
+/**
+ * @file acr_io.h
+ * @brief
+ *
+ * ACR Common I/O functions
+ *
+ */
+/**
+ * Close the ACR Descriptor handle.
+ * @param env Current JNI environment
+ * @param descriptor Descriptor handle to close.
+ * @return ACR error code on failure. If env is not NULL the IO exception
+ * is thrown in case of failure.
+ * @remark The function calls the descriptor cleanup function.
+ */
+ACR_DECLARE(int) ACR_IoClose(JNIEnv *env, int descriptor);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_IO_H */
+

Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_io.h
--
svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c?rev=806614r1=806613r2=806614view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/ios.c Fri Aug 21 
15:54:50 2009
@@ -20,6 +20,7 @@
 #include acr_error.h
 #include acr_memory.h
 #include acr_descriptor.h
+#include acr_io.h
 #include acr_vm.h
 #include pthread.h
 
@@ -259,7 +260,7 @@
 return ACR_EBADF;
 if (!__bitmap)
 return ACR_ENOMEM;
-if (!IS_INVALID_HANDLE(acr_ioh_tab[i].h)  acr_ioh_tab[i].c) {
+if (IS_VALID_HANDLE(acr_ioh_tab[i].h)  acr_ioh_tab[i].c) {
 /* Run the cleanup */
 rc = (*acr_ioh_tab[i].c)(acr_ioh_tab[i].h, acr_ioh_tab[i].type,
  acr_ioh_tab[i].flags);
@@ -280,7 +281,7 @@
 return;
 pthread_mutex_lock(ios_lock);
 for (i = 0;  i  acr_ioh_mask; i++) {
-if (!IS_INVALID_HANDLE(acr_ioh_tab[i].h)  acr_ioh_tab[i].c) {
+if (IS_VALID_HANDLE(acr_ioh_tab[i].h)  acr_ioh_tab[i].c) {
 /* Run the cleanups */
 (*acr_ioh_tab[i].c)(acr_ioh_tab[i].h, acr_ioh_tab[i].type,
 acr_ioh_tab[i].flags);
@@ -295,3 +296,11 @@
 pthread_mutex_destroy(ios_lock);
 }
 
+ACR_DECLARE(int) ACR_IoClose(JNIEnv *_E, int dh)
+{
+int rc = acr_ioh_close(dh);
+
+ACR_THROW_IO_IF_ERR(rc);
+return rc;
+}
+

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c?rev=806614r1=806613r2=806614view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/ios.c Fri Aug 21 
15:54:50 2009
@@ -236,7 +236,7 @@
 return ACR_EBADF;
 if (!__bitmap)
 return ACR_ENOMEM;
-if (!IS_INVALID_HANDLE(acr_ioh_tab[i].h)  acr_ioh_tab[i].c) {
+if (IS_VALID_HANDLE(acr_ioh_tab[i].h)  acr_ioh_tab[i].c) {
 /* Run the cleanup */
 rc = (*acr_ioh_tab[i].c)(acr_ioh_tab[i].h, acr_ioh_tab[i].type,
  acr_ioh_tab[i].flags);
@@ -257,7 +257,7 @@
 return;
 EnterCriticalSection(ios_lock);
 for (i = 0;  i  acr_ioh_mask; i++) {
-   

svn commit: r806618 - /commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 16:02:37 2009
New Revision: 806618

URL: http://svn.apache.org/viewvc?rev=806618view=rev
Log:
Test IoClose

Modified:
commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c?rev=806618r1=806617r2=806618view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c Fri Aug 21 
16:02:37 2009
@@ -35,6 +35,8 @@
 #include acr_crypto.h
 #include acr_getopt.h
 #include acr_env.h
+#include acr_io.h
+#include acr_dso.h
 #include acr_version.h
 
 #if defined (WIN32)
@@ -42,11 +44,13 @@
 #include sys/stat.h
 #define random rand
 #define srandom srand
-#endif
-
-#if !defined(WIN32)
+#define PRINT_PSTR%S
+#define STD_PREFIXLacr-test-
+#else
 extern mode_t acr_default_umask;
 extern mode_t acr_default_perms;
+#define PRINT_PSTR%s
+#define STD_PREFIXacr-test-
 #endif
 
 
@@ -93,33 +97,37 @@
 {
 int failed = 0;
 int   fd;
-char *fn;
-fprintf(stdout, Using Temporary Directory : `%s\'\n,
+acr_pchar_t *fn;
+fprintf(stdout, Using Temporary Directory : ` PRINT_PSTR \'\n,
 ACR_TempPathGet(NULL));
 
 fd = ACR_TempFileMake(NULL, ACR_TempPathGet(NULL),
-  acr-test-, 0);
+  STD_PREFIX, 0);
 if (fd  0)
 failed++;
 else {
-fprintf(stdout, Using Temporary File : `%s\'\n,
+fprintf(stdout, Using Temporary File : ` PRINT_PSTR \'\n,
 ACR_FileNameGet(NULL, fd));
+if (ACR_IoClose(NULL, fd))
+failed++;
 }
 
 fd = ACR_TempFileMake(NULL, ACR_TempPathGet(NULL),
-  acr-test-, 1);
+  STD_PREFIX, 1);
 if (fd  0)
 failed++;
 else {
-fprintf(stdout, Using Temporary File : `%s\'\n,
+fprintf(stdout, Using Temporary File : ` PRINT_PSTR \'\n,
 ACR_FileNameGet(NULL, fd));
+if (ACR_IoClose(NULL, fd))
+failed++;
 }
 fn = ACR_TempDirMake(NULL, ACR_TempPathGet(NULL),
-  acr-test-);
+ STD_PREFIX);
 if (fn == NULL)
 failed++;
 else {
-fprintf(stdout, Using Temporary Dir  : `%s\'\n, fn);
+fprintf(stdout, Using Temporary Dir  : ` PRINT_PSTR \'\n, fn);
 ACR_Free(NULL, THROW_NMARK, fn);
 }
 




svn commit: r806634 - /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 16:37:52 2009
New Revision: 806634

URL: http://svn.apache.org/viewvc?rev=806634view=rev
Log:
Add the Main class

Added:

commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java
   (with props)

Added: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java?rev=806634view=auto
==
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java
 (added)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java
 Fri Aug 21 16:37:52 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.
+ */
+
+package org.apache.commons.runtime;
+
+import org.apache.commons.runtime.exception.*;
+
+/**
+ * Main class.
+ *
+ * @since Runtime 1.0
+ *
+ */
+public final class Main
+{
+
+private Main()
+{
+// No instance.
+}
+
+/**
+ * Dummy main().
+ * p
+ * This class is present only for testing purposes for the moment.
+ * In the future it will be used for launching other Java classes
+ * from detached JVM.
+ * /
+ */
+public static void main(String args[])
+{
+try {
+System.loadLibrary(acr);
+boolean inited = Native.initialize();
+if (inited) {
+System.out.println(Initialized Apache Commons Runtime :  +
+Version.MAJOR   + .  + Version.MINOR + .  + 
+Version.PATCH   +  ( + Version.BUILDMARK + )  + for  
+
+Os.getSysname() + /  + Os.getMachine());
+}
+} catch (Throwable ex) {
+ex.printStackTrace();
+}
+}
+
+}
+

Propchange: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java
--
svn:eol-style = native




svn commit: r806663 - in /commons/sandbox/runtime/trunk/src/main/native: os/unix/main.c test/testsuite.c

2009-08-21 Thread mturk
Author: mturk
Date: Fri Aug 21 18:13:55 2009
New Revision: 806663

URL: http://svn.apache.org/viewvc?rev=806663view=rev
Log:
Add jvm test case

Modified:
commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c

Modified: 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=806663r1=806662r2=806663view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c Fri Aug 21 
18:13:55 2009
@@ -67,10 +67,10 @@
 ACR_DECLARE(int) ACR_Initialize(JavaVM *vm)
 {
 
-if (initialized++)
-return 0;
 
 acr_pvm = vm;
+if (initialized++)
+return 0;
 
 if (pthread_key_create(acr_thread_key, acr_thread_key_destructor))
 return ACR_GET_OS_ERROR();
@@ -90,9 +90,8 @@
 void   *epp;
 
 UNREFERENCED(reserved);
-if ((*vm)-GetEnv(vm, epp, JNI_VERSION_1_4)) {
+if ((*vm)-GetEnv(vm, epp, JNI_VERSION_1_4))
 return JNI_ERR;
-}
 if (ACR_Initialize(vm)) {
 /* Error during our init phase */
 return JNI_ERR;

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c?rev=806663r1=806662r2=806663view=diff
==
--- commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c Fri Aug 21 
18:13:55 2009
@@ -140,6 +140,101 @@
 return 0;
 }
 
+static jint (JNICALL *jni_GetDefaultJavaVMInitArgs)(void *) = NULL;
+static jint (JNICALL *jni_CreateJavaVM)(JavaVM **, void **, void *) = NULL;
+static jint (JNICALL *jni_GetCreatedJavaVMs)(JavaVM **, jsize, jsize *) = NULL;
+
+/* Call with something like:
+ * ./testsuite -t jvm -- /opt/java/jre/lib/amd64/server/libjvm.so \
+ * -Djava.class.path=../../../dist/bin/java org/apache/commons/runtime/Main
+ */
+int test_runjvm(int argc, const char *const argv[])
+{
+const char *jvmso;
+const char *jvmcp;
+const char *jvmmc = NULL;
+int dso;
+int i;
+JavaVMInitArgs  in_args;
+JavaVMOptionoptions[8];
+JavaVMInitArgs  vm_args;
+JavaVM *jvm;
+JNIEnv *_E;
+void   *env;
+jclass  mc;
+jobject mo;
+jmethodID mm;
+
+if (argc  3)
+return 22;
+jvmso = argv[0];
+jvmcp = argv[1];
+
+dso = ACR_DsoLoad(NULL, jvmso);
+if (dso  0) {
+fprintf(stderr, Cannot load JVM from %s\n, jvmso);
+fflush(stderr);
+return 1;
+}
+fprintf(stdout, Using JVM `%s\'\n, jvmso);
+
+jni_GetDefaultJavaVMInitArgs = ACR_DsoSym(NULL, dso,
+ JNI_GetDefaultJavaVMInitArgs);
+jni_CreateJavaVM = ACR_DsoSym(NULL, dso,
+ JNI_CreateJavaVM);
+jni_GetCreatedJavaVMs= ACR_DsoSym(NULL, dso,
+ JNI_GetCreatedJavaVMs);
+if (!jni_GetDefaultJavaVMInitArgs || !jni_CreateJavaVM ||
+!jni_GetCreatedJavaVMs) {
+fprintf(stderr, Cannot load JVM symbols from %s\n, jvmso);
+fflush(stderr);
+return 2;
+
+}
+in_args.version = JNI_VERSION_1_4;
+if (jni_GetDefaultJavaVMInitArgs(in_args) != JNI_OK) {
+fprintf(stderr, Cannot load default VM args from %s\n, jvmso);
+fflush(stderr);
+return 3;
+}
+options[0].optionString = (char *)jvmcp;
+vm_args.options  = options;
+vm_args.nOptions = 1;
+vm_args.ignoreUnrecognized = JNI_TRUE;
+vm_args.version = in_args.version;
+
+for (i = 2; i  argc; i++) {
+if (*argv[i] == '-')
+options[vm_args.nOptions++].optionString = (char *)argv[i];
+else
+jvmmc = argv[i];
+}
+if (jni_CreateJavaVM(jvm, env,
+ vm_args) != JNI_OK) {
+fprintf(stderr, Failed creating JVM\n);
+fflush(stderr);
+return 2;
+
+}
+_E = (JNIEnv *)env;
+mc = (*_E)-FindClass(_E, jvmmc);
+if (!mc) {
+fprintf(stderr, Cannot find Main class %s\n, jvmmc);
+fflush(stderr);
+return 2;
+}
+mo = (*_E)-NewGlobalRef(_E, mc);
+mm = (*_E)-GetStaticMethodID(_E, mo, main, ([Ljava/lang/String;)V);
+if (!mc) {
+fprintf(stderr, Cannot find main method %s\n, jvmmc);
+fflush(stderr);
+return 2;
+}
+(*_E)-CallStaticVoidMethod(_E, mc, mm, NULL);
+return 0;
+}
+
+
 int main(int argc, const char *const argv[])
 {
 int rv = 0;
@@ -193,6 +288,9 @@
 else if (!strcasecmp(run_test, mktemp)) {
 rv = test_mktemp(argc, argv);
 }
+else 

svn commit: r806753 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java site/xdoc/changes.xml test/java/org/apache/commons/math/optimization/

2009-08-21 Thread luc
Author: luc
Date: Fri Aug 21 23:07:42 2009
New Revision: 806753

URL: http://svn.apache.org/viewvc?rev=806753view=rev
Log:
fixed an error leading the simplex solver to compute the right solution but 
return another one
JIRA: MATH-286

Modified:

commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java
commons/proper/math/trunk/src/site/xdoc/changes.xml

commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/linear/SimplexSolverTest.java

Modified: 
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java
URL: 
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java?rev=806753r1=806752r2=806753view=diff
==
--- 
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java
 (original)
+++ 
commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java
 Fri Aug 21 23:07:42 2009
@@ -270,8 +270,27 @@
  * @return the row that the variable is basic in.  null if the column is 
not basic
  */
 private Integer getBasicRow(final int col) {
+return getBasicRow(col, true);
+}
+
+/**
+ * Checks whether the given column is basic.
+ * @param col index of the column to check
+ * @return the row that the variable is basic in.  null if the column is 
not basic
+ */
+private Integer getBasicRowForSolution(final int col) {
+return getBasicRow(col, false);
+}
+
+/**
+ * Checks whether the given column is basic.
+ * @param col index of the column to check
+ * @return the row that the variable is basic in.  null if the column is 
not basic
+ */
+private Integer getBasicRow(final int col, boolean ignoreObjectiveRows) {
 Integer row = null;
-for (int i = getNumObjectiveFunctions(); i  getHeight(); i++) {
+int start = ignoreObjectiveRows ? getNumObjectiveFunctions() : 0;
+for (int i = start; i  getHeight(); i++) {
 if (MathUtils.equals(getEntry(i, col), 1.0, epsilon)  (row == 
null)) {
 row = i;
 } else if (!MathUtils.equals(getEntry(i, col), 0.0, epsilon)) {
@@ -318,24 +337,23 @@
  * @return current solution
  */
 protected RealPointValuePair getSolution() {
-double[] coefficients = new double[getOriginalNumDecisionVariables()];
-Integer basicRow =
-getBasicRow(getNumObjectiveFunctions() + 
getOriginalNumDecisionVariables());
-double mostNegative = basicRow == null ? 0 : getEntry(basicRow, 
getRhsOffset());
-SetInteger basicRows = new HashSetInteger();
-for (int i = 0; i  coefficients.length; i++) {
-basicRow = getBasicRow(getNumObjectiveFunctions() + i);
-if (basicRows.contains(basicRow)) {
-// if multiple variables can take a given value 
-// then we choose the first and set the rest equal to 0
-coefficients[i] = 0;
-} else {
-basicRows.add(basicRow);
-coefficients[i] =
-(basicRow == null ? 0 : getEntry(basicRow, 
getRhsOffset())) -
-(restrictToNonNegative ? 0 : mostNegative);
-}
-}
+  double[] coefficients = new double[getOriginalNumDecisionVariables()];
+  Integer negativeVarBasicRow = 
getBasicRowForSolution(getNegativeDecisionVariableOffset());
+  double mostNegative = negativeVarBasicRow == null ? 0 : 
getEntry(negativeVarBasicRow, getRhsOffset());
+  SetInteger basicRows = new HashSetInteger();
+  for (int i = 0; i  coefficients.length; i++) {
+  Integer basicRow = getBasicRowForSolution(getNumObjectiveFunctions() 
+ i);
+  if (basicRows.contains(basicRow)) {
+  // if multiple variables can take a given value 
+  // then we choose the first and set the rest equal to 0
+  coefficients[i] = 0;
+  } else {
+  basicRows.add(basicRow);
+  coefficients[i] =
+  (basicRow == null ? 0 : getEntry(basicRow, getRhsOffset())) -
+  (restrictToNonNegative ? 0 : mostNegative);
+  }
+  }
 return new RealPointValuePair(coefficients, f.getValue(coefficients));
 }
 
@@ -430,6 +448,15 @@
 protected final int getRhsOffset() {
 return getWidth() - 1;
 }
+
+/**
+ * Returns the offset of the extra decision variable added when there is a
+ * negative decision variable in the original problem.
+ * @return the offset of x-
+ */
+protected final int getNegativeDecisionVariableOffset() {
+  return getNumObjectiveFunctions() + getOriginalNumDecisionVariables();
+}
 
 /**
  * Get the 

svn commit: r806778 - /commons/proper/commons-build/trunk/menus/apache.ent

2009-08-21 Thread rahul
Author: rahul
Date: Sat Aug 22 03:58:34 2009
New Revision: 806778

URL: http://svn.apache.org/viewvc?rev=806778view=rev
Log:
Add 'About Apache' section to site LHS menu, including links to dev resources 
and the ASF Sponsorship program.

Modified:
commons/proper/commons-build/trunk/menus/apache.ent

Modified: commons/proper/commons-build/trunk/menus/apache.ent
URL: 
http://svn.apache.org/viewvc/commons/proper/commons-build/trunk/menus/apache.ent?rev=806778r1=806777r2=806778view=diff
==
--- commons/proper/commons-build/trunk/menus/apache.ent (original)
+++ commons/proper/commons-build/trunk/menus/apache.ent Sat Aug 22 03:58:34 2009
@@ -5,3 +5,10 @@
   img=http://apache.org/images/ac2005us_blue_184x90.jpg; /
 /menu
 --
+menu name=About Apache type=footer
+item name=How the ASF works   
href=http://www.apache.org/foundation/how-it-works.html/
+item name=Get Involved
href=http://www.apache.org/foundation/getinvolved.html/
+item name=Developer Resources href=http://www.apache.org/dev//
+item name=Sponsors of the ASF 
href=http://www.apache.org/foundation/thanks.html/
+item name=Sponsorship program 
href=http://www.apache.org/foundation/sponsorship.html/
+/menu




svn commit: r806779 - /commons/proper/commons-build/trunk/xdocs/navigation.xml

2009-08-21 Thread rahul
Author: rahul
Date: Sat Aug 22 03:59:58 2009
New Revision: 806779

URL: http://svn.apache.org/viewvc?rev=806779view=rev
Log:
Move 'About Apache' section to the bottom of the menu.

Modified:
commons/proper/commons-build/trunk/xdocs/navigation.xml

Modified: commons/proper/commons-build/trunk/xdocs/navigation.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/commons-build/trunk/xdocs/navigation.xml?rev=806779r1=806778r2=806779view=diff
==
--- commons/proper/commons-build/trunk/xdocs/navigation.xml (original)
+++ commons/proper/commons-build/trunk/xdocs/navigation.xml Sat Aug 22 03:59:58 
2009
@@ -23,11 +23,11 @@
   item name=Apache   
 href=http://www.apache.org/
 /links
-apache-menu;
 about-main-menu;
 downloads-menu;
 view-menu;
 support-menu;
 information-menu;
+apache-menu;
   /body
 /project




svn commit: r806780 - in /commons/proper/commons-build/trunk: pluginUpdate.txt project.xml

2009-08-21 Thread rahul
Author: rahul
Date: Sat Aug 22 04:00:45 2009
New Revision: 806780

URL: http://svn.apache.org/viewvc?rev=806780view=rev
Log:
Upgrade to latest maven-xdoc-plugin version (1.10.1)

Modified:
commons/proper/commons-build/trunk/pluginUpdate.txt
commons/proper/commons-build/trunk/project.xml

Modified: commons/proper/commons-build/trunk/pluginUpdate.txt
URL: 
http://svn.apache.org/viewvc/commons/proper/commons-build/trunk/pluginUpdate.txt?rev=806780r1=806779r2=806780view=diff
==
--- commons/proper/commons-build/trunk/pluginUpdate.txt (original)
+++ commons/proper/commons-build/trunk/pluginUpdate.txt Sat Aug 22 04:00:45 2009
@@ -15,4 +15,4 @@
 maven plugin:download -DgroupId=maven -DartifactId=maven-scm-plugin 
-Dversion=1.5 -Dmaven.repo.remote=http://repo1.maven.org/maven
 maven plugin:download -DgroupId=maven -DartifactId=maven-site-plugin 
-Dversion=1.6.1 -Dmaven.repo.remote=http://repo1.maven.org/maven
 maven plugin:download -DgroupId=maven -DartifactId=maven-test-plugin 
-Dversion=1.7 -Dmaven.repo.remote=http://repo1.maven.org/maven
-maven plugin:download -DgroupId=maven -DartifactId=maven-xdoc-plugin 
-Dversion=1.9.2 -Dmaven.repo.remote=http://repo1.maven.org/maven
+maven plugin:download -DgroupId=maven -DartifactId=maven-xdoc-plugin 
-Dversion=1.10.1 -Dmaven.repo.remote=http://repo1.maven.org/maven

Modified: commons/proper/commons-build/trunk/project.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/commons-build/trunk/project.xml?rev=806780r1=806779r2=806780view=diff
==
--- commons/proper/commons-build/trunk/project.xml (original)
+++ commons/proper/commons-build/trunk/project.xml Sat Aug 22 04:00:45 2009
@@ -69,7 +69,7 @@
 dependency
   groupIdmaven/groupId
   artifactIdmaven-xdoc-plugin/artifactId
-  version1.9.2/version
+  version1.10.1/version
   urlhttp://maven.apache.org/maven-1.x/plugins/xdoc//url
   typeplugin/type
 /dependency