GNU Radio's M17 Package
types.h
Go to the documentation of this file.
1/* Copyright 2015, Kenneth MacKay. Licensed under the BSD 2-clause license. */
2
3#ifndef _UECC_TYPES_H_
4#define _UECC_TYPES_H_
5
6#ifndef uECC_PLATFORM
7 #if __AVR__
8 #define uECC_PLATFORM uECC_avr
9 #elif defined(__thumb2__) || defined(_M_ARMT) /* I think MSVC only supports Thumb-2 targets */
10 #define uECC_PLATFORM uECC_arm_thumb2
11 #elif defined(__thumb__)
12 #define uECC_PLATFORM uECC_arm_thumb
13 #elif defined(__arm__) || defined(_M_ARM)
14 #define uECC_PLATFORM uECC_arm
15 #elif defined(__aarch64__)
16 #define uECC_PLATFORM uECC_arm64
17 #elif defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__I86__)
18 #define uECC_PLATFORM uECC_x86
19 #elif defined(__amd64__) || defined(_M_X64)
20 #define uECC_PLATFORM uECC_x86_64
21 #else
22 #define uECC_PLATFORM uECC_arch_other
23 #endif
24#endif
25
26#ifndef uECC_ARM_USE_UMAAL
27 #if (uECC_PLATFORM == uECC_arm) && (__ARM_ARCH >= 6)
28 #define uECC_ARM_USE_UMAAL 1
29 #elif (uECC_PLATFORM == uECC_arm_thumb2) && (__ARM_ARCH >= 6) && !__ARM_ARCH_7M__
30 #define uECC_ARM_USE_UMAAL 1
31 #else
32 #define uECC_ARM_USE_UMAAL 0
33 #endif
34#endif
35
36#ifndef uECC_WORD_SIZE
37 #if uECC_PLATFORM == uECC_avr
38 #define uECC_WORD_SIZE 1
39 #elif (uECC_PLATFORM == uECC_x86_64 || uECC_PLATFORM == uECC_arm64)
40 #define uECC_WORD_SIZE 8
41 #else
42 #define uECC_WORD_SIZE 4
43 #endif
44#endif
45
46#if (uECC_WORD_SIZE != 1) && (uECC_WORD_SIZE != 4) && (uECC_WORD_SIZE != 8)
47 #error "Unsupported value for uECC_WORD_SIZE"
48#endif
49
50#if ((uECC_PLATFORM == uECC_avr) && (uECC_WORD_SIZE != 1))
51 #pragma message ("uECC_WORD_SIZE must be 1 for AVR")
52 #undef uECC_WORD_SIZE
53 #define uECC_WORD_SIZE 1
54#endif
55
56#if ((uECC_PLATFORM == uECC_arm || uECC_PLATFORM == uECC_arm_thumb || \
57 uECC_PLATFORM == uECC_arm_thumb2) && \
58 (uECC_WORD_SIZE != 4))
59 #pragma message ("uECC_WORD_SIZE must be 4 for ARM")
60 #undef uECC_WORD_SIZE
61 #define uECC_WORD_SIZE 4
62#endif
63
64#if defined(__SIZEOF_INT128__) || ((__clang_major__ * 100 + __clang_minor__) >= 302)
65 #define SUPPORTS_INT128 1
66#else
67 #define SUPPORTS_INT128 0
68#endif
69
70typedef int8_t wordcount_t;
71typedef int16_t bitcount_t;
72typedef int8_t cmpresult_t;
73
74#if (uECC_WORD_SIZE == 1)
75
76typedef uint8_t uECC_word_t;
77typedef uint16_t uECC_dword_t;
78
79#define HIGH_BIT_SET 0x80
80#define uECC_WORD_BITS 8
81#define uECC_WORD_BITS_SHIFT 3
82#define uECC_WORD_BITS_MASK 0x07
83
84#elif (uECC_WORD_SIZE == 4)
85
86typedef uint32_t uECC_word_t;
87typedef uint64_t uECC_dword_t;
88
89#define HIGH_BIT_SET 0x80000000
90#define uECC_WORD_BITS 32
91#define uECC_WORD_BITS_SHIFT 5
92#define uECC_WORD_BITS_MASK 0x01F
93
94#elif (uECC_WORD_SIZE == 8)
95
96typedef uint64_t uECC_word_t;
97#if SUPPORTS_INT128
98typedef unsigned __int128 uECC_dword_t;
99#endif
100
101#define HIGH_BIT_SET 0x8000000000000000ull
102#define uECC_WORD_BITS 64
103#define uECC_WORD_BITS_SHIFT 6
104#define uECC_WORD_BITS_MASK 0x03F
105
106#endif /* uECC_WORD_SIZE */
107
108#endif /* _UECC_TYPES_H_ */
uint64_t uECC_dword_t
Definition types.h:87
int8_t wordcount_t
Definition types.h:70
int8_t cmpresult_t
Definition types.h:72
int16_t bitcount_t
Definition types.h:71
uint32_t uECC_word_t
Definition types.h:86