diff -ur ORBit2-2.4.3.orig/configure.in ORBit2-2.4.3/configure.in
--- ORBit2-2.4.3.orig/configure.in	2002-08-24 01:44:08.000000000 +0900
+++ ORBit2-2.4.3/configure.in	2002-09-06 14:34:48.000000000 +0900
@@ -35,6 +35,7 @@
 dnl Initialize automake stuff
 AM_INIT_AUTOMAKE(ORBit2, $ORBIT_VERSION, no-define)
 
+dnl AC_LIBTOOL_WIN32_DLL
 AC_LIBTOOL_DLOPEN
 AM_PROG_LIBTOOL
 AM_MAINTAINER_MODE
@@ -107,6 +108,18 @@
 AC_SUBST(LINC_REQUIRED)
 AC_SUBST(LIBIDL_REQUIRED)
 
+AC_MSG_CHECKING([for cygwin])
+case "$host" in
+  *-*-cygwin*)
+    orbit_with_cygwin=yes
+    ;;
+  *)
+    orbit_with_cygwin=no
+    ;;
+esac
+AC_MSG_RESULT([$orbit_with_cygwin])
+AM_CONDITIONAL(WITH_CYGWIN, test "$orbit_with_cygwin" = "yes")
+
 dnl Checks for libraries.
 PKG_CHECK_MODULES(ORBIT, \
 	linc >= $LINC_REQUIRED \
diff -ur ORBit2-2.4.3.orig/include/orbit/orb-core/corba-typecode.h ORBit2-2.4.3/include/orbit/orb-core/corba-typecode.h
--- ORBit2-2.4.3.orig/include/orbit/orb-core/corba-typecode.h	2002-03-25 20:49:50.000000000 +0900
+++ ORBit2-2.4.3/include/orbit/orb-core/corba-typecode.h	2002-09-06 14:41:36.000000000 +0900
@@ -7,7 +7,11 @@
 
 G_BEGIN_DECLS
 
+#ifdef __CYGWIN__
+#define CORBA_tk_recursive 0xffff
+#else
 #define CORBA_tk_recursive 0xffffffff
+#endif
 #define CORBA_tk_last (CORBA_tk_abstract_interface + 1)
 
 struct CORBA_TypeCode_struct {
diff -ur ORBit2-2.4.3.orig/include/orbit/util/orbit-util.h ORBit2-2.4.3/include/orbit/util/orbit-util.h
--- ORBit2-2.4.3.orig/include/orbit/util/orbit-util.h	2002-02-26 18:45:36.000000000 +0900
+++ ORBit2-2.4.3/include/orbit/util/orbit-util.h	2002-09-06 14:34:48.000000000 +0900
@@ -20,9 +20,27 @@
 #define ALIGN_VALUE(this, boundary) \
   (( ((gulong)(this)) + (((gulong)(boundary)) -1)) & (~(((gulong)(boundary))-1)))
 
+#ifndef __CYGWIN__
 #define ALIGN_ADDRESS(this, boundary) \
   ((gpointer)ALIGN_VALUE(this, boundary))
 
+#else
+	/* Cygwin doubles and long longs have a strange alignment.
+	 * They are a 8-byte intervals, but starting only
+	 * at 0x4 and 0xc (ie displaced by 4).
+	 * So, if the boundary is 8, we need to do extra work.
+	 */
+#define ALIGN_ADDRESS_1(this, boundary) \
+  ((gpointer)ALIGN_VALUE(this, boundary))
+
+#define ALIGN_ADDRESS_2(this) \
+  ((gpointer) ((ALIGN_VALUE(this, 4)) % 8 ? (ALIGN_VALUE(this, 4)) : (ALIGN_VALUE(this, 4)) + 4))
+
+#define ALIGN_ADDRESS(this, boundary) \
+  (boundary == 8 ? ALIGN_ADDRESS_2(this) : ALIGN_ADDRESS_1(this, boundary))
+
+#endif
+
 #ifdef ORBIT2_INTERNAL_API
 
 gulong ORBit_wchar_strlen(CORBA_wchar *wstr);
diff -ur ORBit2-2.4.3.orig/src/orb/GIOP/Makefile.am ORBit2-2.4.3/src/orb/GIOP/Makefile.am
--- ORBit2-2.4.3.orig/src/orb/GIOP/Makefile.am	2002-04-18 23:27:50.000000000 +0900
+++ ORBit2-2.4.3/src/orb/GIOP/Makefile.am	2002-09-06 14:34:48.000000000 +0900
@@ -17,3 +17,7 @@
 	giop-send-buffer.c \
 	giop-recv-buffer.c \
 	giop-endian.c
+
+if WITH_CYGWIN
+libGIOP_la_LIBADD = -lextras
+endif
diff -ur ORBit2-2.4.3.orig/src/orb/GIOP/giop.c ORBit2-2.4.3/src/orb/GIOP/giop.c
--- ORBit2-2.4.3.orig/src/orb/GIOP/giop.c	2002-06-26 00:09:02.000000000 +0900
+++ ORBit2-2.4.3/src/orb/GIOP/giop.c	2002-09-06 14:34:48.000000000 +0900
@@ -8,6 +8,9 @@
 #include <sys/stat.h>
 #include <string.h>
 #include <utime.h>
+#ifdef __CYGWIN__
+#include <cygextras.h>
+#endif
 
 #include "giop-private.h"
 #include "giop-debug.h"
@@ -31,6 +34,10 @@
 		return FALSE;
 	}
 	
+#ifdef __CYGWIN__
+	if(check_ntsec (dirname)) {
+#endif
+
 	if (statbuf.st_uid != getuid ()) {
 		S_PRINT (("Owner of %s is not the current user\n", dirname));
 		return FALSE;
@@ -42,6 +49,10 @@
 		return FALSE;
 	}
 
+#ifdef __CYGWIN__
+	}
+#endif
+
 	return TRUE;
 }
 
