MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxClMemory_Endianness.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/* Copyright 2020-2021 NXP */
3
/* */
4
/* SPDX-License-Identifier: BSD-3-Clause */
5
/* */
6
/* Redistribution and use in source and binary forms, with or without */
7
/* modification, are permitted provided that the following conditions are */
8
/* met: */
9
/* */
10
/* 1. Redistributions of source code must retain the above copyright */
11
/* notice, this list of conditions and the following disclaimer. */
12
/* */
13
/* 2. Redistributions in binary form must reproduce the above copyright */
14
/* notice, this list of conditions and the following disclaimer in the */
15
/* documentation and/or other materials provided with the distribution. */
16
/* */
17
/* 3. Neither the name of the copyright holder nor the names of its */
18
/* contributors may be used to endorse or promote products derived from */
19
/* this software without specific prior written permission. */
20
/* */
21
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS */
22
/* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
23
/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
24
/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
25
/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
26
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
27
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR */
28
/* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
29
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
30
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
31
/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
32
/*--------------------------------------------------------------------------*/
33
38
45
46
#ifndef MCUXCLMEMORY_ENDIANNESS_H_
47
#define MCUXCLMEMORY_ENDIANNESS_H_
48
49
#include <
mcuxClMemory_Types.h
>
50
#include <mcuxClConfig.h>
// Exported features flags header
51
52
53
/**********************************************
54
* MACROS
55
**********************************************/
56
66
#define mcuxClMemory_StoreLittleEndian32( destination, value ) \
67
do \
68
{ \
69
uint32_t local_value = (uint32_t)(value); \
70
((uint8_t*)(destination))[0] = (uint8_t) (((local_value) & 0x000000FFU) >> 0u);\
71
((uint8_t*)(destination))[1] = (uint8_t) (((local_value) & 0x0000FF00U) >> 8u);\
72
((uint8_t*)(destination))[2] = (uint8_t) (((local_value) & 0x00FF0000U) >> 16u);\
73
((uint8_t*)(destination))[3] = (uint8_t) (((local_value) & 0xFF000000U) >> 24u);\
74
} while (false)
75
84
#define mcuxClMemory_StoreBigEndian32( destination, value ) \
85
do \
86
{ \
87
uint32_t local_value = (uint32_t)(value); \
88
((uint8_t*)(destination))[0] = (uint8_t) (((local_value) & 0xFF000000U) >> 24u);\
89
((uint8_t*)(destination))[1] = (uint8_t) (((local_value) & 0x00FF0000U) >> 16u);\
90
((uint8_t*)(destination))[2] = (uint8_t) (((local_value) & 0x0000FF00U) >> 8u);\
91
((uint8_t*)(destination))[3] = (uint8_t) (((local_value) & 0x000000FFU) >> 0u);\
92
} while (false)
93
102
#define mcuxClMemory_LoadLittleEndian32( source ) \
103
( (((uint32_t) ((const uint8_t*)(source))[0]) << 0u) | \
104
(((uint32_t) ((const uint8_t*)(source))[1]) << 8u) | \
105
(((uint32_t) ((const uint8_t*)(source))[2]) << 16u) | \
106
(((uint32_t) ((const uint8_t*)(source))[3]) << 24u) )
107
108
116
#define mcuxClMemory_LoadBigEndian32( source ) \
117
( (((uint32_t) ((const uint8_t*)(source))[0]) << 24u) | \
118
(((uint32_t) ((const uint8_t*)(source))[1]) << 16u) | \
119
(((uint32_t) ((const uint8_t*)(source))[2]) << 8u) | \
120
(((uint32_t) ((const uint8_t*)(source))[3]) << 0u) )
121
128
129
#ifdef __REV
130
#define MCUXCLMEMORY_SWITCH_4BYTE_ENDIANNESS(input) __REV(input)
131
#else
132
#define MCUXCLMEMORY_SWITCH_4BYTE_ENDIANNESS(input) ((((input) & 0xffu) << 24u) | (((input) & 0xff00u) << 8u) | (((input) & 0xff0000u) >> 8u) | (((input) & 0xff000000u) >> 24u))
133
#endif
134
135
#endif
/* MCUXCLMEMORY_ENDIANNESS_H_ */
mcuxClMemory_Types.h
Memory type header.
mcuxClMemory_Endianness.h
Generated by
1.16.1