]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Include/OpenSslSupport.h
CryptoPkg: Fix handling of &strcmp function pointers
[mirror_edk2.git] / CryptoPkg / Include / OpenSslSupport.h
index 2c6e23cee3fed473839fc488d39778fb07fcf4ca..e6858a94a484f49c6ede8943c7185ee918d8de84 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Root include file to support building OpenSSL Crypto Library.\r
 \r
-Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -21,8 +21,36 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DebugLib.h>\r
 \r
+#define OPENSSLDIR ""\r
+#define ENGINESDIR ""\r
+\r
 #define MAX_STRING_SIZE  0x1000\r
 \r
+//\r
+// OpenSSL relies on explicit configuration for word size in crypto/bn,\r
+// but we want it to be automatically inferred from the target. So we\r
+// bypass what's in <openssl/opensslconf.h> for OPENSSL_SYS_UEFI, and\r
+// define our own here.\r
+//\r
+#ifdef CONFIG_HEADER_BN_H\r
+#error CONFIG_HEADER_BN_H already defined\r
+#endif\r
+\r
+#define CONFIG_HEADER_BN_H\r
+\r
+#if defined(MDE_CPU_X64) || defined(MDE_CPU_AARCH64) || defined(MDE_CPU_IA64)\r
+//\r
+// With GCC we would normally use SIXTY_FOUR_BIT_LONG, but MSVC needs\r
+// SIXTY_FOUR_BIT, because 'long' is 32-bit and only 'long long' is\r
+// 64-bit. Since using 'long long' works fine on GCC too, just do that.\r
+//\r
+#define SIXTY_FOUR_BIT\r
+#elif defined(MDE_CPU_IA32) || defined(MDE_CPU_ARM) || defined(MDE_CPU_EBC)\r
+#define THIRTY_TWO_BIT\r
+#else\r
+#error Unknown target architecture\r
+#endif\r
+\r
 //\r
 // File operations are not required for building Open SSL, \r
 // so FILE is mapped to VOID * to pass build\r
@@ -44,7 +72,7 @@ typedef VOID  *FILE;
 #endif\r
 \r
 //\r
-// #defines from EFI Application Toolkit required to buiild Open SSL\r
+// #defines from EFI Application Toolkit required to build Open SSL\r
 //\r
 #define ENOMEM       12               /* Cannot allocate memory */\r
 #define EINVAL       22               /* Invalid argument */\r
@@ -65,9 +93,10 @@ typedef VOID  *FILE;
 #define LOG_DEBUG    7                /* debug-level messages */\r
 #define LOG_PID      0x01             /* log the pid with each message */\r
 #define LOG_CONS     0x02             /* log on the console if errors in sending */\r
+#define CHAR_BIT     8                /* Number of bits in a char */\r
 \r
 //\r
-// Macros from EFI Application Toolkit required to buiild Open SSL\r
+// Macros from EFI Application Toolkit required to build Open SSL\r
 //\r
 /* The offsetof() macro calculates the offset of a structure member\r
    in its structure.  Unfortunately this cannot be written down\r
@@ -77,7 +106,7 @@ typedef VOID  *FILE;
 #define offsetof(type, member) OFFSET_OF (type, member)\r
 \r
 //\r
-// Basic types from EFI Application Toolkit required to buiild Open SSL\r
+// Basic types from EFI Application Toolkit required to build Open SSL\r
 //\r
 typedef UINTN          size_t;\r
 typedef INTN           ssize_t;\r
@@ -93,9 +122,11 @@ typedef UINT16         nlink_t;
 typedef int            pid_t;\r
 typedef void           *DIR;\r
 typedef void           __sighandler_t (int);\r
+typedef UINT8          __uint8_t;\r
+typedef UINT8          sa_family_t;\r
 \r
 //\r
-// Structures from EFI Application Toolkit required to buiild Open SSL\r
+// Structures from EFI Application Toolkit required to build Open SSL\r
 //\r
 struct tm {\r
   int   tm_sec;     /* seconds after the minute [0-60] */\r
@@ -114,7 +145,7 @@ struct tm {
 struct timeval {\r
   long tv_sec;      /* time value, in seconds */\r
   long tv_usec;     /* time value, in microseconds */\r
-} timeval;\r
+};\r
 \r
 struct dirent {\r
   UINT32  d_fileno;         /* file number of entry */\r
@@ -147,13 +178,19 @@ struct stat {
   INT64    st_qspare[2];\r
 };\r
 \r
+struct sockaddr {\r
+  __uint8_t sa_len;         /* total length */\r
+  sa_family_t sa_family;    /* address family */\r
+  char    sa_data[14];      /* actually longer; address value */\r
+};\r
+\r
 //\r
-// Externs from EFI Application Toolkit required to buiild Open SSL\r
+// Externs from EFI Application Toolkit required to build Open SSL\r
 //\r
 extern int errno;\r
 \r
 //\r
-// Function prototypes from EFI Application Toolkit required to buiild Open SSL\r
+// Function prototypes from EFI Application Toolkit required to build Open SSL\r
 //\r
 void           *malloc     (size_t);\r
 void           *realloc    (void *, size_t);\r
@@ -183,6 +220,9 @@ int            strncmp     (const char *, const char *, size_t);
 char           *strrchr    (const char *, int);\r
 unsigned long  strtoul     (const char *, char **, int);\r
 long           strtol      (const char *, char **, int);\r
+char           *strerror   (int);\r
+size_t         strspn      (const char *, const char *);\r
+size_t         strcspn     (const char *, const char *);\r
 int            printf      (const char *, ...);\r
 int            sscanf      (const char *, const char *, ...);\r
 int            open        (const char *, int, ...);\r
@@ -222,7 +262,7 @@ void           abort       (void);
 __sighandler_t *signal     (int, __sighandler_t *);\r
 \r
 //\r
-// Global variables from EFI Application Toolkit required to buiild Open SSL\r
+// Global variables from EFI Application Toolkit required to build Open SSL\r
 //\r
 extern FILE  *stderr;\r
 extern FILE  *stdin;\r
@@ -236,7 +276,6 @@ extern FILE  *stdout;
 #define memchr(buf,ch,count)              ScanMem8(buf,(UINTN)(count),(UINT8)ch)\r
 #define memcmp(buf1,buf2,count)           (int)(CompareMem(buf1,buf2,(UINTN)(count)))\r
 #define memmove(dest,source,count)        CopyMem(dest,source,(UINTN)(count))\r
-#define strcmp                            AsciiStrCmp\r
 #define strncmp(string1,string2,count)    (int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))\r
 #define strcpy(strDest,strSource)         AsciiStrCpyS(strDest,MAX_STRING_SIZE,strSource)\r
 #define strncpy(strDest,strSource,count)  AsciiStrnCpyS(strDest,MAX_STRING_SIZE,strSource,(UINTN)count)\r
@@ -248,5 +287,6 @@ extern FILE  *stdout;
 #define localtime(timer)                  NULL\r
 #define gmtime_r(timer,result)            (result = NULL)\r
 #define atoi(nptr)                        AsciiStrDecimalToUintn(nptr)\r
+#define gettimeofday(tvp,tz)              do { (tvp)->tv_sec = time(NULL); (tvp)->tv_usec = 0; } while (0)\r
 \r
 #endif\r