You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kato-commits@incubator.apache.org by sp...@apache.org on 2009/09/07 09:20:59 UTC

svn commit: r812050 [2/2] - in /incubator/kato/trunk/org.apache.kato: ./ kato.cjvmti/ kato.native/ kato.native/.settings/ kato.native/kato.native.cjvmti/ kato.native/kato.native.cjvmti/.settings/ kato.native/kato.native.cjvmti/linux-x86/ kato.native/ka...

Added: incubator/kato/trunk/org.apache.kato/kato.native/kato.native.cjvmti/src/main/native/include/queue.h
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.native/kato.native.cjvmti/src/main/native/include/queue.h?rev=812050&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.native/kato.native.cjvmti/src/main/native/include/queue.h (added)
+++ incubator/kato/trunk/org.apache.kato/kato.native/kato.native.cjvmti/src/main/native/include/queue.h Mon Sep  7 09:20:52 2009
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Licensed 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.
+ ******************************************************************************/
+struct queueADT;
+struct queueADT * Q_initQueue(int qsize, int sizeofElement);
+int Q_enqueue (void * writeLoc, struct queueADT * q);
+int Q_dequeue(void * readLoc, struct queueADT * q);
+int Q_size(struct queueADT * q);
+int Q_free(struct queueADT * q);

Added: incubator/kato/trunk/org.apache.kato/kato.native/kato.native.cjvmti/src/main/native/queue.c
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.native/kato.native.cjvmti/src/main/native/queue.c?rev=812050&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.native/kato.native.cjvmti/src/main/native/queue.c (added)
+++ incubator/kato/trunk/org.apache.kato/kato.native/kato.native.cjvmti/src/main/native/queue.c Mon Sep  7 09:20:52 2009
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Licensed 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 <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <string.h>
+
+// This is really an array list.
+
+struct queueADT{
+	void * queue;
+	int readPoint;
+	int addPoint;
+	int size;
+	int sizeOfElement;
+	int qID;
+};
+
+static int id;
+int doubleSize(queueADT);
+
+struct queueADT * Q_initQueue(int qsize, int sizeofElement){
+	void * pt;
+	struct queueADT * q = calloc(1, sizeof(struct queueADT));
+	id++;
+	q->qID = id;
+	q->sizeOfElement = sizeofElement;
+	q->size = qsize;
+	q->addPoint = 0;
+	q->readPoint = 0;
+	pt = calloc (qsize, sizeofElement);
+	if (pt == NULL){
+		printf("Problem with malloc \n");
+		abort();
+	}
+	q->queue = pt;
+	return q;
+}
+
+int Q_dequeue (void * writeLoc, struct queueADT * q){
+	char * src;
+	if (q == NULL){
+		printf("null queue passed, abort \n");
+	}
+	if (q->readPoint == q->addPoint){
+		memset(writeLoc, 0, q->sizeOfElement);
+		return 0;
+	}
+	src = (char *)q->queue;
+	memcpy(writeLoc, (void *)&src[q->readPoint*q->sizeOfElement], q->sizeOfElement);
+	q->readPoint++;
+	q->readPoint = (q->readPoint)%q->size;
+	return 1;
+}
+
+int Q_enqueue(void * readLoc, struct queueADT * q){
+	char * dst;
+	if (q == NULL){
+		printf("null queue passed, abort \n");
+		abort();
+	}
+	if (((q->addPoint+1)%q->size) == q->readPoint){
+		doubleSize(q);
+	}
+	dst = q->queue;
+	memcpy((void *)&dst[q->addPoint*q->sizeOfElement], readLoc, q->sizeOfElement);
+	q->addPoint = (q->addPoint+1)%(q->size);
+	return 1;
+}
+
+int Q_size(struct queueADT *q){
+	return q->size;
+}
+
+int doubleSize(struct queueADT * q){
+	void * pt;
+	int i;
+	char * src;
+	char * dst;
+	if (q == NULL){
+		printf("null queue passed, abort \n");
+	}
+	pt = calloc(q->size*2, q->sizeOfElement);
+	if (pt == NULL){
+		printf("Problem with malloc \n");
+		abort();
+	}
+	src = q->queue;
+	dst = pt;
+	for (i = 0; i < q->size; i++){
+		if (i == 0 && q->readPoint == 0){
+			memcpy((void *)&dst[i*(q->sizeOfElement)], (void *)&src[0], q->sizeOfElement);
+		}else{
+			memcpy((void *)&dst[i*(q->sizeOfElement)], (void *)&src[(((q->readPoint)+i)%(q->size))*(q->sizeOfElement)], q->sizeOfElement);
+		}
+	}
+	if (q == q->queue){
+		printf( "? ??? \n ");
+	}
+	free(q->queue);
+	printf("%d doubled %d \n",q->qID, q->size*2);
+	if (q->addPoint >= q->readPoint){
+		q->addPoint = q->addPoint - q->readPoint;
+	}else{
+		q->addPoint = q->size - q->readPoint + q->addPoint;
+	}
+	q->readPoint = 0;
+	q->queue = pt;
+	q->size = q->size*2;
+	return 1;
+}
+
+int Q_free(struct queueADT * q){
+	id--;
+	free(q->queue);
+	free(q);
+	q = NULL;
+	return 1;
+}

