Commit fa6a620b authored by Paul Bakker's avatar Paul Bakker
Browse files

Defines for UEFI environment under MSVC added

parent 178d9bac
......@@ -17,6 +17,7 @@ Bugfix
* Const correctness
* cert_write with selfsign should use issuer_name as subject_name
* Fix ECDSA corner case: missing reduction mod N (found by DualTachyon)
* Defines to handle UEFI environment under MSVC
= PolarSSL 1.3.1 released on 2013-10-15
Features
......
......@@ -31,7 +31,7 @@
#include <string.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......
......@@ -32,7 +32,7 @@
#include "config.h"
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
#if (_MSC_VER <= 1200)
typedef signed short int16_t;
......
......@@ -31,7 +31,7 @@
#include <string.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......
......@@ -31,7 +31,7 @@
#include <string.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......
......@@ -32,7 +32,14 @@
// Comment out to disable prototype change warnings
#define SHOW_PROTOTYPE_CHANGE_WARNINGS
#if defined _MSC_VER
#if defined(_MSC_VER) && !defined(inline)
#define inline _inline
#else
#if defined(__ARMCC_VERSION) && !defined(inline)
#define inline __inline
#endif /* __ARMCC_VERSION */
#if defined(_MSC_VER)
// MSVC does not support #warning
#undef SHOW_PROTOTYPE_CHANGE_WARNINGS
#endif
......
......@@ -31,7 +31,7 @@
#include <string.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......
......@@ -29,7 +29,7 @@
#include "cipher.h"
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
typedef UINT64 uint64_t;
......
......@@ -31,7 +31,7 @@
#include <string.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......
......@@ -31,7 +31,7 @@
#include <string.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......
......@@ -37,7 +37,7 @@
#define POLARSSL_HAVE_X86
#endif
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef INT32 int32_t;
#else
......
......@@ -34,7 +34,7 @@
#include "md.h"
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......
......@@ -34,7 +34,7 @@
#include "asn1.h"
#include "md.h"
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......
......@@ -31,7 +31,7 @@
#include <string.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......
......@@ -31,7 +31,7 @@
#include <string.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......
......@@ -31,7 +31,7 @@
#include <string.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......
......@@ -29,7 +29,7 @@
#include "polarssl/base64.h"
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......
......@@ -44,7 +44,7 @@
#define POLARSSL_CIPHER_MODE_STREAM
#endif
#if defined _MSC_VER && !defined strcasecmp
#if defined(_MSC_VER) && !defined strcasecmp
#define strcasecmp _stricmp
#endif
......
......@@ -32,11 +32,15 @@
#include <stdarg.h>
#include <stdlib.h>
#if defined _MSC_VER && !defined snprintf
#if defined(EFIX64) || defined(EFI32)
#include <stdio.h>
#endif
#if defined(_MSC_VER) && !defined snprintf
#define snprintf _snprintf
#endif
#if defined _MSC_VER && !defined vsnprintf
#if defined(_MSC_VER) && !defined vsnprintf
#define vsnprintf _vsnprintf
#endif
......
......@@ -38,7 +38,7 @@
#endif
#if !defined(POLARSSL_NO_PLATFORM_ENTROPY)
#if defined(_WIN32)
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
#if !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x0400
......
......@@ -160,7 +160,7 @@
#include <string.h>
#if defined _MSC_VER && !defined snprintf
#if defined(_MSC_VER) && !defined snprintf
#define snprintf _snprintf
#endif
......
......@@ -36,8 +36,8 @@
#include <stdlib.h>
#if defined _MSC_VER && !defined strcasecmp
#define strcasecmp _stricmp
#if defined(_MSC_VER) && !defined strcasecmp
#define snprintf _stricmp
#endif
static const int supported_digests[] = {
......
......@@ -29,7 +29,8 @@
#include "polarssl/net.h"
#if defined(_WIN32) || defined(_WIN32_WCE)
#if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(EFIX64) && \
!defined(EFI32)
#include <winsock2.h>
#include <windows.h>
......@@ -64,7 +65,8 @@ static int wsa_init_done = 0;
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
defined(__DragonflyBSD__)
#include <sys/endian.h>
#elif defined(__APPLE__) || defined(HAVE_MACHINE_ENDIAN_H)
#elif defined(__APPLE__) || defined(HAVE_MACHINE_ENDIAN_H) || \
defined(EFIX64) || defined(EFI32)
#include <machine/endian.h>
#elif defined(sun)
#include <sys/isa_defs.h>
......@@ -83,7 +85,7 @@ static int wsa_init_done = 0;
#include <time.h>
#endif
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......@@ -120,7 +122,9 @@ int net_connect( int *fd, const char *host, int port )
struct sockaddr_in server_addr;
struct hostent *server_host;
#if defined(_WIN32) || defined(_WIN32_WCE)
#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
WSADATA wsaData;
if( wsa_init_done == 0 )
......@@ -131,7 +135,9 @@ int net_connect( int *fd, const char *host, int port )
wsa_init_done = 1;
}
#else
#if !defined(EFIX64) && !defined(EFI32)
signal( SIGPIPE, SIG_IGN );
#endif
#endif
if( ( server_host = gethostbyname( host ) ) == NULL )
......@@ -165,7 +171,8 @@ int net_bind( int *fd, const char *bind_ip, int port )
int n, c[4];
struct sockaddr_in server_addr;
#if defined(_WIN32) || defined(_WIN32_WCE)
#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
WSADATA wsaData;
if( wsa_init_done == 0 )
......@@ -176,7 +183,9 @@ int net_bind( int *fd, const char *bind_ip, int port )
wsa_init_done = 1;
}
#else
#if !defined(EFIX64) && !defined(EFI32)
signal( SIGPIPE, SIG_IGN );
#endif
#endif
if( ( *fd = (int) socket( AF_INET, SOCK_STREAM, IPPROTO_IP ) ) < 0 )
......@@ -228,7 +237,8 @@ int net_bind( int *fd, const char *bind_ip, int port )
*/
static int net_is_blocking( void )
{
#if defined(_WIN32) || defined(_WIN32_WCE)
#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
return( WSAGetLastError() == WSAEWOULDBLOCK );
#else
switch( errno )
......@@ -282,7 +292,8 @@ int net_accept( int bind_fd, int *client_fd, void *client_ip )
*/
int net_set_block( int fd )
{
#if defined(_WIN32) || defined(_WIN32_WCE)
#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
u_long n = 0;
return( ioctlsocket( fd, FIONBIO, &n ) );
#else
......@@ -292,7 +303,8 @@ int net_set_block( int fd )
int net_set_nonblock( int fd )
{
#if defined(_WIN32) || defined(_WIN32_WCE)
#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
u_long n = 1;
return( ioctlsocket( fd, FIONBIO, &n ) );
#else
......@@ -317,7 +329,7 @@ void net_usleep( unsigned long usec )
* Read at most 'len' characters
*/
int net_recv( void *ctx, unsigned char *buf, size_t len )
{
{
int ret = read( *((int *) ctx), buf, len );
if( ret < 0 )
......@@ -325,7 +337,8 @@ int net_recv( void *ctx, unsigned char *buf, size_t len )
if( net_is_blocking() != 0 )
return( POLARSSL_ERR_NET_WANT_READ );
#if defined(_WIN32) || defined(_WIN32_WCE)
#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
if( WSAGetLastError() == WSAECONNRESET )
return( POLARSSL_ERR_NET_CONN_RESET );
#else
......@@ -354,7 +367,8 @@ int net_send( void *ctx, const unsigned char *buf, size_t len )
if( net_is_blocking() != 0 )
return( POLARSSL_ERR_NET_WANT_WRITE );
#if defined(_WIN32) || defined(_WIN32_WCE)
#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
if( WSAGetLastError() == WSAECONNRESET )
return( POLARSSL_ERR_NET_CONN_RESET );
#else
......
......@@ -530,7 +530,7 @@ FN_OID_TYPED_FROM_ASN1(oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, oid_pkcs12_pbe_alg)
FN_OID_GET_ATTR2(oid_get_pkcs12_pbe_alg, oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, md_type_t, md_alg, cipher_type_t, cipher_alg);
#endif /* POLARSSL_PKCS12_C */
#if defined _MSC_VER && !defined snprintf
#if defined(_MSC_VER) && !defined snprintf
#include <stdarg.h>
#if !defined vsnprintf
......
......@@ -34,7 +34,7 @@
#include <stdlib.h>
#if defined _MSC_VER && !defined strcasecmp
#if defined(_MSC_VER) && !defined strcasecmp
#define strcasecmp _stricmp
#endif
......
......@@ -40,7 +40,7 @@
#include <stdlib.h>
#include <stdio.h>
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h>
typedef UINT32 uint32_t;
#else
......
......@@ -47,7 +47,7 @@
#include <stdlib.h>
#if defined _MSC_VER && !defined strcasecmp
#if defined(_MSC_VER) && !defined strcasecmp
#define strcasecmp _stricmp
#endif
......
......@@ -29,7 +29,7 @@
#include "polarssl/timing.h"
#if defined(_WIN32)
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
#include <windows.h>
#include <winbase.h>
......@@ -172,14 +172,15 @@ unsigned long hardclock( void )
}
#endif
#if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(_MSC_VER)
#if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(_MSC_VER) && \
!defined(EFIX64) && !defined(EFI32)
#define POLARSSL_HAVE_HARDCLOCK
unsigned long hardclock( void )
{
LARGE_INTEGER offset;
QueryPerformanceCounter( &offset );
return (unsigned long)( offset.QuadPart );
......@@ -211,7 +212,7 @@ unsigned long hardclock( void )
volatile int alarmed = 0;
#if defined(_WIN32)
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
unsigned long get_timer( struct hr_time *val, int reset )
{
......
......@@ -54,12 +54,16 @@
#include <string.h>
#include <stdlib.h>
#if defined(_WIN32)
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
#include <windows.h>
#else
#include <time.h>
#endif
#if defined(EFIX64) || defined(EFI32)
#include <stdio.h>
#endif
#if defined(POLARSSL_FS_IO)
#include <stdio.h>
#if !defined(_WIN32)
......@@ -425,7 +429,7 @@ int x509_load_file( const char *path, unsigned char **buf, size_t *n )
}
#endif /* POLARSSL_FS_IO */
#if defined _MSC_VER && !defined snprintf
#if defined(_MSC_VER) && !defined snprintf
#include <stdarg.h>
#if !defined vsnprintf
......@@ -620,7 +624,7 @@ int x509_time_expired( const x509_time *to )
int year, mon, day;
int hour, min, sec;
#if defined(_WIN32)
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
SYSTEMTIME st;
GetLocalTime(&st);
......
......@@ -53,13 +53,14 @@
#include <string.h>
#include <stdlib.h>
#if defined(_WIN32)
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
#include <windows.h>
#else
#include <time.h>
#endif
#if defined(POLARSSL_FS_IO)
#if defined(POLARSSL_FS_IO) || defined(EFIX64) || defined(EFI32)
#include <stdio.h>
#endif
......@@ -544,7 +545,7 @@ int x509_crl_parse_file( x509_crl *chain, const char *path )
}
#endif /* POLARSSL_FS_IO */
#if defined _MSC_VER && !defined snprintf
#if defined(_MSC_VER) && !defined snprintf
#include <stdarg.h>
#if !defined vsnprintf
......
......@@ -53,12 +53,16 @@
#include <string.h>
#include <stdlib.h>
#if defined(_WIN32)
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
#include <windows.h>
#else
#include <time.h>
#endif
#if defined(EFIX64) || defined(EFI32)
#include <stdio.h>
#endif
#if defined(POLARSSL_FS_IO)
#include <stdio.h>
#if !defined(_WIN32)
......@@ -935,7 +939,7 @@ int x509_crt_parse_file( x509_crt *chain, const char *path )
int x509_crt_parse_path( x509_crt *chain, const char *path )
{
int ret = 0;
#if defined(_WIN32)
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
int w_ret;
WCHAR szDir[MAX_PATH];
char filename[MAX_PATH];
......@@ -1035,7 +1039,7 @@ int x509_crt_parse_path( x509_crt *chain, const char *path )
}
#endif /* POLARSSL_FS_IO */
#if defined _MSC_VER && !defined snprintf
#if defined(_MSC_VER) && !defined snprintf
#include <stdarg.h>
#if !defined vsnprintf
......
......@@ -54,7 +54,7 @@
#include <string.h>
#include <stdlib.h>
#if defined(POLARSSL_FS_IO)
#if defined(POLARSSL_FS_IO) || defined(EFIX64) || defined(EFI32)
#include <stdio.h>
#endif
......@@ -302,7 +302,7 @@ int x509_csr_parse_file( x509_csr *csr, const char *path )
}
#endif /* POLARSSL_FS_IO */
#if defined _MSC_VER && !defined snprintf
#if defined(_MSC_VER) && !defined snprintf
#include <stdarg.h>
#if !defined vsnprintf
......
......@@ -33,7 +33,11 @@ HEADER_INCLUDED
#include <string.h>
#if defined _MSC_VER && !defined snprintf
#if defined(EFIX64) || defined(EFI32)
#include <stdio.h>
#endif
#if defined(_MSC_VER) && !defined snprintf
#define snprintf _snprintf
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment