Index: Configure
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/Configure,v
retrieving revision 1.314.2.21
diff -u -r1.314.2.21 Configure
--- Configure	2002/06/14 20:10:10	1.314.2.21
+++ Configure	2002/06/26 08:55:54
@@ -555,13 +555,16 @@
 ##### OS/2 EMX
 "OS2-EMX", "gcc::::::::",
 
+##### Watcom C
+"Watcom", "wcl386::::::::",
+
 ##### VxWorks for various targets
 "vxworks-ppc405","ccppc:-g -msoft-float -mlongcall -DCPU=PPC405 -I\$(WIND_BASE)/target/h:::VXWORKS:-r:::::",
 
 );
 
 my @WinTargets=qw(VC-NT VC-WIN32 VC-WIN16 VC-W31-16 VC-W31-32 VC-MSDOS BC-32
-	BC-16 Mingw32 OS2-EMX);
+	BC-16 Mingw32 OS2-EMX Watcom);
 
 my $idx = 0;
 my $idx_cc = $idx++;
Index: e_os.h
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/e_os.h,v
retrieving revision 1.56.2.5
diff -u -r1.56.2.5 e_os.h
--- e_os.h	2002/06/13 20:39:30	1.56.2.5
+++ e_os.h	2002/06/26 08:55:54
@@ -160,6 +160,13 @@
 #define closesocket(s)		MacSocket_close(s)
 #define readsocket(s,b,n)	MacSocket_recv((s),(b),(n),true)
 #define writesocket(s,b,n)	MacSocket_send((s),(b),(n))
+#elif defined(__OS2__) && defined(__WATCOMC__)
+#define get_last_socket_error()	sock_errno()
+#define clear_socket_error()	
+#define readsocket(s,b,n)	recv((s),(b),(n),0)
+#define writesocket(s,b,n)	send((s),(char *)(b),(n),0)
+#define ioctlsocket(a,b,c)	ioctl(a,b,(caddr_t)c,0)
+#define closesocket(s)		soclose(s)
 #elif defined(OPENSSL_SYS_VMS)
 #define get_last_socket_error() errno
 #define clear_socket_error()    errno=0
@@ -369,6 +376,26 @@
 #    define SHUTDOWN(fd)		MacSocket_close(fd)
 #    define SHUTDOWN2(fd)		MacSocket_close(fd)
 
+#  elif defined(OPENSSL_SYS_OS2) && defined(__WATCOMC__)
+
+#    define BSD_SELECT
+#    include <string.h>
+#    include <sys/socket.h>
+#    include <sys/select.h>
+#    include <netdb.h>
+#    include <netinet/in.h>
+#    undef sleep
+#    define SSLeay_Write(a,b,c)	send((a),(b),(c),0)
+#    define SSLeay_Read(a,b,c)	recv((a),(b),(c),0)
+#    define SHUTDOWN(fd)    { shutdown((fd),0); closesocket((fd)); }
+#    define SHUTDOWN2(fd)   { shutdown((fd),2); closesocket((fd)); }
+#    define INVALID_SOCKET	(-1)
+#    pragma aux bswap "BSWAP"
+#    pragma aux lswap "LSWAP"
+#    pragma aux getservbyname "GETSERVBYNAME"
+#    pragma aux gethostbyname "GETHOSTBYNAME"
+#    pragma aux gethostbyaddr "GETHOSTBYADDR"
+
 #  else
 
 #    ifndef NO_SYS_PARAM_H
@@ -483,6 +510,17 @@
 # include <fcntl.h>
 # define NO_SYSLOG
 # define strcasecmp stricmp
+#endif
+
+#if defined(OPENSSL_SYS_OS2) && defined(__WATCOMC__)
+# include <fcntl.h>
+# define __i386
+# define NO_SYSLOG
+# ifndef strcasecmp
+#  define strcasecmp stricmp
+# endif
+  typedef signed long ssize_t;
+  typedef int pid_t;
 #endif
 
 #ifdef  __cplusplus
Index: apps/apps.c
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/apps/apps.c,v
retrieving revision 1.49.2.7
diff -u -r1.49.2.7 apps.c
--- apps/apps.c	2002/06/13 17:38:40	1.49.2.7
+++ apps/apps.c	2002/06/26 08:55:54
@@ -128,7 +128,7 @@
 
 #ifdef OPENSSL_SYS_WINDOWS
 #define strcasecmp _stricmp
-#else
+#elif !defined(__WATCOMC__)
 #include <strings.h>
 #endif
 
Index: apps/ca.c
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/apps/ca.c,v
retrieving revision 1.102.2.6
diff -u -r1.102.2.6 ca.c
--- apps/ca.c	2002/05/19 16:32:20	1.102.2.6
+++ apps/ca.c	2002/06/26 08:55:54
@@ -79,7 +79,7 @@
 
 #ifdef OPENSSL_SYS_WINDOWS
 #define strcasecmp _stricmp
