Index: /trunk/openjdk/jdk/make/Makefile
===================================================================
--- /trunk/openjdk/jdk/make/Makefile	(revision 248)
+++ /trunk/openjdk/jdk/make/Makefile	(revision 249)
@@ -260,9 +260,5 @@
 all build:: sanity-all post-sanity-all
 
-ifndef OS2_TEMP
 SUBDIRS    = tools java javax org sun sunw com jpda mkdemo mksample launchers
-else # disable JPDA
-SUBDIRS    = tools java javax org sun sunw com mkdemo mksample launchers
-endif
 all build::
 	$(SUBDIRS-loop)
Index: /trunk/openjdk/jdk/make/common/Release.gmk
===================================================================
--- /trunk/openjdk/jdk/make/common/Release.gmk	(revision 248)
+++ /trunk/openjdk/jdk/make/common/Release.gmk	(revision 249)
@@ -338,11 +338,7 @@
 TOOLS = \
 
-ifndef OS2_TEMP # JPDA
 TOOLS += \
 	META-INF/services/com.sun.jdi.connect.Connector \
 	META-INF/services/com.sun.jdi.connect.spi.TransportService \
-
-endif
-TOOLS += \
 	sun/tools/asm		\
 	sun/tools/jar		\
@@ -370,24 +366,12 @@
 	sun/jvmstat		\
 	com/sun/javadoc		\
-
-ifndef OS2_TEMP # JPDA
-TOOLS += \
 	com/sun/jdi		\
-
-endif
-TOOLS += \
 	com/sun/jarsigner	\
 	com/sun/mirror		\
 	com/sun/source          \
 	com/sun/tools/doclets   \
-
-ifndef OS2_TEMP # JPDA
-TOOLS += \
 	com/sun/tools/example/debug/expr \
 	com/sun/tools/example/debug/tty  \
 	com/sun/tools/extcheck  \
-
-endif
-TOOLS += \
 	com/sun/tools/hat       \
 	com/sun/tools/javac     \
@@ -408,11 +392,5 @@
         org/relaxng/datatype   \
 	com/sun/xml/internal/dtdparser \
-
-ifndef OS2_TEMP # JPDA
-TOOLS += \
 	com/sun/tools/jdi	\
-
-endif
-TOOLS += \
 	com/sun/tools/script/shell	\
 
Index: /trunk/openjdk/jdk/make/jpda/transport/Makefile
===================================================================
--- /trunk/openjdk/jdk/make/jpda/transport/Makefile	(revision 248)
+++ /trunk/openjdk/jdk/make/jpda/transport/Makefile	(revision 249)
@@ -33,5 +33,5 @@
 
 SUBDIRS = socket
-ifeq ($(PLATFORM), windows)
+ifeq ($(filter-out windows os2, $(PLATFORM)),)
 SUBDIRS += shmem
 endif # PLATFORM
Index: /trunk/openjdk/jdk/make/jpda/transport/shmem/Makefile
===================================================================
--- /trunk/openjdk/jdk/make/jpda/transport/shmem/Makefile	(revision 248)
+++ /trunk/openjdk/jdk/make/jpda/transport/shmem/Makefile	(revision 249)
@@ -82,3 +82,3 @@
 # vpaths for the transport (should not be seen by others)
 #
-vpath %.c $(SHARE_SRC)/native/com/sun/tools/jdi:$(SHARE_SRC)/transport/shmem:$(PLATFORM_SRC)/transport/shmem
+vpath %.c $(SHARE_SRC)/native/com/sun/tools/jdi $(SHARE_SRC)/transport/shmem $(PLATFORM_SRC)/transport/shmem
Index: /trunk/openjdk/jdk/make/jpda/transport/socket/Makefile
===================================================================
--- /trunk/openjdk/jdk/make/jpda/transport/socket/Makefile	(revision 248)
+++ /trunk/openjdk/jdk/make/jpda/transport/socket/Makefile	(revision 249)
@@ -30,4 +30,5 @@
 BUILDDIR = ../../..
 LIBRARY = dt_socket
