mirror of
https://github.com/wiiu-env/wiiload_plugin.git
synced 2024-12-01 23:14:13 +01:00
40 lines
1.1 KiB
C
40 lines
1.1 KiB
C
|
#ifndef __UTILS_H_
|
||
|
#define __UTILS_H_
|
||
|
|
||
|
#include <malloc.h>
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
#define LIMIT(x, min, max) \
|
||
|
({ \
|
||
|
typeof( x ) _x = x; \
|
||
|
typeof( min ) _min = min; \
|
||
|
typeof( max ) _max = max; \
|
||
|
( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \
|
||
|
})
|
||
|
|
||
|
#define DegToRad(a) ( (a) * 0.01745329252f )
|
||
|
#define RadToDeg(a) ( (a) * 57.29577951f )
|
||
|
|
||
|
#define ALIGN4(x) (((x) + 3) & ~3)
|
||
|
#define ALIGN32(x) (((x) + 31) & ~31)
|
||
|
|
||
|
|
||
|
#define ROUNDUP(x, align) (((x) + ((align) - 1)) & ~((align) - 1))
|
||
|
|
||
|
#define le16(i) ((((uint16_t) ((i) & 0xFF)) << 8) | ((uint16_t) (((i) & 0xFF00) >> 8)))
|
||
|
#define le32(i) ((((uint32_t)le16((i) & 0xFFFF)) << 16) | ((uint32_t)le16(((i) & 0xFFFF0000) >> 16)))
|
||
|
#define le64(i) ((((uint64_t)le32((i) & 0xFFFFFFFFLL)) << 32) | ((uint64_t)le32(((i) & 0xFFFFFFFF00000000LL) >> 32)))
|
||
|
|
||
|
//Needs to have log_init() called beforehand.
|
||
|
void dumpHex(const void* data, size_t size);
|
||
|
char *str_replace(char *orig, char *rep, char *with);
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#endif // __UTILS_H_
|