-#else
+#elif !defined(__WATCOMC__)
 #include <strings.h>
 #endif
 
Index: apps/s_time.c
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/apps/s_time.c,v
retrieving revision 1.23.2.1
diff -u -r1.23.2.1 s_time.c
--- apps/s_time.c	2002/02/14 16:23:49	1.23.2.1
+++ apps/s_time.c	2002/06/26 08:55:54
@@ -85,7 +85,7 @@
 #include OPENSSL_UNISTD
 #endif
 
-#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
+#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && !defined(__WATCOMC__) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
 #define TIMES
 #endif
 
Index: apps/speed.c
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/apps/speed.c,v
retrieving revision 1.83.2.7
diff -u -r1.83.2.7 speed.c
--- apps/speed.c	2002/05/22 07:53:53	1.83.2.7
+++ apps/speed.c	2002/06/26 08:55:56
@@ -89,7 +89,7 @@
 
 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(OPENSSL_SYS_MACOSX)
 # define USE_TOD
-#elif !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
+#elif !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && !defined(__WATCOMC__) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
 # define TIMES
 #endif
 #if !defined(_UNICOS) && !defined(__OpenBSD__) && !defined(sgi) && !defined(__FreeBSD__) && !(defined(__bsdi) || defined(__bsdi__)) && !defined(_AIX) && !defined(OPENSSL_SYS_MPE) && !defined(__NetBSD__) && !defined(OPENSSL_SYS_VXWORKS) /* FIXME */
Index: crypto/tmdiff.c
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/tmdiff.c,v
retrieving revision 1.9.2.2
diff -u -r1.9.2.2 tmdiff.c
--- crypto/tmdiff.c	2002/02/14 18:52:37	1.9.2.2
+++ crypto/tmdiff.c	2002/06/26 08:55:57
@@ -65,7 +65,7 @@
 #undef TIMES
 #endif
 
-#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_VMS) || defined(__DECC) && !defined(OPENSSL_SYS_MACOSX) && !defined(OPENSSL_SYS_VXWORKS)
+#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_VMS) && !defined(__WATCOMC__) || defined(__DECC) && !defined(OPENSSL_SYS_MACOSX) && !defined(OPENSSL_SYS_VXWORKS)
 # define TIMES
 #endif
 
Index: crypto/uid.c
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/uid.c,v
retrieving revision 1.4
diff -u -r1.4 uid.c
--- crypto/uid.c	2001/04/26 08:26:18	1.4
+++ crypto/uid.c	2002/06/26 08:55:57
@@ -65,7 +65,7 @@
 	return issetugid();
 	}
 
-#elif defined(OPENSSL_SYS_WIN32)
+#elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_OS2)
 
 int OPENSSL_issetugid(void)
 	{
Index: crypto/bf/blowfish.h
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/bf/blowfish.h,v
retrieving revision 1.9
diff -u -r1.9 blowfish.h
--- crypto/bf/blowfish.h	2001/02/19 16:05:25	1.9
+++ crypto/bf/blowfish.h	2002/06/26 08:55:57
@@ -120,6 +120,12 @@
 	const BF_KEY *schedule, unsigned char *ivec, int *num);
 const char *BF_options(void);
 
+#ifdef __WATCOMC__
+#pragma aux ( BF_encrypt, __cdecl )
+#pragma aux ( BF_decrypt, __cdecl )
+#pragma aux ( BF_cbc_encrypt, __cdecl )
+#endif
+
 #ifdef  __cplusplus
 }
 #endif
Index: crypto/bio/bss_file.c
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/bio/bss_file.c,v
retrieving revision 1.14.2.1
diff -u -r1.14.2.1 bss_file.c
--- crypto/bio/bss_file.c	2002/06/11 11:41:21	1.14.2.1
+++ crypto/bio/bss_file.c	2002/06/26 08:55:57
@@ -247,7 +247,7 @@
 			ret=0;
 			break;
 			}
-#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
+#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_OS2)
 		if (!(num & BIO_FP_TEXT))
 			strcat(p,"b");
 		else
Index: crypto/bn/bn.h
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/bn/bn.h,v
retrieving revision 1.66.2.1
diff -u -r1.66.2.1 bn.h
--- crypto/bn/bn.h	2002/05/10 22:08:22	1.66.2.1
+++ crypto/bn/bn.h	2002/06/26 08:55:57
@@ -471,6 +471,15 @@
 		} \
 	}
 
+#ifdef __WATCOMC__
+#pragma aux ( bn_mul_add_words, __cdecl )
+#pragma aux ( bn_mul_words, __cdecl )
+#pragma aux ( bn_sqr_words, __cdecl )
+#pragma aux ( bn_div_words, __cdecl )
+#pragma aux ( bn_add_words, __cdecl )
+#pragma aux ( bn_sub_words, __cdecl )
+#endif
+
 BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
 BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
 void     bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
Index: crypto/bn/bn_lcl.h
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/bn/bn_lcl.h,v
retrieving revision 1.23.2.1
diff -u -r1.23.2.1 bn_lcl.h
--- crypto/bn/bn_lcl.h	2002/03/25 23:14:50	1.23.2.1
+++ crypto/bn/bn_lcl.h	2002/06/26 08:55:57
@@ -433,6 +433,14 @@
 BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
 	int cl, int dl);
 
+#ifdef __WATCOMC__
+#pragma aux ( bn_mul_comba8, __cdecl )
+#pragma aux ( bn_mul_comba4, __cdecl )
+#pragma aux ( bn_sqr_comba8, __cdecl )
+#pragma aux ( bn_sqr_comba4, __cdecl )
+#pragma aux ( bn_sub_part_words, __cdecl )
+#endif
+
 #ifdef  __cplusplus
 }
 #endif
Index: crypto/cast/cast.h
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/cast/cast.h,v
retrieving revision 1.7
diff -u -r1.7 cast.h
--- crypto/cast/cast.h	2001/02/19 16:05:00	1.7
+++ crypto/cast/cast.h	2002/06/26 08:55:57
@@ -96,6 +96,12 @@
 			long length, CAST_KEY *schedule, unsigned char *ivec,
 			int *num);
 
+#ifdef __WATCOMC__
+#pragma aux ( CAST_encrypt, __cdecl )
+#pragma aux ( CAST_decrypt, __cdecl )
+#pragma aux ( CAST_cbc_encrypt, __cdecl )
+#endif
+
 #ifdef  __cplusplus
 }
 #endif
Index: crypto/des/des.h
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/des/des.h,v
retrieving revision 1.40.2.2
diff -u -r1.40.2.2 des.h
--- crypto/des/des.h	2002/03/26 14:26:08	1.40.2.2
+++ crypto/des/des.h	2002/06/26 08:55:58
@@ -233,6 +233,15 @@
 
 #define DES_fixup_key_parity DES_set_odd_parity
 
+#ifdef __WATCOMC__
+#pragma aux ( DES_ncbc_encrypt, __cdecl )
+#pragma aux ( DES_encrypt1, __cdecl )
+#pragma aux ( DES_encrypt2, __cdecl )
+#pragma aux ( DES_encrypt3, __cdecl )
+#pragma aux ( DES_decrypt3, __cdecl )
+#pragma aux ( DES_ede3_cbc_encrypt, __cdecl )
+#endif
+
 #ifdef  __cplusplus
 }
 #endif
Index: crypto/des/des_locl.h
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/des/des_locl.h,v
retrieving revision 1.19.2.1
diff -u -r1.19.2.1 des_locl.h
--- crypto/des/des_locl.h	2002/03/04 16:08:35	1.19.2.1
+++ crypto/des/des_locl.h	2002/06/26 08:55:58
@@ -414,4 +414,9 @@
 
 void fcrypt_body(DES_LONG *out,DES_key_schedule *ks,
 		 DES_LONG Eswap0, DES_LONG Eswap1);
+
+#ifdef __WATCOMC__
+#pragma aux ( fcrypt_body, __cdecl )
+#endif
+
 #endif
Index: crypto/engine/hw_aep_err.c
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/engine/hw_aep_err.c,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 hw_aep_err.c
--- crypto/engine/hw_aep_err.c	2002/02/28 11:37:34	1.2.2.1
+++ crypto/engine/hw_aep_err.c	2002/06/26 08:55:58
@@ -61,6 +61,7 @@
 #include <stdio.h>
 #include <openssl/err.h>
 #include "hw_aep_err.h"
+#include "e_os.h"
 
 /* BEGIN ERROR CODES */
 #ifndef OPENSSL_NO_ERR
Index: crypto/md5/md5_locl.h
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/md5/md5_locl.h,v
retrieving revision 1.16
diff -u -r1.16 md5_locl.h
--- crypto/md5/md5_locl.h	2001/10/14 00:57:25	1.16
+++ crypto/md5/md5_locl.h	2002/06/26 08:55:58
@@ -77,6 +77,10 @@
 void md5_block_host_order (MD5_CTX *c, const void *p,int num);
 void md5_block_data_order (MD5_CTX *c, const void *p,int num);
 