diff -ur ORBit2-2.4.3.orig/src/orb/dynamic/dynany.c ORBit2-2.4.3/src/orb/dynamic/dynany.c
--- ORBit2-2.4.3.orig/src/orb/dynamic/dynany.c	2002-08-05 20:49:46.000000000 +0900
+++ ORBit2-2.4.3/src/orb/dynamic/dynany.c	2002-09-06 14:34:48.000000000 +0900
@@ -452,8 +452,21 @@
 	return TRUE;
 }
 
+#ifndef __CYGWIN__
 #define DYNANY_GET_OFFSET(p,i,tc) \
 	((gpointer) (((guchar *) (p)) + ORBit_gather_alloc_info (tc) * (i)))
+#else
+   /* Cygwin 8-byte types are aligned on 8-byte boundaries starting
+    * at 4. So we need to add 4 to the offset for those types if the
+    * address is divisible by 8
+    */
+#define DYNANY_GET_OFFSET_1(p,i,tc) \
+	((gpointer) (((guchar *) (p)) + ORBit_gather_alloc_info (tc) * (i)))
+   
+#define DYNANY_GET_OFFSET(p,i,tc) \
+	(((tc)->c_align == 8) && (!((unsigned long)(p) % 8)) ? (gpointer) ((unsigned long) DYNANY_GET_OFFSET_1((p),(i),(tc)) + 4) : DYNANY_GET_OFFSET_1((p),(i),(tc)))
+
+#endif
 
 /**
  * dynany_get_value:
diff -ur ORBit2-2.4.3.orig/src/orb/orb-core/corba-any.c ORBit2-2.4.3/src/orb/orb-core/corba-any.c
--- ORBit2-2.4.3.orig/src/orb/orb-core/corba-any.c	2002-08-24 01:43:42.000000000 +0900
+++ ORBit2-2.4.3/src/orb/orb-core/corba-any.c	2002-09-06 14:38:36.000000000 +0900
@@ -13,10 +13,15 @@
 	switch (tc->kind) {
 	case CORBA_tk_long:
 	case CORBA_tk_ulong:
+#ifndef __CYGWIN__
 	case CORBA_tk_enum:
+#endif
 		return sizeof (CORBA_long);
 	case CORBA_tk_short:
 	case CORBA_tk_ushort:
+#ifdef __CYGWIN__
+	case CORBA_tk_enum:
+#endif
 		return sizeof (CORBA_short);
 	case CORBA_tk_float:
 		return sizeof (CORBA_float);
diff -ur ORBit2-2.4.3.orig/src/orb/orb-core/corba-typecode.c ORBit2-2.4.3/src/orb/orb-core/corba-typecode.c
--- ORBit2-2.4.3.orig/src/orb/orb-core/corba-typecode.c	2002-06-07 19:26:26.000000000 +0900
+++ ORBit2-2.4.3/src/orb/orb-core/corba-typecode.c	2002-09-06 14:36:30.000000000 +0900
@@ -352,8 +352,13 @@
 		return retval;
 	case CORBA_tk_ulong:
 	case CORBA_tk_long:
+#ifndef __CYGWIN__
 	case CORBA_tk_enum:
+#endif
 		return ORBIT_ALIGNOF_CORBA_LONG;
+#ifndef __CYGWIN__
+	case CORBA_tk_enum:
+#endif
 	case CORBA_tk_ushort:
 	case CORBA_tk_short:
 	case CORBA_tk_wchar:
diff -ur ORBit2-2.4.3.orig/src/idl-compiler/orbit-idl-c-skels.c ORBit2-2.4.3/src/idl-compiler/orbit-idl-c-skels.c
--- ORBit2-2.4.3.orig/src/idl-compiler/orbit-idl-c-skels.c	2002-05-23 01:49:56.000000000 +0900
+++ ORBit2-2.4.3/src/idl-compiler/orbit-idl-c-skels.c	2002-09-06 18:12:42.000000000 +0900
@@ -710,8 +710,18 @@
       fprintf(iti->ci->fh, "*impl = (gpointer)servant->vepv->%s_epv->%s;\n",
 	      opi->iface_id, opi->opname);
       if (iti->small) {
+#ifdef __CYGWIN__
+	fprintf(iti->ci->fh, "{\n"
+		"/* This workaround is for win32 and cygwin; do not \"optimize\" */\n"
+		"volatile ORBit_IInterface *interface = &%s__iinterface;\n",
+		opi->iface_id);
+        fprintf(iti->ci->fh, "*m_data = (gpointer)&interface->methods._buffer [%d];\n",
+		opi->idx);
+	fprintf(iti->ci->fh, "}\n");
+#else
         fprintf(iti->ci->fh, "*m_data = (gpointer)&%s__iinterface.methods._buffer [%d];\n",
 		opi->iface_id, opi->idx);
