mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 18:05:37 +01:00
Merge pull request #165 from ARMmbed/dev/dgreen-arm/windows_proj_wip
Windows build fixes (#165)
This commit is contained in:
commit
2d23af75da
@ -200,5 +200,6 @@ clean:
|
|||||||
ifndef WINDOWS
|
ifndef WINDOWS
|
||||||
rm -f *.o libmbed*
|
rm -f *.o libmbed*
|
||||||
else
|
else
|
||||||
del /Q /F *.o libmbed*
|
if exist *.o del /Q /F *.o
|
||||||
|
if exist libmbed* del /Q /F libmbed*
|
||||||
endif
|
endif
|
||||||
|
@ -96,7 +96,12 @@ all: $(APPS)
|
|||||||
$(DEP):
|
$(DEP):
|
||||||
$(MAKE) -C ../library
|
$(MAKE) -C ../library
|
||||||
|
|
||||||
|
ifdef WINDOWS
|
||||||
|
EXTRA_GENERATED += psa\psa_constant_names_generated.c
|
||||||
|
else
|
||||||
EXTRA_GENERATED += psa/psa_constant_names_generated.c
|
EXTRA_GENERATED += psa/psa_constant_names_generated.c
|
||||||
|
endif
|
||||||
|
|
||||||
psa/psa_constant_names$(EXEXT): psa/psa_constant_names_generated.c
|
psa/psa_constant_names$(EXEXT): psa/psa_constant_names_generated.c
|
||||||
psa/psa_constant_names_generated.c: ../scripts/generate_psa_constants.py ../include/psa/crypto.h
|
psa/psa_constant_names_generated.c: ../scripts/generate_psa_constants.py ../include/psa/crypto.h
|
||||||
../scripts/generate_psa_constants.py
|
../scripts/generate_psa_constants.py
|
||||||
@ -317,7 +322,9 @@ clean:
|
|||||||
ifndef WINDOWS
|
ifndef WINDOWS
|
||||||
rm -f $(APPS) $(EXTRA_GENERATED)
|
rm -f $(APPS) $(EXTRA_GENERATED)
|
||||||
else
|
else
|
||||||
del /S /Q /F *.o *.exe $(EXTRA_GENERATED)
|
if exist *.o del /S /Q /F *.o
|
||||||
|
if exist *.exe del /S /Q /F *.exe
|
||||||
|
if exist $(EXTRA_GENERATED) del /S /Q /F $(EXTRA_GENERATED)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
list:
|
list:
|
||||||
|
@ -4,6 +4,35 @@
|
|||||||
|
|
||||||
#include "psa/crypto.h"
|
#include "psa/crypto.h"
|
||||||
|
|
||||||
|
/* This block is present to support Visual Studio builds prior to 2015 */
|
||||||
|
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||||
|
#include <stdarg.h>
|
||||||
|
int snprintf( char *s, size_t n, const char *fmt, ... )
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
va_list argp;
|
||||||
|
|
||||||
|
/* Avoid calling the invalid parameter handler by checking ourselves */
|
||||||
|
if( s == NULL || n == 0 || fmt == NULL )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
|
va_start( argp, fmt );
|
||||||
|
#if defined(_TRUNCATE) && !defined(__MINGW32__)
|
||||||
|
ret = _vsnprintf_s( s, n, _TRUNCATE, fmt, argp );
|
||||||
|
#else
|
||||||
|
ret = _vsnprintf( s, n, fmt, argp );
|
||||||
|
if( ret < 0 || (size_t) ret == n )
|
||||||
|
{
|
||||||
|
s[n-1] = '\0';
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
va_end( argp );
|
||||||
|
|
||||||
|
return( ret );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* There are different GET_HASH macros for different kinds of algorithms
|
/* There are different GET_HASH macros for different kinds of algorithms
|
||||||
* built from hashes, but the values are all constructed on the
|
* built from hashes, but the values are all constructed on the
|
||||||
* same model. */
|
* same model. */
|
||||||
@ -83,9 +112,9 @@ static int psa_snprint_status(char *buffer, size_t buffer_size,
|
|||||||
size_t length = strlen(name);
|
size_t length = strlen(name);
|
||||||
if (length < buffer_size) {
|
if (length < buffer_size) {
|
||||||
memcpy(buffer, name, length + 1);
|
memcpy(buffer, name, length + 1);
|
||||||
return length;
|
return (int) length;
|
||||||
} else {
|
} else {
|
||||||
return buffer_size;
|
return (int) buffer_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,9 +129,9 @@ static int psa_snprint_ecc_curve(char *buffer, size_t buffer_size,
|
|||||||
size_t length = strlen(name);
|
size_t length = strlen(name);
|
||||||
if (length < buffer_size) {
|
if (length < buffer_size) {
|
||||||
memcpy(buffer, name, length + 1);
|
memcpy(buffer, name, length + 1);
|
||||||
return length;
|
return (int) length;
|
||||||
} else {
|
} else {
|
||||||
return buffer_size;
|
return (int) buffer_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,15 +173,15 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(argv[1], "error") || !strcmp(argv[1], "status"))
|
if (!strcmp(argv[1], "error") || !strcmp(argv[1], "status"))
|
||||||
psa_snprint_status(buffer, sizeof(buffer), value);
|
psa_snprint_status(buffer, sizeof(buffer), (psa_status_t) value);
|
||||||
else if (!strcmp(argv[1], "alg") || !strcmp(argv[1], "algorithm"))
|
else if (!strcmp(argv[1], "alg") || !strcmp(argv[1], "algorithm"))
|
||||||
psa_snprint_algorithm(buffer, sizeof(buffer), value);
|
psa_snprint_algorithm(buffer, sizeof(buffer), (psa_algorithm_t) value);
|
||||||
else if (!strcmp(argv[1], "curve") || !strcmp(argv[1], "ecc_curve"))
|
else if (!strcmp(argv[1], "curve") || !strcmp(argv[1], "ecc_curve"))
|
||||||
psa_snprint_ecc_curve(buffer, sizeof(buffer), value);
|
psa_snprint_ecc_curve(buffer, sizeof(buffer), (psa_ecc_curve_t) value);
|
||||||
else if (!strcmp(argv[1], "type") || !strcmp(argv[1], "key_type"))
|
else if (!strcmp(argv[1], "type") || !strcmp(argv[1], "key_type"))
|
||||||
psa_snprint_key_type(buffer, sizeof(buffer), value);
|
psa_snprint_key_type(buffer, sizeof(buffer), (psa_key_type_t) value);
|
||||||
else if (!strcmp(argv[1], "usage") || !strcmp(argv[1], "key_usage"))
|
else if (!strcmp(argv[1], "usage") || !strcmp(argv[1], "key_usage"))
|
||||||
psa_snprint_key_usage(buffer, sizeof(buffer), value);
|
psa_snprint_key_usage(buffer, sizeof(buffer), (psa_key_usage_t) value);
|
||||||
else {
|
else {
|
||||||
printf("Unknown type: %s\n", argv[1]);
|
printf("Unknown type: %s\n", argv[1]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -44,7 +44,7 @@ static int psa_snprint_key_type(char *buffer, size_t buffer_size,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
return required_size;
|
return (int) required_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int psa_snprint_algorithm(char *buffer, size_t buffer_size,
|
static int psa_snprint_algorithm(char *buffer, size_t buffer_size,
|
||||||
@ -84,7 +84,7 @@ static int psa_snprint_algorithm(char *buffer, size_t buffer_size,
|
|||||||
append(&buffer, buffer_size, &required_size, ")", 1);
|
append(&buffer, buffer_size, &required_size, ")", 1);
|
||||||
}
|
}
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
return required_size;
|
return (int) required_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int psa_snprint_key_usage(char *buffer, size_t buffer_size,
|
static int psa_snprint_key_usage(char *buffer, size_t buffer_size,
|
||||||
@ -110,7 +110,7 @@ static int psa_snprint_key_usage(char *buffer, size_t buffer_size,
|
|||||||
} else {
|
} else {
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
}
|
}
|
||||||
return required_size;
|
return (int) required_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of automatically generated file. */
|
/* End of automatically generated file. */
|
||||||
|
@ -107,7 +107,9 @@ clean:
|
|||||||
ifndef WINDOWS
|
ifndef WINDOWS
|
||||||
rm -rf $(BINARIES) *.c *.datax TESTS
|
rm -rf $(BINARIES) *.c *.datax TESTS
|
||||||
else
|
else
|
||||||
del /Q /F *.c *.exe *.datax
|
if exist *.c del /Q /F *.c
|
||||||
|
if exist *.exe del /Q /F *.exe
|
||||||
|
if exist *.datax del /Q /F *.datax
|
||||||
ifneq ($(wildcard TESTS/.*),)
|
ifneq ($(wildcard TESTS/.*),)
|
||||||
rmdir /Q /S TESTS
|
rmdir /Q /S TESTS
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user