+#ifdef __WATCOMC__
+#pragma aux ( md5_block_host_order, __cdecl )
+#endif
+
 #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
 /*
  * *_block_host_order is expected to handle aligned data while
Index: crypto/perlasm/x86asm.pl
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/perlasm/x86asm.pl,v
retrieving revision 1.6
diff -u -r1.6 x86asm.pl
--- crypto/perlasm/x86asm.pl	2000/02/28 19:16:27	1.6
+++ crypto/perlasm/x86asm.pl	2002/06/26 08:55:59
@@ -33,6 +33,8 @@
 		{ $win32=1; require "x86ms.pl"; }
 	elsif (	($type eq "win32n"))
 		{ $win32=1; require "x86nasm.pl"; }
+	elsif (	($type eq "wasm"))
+		{ $wasm=1; require "x86wasm.pl"; }
 	else
 		{
 		print STDERR <<"EOF";
@@ -43,6 +45,7 @@
 	cpp	- format so x86unix.cpp can be used
 	win32	- Windows 95/Windows NT
 	win32n	- Windows 95/Windows NT NASM format
+	wasm	- Watcom Assembler
 EOF
 		exit(1);
 		}
Index: crypto/perlasm/x86wasm.pl
===================================================================
RCS file: x86wasm.pl
diff -N x86wasm.pl
--- /dev/null	Sun Apr 15 10:46:23 2001
+++ crypto/perlasm/x86wasm.pl	Wed Jun 26 18:55:59 2002
@@ -0,0 +1,358 @@
+#!/usr/local/bin/perl
+
+package x86wasm;
+
+$label="L000";
+
+%lb=(	'eax',	'al',
+	'ebx',	'bl',
+	'ecx',	'cl',
+	'edx',	'dl',
+	'ax',	'al',
+	'bx',	'bl',
+	'cx',	'cl',
+	'dx',	'dl',
+	);
+
+%hb=(	'eax',	'ah',
+	'ebx',	'bh',
+	'ecx',	'ch',
+	'edx',	'dh',
+	'ax',	'ah',
+	'bx',	'bh',
+	'cx',	'ch',
+	'dx',	'dh',
+	);
+
+sub main'asm_init_output { @out=(); }
+sub main'asm_get_output { return(@out); }
+sub main'get_labels { return(@labels); }
+sub main'external_label { push(@labels,@_); }
+
+sub main'LB
+	{
+	(defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n";
+	return($lb{$_[0]});
+	}
+
+sub main'HB
+	{
+	(defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
+	return($hb{$_[0]});
+	}
+
+sub main'BP
+	{
+	&get_mem("BYTE",@_);
+	}
+
+sub main'DWP
+	{
+	&get_mem("DWORD",@_);
+	}
+
+sub main'BC
+	{
+	return @_;
+	}
+
+sub main'DWC
+	{
+	return @_;
+	}
+
+sub main'stack_push
+	{
+	local($num)=@_;
+	$stack+=$num*4;
+	&main'sub("esp",$num*4);
+	}
+
+sub main'stack_pop
+	{
+	local($num)=@_;
+	$stack-=$num*4;
+	&main'add("esp",$num*4);
+	}
+
+sub get_mem
+	{
+	local($size,$addr,$reg1,$reg2,$idx)=@_;
+	local($t,$post);
+	local($ret)="$size PTR ";
+
+	$addr =~ s/^\s+//;
+	if ($addr =~ /^(.+)\+(.+)$/)
+		{
+		$reg2=&conv($1);
+		$addr="_$2";
+		}
+	elsif ($addr =~ /^[_a-zA-Z]/)
+		{
+		$addr="_$addr";
+		}
+
+	$reg1="$regs{$reg1}" if defined($regs{$reg1});
+	$reg2="$regs{$reg2}" if defined($regs{$reg2});
+	if (($addr ne "") && ($addr ne 0))
+		{
+		if ($addr !~ /^-/)
+			{ $ret.=$addr; }
+		else	{ $post=$addr; }
+		}
+	if ($reg2 ne "")
+		{
+		$t="";
+		$t="*$idx" if ($idx != 0);
+		$reg1="+".$reg1 if ("$reg1$post" ne "");
+		$ret.="[$reg2$t$reg1$post]";
+		}
+	else
+		{
+		$ret.="[$reg1$post]"
+		}
+	return($ret);
+	}
+
+sub main'mov	{ &out2("mov",@_); }
+sub main'movb	{ &out2("mov",@_); }
+sub main'and	{ &out2("and",@_); }
+sub main'or	{ &out2("or",@_); }
+sub main'shl	{ &out2("shl",@_); }
+sub main'shr	{ &out2("shr",@_); }
+sub main'xor	{ &out2("xor",@_); }
+sub main'xorb	{ &out2("xor",@_); }
+sub main'add	{ &out2("add",@_); }
+sub main'adc	{ &out2("adc",@_); }
+sub main'sub	{ &out2("sub",@_); }
+sub main'rotl	{ &out2("rol",@_); }
+sub main'rotr	{ &out2("ror",@_); }
+sub main'exch	{ &out2("xchg",@_); }
+sub main'cmp	{ &out2("cmp",@_); }
+sub main'lea	{ &out2("lea",@_); }
+sub main'mul	{ &out1("mul",@_); }
+sub main'div	{ &out1("div",@_); }
+sub main'dec	{ &out1("dec",@_); }
+sub main'inc	{ &out1("inc",@_); }
+sub main'jmp	{ &out1("jmp",@_); }
+sub main'jmp_ptr { &out1p("jmp",@_); }
+sub main'je	{ &out1("je",@_); }
+sub main'jle	{ &out1("jle",@_); }
+sub main'jz	{ &out1("jz",@_); }
+sub main'jge	{ &out1("jge",@_); }
+sub main'jl	{ &out1("jl",@_); }
+sub main'jb	{ &out1("jb",@_); }
+sub main'jc	{ &out1("jc",@_); }
+sub main'jnc	{ &out1("jnc",@_); }
+sub main'jnz	{ &out1("jnz",@_); }
+sub main'jne	{ &out1("jne",@_); }
+sub main'jno	{ &out1("jno",@_); }
+sub main'push	{ &out1("push",@_); $stack+=4; }
+sub main'pop	{ &out1("pop",@_); $stack-=4; }
+sub main'bswap	{ &out1("bswap",@_); &using486(); }
+sub main'not	{ &out1("not",@_); }
+sub main'call	{ &out1("call",'_'.$_[0]); }
+sub main'ret	{ &out0("ret"); }
+sub main'nop	{ &out0("nop"); }
+
+sub out2
+	{
+	local($name,$p1,$p2)=@_;
+	local($l,$t);
+
+	push(@out,"\t$name\t");
+	$t=&conv($p1).",";
+	$l=length($t);
+	push(@out,$t);
+	$l=4-($l+9)/8;
+	push(@out,"\t" x $l);
+	push(@out,&conv($p2));
+	push(@out,"\n");
+	}
+
+sub out0
+	{
+	local($name)=@_;
+
+	push(@out,"\t$name\n");
+	}
+
+sub out1
+	{
+	local($name,$p1)=@_;
+	local($l,$t);
+
+	push(@out,"\t$name\t".&conv($p1)."\n");
+	}
+
+sub conv
+	{
+	local($p)=@_;
+
+	$p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
+	return $p;
+	}
+
+sub using486
+	{
+	return if $using486;
+	$using486++;
+	grep(s/\.386/\.486/,@out);
+	}
+
+sub main'file
+	{
+	local($file)=@_;
+
+	local($tmp)=<<"EOF";
+	TITLE	$file.asm
+        .386
+.model FLAT
+EOF
+	push(@out,$tmp);
+	}
+
+sub main'function_begin
+	{
+	local($func,$extra)=@_;
+
+	push(@labels,$func);
+
+	local($tmp)=<<"EOF";
+_TEXT	SEGMENT
+PUBLIC	_$func
+$extra
+_$func PROC NEAR
+	push	ebp
+	push	ebx
+	push	esi
+	push	edi
+EOF
+	push(@out,$tmp);
+	$stack=20;
+	}
+
+sub main'function_begin_B
+	{
+	local($func,$extra)=@_;
+
+	local($tmp)=<<"EOF";
+_TEXT	SEGMENT
+PUBLIC	_$func
+$extra
+_$func PROC NEAR
+EOF
+	push(@out,$tmp);
+	$stack=4;
+	}
+
+sub main'function_end
+	{
+	local($func)=@_;
+
+	local($tmp)=<<"EOF";
+	pop	edi
+	pop	esi
+	pop	ebx
+	pop	ebp
+	ret
+_$func ENDP
+_TEXT	ENDS
+EOF
+	push(@out,$tmp);
+	$stack=0;
+	%label=();
+	}
+
+sub main'function_end_B
+	{
+	local($func)=@_;
+
+	local($tmp)=<<"EOF";
+_$func ENDP
+_TEXT	ENDS
+EOF
+	push(@out,$tmp);
+	$stack=0;
+	%label=();
+	}
+
+sub main'function_end_A
+	{
+	local($func)=@_;
+
+	local($tmp)=<<"EOF";
+	pop	edi
+	pop	esi
+	pop	ebx
+	pop	ebp
+	ret
+EOF
+	push(@out,$tmp);
+	}
+
+sub main'file_end
+	{
+	push(@out,"END\n");
+	}
+
+sub main'wparam
+	{
+	local($num)=@_;
+
+	return(&main'DWP($stack+$num*4,"esp","",0));
+	}
+
+sub main'swtmp
+	{
+	return(&main'DWP($_[0]*4,"esp","",0));
+	}
+
+# Should use swtmp, which is above esp.  Linix can trash the stack above esp
+#sub main'wtmp
+#	{
+#	local($num)=@_;
+#
+#	return(&main'DWP(-(($num+1)*4),"esp","",0));
+#	}
+
+sub main'comment
+	{
+	foreach (@_)
+		{
+		push(@out,"\t; $_\n");
+		}
+	}
+
+sub main'label
+	{
+	if (!defined($label{$_[0]}))
+		{
+		$label{$_[0]}="\$${label}${_[0]}";
+		$label++;
+		}
+	return($label{$_[0]});
+	}
+
+sub main'set_label
+	{
+	if (!defined($label{$_[0]}))
+		{
+		$label{$_[0]}="${label}${_[0]}";
+		$label++;
+		}
+		push(@out,"$label{$_[0]}:\n");
+	}
+
+sub main'data_word
+	{
+	push(@out,"\tDD\t$_[0]\n");
+	}
+
+sub out1p
+	{
+	local($name,$p1)=@_;
+	local($l,$t);
+
+	push(@out,"\t$name\t ".&conv($p1)."\n");
+	}
Index: crypto/rand/rand_egd.c
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/rand/rand_egd.c,v
retrieving revision 1.16.2.3
diff -u -r1.16.2.3 rand_egd.c
--- crypto/rand/rand_egd.c	2002/06/13 20:40:24	1.16.2.3
+++ crypto/rand/rand_egd.c	2002/06/26 08:55:59
@@ -94,7 +94,7 @@
  *   RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255.
  */
 
