MythTV master
goom_tools.h
Go to the documentation of this file.
1#ifndef GOOMTOOLS_H
2#define GOOMTOOLS_H
3
4#include <cinttypes>
5#include <cstddef>
6#include <cstdlib>
7
8#if !defined( M_PI )
9static constexpr double M_PI { 3.14159265358979323846 };
10#endif
11static constexpr float M_PI_F { static_cast<float>(M_PI) };
12
13static constexpr size_t NB_RAND { 0x10000 };
14
15/* in graphic.c */
16extern int *rand_tab;
17static unsigned short rand_pos;
18
19static inline void RAND_INIT(int i)
20{
21 srand (i) ;
22 if (!rand_tab)
23 rand_tab = (int *) malloc (NB_RAND * sizeof(int)) ;
24 rand_pos = 1 ;
25 while (rand_pos != 0)
26 rand_tab[rand_pos++] = rand () ;
27}
28
29static inline int RAND(void)
30{
31 ++rand_pos;
32 return rand_tab[rand_pos];
33}
34
35static inline void RAND_CLOSE()
36{
37 free(rand_tab);
38 rand_tab = nullptr;
39}
40
41//#define iRAND(i) ((guint32)((float)i * RAND()/RAND_MAX))
42static inline unsigned int iRAND(int i)
43 { return static_cast<unsigned int>(RAND()) % i; }
44
45//inline unsigned int RAND(void);
46//inline unsigned int iRAND(int i);
47
48#endif // GOOMTOOLS_H
static constexpr float M_PI_F
Definition: goom_tools.h:11
static unsigned int iRAND(int i)
Definition: goom_tools.h:42
static constexpr size_t NB_RAND
Definition: goom_tools.h:13
static void RAND_CLOSE()
Definition: goom_tools.h:35
static constexpr double M_PI
Definition: goom_tools.h:9
int * rand_tab
Definition: graphic.cpp:16
static unsigned short rand_pos
Definition: goom_tools.h:17
static void RAND_INIT(int i)
Definition: goom_tools.h:19
static int RAND(void)
Definition: goom_tools.h:29