Skip to content

Commit e9a7e94

Browse files
karel-msjaeckel
authored andcommitted
fix build failures with -std=c99
1 parent 9841566 commit e9a7e94

11 files changed

Lines changed: 17 additions & 8 deletions

File tree

demos/constants.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* LibTomCrypt, modular cryptographic library -- Tom St Denis */
22
/* SPDX-License-Identifier: Unlicense */
3+
4+
#define _POSIX_C_SOURCE 200809L /* otherwise PATH_MAX + strdup are not defined for build with -std=c99 */
35
#include "tomcrypt.h"
46

57
#include <string.h>

demos/hashsum.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* more functions ;)
1111
*/
1212

13+
#define _POSIX_C_SOURCE 200809L /* otherwise PATH_MAX + strdup are not defined for build with -std=c99 */
1314
#include <tomcrypt.h>
1415

1516
#include <string.h>

demos/sizes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* LibTomCrypt, modular cryptographic library -- Tom St Denis */
22
/* SPDX-License-Identifier: Unlicense */
33

4+
#define _POSIX_C_SOURCE 200809L /* otherwise PATH_MAX + strdup are not defined for build with -std=c99 */
45
#include "tomcrypt.h"
56

67
#include <string.h>

src/ciphers/aes/aes_desc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static LTC_INLINE void s_x86_cpuid(int* regs, int leaf)
2222

2323
a = leaf;
2424
b = c = d = 0;
25-
asm volatile ("cpuid"
25+
__asm__ volatile ("cpuid"
2626
:"=a"(a), "=b"(b), "=c"(c), "=d"(d)
2727
:"a"(a), "c"(c)
2828
);

src/encauth/gcm/gcm_gf_mult.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static LTC_INLINE void s_x86_cpuid(int* regs, int leaf)
4040

4141
a = leaf;
4242
b = c = d = 0;
43-
asm volatile ("cpuid"
43+
__asm__ volatile ("cpuid"
4444
:"=a"(a), "=b"(b), "=c"(c), "=d"(d)
4545
:"a"(a), "c"(c)
4646
);

src/hashes/sha1_desc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static LTC_INLINE void s_x86_cpuid(int* regs, int leaf)
3535

3636
a = leaf;
3737
b = c = d = 0;
38-
asm volatile ("cpuid"
38+
__asm__ volatile ("cpuid"
3939
:"=a"(a), "=b"(b), "=c"(c), "=d"(d)
4040
:"a"(a), "c"(c)
4141
);

src/hashes/sha2/sha224_desc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static LTC_INLINE void s_x86_cpuid(int* regs, int leaf)
4040

4141
a = leaf;
4242
b = c = d = 0;
43-
asm volatile ("cpuid"
43+
__asm__ volatile ("cpuid"
4444
:"=a"(a), "=b"(b), "=c"(c), "=d"(d)
4545
:"a"(a), "c"(c)
4646
);

src/hashes/sha2/sha256_desc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static LTC_INLINE void s_x86_cpuid(int* regs, int leaf)
1515

1616
a = leaf;
1717
b = c = d = 0;
18-
asm volatile ("cpuid"
18+
__asm__ volatile ("cpuid"
1919
:"=a"(a), "=b"(b), "=c"(c), "=d"(d)
2020
:"a"(a), "c"(c)
2121
);

tests/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* LibTomCrypt, modular cryptographic library -- Tom St Denis */
22
/* SPDX-License-Identifier: Unlicense */
33

4-
#include "common.h"
4+
#include <tomcrypt_test.h>
55

66
/**
77
@file common.c

tests/der_test.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,11 @@ static void der_Xcode_run(const der_Xcode_t* x)
966966
}
967967

968968
#if defined(_MSC_VER)
969-
#define typeof(x) x
969+
#define LTC_TYPEOF(x) x
970+
#elif defined(__GNUC__) && defined(__STRICT_ANSI__)
971+
#define LTC_TYPEOF(x) __typeof__(x) /* needed for build with -std=c99 */
972+
#else
973+
#define LTC_TYPEOF(x) typeof(x)
970974
#endif
971975

972976
#define DER_XCODE_X(n, b, x) { \
@@ -975,7 +979,7 @@ static void der_Xcode_run(const der_Xcode_t* x)
975979
b, \
976980
sizeof(b), \
977981
x, \
978-
sizeof(typeof(b[0])),\
982+
sizeof(LTC_TYPEOF(b[0])),\
979983
#n \
980984
}
981985

0 commit comments

Comments
 (0)