lasp/lasp/c/lasp_types.h

65 lines
1.5 KiB
C++

// types.h
//
// Author: J.A. de Jong - ASCEE
//
// Description:
// Typedefs and namespace pollution for stuff that is almost always
// needed.
//////////////////////////////////////////////////////////////////////
#pragma once
#ifndef LASP_TYPES_H
#define LASP_TYPES_H
#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
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 double */
#elif LASP_FLOAT_SIZE == 64
typedef double d; /* Shortcut for double */
#else
#error LASP_FLOAT_SIZE should be either 32 or 64
#endif
#include <complex.h>
#ifdef __cplusplus
typedef std::complex<d> c;
#else
#if LASP_FLOAT_SIZE == 32
typedef float complex c;
#else
typedef double complex c;
#endif
#endif
/// I need these numbers so often, that they can be in the global
/// namespace.
#define LASP_SUCCESS 0
#define LASP_INTERRUPTED (-3)
#define LASP_MALLOC_FAILED (-1)
#define LASP_FAILURE (-2)
#endif // LASP_TYPES_H
//////////////////////////////////////////////////////////////////////