Commit 62dc5aad authored by Richard Levitte's avatar Richard Levitte
Browse files

Introduce the possibility to access global variables through

functions on platform were that's the best way to handle exporting
global variables in shared libraries.  To enable this functionality,
one must configure with "EXPORT_VAR_AS_FN" or defined the C macro
"OPENSSL_EXPORT_VAR_AS_FUNCTION" in crypto/opensslconf.h (the latter
is normally done by Configure or something similar).

To implement a global variable, use the macro OPENSSL_IMPLEMENT_GLOBAL
in the source file (foo.c) like this:

	OPENSSL_IMPLEMENT_GLOBAL(int,foo)=1;
	OPENSSL_IMPLEMENT_GLOBAL(double,bar);

To declare a global variable, use the macros OPENSSL_DECLARE_GLOBAL
and OPENSSL_GLOBAL_REF in the header file (foo.h) like this:

	OPENSSL_DECLARE_GLOBAL(int,foo);
	#define foo OPENSSL_GLOBAL_REF(foo)
	OPENSSL_DECLARE_GLOBAL(double,bar);
	#define bar OPENSSL_GLOBAL_REF(bar)

The #defines are very important, and therefore so is including the
header file everywere where the defined globals are used.

The macro OPENSSL_EXPORT_VAR_AS_FUNCTION also affects the definition
of ASN.1 items, but that structure is a bt different.

The largest change is in util/mkdef.pl which has been enhanced with
better and easier to understand logic to choose which symbols should
go into the Windows .def files as well as a number of fixes and code
cleanup (among others, algorithm keywords are now sorted
lexicographically to avoid constant rewrites).
parent 45ecfb19
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -3,6 +3,40 @@

 Changes between 0.9.6 and 0.9.7  [xx XXX 2000]

  *) Introduce the possibility to access global variables through
     functions on platform were that's the best way to handle exporting
     global variables in shared libraries.  To enable this functionality,
     one must configure with "EXPORT_VAR_AS_FN" or defined the C macro
     "OPENSSL_EXPORT_VAR_AS_FUNCTION" in crypto/opensslconf.h (the latter
     is normally done by Configure or something similar).

     To implement a global variable, use the macro OPENSSL_IMPLEMENT_GLOBAL
     in the source file (foo.c) like this:

	OPENSSL_IMPLEMENT_GLOBAL(int,foo)=1;
	OPENSSL_IMPLEMENT_GLOBAL(double,bar);

     To declare a global variable, use the macros OPENSSL_DECLARE_GLOBAL
     and OPENSSL_GLOBAL_REF in the header file (foo.h) like this:

	OPENSSL_DECLARE_GLOBAL(int,foo);
	#define foo OPENSSL_GLOBAL_REF(foo)
	OPENSSL_DECLARE_GLOBAL(double,bar);
	#define bar OPENSSL_GLOBAL_REF(bar)

     The #defines are very important, and therefore so is including the
     header file everywere where the defined globals are used.

     The macro OPENSSL_EXPORT_VAR_AS_FUNCTION also affects the definition
     of ASN.1 items, but that structure is a bt different.

     The largest change is in util/mkdef.pl which has been enhanced with
     better and easier to understand logic to choose which symbols should
     go into the Windows .def files as well as a number of fixes and code
     cleanup (among others, algorithm keywords are now sorted
     lexicographically to avoid constant rewrites).
     [Richard Levitte]

  *) In copy_email() check for >= 0 as a return value for
     X509_NAME_get_index_by_NID() since 0 is a valid index.
     [Steve Henson reported by Massimiliano Pala <madwolf@opensca.org>]
+7 −0
Original line number Diff line number Diff line
@@ -968,6 +968,7 @@ my $rc4_chunk=0;
my $bf_ptr=0;
my @type=("char","short","int","long");
my ($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0);
my $export_var_as_fn=0;

my $des_int;

@@ -997,6 +998,7 @@ foreach (sort split(/\s+/,$bn_ops))
	($b64l,$b64,$b32,$b16,$b8)=(0,0,1,0,0) if /THIRTY_TWO_BIT/;
	($b64l,$b64,$b32,$b16,$b8)=(0,0,0,1,0) if /SIXTEEN_BIT/;
	($b64l,$b64,$b32,$b16,$b8)=(0,0,0,0,1) if /EIGHT_BIT/;
	$export_var_as_fn=1 if /EXPORT_VAR_AS_FN/;
	}

open(IN,'<crypto/opensslconf.h.in') || die "unable to read crypto/opensslconf.h.in:$!\n";
@@ -1029,6 +1031,11 @@ while (<IN>)
	{
	if	(/^#define\s+OPENSSLDIR/)
		{ print OUT "#define OPENSSLDIR \"$openssldir\"\n"; }
	elsif	(/^#((define)|(undef))\s+OPENSSL_EXPORT_VAR_AS_FUNCTION/)
		{ printf OUT "#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n"
			if $export_var_as_fn;
		  printf OUT "#%s OPENSSL_EXPORT_VAR_AS_FUNCTION\n",
			($export_var_as_fn)?"define":"undef"; }
	elsif	(/^#define\s+OPENSSL_UNISTD/)
		{
		$unistd = "<unistd.h>" if $unistd eq "";
+1 −1
Original line number Diff line number Diff line
@@ -357,7 +357,7 @@ typedef struct ASN1_VALUE_st ASN1_VALUE;
 *
 */

#ifndef ASN1_ITEM_FUNCTIONS
#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION

/* ASN1_ITEM pointer exported type */
typedef const ASN1_ITEM ASN1_ITEM_EXP;
+3 −3
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ extern "C" {
#endif


#ifndef ASN1_ITEM_FUNCTIONS
#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION

/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
#define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))
@@ -287,7 +287,7 @@ extern "C" {

/* Any defined by macros: the field used is in the table itself */

#ifndef ASN1_ITEM_FUNCTIONS
#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
#define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
#define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }
#else
@@ -358,7 +358,7 @@ extern "C" {
#define ASN1_ADB(name) \
	const static ASN1_ADB_TABLE name##_adbtbl[] 

#ifndef ASN1_ITEM_FUNCTIONS
#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION

#define ASN1_ADB_END(name, flags, field, app_table, def, none) \
	;\
+4 −2
Original line number Diff line number Diff line
@@ -116,8 +116,10 @@ typedef struct des_ks_struct
#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
	des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))

OPENSSL_EXTERN int des_check_key;	/* defaults to false */
OPENSSL_EXTERN int des_rw_mode;		/* defaults to DES_PCBC_MODE */
OPENSSL_DECLARE_GLOBAL(int,des_check_key);	/* defaults to false */
#define des_check_key OPENSSL_GLOBAL_REF(des_check_key)
OPENSSL_DECLARE_GLOBAL(int,des_rw_mode);	/* defaults to DES_PCBC_MODE */
#define des_rw_mode OPENSSL_GLOBAL_REF(des_rw_mode)

const char *des_options(void);
void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output,
Loading