GNU Radio's RTP Package
misc.h File Reference
#include <pthread.h>
#include <stdint.h>
#include <limits.h>
#include <complex.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#include <sys/errno.h>
#include <assert.h>
#include <sys/types.h>
#include <malloc.h>

Go to the source code of this file.

Classes

struct  xoshiro256ss_state

Macros

#define _GNU_SOURCE   1
#define VERSION()
#define ASSERT_ZEROED(ptr, size)
#define DEGPRA   (180./M_PI)
#define RAPDEG   (M_PI/180.)
#define TAI_GPS_OFFSET   (19)
#define GPS_UTC_OFFSET   (18)
#define TAI_UTC_OFFSET   (TAI_GPS_OFFSET+GPS_UTC_OFFSET)
#define UNIX_EPOCH   ((time_t)315964800)
#define BOLTZMANN   (1.380649e-23)
#define FULL_SAMPRATE   (48000)
#define pthread_setname(x)
#define min(x, y)
#define max(x, y)
#define cisf(x)
#define cispif(x)
#define cis(x)
#define cispi(x)
#define FREE(p)

Functions

static void ASSERT_UNLOCKED (pthread_mutex_t *mutex)
int default_prio (void)
void realtime (int prio)
int norealtime (void)
void stick_core (void)
void * lmalloc (size_t size)
static int init_recursive_mutex (pthread_mutex_t *m)
static double dB2power (double x)
static double power2dB (double x)
static double dB2voltage (double x)
static double voltage2dB (double x)
void sincospi (double x, double *s, double *c)
void sincospif (float x, float *s, float *c)
static double sinc (double x)
int dist_path (char *path, int path_len, const char *fname)
char * format_gpstime (char *result, int len, int64_t t)
char * format_gpstime_iso8601 (char *result, int len, int64_t t)
char * format_utctime (char *result, int len, int64_t t)
char * format_utctime_iso8601 (char *result, int len, int64_t t)
char * ftime (char *result, int size, int64_t t)
void normalize_time (struct timespec *x)
uint32_t nextfastfft (uint32_t n)
ssize_t pipefill (int, void *, size_t)
void chomp (char *)
char * ensure_suffix (char const *str, char const *suffix)
uint32_t ElfHash (uint8_t const *s, size_t length)
uint32_t ElfHashString (char const *s)
uint32_t fnv1hash (const uint8_t *s, size_t length)
double i0 (double const z)
double i1 (double const z)
double xi (double thetasq)
double fm_snr (double r)
static int16_t scaleclip (float const x)
static float complex csincosf (float const x)
static float complex csincospif (float const x)
static double complex csincos (double const x)
static double complex csincospi (double const x)
static float cnrmf (float complex const x)
static double cnrm (double complex const x)
static double approx_magf (double complex x)
static void time_sub (struct timespec *result, struct timespec const *a, struct timespec const *b)
static void time_add (struct timespec *result, struct timespec const *a, struct timespec const *b)
static int time_cmp (struct timespec const *a, struct timespec const *b)
static int64_t ts2ns (struct timespec const *ts)
static void ns2ts (struct timespec *ts, int64_t ns)
static time_t utc_time_sec (void)
static time_t gps_time_sec (void)
static int64_t utc_time_ns (void)
int64_t gps_time_ns (void)
void * mirror_alloc (size_t size)
void mirror_free (void **p, size_t size)
static void mirror_wrap (void const **p, void const *const base, size_t const size)
size_t round_to_page (size_t size)
uint32_t round2 (uint32_t v)
void drop_cache (void *mem, size_t bytes)
void xoshiro256ss_seed (xoshiro256ss_state *st, uint64_t seed)
uint64_t xoshiro256ss_next (xoshiro256ss_state *st)
void xoshiro256ss_jump (xoshiro256ss_state *st)
void rand_init (void)
double real_gauss (void)
static double complex complex_gauss (void)

Variables

static float const SCALE16 = 1.f/INT16_MAX
static float const SCALE12 = 1.f/2048.
static float const SCALE8 = 1.f/INT8_MAX
const char * App_path
int Verbose
char const * Months [12]
bool Affinity
static int64_t const BILLION = 1000000000LL
static int const MILLION = 1000000
static int const THOUSAND = 1000

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE   1