+LIBRARY_SHORT = dt_sock
 PRODUCT = jbug
 
@@ -54,4 +55,8 @@
 endif
 
+ifeq ($(PLATFORM), os2)
+  OTHER_LDLIBS += -lws2_32.lib
+endif
+
 OTHER_INCLUDES = -I$(INCLUDEDIR) -I$(PLATFORM_INCLUDE) \
                  -I$(SHARE_SRC)/transport/export \
@@ -73,9 +78,4 @@
 endif
 
-#
-# Rules.
-#
-include $(BUILDDIR)/common/Library.gmk
-
 # We don't want to link against -ljava
 JAVALIB=
@@ -86,6 +86,29 @@
 endif
 
+ifeq ($(PLATFORM), os2)
+
+FILES_c += socket_md_init.c
+vpath %.c $(PLATFORM_SRC_OS2)/transport/socket
+
+# exports live in .def file
+DEF_FILE = $(OBJDIR)/$(LIBRARY).def
+$(DEF_FILE): $(MAKEFILE_LIST)
+	@$(ECHO) "LIBRARY $(LIBRARY) INITINSTANCE TERMINSTANCE" > $@
+	@$(ECHO) 'EXPORTS \n \
+  jdwpTransport_OnLoad = "_jdwpTransport_OnLoad@16" \n \
+' >> $@
+
+clean::
+	-$(RM) $(DEF_FILE)
+
+endif
+
+#
+# Rules.
+#
+include $(BUILDDIR)/common/Library.gmk
+
 #
 # Add to ambient vpath so we pick up the library files
 #
-vpath %.c $(SHARE_SRC)/transport/socket:$(PLATFORM_SRC)/transport/socket
+vpath %.c $(SHARE_SRC)/transport/socket $(PLATFORM_SRC)/transport/socket
Index: /trunk/openjdk/jdk/make/mkdemo/Makefile
===================================================================
--- /trunk/openjdk/jdk/make/mkdemo/Makefile	(revision 248)
+++ /trunk/openjdk/jdk/make/mkdemo/Makefile	(revision 249)
@@ -32,9 +32,5 @@
 include $(BUILDDIR)/common/Defs.gmk
 
-ifndef OS2_TEMP
 SUBDIRS = applets jfc jvmti management jni scripting jpda
-else # disable JPDA
-SUBDIRS = applets jfc jvmti management jni scripting
-endif
 
 all build:: nbproject
