diff --git a/Makefile b/Makefile index 788f484..60b03e5 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ PROJECT=tracem AUTHOR=Avril (Flanchan) VERSION_MAJOR=0 -VERSION_MINOR=0 +VERSION_MINOR=1 VERSION=$(VERSION_MAJOR).$(VERSION_MINOR) ifeq ($(PREFIX),) diff --git a/include/tracem/ifunc.h b/include/tracem/ifunc.h new file mode 100644 index 0000000..9fb6535 --- /dev/null +++ b/include/tracem/ifunc.h @@ -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 */ diff --git a/include/tracem/macros.h b/include/tracem/macros.h index d96c89c..e95a0ed 100644 --- a/include/tracem/macros.h +++ b/include/tracem/macros.h @@ -16,6 +16,8 @@ extern "C" { #include #include +#include "ifunc.h" + // Attribute macros #define _pure __attribute__((const)) diff --git a/include/tracem/types.h b/include/tracem/types.h new file mode 100644 index 0000000..e61a9b3 --- /dev/null +++ b/include/tracem/types.h @@ -0,0 +1,65 @@ +#ifndef _TM_TYPES_H +#define _TM_TYPES_H + +#include + +// 128-bit vector types +#ifndef _TM_NO_VECTORS +#include +#include +#include + +#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 */ diff --git a/src/trace.c b/src/trace.c index 49afbea..9d28521 100644 --- a/src/trace.c +++ b/src/trace.c @@ -9,7 +9,7 @@ #include #include -#include +#include static _Atomic enum trace_level _t_level = _TRACE_LEVEL_DEFAULT;