◆ ASSERT_ZEROED

#define ASSERT_ZEROED ( ptr,
size )
Value:
assert(memcmp(ptr, &(typeof(*(ptr))){0}, size) == 0)

◆ BOLTZMANN

#define BOLTZMANN   (1.380649e-23)

◆ cis

#define cis ( x)
Value:
static double complex csincos(double const x)
Definition misc.h:242

◆ cisf

#define cisf ( x)
Value:
static float complex csincosf(float const x)
Definition misc.h:230

◆ cispi

#define cispi ( x)
Value:
static double complex csincospi(double const x)
Definition misc.h:248

◆ cispif

#define cispif ( x)
Value:
static float complex csincospif(float const x)
Definition misc.h:236

◆ DEGPRA

#define DEGPRA   (180./M_PI)

◆ FREE

#define FREE ( p)
Value:
(free(p), p = NULL)

◆ FULL_SAMPRATE

#define FULL_SAMPRATE   (48000)

◆ GPS_UTC_OFFSET

#define GPS_UTC_OFFSET   (18)

Referenced by gps_time_sec().

◆ max

#define max ( x,
y )
Value:
({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x > _y ? _x : _y; })

Referenced by approx_magf().

◆ min

#define min ( x,
y )
Value:
({ \
typeof(x) _x = (x); \
typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x < _y ? _x : _y; })

Referenced by approx_magf().

◆ pthread_setname

#define pthread_setname ( x)
Value:
pthread_setname_np(pthread_self(),(x))

◆ RAPDEG

#define RAPDEG   (M_PI/180.)

◆ TAI_GPS_OFFSET

#define TAI_GPS_OFFSET   (19)

◆ TAI_UTC_OFFSET

#define TAI_UTC_OFFSET   (TAI_GPS_OFFSET+GPS_UTC_OFFSET)

◆ UNIX_EPOCH

#define UNIX_EPOCH   ((time_t)315964800)

Referenced by gps_time_sec().

◆ VERSION

#define VERSION ( )
Value:
{ fprintf(stderr,"KA9Q Multichannel SDR %s last modified %s\n",__FILE__,__TIMESTAMP__); \
fprintf(stderr,"Copyright 2026, Phil Karn, KA9Q. May be used under the terms of the GNU Public License\n"); \
fprintf(stderr," Repo: %s\n",GIT_REMOTE_URL); \
fprintf(stderr," Commit: %s\n",GIT_HASH); \
}

Function Documentation

◆ approx_magf()

double approx_magf ( double complex x)
inlinestatic

References max, and min.

◆ ASSERT_UNLOCKED()

void ASSERT_UNLOCKED ( pthread_mutex_t * mutex)
inlinestatic

◆ chomp()

void chomp ( char * )

◆ cnrm()

double cnrm ( double complex const x)
inlinestatic

◆ cnrmf()

float cnrmf ( float complex const x)
inlinestatic

◆ complex_gauss()

double complex complex_gauss ( void )
inlinestatic

References real_gauss().

◆ csincos()

double complex csincos ( double const x)
inlinestatic

◆ csincosf()

float complex csincosf ( float const x)
inlinestatic

◆ csincospi()

double complex csincospi ( double const x)
inlinestatic

References sincospi().

◆ csincospif()

float complex csincospif ( float const x)
inlinestatic

References sincospif().

◆ dB2power()

double dB2power ( double x)
inlinestatic

◆ dB2voltage()

double dB2voltage ( double x)
inlinestatic

◆ default_prio()

int default_prio ( void )

◆ dist_path()

int dist_path ( char * path,
int path_len,
const char * fname )

◆ drop_cache()

void drop_cache ( void * mem,
size_t bytes )

◆ ElfHash()

uint32_t ElfHash ( uint8_t const * s,
size_t length )

◆ ElfHashString()

uint32_t ElfHashString ( char const * s)

◆ ensure_suffix()

char * ensure_suffix ( char const * str,
char const * suffix )

◆ fm_snr()

double fm_snr ( double r)

◆ fnv1hash()

uint32_t fnv1hash ( const uint8_t * s,
size_t length )

◆ format_gpstime()

char * format_gpstime ( char * result,
int len,
int64_t t )

◆ format_gpstime_iso8601()

