ROFL-pipeline
v0.6.0dev
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
src
rofl
datapath
pipeline
common
large_types.h
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#ifndef __LARGE_TYPES_H__
6
#define __LARGE_TYPES_H__
7
8
#include <stdint.h>
9
#include "endianness.h"
10
11
/*
12
* This header file defines a structure for a type of 128 bits
13
* It is meant to be shared between Rofl-core, pipeline and xDPd
14
*/
15
16
// This is defined as a 16 vector so the pipeline doesn't has to deal with byte order at all (e.g. upper and lower u64, etc)
17
typedef
struct
uint128_
{
18
uint8_t val[16];
19
}
uint128__t
;
20
21
//This is a wrapper that helps accessing uin128__t types
22
typedef
struct
wrap_u128
{
23
uint64_t hi;
24
uint64_t lo;
25
} __attribute__ ((__may_alias__)) w128_t;
26
27
#define UINT128__T_HI(x) ((w128_t*)&x)->hi
28
#define UINT128__T_LO(x) ((w128_t*)&x)->lo
29
30
#if defined(LITTLE_ENDIAN_DETECTED)
31
#define HTONB128(x) do{ \
32
((w128_t*)&(x))->hi = HTONB64(((w128_t*)&(x))->hi); \
33
((w128_t*)&(x))->lo = HTONB64(((w128_t*)&(x))->lo); \
34
}while(0)
35
#define NTOHB128(x) HTONB128(x)
36
37
//Conditional byte swap
38
#define COND_NTOHB128(cond, x) do { if(cond)NTOHB128(x); }while(0)
39
#else
40
#define HTONB128(x) do{}while(0)
41
#define NTOHB128(x) do{}while(0)
42
43
//Conditional byte swap
44
#define COND_NTOHB128(cond, x) do{}while(0);
45
#endif //LITTLE_ENDIAN_DETECTED
46
47
//Helpers
48
#define UINT128__T_IS_NOT_ZERO(x) ( (UINT128__T_HI(x) != 0x0ULL) || (UINT128__T_LO(x) != 0x0ULL) )
49
#define UINT128__T_IS_ZERO(x) ! UINT128__T_IS_NOT_ZERO(x)
50
51
#endif //__LARGE_TYPES_H__
wrap_u128
Definition:
large_types.h:22
uint128_
Definition:
large_types.h:17
Generated by
1.8.6