mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-01-01 06:23:35 +01:00
defs: remove useless definitions
This commit is contained in:
parent
5a575a278f
commit
3d362bb0bf
1 changed files with 4 additions and 30 deletions
|
@ -2,6 +2,9 @@
|
||||||
// gint:defs:util - Various utility macros
|
// gint:defs:util - Various utility macros
|
||||||
//---
|
//---
|
||||||
|
|
||||||
|
#ifndef GINT_DEFS_UTIL
|
||||||
|
#define GINT_DEFS_UTIL
|
||||||
|
|
||||||
/* min(), max() (without double evaluation) */
|
/* min(), max() (without double evaluation) */
|
||||||
#define min(a, b) ({ \
|
#define min(a, b) ({ \
|
||||||
__auto_type _a = (a); \
|
__auto_type _a = (a); \
|
||||||
|
@ -35,33 +38,4 @@
|
||||||
(b) = _tmp; \
|
(b) = _tmp; \
|
||||||
})
|
})
|
||||||
|
|
||||||
//---
|
#endif /* GINT_DEFS_UTIL */
|
||||||
// Const casts
|
|
||||||
//---
|
|
||||||
|
|
||||||
/* const_cast() - perform const casts
|
|
||||||
This is intended for initialization purposes only, like "final" in Java.
|
|
||||||
This macro is the most generic form without any type inference; using
|
|
||||||
const_cint() or const_cptr() may be more convenient for simple types */
|
|
||||||
#define const_cast(x, T) (*((T *)(&(x))))
|
|
||||||
|
|
||||||
/* const_cptr() - perform const casts on pointers */
|
|
||||||
#define const_cptr(x) (*((void **)(&(x))))
|
|
||||||
|
|
||||||
/* const_cint() - perform const casts on integers
|
|
||||||
This macro infers the integer type it's using, which may avoid errors when
|
|
||||||
types change during code maintenance. It only works on primitive types and
|
|
||||||
their aliases, this is on purpose to avoid integer coercion with tricks such
|
|
||||||
as typeof(x + 0). */
|
|
||||||
#define const_cint(x) (*_Generic((x), \
|
|
||||||
char: (char *) (&(x)), \
|
|
||||||
unsigned char: (unsigned char *) (&(x)), \
|
|
||||||
short: (short *) (&(x)), \
|
|
||||||
unsigned short: (unsigned short *) (&(x)), \
|
|
||||||
int: (int *) (&(x)), \
|
|
||||||
unsigned int: (unsigned int *) (&(x)), \
|
|
||||||
long: (long *) (&(x)), \
|
|
||||||
unsigned long: (unsigned long *) (&(x)), \
|
|
||||||
long long: (long long *) (&(x)), \
|
|
||||||
unsigned long long: (unsigned long long *) (&(x)) \
|
|
||||||
))
|
|
||||||
|
|
Loading…
Reference in a new issue