Added `types.h`: Include the ints, and added 128-bit vectors.

Added IFUNC helper macros

Fortune for tracemac's current commit: Small blessing − 小吉
master
Avril 3 years ago
parent d681471216
commit 550cf06e9d
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -4,7 +4,7 @@ PROJECT=tracem
AUTHOR=Avril (Flanchan) <flanchan@cumallover.me>
VERSION_MAJOR=0
VERSION_MINOR=0
VERSION_MINOR=1
VERSION=$(VERSION_MAJOR).$(VERSION_MINOR)
ifeq ($(PREFIX),)

@ -0,0 +1,11 @@
#ifndef _TM_IFUNC_H
#define _TM_IFUNC_H
//! ifunc helpers
#define IFUNC_NAME(name, ver) _impl__ ## name ## __ ## ver
#define IFUNC_IMPL(name, ver) __attribute__((copy(name))) IFUNC_NAME(name, ver)
#define IFUNC_RESOLVER_A(attr, name) __attribute__((returns_nonnull)) (* __attribute__(attr) _ifun__ ## name (void)) // When the ifunc resolver wants to return a function pointer that has attributes on it, the attribute inner list (e.g. `(returns_nonnull, const, nonnull)') can be provided as the first argument
#define IFUNC_RESOLVER(name) IFUNC_RESOLVER_A((copy(name)), name)
#define IFUNC_DEF(name, params) name params __attribute__((__ifunc__("_ifun__" #name)))
#endif /* _TM_IFUNC_H */

@ -16,6 +16,8 @@ extern "C" {
#include <stdarg.h>
#include <assert.h>
#include "ifunc.h"
// Attribute macros
#define _pure __attribute__((const))

@ -0,0 +1,65 @@
#ifndef _TM_TYPES_H
#define _TM_TYPES_H
#include <stdint.h>
// 128-bit vector types
#ifndef _TM_NO_VECTORS
#include <mmintrin.h>
#include <xmmintrin.h>
#include <emmintrin.h>
#define _VECTOR_SIZE 16
// Vector128 int 8
typedef uint8_t v8_u128n __attribute__((vector_size(_VECTOR_SIZE)));
typedef int8_t v8_i128n __attribute__((vector_size(_VECTOR_SIZE)));
// Vector128 int 16
typedef uint16_t v16_u128n __attribute__((vector_size(_VECTOR_SIZE)));
typedef int16_t v16_i128n __attribute__((vector_size(_VECTOR_SIZE)));
// Vector128 int 32
typedef uint32_t v32_u128n __attribute__((vector_size(_VECTOR_SIZE)));
typedef int32_t v32_i128n __attribute__((vector_size(_VECTOR_SIZE)));
// Vector128 int 64
typedef uint64_t v64_u128n __attribute__((vector_size(_VECTOR_SIZE)));
typedef int64_t v64_i128n __attribute__((vector_size(_VECTOR_SIZE)));
typedef union v128 {
// Intrinsics
__m128i mm; // long int
__m128d mmd; // double
__m128 mmf; // float //XXX: Should we have the halfs
// Vectorised integers
union {
v8_u128n u8;
v8_i128n i8;
v16_u128n u16;
v16_i128n i16;
v32_u128n u32;
v32_i128n i32;
v64_u128n u64;
v64_i128n i64;
} as;
// Native 128 bit integers
unsigned __int128 u128;
__int128 i128;
// Raw bytes
uint8_t bytes[_VECTOR_SIZE];
} v128_t;
_Static_assert(sizeof(union v128)==_VECTOR_SIZE, "invalid vector size");
_Static_assert(_Alignof(union v128)==_Alignof(__m128i), "invalid vector alignment");
#endif
#include "ints.h"
#endif /* _TM_TYPES_H */

@ -9,7 +9,7 @@
#include <trace.h>
#include <tracem/macros.h>
#include <tracem/ints.h>
#include <tracem/types.h>
static _Atomic enum trace_level _t_level = _TRACE_LEVEL_DEFAULT;

Loading…
Cancel
Save