2018-01-29 15:14:50 +00:00
|
|
|
// types.h
|
|
|
|
//
|
|
|
|
// Author: J.A. de Jong - ASCEE
|
|
|
|
//
|
|
|
|
// Description:
|
|
|
|
// Typedefs and namespace pollution for stuff that is almost always
|
|
|
|
// needed.
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#pragma once
|
2021-09-14 18:05:42 +00:00
|
|
|
#include "lasp_config.h"
|
2018-02-09 10:56:49 +00:00
|
|
|
#include <stddef.h>
|
2021-09-14 18:05:42 +00:00
|
|
|
|
2018-02-09 10:56:49 +00:00
|
|
|
// // Branch prediction performance improvement
|
2020-10-16 18:37:02 +00:00
|
|
|
#if !defined(islikely) && defined(__GNUC__) && !defined(LASP_DEBUG)
|
|
|
|
#define islikely(x) __builtin_expect(!!(x), 1)
|
|
|
|
#define isunlikely(x) __builtin_expect(!!(x), 0)
|
2018-02-06 11:01:27 +00:00
|
|
|
#else
|
2020-10-16 18:37:02 +00:00
|
|
|
#define islikely(x) (x)
|
|
|
|
#define isunlikely(x) (x)
|
2018-02-09 10:56:49 +00:00
|
|
|
#endif // !defined(likely)
|
2018-02-06 11:01:27 +00:00
|
|
|
|
2018-01-29 15:14:50 +00:00
|
|
|
/// We often use boolean values
|
2021-09-14 18:05:42 +00:00
|
|
|
#ifndef __cplusplus
|
2018-01-29 15:14:50 +00:00
|
|
|
#include <stdbool.h> // true, false
|
|
|
|
#include <stddef.h>
|
2021-09-14 18:05:42 +00:00
|
|
|
#endif
|
2022-09-03 18:59:14 +00:00
|
|
|
|
2022-10-10 17:17:38 +00:00
|
|
|
static_assert(sizeof(size_t) == 8);
|
2018-01-29 15:14:50 +00:00
|
|
|
typedef size_t us; /* Size type I always use */
|
|
|
|
|
|
|
|
// To change the whole code to 32-bit floating points, change this to
|
|
|
|
// float.
|
2021-10-04 13:53:22 +00:00
|
|
|
#if LASP_FLOAT_SIZE == 32
|
2022-09-03 18:59:14 +00:00
|
|
|
typedef float d; /* Shortcut for floating point - single precision */
|
2021-10-04 13:53:22 +00:00
|
|
|
#elif LASP_FLOAT_SIZE == 64
|
2022-09-03 18:59:14 +00:00
|
|
|
typedef double d; /* Shortcut for floating point - double precision */
|
2018-01-29 15:14:50 +00:00
|
|
|
#else
|
2021-10-04 13:53:22 +00:00
|
|
|
#error LASP_FLOAT_SIZE should be either 32 or 64
|
2018-01-29 15:14:50 +00:00
|
|
|
#endif
|
|
|
|
|
2021-09-14 18:05:42 +00:00
|
|
|
#ifdef __cplusplus
|
2022-09-03 18:59:14 +00:00
|
|
|
#include <complex>
|
|
|
|
typedef std::complex<d> c;
|
2021-09-14 18:05:42 +00:00
|
|
|
#else
|
2022-09-03 18:59:14 +00:00
|
|
|
#include <complex.h>
|
|
|
|
#if LASP_FLOAT_SIZE == 32
|
|
|
|
typedef float complex c;
|
|
|
|
#else
|
|
|
|
typedef double complex c;
|
2021-09-14 18:05:42 +00:00
|
|
|
#endif
|
|
|
|
|
2022-09-03 18:59:14 +00:00
|
|
|
#endif
|
2021-09-14 18:05:42 +00:00
|
|
|
|
2018-01-29 15:14:50 +00:00
|
|
|
|