Index: /trunk/openjdk/jdk/src/os2/transport/socket/socket_md_init.c
===================================================================
--- /trunk/openjdk/jdk/src/os2/transport/socket/socket_md_init.c	(revision 249)
+++ /trunk/openjdk/jdk/src/os2/transport/socket/socket_md_init.c	(revision 249)
@@ -0,0 +1,77 @@
+/*
+ * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2010 netlabs.org. OS/2 Parts.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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 GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+// This code redirects the OS/2 DLL initialization/termination calls to
+// the Windows DllMain() and registers the DLL with Odin
+
+#include <os2wrap.h> // Odin32 OS/2 api wrappers
+#include <odinlx.h>
+#include <misc.h>
+
+#include <types.h>
+
+extern BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved);
+
+static HMODULE dllHandle = 0;
+
+unsigned long SYSTEM _DLL_InitTerm(unsigned long hModule, unsigned long ulFlag)
+{
+    size_t i;
+    APIRET rc;
+
+    // If ulFlag is zero then the DLL is being loaded so initialization should
+    // be performed.  If ulFlag is 1 then the DLL is being freed so termination
+    // should be performed. A non-zero value must be returned to indicate success.
+
+    // Note that we don't perform CRT initialization and things because this
+    // is done in os_os2_init.cpp of JVM.DLL that is already loaded
+
+    switch (ulFlag) {
+        case 0 :
+            dllHandle = RegisterLxDll(hModule, DllMain, NULL,
+                                      ODINNT_MAJOR_VERSION,
+                                      ODINNT_MINOR_VERSION,
+                                      IMAGE_SUBSYSTEM_WINDOWS_CUI);
+            if (dllHandle == 0)
+              break;
+
+            return 1;
+
+        case 1 :
+            if (dllHandle) {
+              UnregisterLxDll(dllHandle);
+            }
+            return 0;
+
+        default:
+            break;
+    }
+
+    // failure
+    return 0;
+}
+
Index: /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/ProcessAttachingConnector.java
===================================================================
--- /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/ProcessAttachingConnector.java	(revision 248)
+++ /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/ProcessAttachingConnector.java	(revision 249)
@@ -123,5 +123,6 @@
 
         TransportService ts = null;
-        if (lib.equals("dt_socket")) {
+        final String sockLib = System.getProperty("os.name").startsWith("OS/2") ? "dt_sock" : "dt_socket";
+        if (lib.equals(sockLib)) {
             ts = new SocketTransportService();
         } else {
Index: /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/RawCommandLineLauncher.java
===================================================================
--- /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/RawCommandLineLauncher.java	(revision 248)
+++ /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/RawCommandLineLauncher.java	(revision 249)
@@ -71,4 +71,6 @@
             transport = new Transport() {
                 public String name() {
+                    if (System.getProperty("os.name").startsWith("OS/2"))
+                        return "dt_sock";
                     return "dt_socket";
                 }
Index: /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/SocketAttachingConnector.java
===================================================================
--- /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/SocketAttachingConnector.java	(revision 248)
+++ /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/SocketAttachingConnector.java	(revision 249)
@@ -69,4 +69,6 @@
         transport = new Transport() {
             public String name() {
+                if (System.getProperty("os.name").startsWith("OS/2"))
+                    return "dt_sock";
                 return "dt_socket";     // for compatability reasons
             }
Index: /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/SocketListeningConnector.java
===================================================================
--- /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/SocketListeningConnector.java	(revision 248)
+++ /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/SocketListeningConnector.java	(revision 249)
@@ -59,4 +59,6 @@
         transport = new Transport() {
             public String name() {
+                if (System.getProperty("os.name").startsWith("OS/2"))
+                    return "dt_sock";
                 return "dt_socket";     // for compatability reasons
             }
Index: /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java
===================================================================
--- /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java	(revision 248)
+++ /trunk/openjdk/jdk/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java	(revision 249)
@@ -82,4 +82,6 @@
             transport = new Transport() {
                 public String name() {
+                    if (System.getProperty("os.name").startsWith("OS/2"))
+                        return "dt_sock";
                     return "dt_socket";
                 }
Index: /trunk/openjdk/jdk/src/share/transport/shmem/shmemBase.c
===================================================================
--- /trunk/openjdk/jdk/src/share/transport/shmem/shmemBase.c	(revision 248)
+++ /trunk/openjdk/jdk/src/share/transport/shmem/shmemBase.c	(revision 249)
@@ -32,5 +32,7 @@
 #include "jdwpTransport.h"  /* for Packet, TransportCallback */
 
+#ifndef MIN
 #define MIN(x,y) ((x)<(y)?(x):(y))
+#endif
 
 /*
@@ -83,5 +85,5 @@
 } SharedListener;
 
-typedef struct SharedMemoryTransport {
+struct SharedMemoryTransport {
     char name[MAX_IPC_PREFIX];
     sys_ipmutex_t mutex;
@@ -90,5 +92,5 @@
     sys_shmem_t sharedMemory;
     SharedListener *shared;
-} SharedMemoryTransport;
+};
 
 /*
@@ -143,5 +145,5 @@
 
 
-typedef struct SharedMemoryConnection {
+struct SharedMemoryConnection {
     char name[MAX_IPC_NAME];
     SharedMemory *shared;
@@ -151,5 +153,5 @@
     sys_process_t otherProcess;
     sys_event_t shutdown;           /* signalled to indicate shutdown */
-} SharedMemoryConnection;
+};
 
 static jdwpTransportCallback *callback;
Index: /trunk/openjdk/jdk/src/windows/back/util_md.h
===================================================================
--- /trunk/openjdk/jdk/src/windows/back/util_md.h	(revision 248)
+++ /trunk/openjdk/jdk/src/windows/back/util_md.h	(revision 249)
@@ -30,5 +30,12 @@
 #include <stdlib.h>      /* for _MAx_PATH */
 