-#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(__DJGPP__)
+#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(__DJGPP__) || defined(OPENSSL_SYS_OS2)
 int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes)
 	{
 	return(-1);
Index: crypto/rc4/rc4.h
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/rc4/rc4.h,v
retrieving revision 1.10
diff -u -r1.10 rc4.h
--- crypto/rc4/rc4.h	2001/02/19 16:02:55	1.10
+++ crypto/rc4/rc4.h	2002/06/26 08:55:59
@@ -81,6 +81,10 @@
 void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
 		unsigned char *outdata);
 
+#ifdef __WATCOMC__
+#pragma aux ( RC4, __cdecl )
+#endif
+
 #ifdef  __cplusplus
 }
 #endif
Index: crypto/rc5/rc5.h
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/rc5/rc5.h,v
retrieving revision 1.5
diff -u -r1.5 rc5.h
--- crypto/rc5/rc5.h	2001/02/19 16:02:52	1.5
+++ crypto/rc5/rc5.h	2002/06/26 08:55:59
@@ -109,6 +109,12 @@
 			  long length, RC5_32_KEY *schedule,
 			  unsigned char *ivec, int *num);
 
+#ifdef __WATCOMC__
+#pragma aux ( RC5_32_encrypt, __cdecl )
+#pragma aux ( RC5_32_decrypt, __cdecl )
+#pragma aux ( RC5_32_cbc_encrypt, __cdecl )
+#endif
+
 #ifdef  __cplusplus
 }
 #endif
