lasp/src/lasp/dsp/lasp_types.h

55 lines
1.3 KiB
C++

// types.h
//
// Author: J.A. de Jong - ASCEE
//
// Description:
// Typedefs and namespace pollution for stuff that is almost always
// needed.
//////////////////////////////////////////////////////////////////////
#pragma once
#include "lasp_config.h"
#include <stddef.h>
// // Branch prediction performance improvement
#if !defined(islikely) && defined(__GNUC__) && !defined(LASP_DEBUG)
#define islikely(x) __builtin_expect(!!(x), 1)
#define isunlikely(x) __builtin_expect(!!(x), 0)
#else
#define islikely(x) (x)
#define isunlikely(x) (x)
#endif // !defined(likely)
/// We often use boolean values
#ifndef __cplusplus
#include <stdbool.h> // true, false
#include <stddef.h>
#endif
static_assert(sizeof(size_t) == 8);
typedef size_t us; /* Size type I always use */
// To change the whole code to 32-bit floating points, change this to
// float.
#if LASP_FLOAT_SIZE == 32
typedef float d; /* Shortcut for floating point - single precision */
#elif LASP_FLOAT_SIZE == 64
typedef double d; /* Shortcut for floating point - double precision */
#else
#error LASP_FLOAT_SIZE should be either 32 or 64
#endif
#ifdef __cplusplus
#include <complex>
typedef std::complex<d> c;
#else
#include <complex.h>
#if LASP_FLOAT_SIZE == 32
typedef float complex c;
#else
typedef double complex c;
#endif
#endif