mirror of
https://github.com/openssl/openssl.git
synced 2024-11-24 02:23:51 +08:00
Changes to have OpenSSL compile on OS/2.
Contributed by "Brian Havard" <brianh@kheldar.apana.org.au>
This commit is contained in:
parent
b7a26e6daf
commit
dc01b6b1f2
@ -453,10 +453,13 @@ my %table=(
|
||||
##### GNU Hurd
|
||||
"hurd-x86", "gcc:-DL_ENDIAN -DTERMIOS -O3 -fomit-frame-pointer -m486 -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC",
|
||||
|
||||
##### OS/2 EMX
|
||||
"OS2-EMX", "gcc::::::::",
|
||||
|
||||
);
|
||||
|
||||
my @WinTargets=qw(VC-NT VC-WIN32 VC-WIN16 VC-W31-16 VC-W31-32 VC-MSDOS BC-32
|
||||
BC-16 Mingw32);
|
||||
BC-16 Mingw32 OS2-EMX);
|
||||
|
||||
my $prefix="";
|
||||
my $openssldir="";
|
||||
|
22
INSTALL.OS2
Normal file
22
INSTALL.OS2
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
Installation on OS/2
|
||||
--------------------
|
||||
|
||||
You need to have the following tools installed:
|
||||
|
||||
* EMX GCC
|
||||
* PERL
|
||||
* GNU make
|
||||
|
||||
|
||||
To build the makefile, run
|
||||
|
||||
> os2\os2-emx
|
||||
|
||||
This will configure OpenSSL and create OS2-EMX.mak which you then use to
|
||||
build the OpenSSL libraries & programs by running
|
||||
|
||||
> make -f os2-emx.mak
|
||||
|
||||
If that finishes successfully you will find the libraries and programs in the
|
||||
"out" directory.
|
@ -210,6 +210,11 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
_setmode(fileno((FILE *)ptr),_O_TEXT);
|
||||
else
|
||||
_setmode(fileno((FILE *)ptr),_O_BINARY);
|
||||
#elif defined(OPENSSL_SYS_OS2)
|
||||
if (num & BIO_FP_TEXT)
|
||||
setmode(fileno((FILE *)ptr), O_TEXT);
|
||||
else
|
||||
setmode(fileno((FILE *)ptr), O_BINARY);
|
||||
#endif
|
||||
break;
|
||||
case BIO_C_SET_FILENAME:
|
||||
|
@ -77,7 +77,7 @@
|
||||
# include <starlet.h>
|
||||
#elif defined(__ultrix)
|
||||
# include <sys/syslog.h>
|
||||
#elif !defined(MSDOS) /* Unix */
|
||||
#elif !defined(MSDOS) && !defined(NO_SYSLOG) /* Unix */
|
||||
# include <syslog.h>
|
||||
#endif
|
||||
|
||||
|
@ -72,7 +72,7 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
|
||||
{
|
||||
struct tm *ts = NULL;
|
||||
|
||||
#if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(__CYGWIN32__) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r))
|
||||
#if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_OS2) && !defined(__CYGWIN32__) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r))
|
||||
/* should return &data, but doesn't on some systems,
|
||||
so we don't even look at the return value */
|
||||
gmtime_r(timer,result);
|
||||
|
147
crypto/rand/rand_os2.c
Normal file
147
crypto/rand/rand_os2.c
Normal file
@ -0,0 +1,147 @@
|
||||
/* crypto/rand/rand_os2.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/rand.h>
|
||||
#include "rand_lcl.h"
|
||||
|
||||
#ifdef OPENSSL_SYS_OS2
|
||||
|
||||
#define INCL_DOSPROCESS
|
||||
#define INCL_DOSPROFILE
|
||||
#define INCL_DOSMISC
|
||||
#define INCL_DOSMODULEMGR
|
||||
#include <os2.h>
|
||||
|
||||
#define CMD_KI_RDCNT (0x63)
|
||||
|
||||
typedef struct _CPUUTIL {
|
||||
ULONG ulTimeLow; /* Low 32 bits of time stamp */
|
||||
ULONG ulTimeHigh; /* High 32 bits of time stamp */
|
||||
ULONG ulIdleLow; /* Low 32 bits of idle time */
|
||||
ULONG ulIdleHigh; /* High 32 bits of idle time */
|
||||
ULONG ulBusyLow; /* Low 32 bits of busy time */
|
||||
ULONG ulBusyHigh; /* High 32 bits of busy time */
|
||||
ULONG ulIntrLow; /* Low 32 bits of interrupt time */
|
||||
ULONG ulIntrHigh; /* High 32 bits of interrupt time */
|
||||
} CPUUTIL;
|
||||
|
||||
APIRET APIENTRY(*DosPerfSysCall) (ULONG ulCommand, ULONG ulParm1, ULONG ulParm2, ULONG ulParm3) = NULL;
|
||||
APIRET APIENTRY(*DosQuerySysState) (ULONG func, ULONG arg1, ULONG pid, ULONG _res_, PVOID buf, ULONG bufsz) = NULL;
|
||||
HMODULE hDoscalls = 0;
|
||||
|
||||
int RAND_poll(void)
|
||||
{
|
||||
char failed_module[20];
|
||||
QWORD qwTime;
|
||||
ULONG SysVars[QSV_FOREGROUND_PROCESS];
|
||||
|
||||
if (hDoscalls == 0) {
|
||||
ULONG rc = DosLoadModule(failed_module, sizeof(failed_module), "DOSCALLS", &hDoscalls);
|
||||
|
||||
if (rc == 0) {
|
||||
rc = DosQueryProcAddr(hDoscalls, 976, NULL, (PFN *)&DosPerfSysCall);
|
||||
|
||||
if (rc)
|
||||
DosPerfSysCall = NULL;
|
||||
|
||||
rc = DosQueryProcAddr(hDoscalls, 368, NULL, (PFN *)&DosQuerySysState);
|
||||
|
||||
if (rc)
|
||||
DosQuerySysState = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Sample the hi-res timer, runs at around 1.1 MHz */
|
||||
DosTmrQueryTime(&qwTime);
|
||||
RAND_add(&qwTime, sizeof(qwTime), 2);
|
||||
|
||||
/* Sample a bunch of system variables, includes various process & memory statistics */
|
||||
DosQuerySysInfo(1, QSV_FOREGROUND_PROCESS, SysVars, sizeof(SysVars));
|
||||
RAND_add(SysVars, sizeof(SysVars), 4);
|
||||
|
||||
/* If available, sample CPU registers that count at CPU MHz
|
||||
* Only fairly new CPUs (PPro & K6 onwards) & OS/2 versions support this
|
||||
*/
|
||||
if (DosPerfSysCall) {
|
||||
CPUUTIL util;
|
||||
|
||||
if (DosPerfSysCall(CMD_KI_RDCNT, (ULONG)&util, 0, 0) == 0) {
|
||||
RAND_add(&util, sizeof(util), 10);
|
||||
}
|
||||
else {
|
||||
DosPerfSysCall = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* DosQuerySysState() gives us a huge quantity of process, thread, memory & handle stats */
|
||||
if (DosQuerySysState) {
|
||||
char *buffer = OPENSSL_malloc(256 * 1024);
|
||||
|
||||
if (DosQuerySysState(0x1F, 0, 0, 0, buffer, 256 * 1024) == 0) {
|
||||
/* First 4 bytes in buffer is a pointer to the thread count
|
||||
* there should be at least 1 byte of entropy per thread
|
||||
*/
|
||||
RAND_add(buffer, 256 * 1024, **(ULONG **)buffer);
|
||||
}
|
||||
|
||||
OPENSSL_free(buffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* OPENSSL_SYS_OS2 */
|
@ -113,7 +113,7 @@
|
||||
#include <openssl/rand.h>
|
||||
#include "rand_lcl.h"
|
||||
|
||||
#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS))
|
||||
#if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2))
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
|
6
e_os2.h
6
e_os2.h
@ -136,6 +136,12 @@ extern "C" {
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* --------------------------------- OS/2 ---------------------------------- */
|
||||
#if defined(__EMX__) || defined(__OS2__)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# define OPENSSL_SYS_OS2
|
||||
#endif
|
||||
|
||||
/* --------------------------------- Unix ---------------------------------- */
|
||||
#ifdef OPENSSL_SYS_UNIX
|
||||
# if defined(linux) || defined(OPENSSL_SYSNAME_LINUX)
|
||||
|
61
os2/OS2-EMX.cmd
Normal file
61
os2/OS2-EMX.cmd
Normal file
@ -0,0 +1,61 @@
|
||||
@echo off
|
||||
|
||||
perl Configure OS2-EMX
|
||||
perl util\mkfiles.pl > MINFO
|
||||
|
||||
@rem create make file
|
||||
perl util\mk1mf.pl OS2-EMX > OS2-EMX.mak
|
||||
|
||||
echo Generating x86 for GNU assember
|
||||
|
||||
echo Bignum
|
||||
cd crypto\bn\asm
|
||||
rem perl x86.pl a.out > bn-os2.asm
|
||||
perl bn-586.pl a.out > bn-os2.asm
|
||||
perl co-586.pl a.out > co-os2.asm
|
||||
cd ..\..\..
|
||||
|
||||
echo DES
|
||||
cd crypto\des\asm
|
||||
perl des-586.pl a.out > d-os2.asm
|
||||
cd ..\..\..
|
||||
|
||||
echo crypt(3)
|
||||
cd crypto\des\asm
|
||||
perl crypt586.pl a.out > y-os2.asm
|
||||
cd ..\..\..
|
||||
|
||||
echo Blowfish
|
||||
cd crypto\bf\asm
|
||||
perl bf-586.pl a.out > b-os2.asm
|
||||
cd ..\..\..
|
||||
|
||||
echo CAST5
|
||||
cd crypto\cast\asm
|
||||
perl cast-586.pl a.out > c-os2.asm
|
||||
cd ..\..\..
|
||||
|
||||
echo RC4
|
||||
cd crypto\rc4\asm
|
||||
perl rc4-586.pl a.out > r4-os2.asm
|
||||
cd ..\..\..
|
||||
|
||||
echo MD5
|
||||
cd crypto\md5\asm
|
||||
perl md5-586.pl a.out > m5-os2.asm
|
||||
cd ..\..\..
|
||||
|
||||
echo SHA1
|
||||
cd crypto\sha\asm
|
||||
perl sha1-586.pl a.out > s1-os2.asm
|
||||
cd ..\..\..
|
||||
|
||||
echo RIPEMD160
|
||||
cd crypto\ripemd\asm
|
||||
perl rmd-586.pl a.out > rm-os2.asm
|
||||
cd ..\..\..
|
||||
|
||||
echo RC5\32
|
||||
cd crypto\rc5\asm
|
||||
perl rc5-586.pl a.out > r5-os2.asm
|
||||
cd ..\..\..
|
@ -37,6 +37,7 @@ $infile="MINFO";
|
||||
"linux-elf","Linux elf",
|
||||
"ultrix-mips","DEC mips ultrix",
|
||||
"FreeBSD","FreeBSD distribution",
|
||||
"OS2-EMX", "EMX GCC OS/2",
|
||||
"default","cc under unix",
|
||||
);
|
||||
|
||||
@ -182,6 +183,11 @@ elsif ($platform eq "ultrix-mips")
|
||||
require "ultrix.pl";
|
||||
$unix=1;
|
||||
}
|
||||
elsif ($platform eq "OS2-EMX")
|
||||
{
|
||||
$wc=1;
|
||||
require 'OS2-EMX.pl';
|
||||
}
|
||||
else
|
||||
{
|
||||
require "unix.pl";
|
||||
|
96
util/pl/OS2-EMX.pl
Normal file
96
util/pl/OS2-EMX.pl
Normal file
@ -0,0 +1,96 @@
|
||||
#!/usr/local/bin/perl
|
||||
#
|
||||
# OS2-EMX.pl - for EMX GCC on OS/2
|
||||
#
|
||||
|
||||
$o='\\';
|
||||
$cp='copy';
|
||||
$rm='rm -f';
|
||||
|
||||
# C compiler stuff
|
||||
|
||||
$cc='gcc';
|
||||
$cflags="-DL_ENDIAN -O3 -fomit-frame-pointer -m486 -Zmt -Wall ";
|
||||
|
||||
if ($debug) {
|
||||
$cflags.="-g ";
|
||||
}
|
||||
|
||||
$obj='.o';
|
||||
$ofile='-o ';
|
||||
|
||||
# EXE linking stuff
|
||||
$link='${CC}';
|
||||
$lflags='${CFLAGS} -Zbsd-signals';
|
||||
$efile='-o ';
|
||||
$exep='.exe';
|
||||
$ex_libs="-lsocket";
|
||||
|
||||
# static library stuff
|
||||
$mklib='ar r';
|
||||
$mlflags='';
|
||||
$ranlib="ar s";
|
||||
$plib='lib';
|
||||
$libp=".a";
|
||||
$shlibp=".a";
|
||||
$lfile='';
|
||||
|
||||
$asm='as';
|
||||
$afile='-o ';
|
||||
$bn_asm_obj="";
|
||||
$bn_asm_src="";
|
||||
$des_enc_obj="";
|
||||
$des_enc_src="";
|
||||
$bf_enc_obj="";
|
||||
$bf_enc_src="";
|
||||
|
||||
if (!$no_asm)
|
||||
{
|
||||
$bn_asm_obj='crypto\bn\asm\bn-os2.o crypto\bn\asm\co-os2.o';
|
||||
$bn_asm_src='crypto\bn\asm\bn-os2.asm crypto\bn\asm\co-os2.asm';
|
||||
$des_enc_obj='crypto\des\asm\d-os2.o crypto\des\asm\y-os2.o';
|
||||
$des_enc_src='crypto\des\asm\d-os2.asm crypto\des\asm\y-os2.asm';
|
||||
$bf_enc_obj='crypto\bf\asm\b-os2.o';
|
||||
$bf_enc_src='crypto\bf\asm\b-os2.asm';
|
||||
$cast_enc_obj='crypto\cast\asm\c-os2.o';
|
||||
$cast_enc_src='crypto\cast\asm\c-os2.asm';
|
||||
$rc4_enc_obj='crypto\rc4\asm\r4-os2.o';
|
||||
$rc4_enc_src='crypto\rc4\asm\r4-os2.asm';
|
||||
$rc5_enc_obj='crypto\rc5\asm\r5-os2.o';
|
||||
$rc5_enc_src='crypto\rc5\asm\r5-os2.asm';
|
||||
$md5_asm_obj='crypto\md5\asm\m5-os2.o';
|
||||
$md5_asm_src='crypto\md5\asm\m5-os2.asm';
|
||||
$sha1_asm_obj='crypto\sha\asm\s1-os2.o';
|
||||
$sha1_asm_src='crypto\sha\asm\s1-os2.asm';
|
||||
$rmd160_asm_obj='crypto\ripemd\asm\rm-os2.o';
|
||||
$rmd160_asm_src='crypto\ripemd\asm\rm-os2.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\$(RM) $target\n";
|
||||
$ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
|
||||
$ret.="\t\$(RANLIB) $target\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 \$(LFLAGS) $files $libs\n\n";
|
||||
return($ret);
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in New Issue
Block a user