Added: incubator/kato/trunk/org.apache.kato/kato.native/kato.native.cjvmti/win32/pom.xml
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.native/kato.native.cjvmti/win32/pom.xml?rev=812050&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.native/kato.native.cjvmti/win32/pom.xml (added)
+++ incubator/kato/trunk/org.apache.kato/kato.native/kato.native.cjvmti/win32/pom.xml Mon Sep  7 09:20:52 2009
@@ -0,0 +1,74 @@
+<project>
+
+  <modelVersion>4.0.0</modelVersion>
+  <description>Create Windows 32bit version of libcjvmti library</description>
+
+  <parent>
+    <groupId>org.apache.kato</groupId>
+    <artifactId>kato.native.cjvmti</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.kato.native</groupId>
+  
+  
+    
+    
+   <artifactId>cjvmti.dll</artifactId>
+  
+  <name>Win32 Version of CJVMTI Native Library</name>
+  
+  <packaging>dll</packaging>
+  
+  
+  
+  
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>native-maven-plugin</artifactId>
+        <extensions>true</extensions>   
+        <configuration>
+          <compilerStartOptions>
+            <compilerStartOption>-fPIC -O  /DBUILD_DLL</compilerStartOption>
+          </compilerStartOptions>
+          
+          <javahOS>windows</javahOS>
+          
+          <sources>
+            <source>
+              <directory>${native.source.dir}</directory>
+              <fileNames>
+                <fileName>cjvmti.c</fileName>
+                <fileName>addClass.c</fileName>
+                <fileName>addField.c</fileName>
+                <fileName>addObject.c</fileName>
+                <fileName>addThreads.c</fileName>
+                <fileName>queue.c</fileName>
+              </fileNames>
+            </source>  
+            <source>
+              <directory>${native.source.dir}/include</directory>
+            </source>            
+          </sources>
+            
+          
+          <linkerStartOptions>
+            <linkerStartOption>/DLL</linkerStartOption>
+          </linkerStartOptions>
+          
+          <linkerSecondaryOutputExtensions >lib</linkerSecondaryOutputExtensions >
+          
+          
+        </configuration>
+        
+      </plugin>
+
+    </plugins>    
+
+  </build>
+  
+  
+</project>

Propchange: incubator/kato/trunk/org.apache.kato/kato.native/kato.native.cjvmti/win32/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/kato/trunk/org.apache.kato/kato.native/pom.xml
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.native/pom.xml?rev=812050&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.native/pom.xml (added)
+++ incubator/kato/trunk/org.apache.kato/kato.native/pom.xml Mon Sep  7 09:20:52 2009
@@ -0,0 +1,17 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <artifactId>kato</artifactId>
+    <groupId>org.apache.kato</groupId>
+    <version>0.0.1-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.kato</groupId>
+  <artifactId>kato.native</artifactId>
+  <packaging>pom</packaging>
+  <name>Apache Kato native code modules</name>
+  <version>0.0.1-SNAPSHOT</version>
+  <description>Apache Kato native code modules	</description>
+  <modules>
+  	<module>kato.native.cjvmti</module>
+  </modules>
+</project>
\ No newline at end of file

Propchange: incubator/kato/trunk/org.apache.kato/kato.native/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/kato/trunk/org.apache.kato/pom.xml
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/pom.xml?rev=812050&r1=812049&r2=812050&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/pom.xml (original)
+++ incubator/kato/trunk/org.apache.kato/pom.xml Mon Sep  7 09:20:52 2009
@@ -21,6 +21,8 @@
 		<module>kato.tck.testsuite</module>
 		<module>kato.docs</module>
 		<module>kato.common</module>
+		<module>kato.cjvmti</module>
+		<module>kato.native</module>
 		
 	</modules>
 	<build>