Index: crypto/ripemd/rmd_locl.h
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/ripemd/rmd_locl.h,v
retrieving revision 1.7
diff -u -r1.7 rmd_locl.h
--- crypto/ripemd/rmd_locl.h	2001/10/14 00:57:27	1.7
+++ crypto/ripemd/rmd_locl.h	2002/06/26 08:55:59
@@ -79,6 +79,10 @@
 void ripemd160_block_host_order (RIPEMD160_CTX *c, const void *p,int num);
 void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,int num);
 
+#ifdef __WATCOMC__
+#pragma aux ( ripemd160_block_host_order, __cdecl )
+#endif
+
 #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
 #define ripemd160_block_data_order ripemd160_block_host_order
 #endif
Index: crypto/sha/sha_locl.h
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/sha/sha_locl.h,v
retrieving revision 1.16
diff -u -r1.16 sha_locl.h
--- crypto/sha/sha_locl.h	2001/10/14 00:57:30	1.16
+++ crypto/sha/sha_locl.h	2002/06/26 08:55:59
@@ -126,6 +126,11 @@
   void sha1_block_host_order (SHA_CTX *c, const void *p,int num);
   void sha1_block_data_order (SHA_CTX *c, const void *p,int num);
 
+# ifdef __WATCOMC__
+#  pragma aux ( sha1_block_host_order, __cdecl )
+#  pragma aux ( sha1_block_data_order, __cdecl )
+# endif
+
 #else
 # error "Either SHA_0 or SHA_1 must be defined."
 #endif
Index: crypto/ui/ui_openssl.c
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/crypto/ui/ui_openssl.c,v
retrieving revision 1.11.2.3
diff -u -r1.11.2.3 ui_openssl.c
--- crypto/ui/ui_openssl.c	2002/06/13 20:40:28	1.11.2.3
+++ crypto/ui/ui_openssl.c	2002/06/26 08:55:59
@@ -185,7 +185,7 @@
 # undef  SGTTY
 #endif
 
