OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
macros.h File Reference

Go to the source code of this file.

Macros

#define min(a, b)
#define max(a, b)
#define mymalloc(ptr, nr, type)
#define myrealloc(ptr, nr, type)
#define myrandom(range)
#define swap(a, b, tmp)
#define seed()
#define bit(var, d)
#define negbit(var, d)
#define waitkey()
#define pord_resettimer(var)
#define pord_starttimer(var)
#define pord_stoptimer(var)
#define quit()

Macro Definition Documentation

◆ bit

#define bit ( var,
d )
Value:
((var) & (1 << (d)))

Definition at line 46 of file macros.h.

46#define bit(var, d) \
47 ((var) & (1 << (d)))

◆ max

#define max ( a,
b )
Value:
((a) > (b) ? (a) : (b))

Definition at line 21 of file macros.h.

◆ min

#define min ( a,
b )
Value:
((a) < (b) ? (a) : (b))

Definition at line 20 of file macros.h.

◆ mymalloc

#define mymalloc ( ptr,
nr,
type )
Value:
if (!(ptr = (type*)malloc((max(nr,1)) * sizeof(type)))) \
{ printf("malloc failed on line %d of file %s (nr=%d)\n", \
__LINE__, __FILE__, nr); \
exit(ERR); \
}
#define ERR
Definition const.h:53
#define max(a, b)
Definition macros.h:21

Definition at line 23 of file macros.h.

23#define mymalloc(ptr, nr, type) \
24 if (!(ptr = (type*)malloc((max(nr,1)) * sizeof(type)))) \
25 { printf("malloc failed on line %d of file %s (nr=%d)\n", \
26 __LINE__, __FILE__, nr); \
27 exit(ERR); \
28 }

◆ myrandom

#define myrandom ( range)
Value:
rand() % (range);

Definition at line 37 of file macros.h.

37#define myrandom(range) \
38 rand() % (range);

◆ myrealloc

#define myrealloc ( ptr,
nr,
type )
Value:
if (!(ptr = (type*)realloc(ptr, (nr) * sizeof(type)))) \
{ printf("realloc failed on line %d of file %s (nr=%d)\n", \
__LINE__, __FILE__, nr); \
exit(ERR); \
}

Definition at line 30 of file macros.h.

30#define myrealloc(ptr, nr, type) \
31 if (!(ptr = (type*)realloc(ptr, (nr) * sizeof(type)))) \
32 { printf("realloc failed on line %d of file %s (nr=%d)\n", \
33 __LINE__, __FILE__, nr); \
34 exit(ERR); \
35 }

◆ negbit

#define negbit ( var,
d )
Value:
((var) ^ (1 << (d)))

Definition at line 49 of file macros.h.

49#define negbit(var, d) \
50 ((var) ^ (1 << (d)))

◆ pord_resettimer

#define pord_resettimer ( var)
Value:
var = 0;

Definition at line 55 of file macros.h.

55#define pord_resettimer(var) \
56 var = 0;

◆ pord_starttimer

#define pord_starttimer ( var)
Value:
var -= ((FLOAT)clock()/CLOCKS_PER_SEC);
double FLOAT
Definition types.h:23

Definition at line 58 of file macros.h.

58#define pord_starttimer(var) \
59 var -= ((FLOAT)clock()/CLOCKS_PER_SEC);

◆ pord_stoptimer

#define pord_stoptimer ( var)
Value:
var += ((FLOAT)clock()/CLOCKS_PER_SEC);

Definition at line 61 of file macros.h.

61#define pord_stoptimer(var) \
62 var += ((FLOAT)clock()/CLOCKS_PER_SEC);

◆ quit

#define quit ( )
Value:
exit(ERR);

Definition at line 64 of file macros.h.

64#define quit() \
65 exit(ERR);

◆ seed

#define seed ( )
Value:
srand((PORD_INT)time(0) % 10000);
#define PORD_INT
Definition types.h:20

Definition at line 43 of file macros.h.

43#define seed() \
44 srand((PORD_INT)time(0) % 10000);

◆ swap

#define swap ( a,
b,
tmp )
Value:
{ (tmp) = (a); (a) = (b); (b) = (tmp); }

Definition at line 40 of file macros.h.

40#define swap(a, b, tmp) \
41 { (tmp) = (a); (a) = (b); (b) = (tmp); }

◆ waitkey

#define waitkey ( )
Value:
{ char _s[MAX_LINE_LEN]; printf("\n<RETURN>"); gets(_s); }
#define MAX_LINE_LEN
Definition const.h:55

Definition at line 52 of file macros.h.

52#define waitkey() \
53 { char _s[MAX_LINE_LEN]; printf("\n<RETURN>"); gets(_s); }