char * format_gpstime_iso8601 ( char * result,
int len,
int64_t t )

◆ format_utctime()

char * format_utctime ( char * result,
int len,
int64_t t )

◆ format_utctime_iso8601()

char * format_utctime_iso8601 ( char * result,
int len,
int64_t t )

◆ ftime()

char * ftime ( char * result,
int size,
int64_t t )

◆ gps_time_ns()

int64_t gps_time_ns ( void )

◆ gps_time_sec()

time_t gps_time_sec ( void )
inlinestatic

◆ i0()

double i0 ( double const z)

◆ i1()

double i1 ( double const z)

◆ init_recursive_mutex()

int init_recursive_mutex ( pthread_mutex_t * m)
inlinestatic

◆ lmalloc()

void * lmalloc ( size_t size)

◆ mirror_alloc()

void * mirror_alloc ( size_t size)

◆ mirror_free()

void mirror_free ( void ** p,
size_t size )

◆ mirror_wrap()

void mirror_wrap ( void const ** p,
void const *const base,
size_t const size )
inlinestatic

◆ nextfastfft()

uint32_t nextfastfft ( uint32_t n)

◆ norealtime()

int norealtime ( void )

◆ normalize_time()

void normalize_time ( struct timespec * x)

Referenced by time_add(), and time_sub().

◆ ns2ts()

void ns2ts ( struct timespec * ts,
int64_t ns )
inlinestatic

References BILLION.

◆ pipefill()

ssize_t pipefill ( int ,
void * ,
size_t  )

◆ power2dB()

double power2dB ( double x)
inlinestatic

◆ rand_init()

void rand_init ( void )

◆ real_gauss()

double real_gauss ( void )

Referenced by complex_gauss().

◆ realtime()

void realtime ( int prio)

◆ round2()

uint32_t round2 ( uint32_t v)

◆ round_to_page()

size_t round_to_page ( size_t size)

◆ scaleclip()

int16_t scaleclip ( float const x)
inlinestatic

◆ sinc()

double sinc ( double x)
inlinestatic

◆ sincospi()

void sincospi ( double x,
double * s,
double * c )

Referenced by csincospi().

◆ sincospif()

void sincospif ( float x,
float * s,
float * c )

Referenced by csincospif().

◆ stick_core()

void stick_core ( void )

◆ time_add()

void time_add ( struct timespec * result,
struct timespec const * a,
struct timespec const * b )
inlinestatic

References normalize_time().

◆ time_cmp()

int time_cmp ( struct timespec const * a,
struct timespec const * b )
inlinestatic

◆ time_sub()

void time_sub ( struct timespec * result,
struct timespec const * a,
struct timespec const * b )
inlinestatic

References normalize_time().

◆ ts2ns()

int64_t ts2ns ( struct timespec const * ts)
inlinestatic

References BILLION.

Referenced by utc_time_ns().

◆ utc_time_ns()

int64_t utc_time_ns ( void )
inlinestatic

References ts2ns().

◆ utc_time_sec()

time_t utc_time_sec ( void )
inlinestatic

Referenced by gps_time_sec().

◆ voltage2dB()

double voltage2dB ( double x)
inlinestatic

◆ xi()

double xi ( double thetasq)

◆ xoshiro256ss_jump()

void xoshiro256ss_jump ( xoshiro256ss_state * st)

◆ xoshiro256ss_next()

uint64_t xoshiro256ss_next ( xoshiro256ss_state * st)

◆ xoshiro256ss_seed()

void xoshiro256ss_seed ( xoshiro256ss_state * st,
uint64_t seed )

Variable Documentation

◆ Affinity

bool Affinity
extern

◆ App_path

const char* App_path
extern

◆ BILLION

int64_t const BILLION = 1000000000LL
static

Referenced by ns2ts(), and ts2ns().

◆ MILLION

int const MILLION = 1000000
static

◆ Months

char const* Months[12]
extern

◆ SCALE12

float const SCALE12 = 1.f/2048.
static

◆ SCALE16

float const SCALE16 = 1.f/INT16_MAX
static

◆ SCALE8

float const SCALE8 = 1.f/INT8_MAX
static

◆ THOUSAND

int const THOUSAND = 1000
static

◆ Verbose

int Verbose
extern