+#endif
         fprintf(iti->ci->fh, "return (ORBitSmallSkeleton)_ORBIT_skel_small_%s_%s;\n",
 	        opi->iface_id, opi->opname);
       } else
diff -ur ORBit2-2.4.3.orig/src/idl-compiler/orbit-idl-c-stubs.c ORBit2-2.4.3/src/idl-compiler/orbit-idl-c-stubs.c
--- ORBit2-2.4.3.orig/src/idl-compiler/orbit-idl-c-stubs.c	2002-05-25 00:58:24.000000000 +0900
+++ ORBit2-2.4.3/src/idl-compiler/orbit-idl-c-stubs.c	2002-09-06 17:43:16.000000000 +0900
@@ -133,8 +133,17 @@
 		if (has_args)
 			cbe_small_flatten_args (tree, of, "_args");
 
+#ifdef __CYGWIN__
+		fprintf (of, "{\n"
+			 "/* This workaround is for win32 and cygwin; do not \"optimize\" */\n"
+			 "volatile ORBit_IInterface *interface = &%s__iinterface;\n",
+			 id);
+		fprintf (of, "ORBit_small_invoke_stub_n (_obj, "
+			 "&interface->methods, %d, ", *idx);
+#else
 		fprintf (of, "ORBit_small_invoke_stub_n (_obj, "
 			 "&%s__iinterface.methods, %d, ", id, *idx);
+#endif
 
 		if (has_retval)
 			fprintf (of, "&_ORBIT_retval, ");
@@ -152,7 +161,9 @@
 			fprintf(ci->fh, "NULL, ");
 		
 		fprintf (of, "ev);\n\n");
-
+#ifdef __CYGWIN__
+		fprintf (of, "}\n\n");
+#endif
 	}
 
 	fprintf (of, "}\n");
diff -ur ORBit2-2.4.3.orig/test/typelib-dump.c ORBit2-2.4.3/test/typelib-dump.c
--- ORBit2-2.4.3.orig/test/typelib-dump.c	2001-11-01 10:50:58.000000000 +0900
+++ ORBit2-2.4.3/test/typelib-dump.c	2002-09-07 11:23:26.000000000 +0900
@@ -17,9 +17,19 @@
 	memset (id_str, ' ', ident);
 	id_str [ident] = '\0';
 
+#ifdef __CYGWIN__
+	/* This workaround is for win32 and cygwin; do not "optimize" */
+	{
+		volatile CORBA_TypeCode tmp = TC_CORBA_TCKind;
+		printf ("%sType %12s: '%s'\n",
+			id_str, tmp->subnames [tc->kind],
+			tc->repo_id);
+	}
+#else	
 	printf ("%sType %12s: '%s'\n",
 		id_str, TC_CORBA_TCKind->subnames [tc->kind],
 		tc->repo_id);
+#endif
 }
 
 static void