-#if !defined(TERMIO) && !defined(TERMIOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(MAC_OS_GUSI_SOURCE)
+#if !defined(TERMIO) && !defined(TERMIOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MSDOS) && !defined(__WATCOMC__) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(MAC_OS_GUSI_SOURCE)
 # undef  TERMIOS
 # undef  TERMIO
 # define SGTTY
@@ -269,7 +269,7 @@
 static long status;
 static unsigned short channel = 0;
 #else
-#if !defined(OPENSSL_SYS_MSDOS) || defined(__DJGPP__)
+#if (!defined(OPENSSL_SYS_MSDOS) && !defined(__WATCOMC__)) || defined(__DJGPP__)
 static TTY_STRUCT tty_orig,tty_new;
 #endif
 #endif
Index: os2/OS2-WC.cmd
===================================================================
RCS file: OS2-WC.cmd
diff -N OS2-WC.cmd
--- /dev/null	Sun Apr 15 10:46:23 2001
+++ os2/OS2-WC.cmd	Wed Jun 26 18:55:59 2002
@@ -0,0 +1,60 @@
+@echo off
+
+perl Configure Watcom
+perl util\mkfiles.pl > MINFO
+
+@rem create make file
+perl util\mk1mf.pl OS2-WC > OS2-WC.mak
+
+echo Generating x86 for WASM assember
+
+echo Bignum
+cd crypto\bn\asm
+perl bn-586.pl wasm > bn-wasm.asm
+perl co-586.pl wasm > co-wasm.asm
+cd ..\..\..
+
+echo DES
+cd crypto\des\asm
+perl des-586.pl wasm > d-wasm.asm
+cd ..\..\..
+
+echo crypt(3)
+cd crypto\des\asm
+perl crypt586.pl wasm > y-wasm.asm
+cd ..\..\..
+
+echo Blowfish
+cd crypto\bf\asm
+perl bf-586.pl wasm > b-wasm.asm
+cd ..\..\..
+
+echo CAST5
+cd crypto\cast\asm
+perl cast-586.pl wasm > c-wasm.asm
+cd ..\..\..
+
+echo RC4
+cd crypto\rc4\asm
+perl rc4-586.pl wasm > r4-wasm.asm
+cd ..\..\..
+
+echo MD5
+cd crypto\md5\asm
+perl md5-586.pl wasm > m5-wasm.asm
+cd ..\..\..
+
+echo SHA1
+cd crypto\sha\asm
+perl sha1-586.pl wasm > s1-wasm.asm
+cd ..\..\..
+
+echo RIPEMD160
+cd crypto\ripemd\asm
+perl rmd-586.pl wasm > rm-wasm.asm
+cd ..\..\..
+
+echo RC5\32
+cd crypto\rc5\asm
+perl rc5-586.pl wasm > r5-wasm.asm
+cd ..\..\..
Index: ssl/ssl_cert.c
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/ssl/ssl_cert.c,v
retrieving revision 1.48.2.3
diff -u -r1.48.2.3 ssl_cert.c
--- ssl/ssl_cert.c	2002/05/11 12:42:23	1.48.2.3
+++ ssl/ssl_cert.c	2002/06/26 08:55:59
@@ -111,8 +111,10 @@
 # include <sys/types.h>
 #endif
 
-#if !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_VMS) && !defined(NeXT) && !defined(MAC_OS_pre_X)
-#include <dirent.h>
+#if defined(__WATCOMC__)
+# include <direct.h>
+#elif !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_VMS) && !defined(NeXT) && !defined(MAC_OS_pre_X)
+# include <dirent.h>
 #endif
 
 #if defined(WIN32)
Index: util/mk1mf.pl
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/util/mk1mf.pl,v
retrieving revision 1.41.2.1
diff -u -r1.41.2.1 mk1mf.pl
--- util/mk1mf.pl	2002/04/20 10:25:19	1.41.2.1
+++ util/mk1mf.pl	2002/06/26 08:55:59
@@ -38,6 +38,7 @@
 	"ultrix-mips","DEC mips ultrix",
 	"FreeBSD","FreeBSD distribution",
 	"OS2-EMX", "EMX GCC OS/2",
+	"OS2-WC", "Watcom C - OS/2",
 	"default","cc under unix",
 	);
 
