summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormalosek <malosek@fastmq.com>2009-09-08 14:54:52 +0200
committermalosek <malosek@fastmq.com>2009-09-08 14:54:52 +0200
commitb3fc14522574ccad233bee02ea135d8a93fb2441 (patch)
treee02c81fa44c08bf690d405c8f57dc3be68a01e8e
parent2a4a10c8be92c5ce6314378fc4de163888075279 (diff)
parent3069b6bd54486346f7bfcce58d6a5e34d129965c (diff)
Merge branch 'master' of git@github.com:sustrik/zeromq2
-rw-r--r--java/Context.cpp7
-rw-r--r--java/Message.cpp138
-rw-r--r--java/Socket.cpp7
-rw-r--r--java/org/zmq/Socket.java2
-rw-r--r--msvc/j_local_lat/j_local_lat.vcproj78
-rw-r--r--msvc/j_local_thr/j_local_thr.vcproj78
-rw-r--r--msvc/j_remote_lat/j_remote_lat.vcproj78
-rw-r--r--msvc/j_remote_thr/j_remote_thr.vcproj78
-rw-r--r--msvc/msvc.sln45
-rw-r--r--perf/c/local_thr.c3
10 files changed, 374 insertions, 140 deletions
diff --git a/java/Context.cpp b/java/Context.cpp
index 3fc66bd..67094e8 100644
--- a/java/Context.cpp
+++ b/java/Context.cpp
@@ -34,7 +34,14 @@ static void raise_exception (JNIEnv *env, int err)
assert (exception_class);
// Get text description of the exception.
+#if defined _MSC_VER
+#pragma warning (push)
+#pragma warning (disable:4996)
+#endif
const char *err_msg = strerror (err);
+#if defined _MSC_VER
+#pragma warning (pop)
+#endif
// Raise the exception.
int rc = env->ThrowNew (exception_class, err_msg);
diff --git a/java/Message.cpp b/java/Message.cpp
deleted file mode 100644
index 2105216..0000000
--- a/java/Message.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- Copyright (c) 2007-2009 FastMQ Inc.
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the Lesser GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- Lesser GNU General Public License for more details.
-
- You should have received a copy of the Lesser GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-
-#include "zmq.h"
-#include "org_zmq_Message.h"
-
-static jfieldID msg_handle_fid = NULL;
-
-static void
-raise_exception (JNIEnv *env, int err)
-{
- // Get exception class.
- jclass exception_class = env->FindClass ("java/lang/Exception");
- assert (exception_class);
-
- // Get text description of the exception.
- const char *err_msg = strerror (err);
-
- // Raise the exception.
- int rc = env->ThrowNew (exception_class, err_msg);
- assert (rc == 0);
-
- // Free the local ref.
- env->DeleteLocalRef (exception_class);
-}
-
-JNIEXPORT void JNICALL
-Java_org_zmq_Message_construct (JNIEnv *env, jobject obj)
-{
- if (msg_handle_fid == NULL) {
- jclass cls = env->GetObjectClass (obj);
- assert (cls != NULL);
- msg_handle_fid = env->GetFieldID (cls, "msgHandle", "J");
- assert (msg_handle_fid != NULL);
- env->DeleteLocalRef (cls);
- }
-
- zmq_msg_t *msg = (zmq_msg_t*) malloc (sizeof (zmq_msg_t));
- if (msg == NULL) {
- raise_exception (env, ENOMEM);
- return;
- }
-
- int rc = zmq_msg_init (msg);
- assert (rc == 0);
- env->SetLongField (obj, msg_handle_fid, (jlong) msg);
-}
-
-JNIEXPORT void JNICALL
-Java_org_zmq_Message_constructWithData (JNIEnv *env, jobject obj,
- jbyteArray payload)
-{
- if (msg_handle_fid == NULL) {
- jclass cls = env->GetObjectClass (obj);
- assert (cls != NULL);
- msg_handle_fid = env->GetFieldID (cls, "msgHandle", "J");
- assert (msg_handle_fid != NULL);
- env->DeleteLocalRef (cls);
- }
-
- zmq_msg_t *msg = (zmq_msg_t*) malloc (sizeof (zmq_msg_t));
- if (msg == NULL) {
- raise_exception (env, ENOMEM);
- return;
- }
-
- jsize array_size = env->GetArrayLength (payload);
- jbyte *array_data = env->GetByteArrayElements (payload, NULL);
-
- int rc = zmq_msg_init_size (msg, array_size);
- assert (rc == 0);
-
- memcpy (zmq_msg_data (msg), array_data, array_size);
- env->ReleaseByteArrayElements (payload, array_data, JNI_ABORT);
-
- env->SetLongField (obj, msg_handle_fid, (jlong) msg);
-}
-
-JNIEXPORT void JNICALL
-Java_org_zmq_Message_finalize (JNIEnv *env, jobject obj)
-{
- zmq_msg_t *msg = (zmq_msg_t*) env->GetLongField (obj, msg_handle_fid);
- assert (msg);
-
- int rc = zmq_msg_close (msg);
- assert (rc == 0);
-
- free (msg);
-}
-
-JNIEXPORT jbyteArray JNICALL
-Java_org_zmq_Message_getMsgPayload (JNIEnv *env, jobject obj)
-{
- zmq_msg_t *msg = (zmq_msg_t*) env->GetLongField (obj, msg_handle_fid);
- assert (msg);
-
- jsize msg_size = zmq_msg_size (msg);
- jbyte *msg_data = (jbyte*) zmq_msg_data (msg);
-
- jbyteArray payload = env->NewByteArray (msg_size);
- if (payload == NULL)
- return NULL;
-
- env->SetByteArrayRegion (payload, 0, msg_size, msg_data);
- assert (!env->ExceptionCheck ());
-
- return payload;
-}
-
-JNIEXPORT jint JNICALL
-Java_org_zmq_Message_getMsgType (JNIEnv *env, jobject obj)
-{
- zmq_msg_t *msg = (zmq_msg_t*) env->GetLongField (obj, msg_handle_fid);
- assert (msg);
-
- return (jint) zmq_msg_type (msg);
-}
diff --git a/java/Socket.cpp b/java/Socket.cpp
index f87c298..51ee816 100644
--- a/java/Socket.cpp
+++ b/java/Socket.cpp
@@ -35,7 +35,14 @@ static void raise_exception (JNIEnv *env, int err)
assert (exception_class);
// Get text description of the exception.
+#if defined _MSC_VER
+#pragma warning (push)
+#pragma warning (disable:4996)
+#endif
const char *err_msg = strerror (err);
+#if defined _MSC_VER
+#pragma warning (pop)
+#endif
// Raise the exception.
int rc = env->ThrowNew (exception_class, err_msg);
diff --git a/java/org/zmq/Socket.java b/java/org/zmq/Socket.java
index 832467f..4c6a3d3 100644
--- a/java/org/zmq/Socket.java
+++ b/java/org/zmq/Socket.java
@@ -1,4 +1,4 @@
-/*
+ /*
Copyright (c) 2007-2009 FastMQ Inc.
This file is part of 0MQ.
diff --git a/msvc/j_local_lat/j_local_lat.vcproj b/msvc/j_local_lat/j_local_lat.vcproj
new file mode 100644
index 0000000..be8da5f
--- /dev/null
+++ b/msvc/j_local_lat/j_local_lat.vcproj
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="j_local_lat"
+ ProjectGUID="{F4D93BC6-9D70-4113-94A8-817A52B49290}"
+ RootNamespace="j_local_lat"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ Description="Compiling Java classes"
+ CommandLine="javac -classpath ..\..\java ..\..\perf\java\local_lat.java"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ Description="Compiling Java classes"
+ CommandLine="javac -classpath ..\..\java ..\..\perf\java\local_lat.java"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Java Files"
+ >
+ <File
+ RelativePath="..\..\perf\java\local_lat.java"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/msvc/j_local_thr/j_local_thr.vcproj b/msvc/j_local_thr/j_local_thr.vcproj
new file mode 100644
index 0000000..465b859
--- /dev/null
+++ b/msvc/j_local_thr/j_local_thr.vcproj
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="j_local_thr"
+ ProjectGUID="{95E6161D-418B-4ABF-85E2-F07797742156}"
+ RootNamespace="j_local_thr"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ Description="Compiling Java classes"
+ CommandLine="javac -classpath ..\..\java ..\..\perf\java\local_thr.java"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ Description="Compiling Java classes"
+ CommandLine="javac -classpath ..\..\java ..\..\perf\java\local_thr.java"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Java Files"
+ >
+ <File
+ RelativePath="..\..\perf\java\local_thr.java"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/msvc/j_remote_lat/j_remote_lat.vcproj b/msvc/j_remote_lat/j_remote_lat.vcproj
new file mode 100644
index 0000000..9b62d34
--- /dev/null
+++ b/msvc/j_remote_lat/j_remote_lat.vcproj
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="j_remote_lat"
+ ProjectGUID="{15C832D0-2E68-484A-9DCE-BC872FE1C7EF}"
+ RootNamespace="j_remote_lat"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ Description="Compiling Java classes"
+ CommandLine="javac -classpath ..\..\java ..\..\perf\java\remote_lat.java"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ Description="Compiling Java classes"
+ CommandLine="javac -classpath ..\..\java ..\..\perf\java\remote_lat.java"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Java Files"
+ >
+ <File
+ RelativePath="..\..\perf\java\remote_lat.java"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/msvc/j_remote_thr/j_remote_thr.vcproj b/msvc/j_remote_thr/j_remote_thr.vcproj
new file mode 100644
index 0000000..5993087
--- /dev/null
+++ b/msvc/j_remote_thr/j_remote_thr.vcproj
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="j_remote_thr"
+ ProjectGUID="{00A421BA-3B6B-45BD-B91F-DED953472622}"
+ RootNamespace="j_remote_thr"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ Description="Compiling Java classes"
+ CommandLine="javac -classpath ..\..\java ..\..\perf\java\remote_thr.java"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ Description="Compiling Java classes"
+ CommandLine="javac -classpath ..\..\java ..\..\perf\java\remote_thr.java"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Java Files"
+ >
+ <File
+ RelativePath="..\..\perf\java\remote_thr.java"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/msvc/msvc.sln b/msvc/msvc.sln
index b9efc82..0cc5eb4 100644
--- a/msvc/msvc.sln
+++ b/msvc/msvc.sln
@@ -43,6 +43,31 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp_remote_thr", "cpp_remot
{641C5F36-32EE-4323-B740-992B651CF9D6} = {641C5F36-32EE-4323-B740-992B651CF9D6}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "java", "java\java.vcproj", "{66C40C34-7E05-4B03-8027-F40850C01364}"
+ ProjectSection(ProjectDependencies) = postProject
+ {641C5F36-32EE-4323-B740-992B651CF9D6} = {641C5F36-32EE-4323-B740-992B651CF9D6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "j_local_lat", "j_local_lat\j_local_lat.vcproj", "{F4D93BC6-9D70-4113-94A8-817A52B49290}"
+ ProjectSection(ProjectDependencies) = postProject
+ {66C40C34-7E05-4B03-8027-F40850C01364} = {66C40C34-7E05-4B03-8027-F40850C01364}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "j_remote_lat", "j_remote_lat\j_remote_lat.vcproj", "{15C832D0-2E68-484A-9DCE-BC872FE1C7EF}"
+ ProjectSection(ProjectDependencies) = postProject
+ {66C40C34-7E05-4B03-8027-F40850C01364} = {66C40C34-7E05-4B03-8027-F40850C01364}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "j_local_thr", "j_local_thr\j_local_thr.vcproj", "{95E6161D-418B-4ABF-85E2-F07797742156}"
+ ProjectSection(ProjectDependencies) = postProject
+ {66C40C34-7E05-4B03-8027-F40850C01364} = {66C40C34-7E05-4B03-8027-F40850C01364}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "j_remote_thr", "j_remote_thr\j_remote_thr.vcproj", "{00A421BA-3B6B-45BD-B91F-DED953472622}"
+ ProjectSection(ProjectDependencies) = postProject
+ {66C40C34-7E05-4B03-8027-F40850C01364} = {66C40C34-7E05-4B03-8027-F40850C01364}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -85,6 +110,26 @@ Global
{EB051624-35C2-4B51-B5DD-8734372617A7}.Debug|Win32.Build.0 = Debug|Win32
{EB051624-35C2-4B51-B5DD-8734372617A7}.Release|Win32.ActiveCfg = Release|Win32
{EB051624-35C2-4B51-B5DD-8734372617A7}.Release|Win32.Build.0 = Release|Win32
+ {66C40C34-7E05-4B03-8027-F40850C01364}.Debug|Win32.ActiveCfg = Debug|Win32
+ {66C40C34-7E05-4B03-8027-F40850C01364}.Debug|Win32.Build.0 = Debug|Win32
+ {66C40C34-7E05-4B03-8027-F40850C01364}.Release|Win32.ActiveCfg = Release|Win32
+ {66C40C34-7E05-4B03-8027-F40850C01364}.Release|Win32.Build.0 = Release|Win32
+ {F4D93BC6-9D70-4113-94A8-817A52B49290}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F4D93BC6-9D70-4113-94A8-817A52B49290}.Debug|Win32.Build.0 = Debug|Win32
+ {F4D93BC6-9D70-4113-94A8-817A52B49290}.Release|Win32.ActiveCfg = Release|Win32
+ {F4D93BC6-9D70-4113-94A8-817A52B49290}.Release|Win32.Build.0 = Release|Win32
+ {15C832D0-2E68-484A-9DCE-BC872FE1C7EF}.Debug|Win32.ActiveCfg = Debug|Win32
+ {15C832D0-2E68-484A-9DCE-BC872FE1C7EF}.Debug|Win32.Build.0 = Debug|Win32
+ {15C832D0-2E68-484A-9DCE-BC872FE1C7EF}.Release|Win32.ActiveCfg = Release|Win32
+ {15C832D0-2E68-484A-9DCE-BC872FE1C7EF}.Release|Win32.Build.0 = Release|Win32
+ {95E6161D-418B-4ABF-85E2-F07797742156}.Debug|Win32.ActiveCfg = Debug|Win32
+ {95E6161D-418B-4ABF-85E2-F07797742156}.Debug|Win32.Build.0 = Debug|Win32
+ {95E6161D-418B-4ABF-85E2-F07797742156}.Release|Win32.ActiveCfg = Release|Win32
+ {95E6161D-418B-4ABF-85E2-F07797742156}.Release|Win32.Build.0 = Release|Win32
+ {00A421BA-3B6B-45BD-B91F-DED953472622}.Debug|Win32.ActiveCfg = Debug|Win32
+ {00A421BA-3B6B-45BD-B91F-DED953472622}.Debug|Win32.Build.0 = Debug|Win32
+ {00A421BA-3B6B-45BD-B91F-DED953472622}.Release|Win32.ActiveCfg = Release|Win32
+ {00A421BA-3B6B-45BD-B91F-DED953472622}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/perf/c/local_thr.c b/perf/c/local_thr.c
index 83ebee1..68d9ec6 100644
--- a/perf/c/local_thr.c
+++ b/perf/c/local_thr.c
@@ -73,7 +73,8 @@ int main (int argc, char *argv [])
if (elapsed == 0)
elapsed = 1;
- throughput = (double) message_count / (double) elapsed * 1000000;
+ throughput = (unsigned long)
+ ((double) message_count / (double) elapsed * 1000000);
megabits = (double) (throughput * message_size * 8) / 1000000;
printf ("message size: %d [B]\n", (int) message_size);