+#ifdef __EMX__
+typedef __uint64_t UNSIGNED_JLONG;
+#define CONST_JLONG(x) x##LL
+#else
 typedef unsigned __int64 UNSIGNED_JLONG;
+#define CONST_JLONG(x) x
+#endif
+
 typedef unsigned long UNSIGNED_JINT;
 
@@ -51,11 +58,11 @@
 #define HOST_TO_JAVA_LONG(x)                                            \
                   ((x << 56) |                                          \
-                   ((x & 0x000000000000ff00) << 40) |                   \
-                   ((x & 0x0000000000ff0000) << 24) |                   \
-                   ((x & 0x00000000ff000000) << 8) |                    \
-                   ((x & 0x000000ff00000000) >> 8) |                    \
-                   ((x & 0x0000ff0000000000) >> 24) |                   \
-                   ((x & 0x00ff000000000000) >> 40) |                   \
-                   (((UNSIGNED_JLONG)(x & 0xff00000000000000)) >> 56))
+                   ((x & CONST_JLONG(0x000000000000ff00)) << 40) |                   \
+                   ((x & CONST_JLONG(0x0000000000ff0000)) << 24) |                   \
+                   ((x & CONST_JLONG(0x00000000ff000000)) << 8) |                    \
+                   ((x & CONST_JLONG(0x000000ff00000000)) >> 8) |                    \
+                   ((x & CONST_JLONG(0x0000ff0000000000)) >> 24) |                   \
+                   ((x & CONST_JLONG(0x00ff000000000000)) >> 40) |                   \
+                   (((UNSIGNED_JLONG)(x & CONST_JLONG(0xff00000000000000))) >> 56))
 #define HOST_TO_JAVA_FLOAT(x) stream_encodeFloat(x)
 #define HOST_TO_JAVA_DOUBLE(x) stream_encodeDouble(x)
Index: /trunk/openjdk/jdk/src/windows/transport/shmem/shmem_md.c
===================================================================
--- /trunk/openjdk/jdk/src/windows/transport/shmem/shmem_md.c	(revision 248)
+++ /trunk/openjdk/jdk/src/windows/transport/shmem/shmem_md.c	(revision 249)
@@ -27,5 +27,4 @@
 #include <errno.h>
 
-#include "shmem_md.h"
 #include "sysShmem.h"
 #include "shmemBase.h"  /* for exitTransportWithError */
Index: /trunk/openjdk/jdk/src/windows/transport/socket/socket_md.c
===================================================================
--- /trunk/openjdk/jdk/src/windows/transport/socket/socket_md.c	(revision 248)
+++ /trunk/openjdk/jdk/src/windows/transport/socket/socket_md.c	(revision 249)
@@ -26,4 +26,9 @@
 #include <winsock2.h>
 
+#ifdef __EMX__
+#include <string.h>
+#include <memory.h>
+#endif
+
 #include "sysSocket.h"
 #include "socketTransport.h"
@@ -41,5 +46,7 @@
     const char *errString;
 } const winsock_errors[] = {
+#ifndef __WIN32OS2__
     { WSAEPROVIDERFAILEDINIT,   "Provider initialization failed (check %SystemRoot%)" },
+#endif
     { WSAEACCES,                "Permission denied" },
     { WSAEADDRINUSE,            "Address already in use" },
@@ -427,9 +434,9 @@
 
 #define FT2INT64(ft) \
-        ((long)(ft).dwHighDateTime << 32 | (long)(ft).dwLowDateTime)
+        ((jlong)(ft).dwHighDateTime << 32 | (jlong)(ft).dwLowDateTime)
 
 long
 dbgsysCurrentTimeMillis() {
-    static long fileTime_1_1_70 = 0;    /* midnight 1/1/70 */
+    static jlong fileTime_1_1_70 = 0;    /* midnight 1/1/70 */
     SYSTEMTIME st0;
     FILETIME   ft0;
