1 /* 2 * Copyright (C) 2017 - This file is part of libecc project 3 * 4 * Authors: 5 * Ryad BENADJILA <ryadbenadjila@gmail.com> 6 * Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr> 7 * Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr> 8 * 9 * Contributors: 10 * Nicolas VIVET <nicolas.vivet@ssi.gouv.fr> 11 * Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr> 12 * 13 * This software is licensed under a dual BSD and GPL v2 license. 14 * See LICENSE file at the root folder of the project. 15 */ 16 #ifndef __WORDS_64_H__ 17 #define __WORDS_64_H__ 18 19 /* 20 * Types for 64-bit long words and a few useful macros. 21 */ 22 23 #include "types.h" 24 25 typedef uint64_t word_t; 26 typedef uint32_t hword_t; 27 28 /* WORD_BITS (resp. WORD_BYTES): number of bits (resp. bytes) in a word. */ 29 #define WORD_BITS (64) 30 #define WORD_BYTES (WORD_BITS / 8) 31 #define HWORD_BITS (32) 32 #define HWORD_BYTES (HWORD_BITS / 8) 33 34 /* WORD: constant of word-size. */ 35 #define WORD(A) (UINT64_C(A)) 36 #define HWORD(A) (UINT32_C(A)) 37 38 /* WORD_MAX: maximal value of a word. */ 39 #define WORD_MAX UINT64_MAX 40 #define HWORD_MAX UINT32_MAX 41 42 /* Prefix for the specific case of u32 that can be either 43 * unsigned int or unsigned long 44 */ 45 #ifdef UINT32_IS_LONG 46 #define PRI32_PREFIX "l" 47 #else 48 #define PRI32_PREFIX 49 #endif 50 51 /* PRINTF_WORD_HEX_FMT: printf hex format string for word */ 52 #ifndef PRIx16 53 #define PRIx16 "hx" 54 #endif 55 #ifndef PRIx32 56 #define PRIx32 PRI32_PREFIX "x" 57 #endif 58 #ifndef PRIx64 59 #define PRIx64 "llx" 60 #endif 61 62 #define PRINTF_WORD_HEX_FMT "%016" PRIx64 63 64 #ifndef PRIu16 65 #define PRIu16 "hu" 66 #endif 67 #ifndef PRIu32 68 #define PRIu32 PRI32_PREFIX "u" 69 #endif 70 #ifndef PRIu64 71 #define PRIu64 "llu" 72 #endif 73 74 #endif /* __WORDS_64_H__ */ 75