Skip to content

Commit

Permalink
deps: make opensslconf.h work on multi platform
Browse files Browse the repository at this point in the history
This updates opensslconf.h generated on linux-x86_64 so as to work on
multi platform. Several defines are need to be changed according to
its architecture. See tables in `deps/openssl/doc/openssl_conf.pdf`
for details.

In addition to above, the following two changes were made.
- OPENSSL_CPUID_OBJ was commented out because it's already defined within GYP
- added `OPENSSL_NO_CAPIENG` define on WIN32 because it caused build
errors in linking functions of crypt32.lib. See comments in
`deps/openssl/openssl/engine/e_capi.c` for details.
  • Loading branch information
Shigeki Ohtsu committed Apr 6, 2015
1 parent f3fe676 commit 2d5ca2a
Showing 1 changed file with 105 additions and 22 deletions.
127 changes: 105 additions & 22 deletions deps/openssl/config/opensslconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@
#ifdef __cplusplus
extern "C" {
#endif

#undef OPENSSL_SYSNAME_WIN32
/* VC-WIN32 */
#if defined(_WIN32)
# define OPENSSL_SYSNAME_WIN32
#endif

#ifndef OPENSSL_SYSNAME_WIN64A
/* VC-WIN64A */
#if defined(_WIN64)
# define OPENSSL_SYSNAME_WIN64A
#endif

#undef OPENSSL_SYSNAME_MACOSX
/* darwin-i386, darwin64-x86_64 */
#if defined(__APPLE__) && defined(__MACH__)
# define OPENSSL_SYSNAME_MACOSX
#endif

/* for avoiding build error on engines/e_capi.c on Windows */
/* VC-WIN32, VC-WIN64A */
#if defined(_WIN32) || defined(_WIN64)
#define OPENSSL_NO_CAPIENG
#endif

/* OpenSSL was configured with the following options: */
#ifndef OPENSSL_DOING_MAKEDEPEND

Expand Down Expand Up @@ -51,7 +76,10 @@ extern "C" {
# define OPENSSL_THREADS
#endif
#ifndef OPENSSL_NO_DYNAMIC_ENGINE
# define OPENSSL_NO_DYNAMIC_ENGINE
/* linux-elf, linux-x86_64, dawrin-i386, darwin64-x86_64, linux-armv4, linux-aarch64 */
# if !defined(_WIN32) && !defined(_WIN64)
# define OPENSSL_NO_DYNAMIC_ENGINE
# endif
#endif

/* The OPENSSL_NO_* macros are also defined as NO_* if the application
Expand Down Expand Up @@ -97,7 +125,10 @@ extern "C" {
# endif
#endif

#define OPENSSL_CPUID_OBJ
/*
OPENSSL_CPUID_OBJ is already defined in compile option
#define OPENSSL_CPUID_OBJ
*/

/* crypto/opensslconf.h.in */

Expand All @@ -115,6 +146,10 @@ extern "C" {
#define OPENSSL_UNISTD <unistd.h>

#undef OPENSSL_EXPORT_VAR_AS_FUNCTION
/* VC-WIN32, VC-WIN64A */
#if defined(_WIN32) || defined(_WIN64)
#define OPENSSL_EXPORT_VAR_AS_FUNCTION
#endif

#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
#define IDEA_INT unsigned int
Expand All @@ -138,64 +173,111 @@ extern "C" {
* - Intel P6 because partial register stalls are very expensive;
* - elder Alpha because it lacks byte load/store instructions;
*/
#define RC4_INT unsigned int
/* linux-armv4, linux-aarch64 */
# if defined(__arm__) || defined(__aarch64__)
# define RC4_INT unsigned char
# else
/* linux-elf, linux-x86_64, darwin-i386, darwin64-x86_64, VC-WIN32, VC-WIN64A */
# define RC4_INT unsigned int
# endif
#endif
#if !defined(RC4_CHUNK)

/*
* This enables code handling data aligned at natural CPU word
* boundary. See crypto/rc4/rc4_enc.c for further details.
*/
#define RC4_CHUNK unsigned long
#endif
# undef RC4_CHUNK
/* VC-WIN64A, linux-x32 */
# if (defined(_WIN64) && defined(_M_X64)) || defined(_ILP32)
# define RC4_CHUNK unsigned long long
/* linux-x86_64, darwin64-x86_64, linux-armv4, linux-aarch64 */
# elif defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
# define RC4_CHUNK unsigned long
# else
/* On x86 RC4_CHUNK is not defined */
# endif
#endif

#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG)
/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
* %20 speed up (longs are 8 bytes, int's are 4). */
#ifndef DES_LONG
#define DES_LONG unsigned int
#endif
# undef DES_LONG
/* linux-x86_64, darwin64-x86_64, VC-WIN64A, linux-armv4, linux-aarch64 */
# if defined(__x86_64__) || defined(_M_X64) || defined(__arm__) || defined(__aarch64__)
# define DES_LONG unsigned int
/* darwin-i386, VC-WIN32 */
# else
# define DES_LONG unsigned long
# endif
#endif

#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
#define CONFIG_HEADER_BN_H
#undef BN_LLONG

/* linux-elf, darwin-i386, VC-WIN32, linux-armv4 */
#if defined(__i386__) || defined(_M_IX86) || defined(__arm__)
# define BN_LLONG
#endif
/* Should we define BN_DIV2W here? */

/* Only one for the following should be defined */
#define SIXTY_FOUR_BIT_LONG
#undef SIXTY_FOUR_BIT_LONG
#undef SIXTY_FOUR_BIT
#undef THIRTY_TWO_BIT
# if defined(_M_X64) || defined(__aarch64__) || defined(__x86_64__)
/* linux-x86_64, darwin64-x86_64, linux-aarch64*/
# if defined(_LP64)
# define SIXTY_FOUR_BIT_LONG
# else
/* VC-WIN64A */
# define SIXTY_FOUR_BIT
# endif
/* linux-elf, darwin-i386, VC-WIN32, linux-armv4 */
# elif defined(_M_IX86) || defined(__i386__) || defined(__arm__) || defined(__mips__)
# define THIRTY_TWO_BIT
# endif
#endif

#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
#define CONFIG_HEADER_RC4_LOCL_H
/* if this is defined data[i] is used instead of *data, this is a %20
* speedup on x86 */
#undef RC4_INDEX
# undef RC4_INDEX
/* linux-elf, VC-WIN32 */
# if (defined(__linux__) && defined(__i386__)) || (defined(__WIN32) && defined(_M_IX86))
# define RC4_INDEX
# endif
#endif
#endif

#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
#define CONFIG_HEADER_BF_LOCL_H
#undef BF_PTR
/* darwin-i386, linux-armv4 , linux-aarch64 */
#if (defined(__APPLE__) && defined(__MACH__)) || defined(__arm__) || defined(__aarch64__)
#define BF_PTR
#endif
#endif /* HEADER_BF_LOCL_H */

#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
#define CONFIG_HEADER_DES_LOCL_H
#ifndef DES_DEFAULT_OPTIONS
/* the following is tweaked from a config script, that is why it is a
* protected undef/define */
#ifndef DES_PTR
#undef DES_PTR
#endif
# undef DES_PTR
/* linux-elf */
# if defined(__linux__) && defined(__i386__)
# define DES_PTR
# endif

/* This helps C compiler generate the correct code for multiple functional
* units. It reduces register dependancies at the expense of 2 more
* registers */
#ifndef DES_RISC1
#undef DES_RISC1
#endif
# undef DES_RISC1
/* linux-elf, linux-armv4 */
# if (defined(__linux_) && defined(__i386__)) || defined(__arm__)
# define DES_RISC1
# endif

#ifndef DES_RISC2
#undef DES_RISC2
Expand All @@ -207,9 +289,10 @@ YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!

/* Unroll the inner loop, this sometimes helps, sometimes hinders.
* Very mucy CPU dependant */
#ifndef DES_UNROLL
#define DES_UNROLL
#endif
/* linux-elf, linux-x86_64, darwin-i386, darwin64-x86_64, linux-armv4, linux-aarch64 */
# if !(defined(_WIN32) || defined(_WIN64))
# define DES_UNROLL
# endif

/* These default values were supplied by
* Peter Gutman <[email protected]>
Expand All @@ -220,7 +303,7 @@ YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
even newer MIPS CPU's, but at the moment one size fits all for
optimization options. Older Sparc's work better with only UNROLL, but
there's no way to tell at compile time what it is you're running on */

#if defined( sun ) /* Newer Sparc's */
# define DES_PTR
# define DES_RISC1
Expand Down

0 comments on commit 2d5ca2a

Please sign in to comment.