@@ -188,6 +189,11 @@
 	{
 	$wc=1;
 	require 'OS2-EMX.pl';
+	}
+elsif ($platform eq "OS2-WC")
+	{
+	$wc=1;
+	require 'OS2-WC.pl';
 	}
 else
 	{
Index: util/pl/OS2-EMX.pl
===================================================================
RCS file: /usr/local/cvs/openssl.org/openssl/util/pl/OS2-EMX.pl,v
retrieving revision 1.1
diff -u -r1.1 OS2-EMX.pl
--- util/pl/OS2-EMX.pl	2001/07/01 22:39:46	1.1
+++ util/pl/OS2-EMX.pl	2002/06/26 08:55:59
@@ -21,7 +21,7 @@
 
 # EXE linking stuff
 $link='${CC}';
-$lflags='${CFLAGS} -Zbsd-signals';
+$lflags='${CFLAG} -Zbsd-signals';
 $efile='-o ';
 $exep='.exe';
 $ex_libs="-lsocket";
Index: util/pl/OS2-WC.pl
===================================================================
RCS file: OS2-WC.pl
diff -N OS2-WC.pl
--- /dev/null	Sun Apr 15 10:46:23 2001
+++ util/pl/OS2-WC.pl	Wed Jun 26 18:55:59 2002
@@ -0,0 +1,95 @@
+#!/usr/local/bin/perl
+#
+# OS2-WC.pl - for Watcom C on OS/2
+#
+
+$o='\\';
+$cp='copy';
+$rm='del';
+
+# C compiler stuff
+
+$cc='wcl386';
+$cflags="-DL_ENDIAN -zq -otxr -4r -bm -wx";
+
+if ($debug) { 
+	$cflags.="-d2 "; 
+}
+
+$obj='.obj';
+$ofile='-Fo=';
+
+# EXE linking stuff
+$link='wlink';
+$lflags='${CFLAG}';
+$efile='name ';
+$exep='.exe';
+$ex_libs="so32dll tcp32dll";
+
+# static library stuff
+$mklib='wlib -q -n -b -c';
+$mlflags='';
+$ranlib="";
+$plib='';
+$libp=".lib";
+$shlibp=($shlib)?".dll":".lib";
+$lfile='';
+
+$asm='wasm -zq';
+$afile='-fo=';
+$bn_asm_obj="";
+$bn_asm_src="";
+$des_enc_obj="";
+$des_enc_src="";
+$bf_enc_obj="";
+$bf_enc_src="";
+
+if (!$no_asm)
+	{
+	$cflags.=" -DOPENSSL_ASM_CC=__cdecl";
+	$bn_asm_obj='crypto\bn\asm\bn-wasm.obj crypto\bn\asm\co-wasm.obj';
+	$bn_asm_src='crypto\bn\asm\bn-wasm.asm crypto\bn\asm\co-wasm.asm';
+	$des_enc_obj='crypto\des\asm\d-wasm.obj crypto\des\asm\y-wasm.obj';
+	$des_enc_src='crypto\des\asm\d-wasm.asm crypto\des\asm\y-wasm.asm';
+	$bf_enc_obj='crypto\bf\asm\b-wasm.obj';
+	$bf_enc_src='crypto\bf\asm\b-wasm.asm';
+	$cast_enc_obj='crypto\cast\asm\c-wasm.obj';
+	$cast_enc_src='crypto\cast\asm\c-wasm.asm';
+	$rc4_enc_obj='crypto\rc4\asm\r4-wasm.obj';
+	$rc4_enc_src='crypto\rc4\asm\r4-wasm.asm';
+	$rc5_enc_obj='crypto\rc5\asm\r5-wasm.obj';
+	$rc5_enc_src='crypto\rc5\asm\r5-wasm.asm';
+	$md5_asm_obj='crypto\md5\asm\m5-wasm.obj';
+	$md5_asm_src='crypto\md5\asm\m5-wasm.asm';
+	$sha1_asm_obj='crypto\sha\asm\s1-wasm.obj';
+	$sha1_asm_src='crypto\sha\asm\s1-wasm.asm';
+	$rmd160_asm_obj='crypto\ripemd\asm\rm-wasm.obj';
+	$rmd160_asm_src='crypto\ripemd\asm\rm-wasm.asm';
+	}
+
+sub do_lib_rule
+	{
+	local($obj,$target,$name,$shlib)=@_;
+	local($ret,$_,$Name);
+
+	$target =~ s/\//$o/g if $o ne '/';
+	$target="$target";
+	($Name=$name) =~ tr/a-z/A-Z/;
+
+	$ret.="$target: \$(${Name}OBJ)\n";
+	$ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n\n";
+	}
+
+sub do_link_rule
+	{
+	local($target,$files,$dep_libs,$libs)=@_;
+	local($ret,$_);
+	
+	$file =~ s/\//$o/g if $o ne '/';
+	$n=&bname($target);
+	$ret.="$target: $files $dep_libs\n";
+	$ret.="\t\$(LINK) ${efile}$target file {$files} lib {$libs} op q,c\n\n";
+	return($ret);
+	}
+
+1;
