2010-08-26 06:20:16 -05:00
|
|
|
#ifndef UTILS_H
|
|
|
|
#define UTILS_H
|
2010-08-29 07:10:58 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2010-08-26 06:20:16 -05:00
|
|
|
|
2010-09-01 05:40:29 -05:00
|
|
|
#ifdef WIN32
|
|
|
|
#define x86_cpuid(func,af,bf,cf,df) \
|
|
|
|
do {\
|
|
|
|
__asm mov eax, func\
|
|
|
|
__asm cpuid\
|
|
|
|
__asm mov af, eax\
|
|
|
|
__asm mov bf, ebx\
|
|
|
|
__asm mov cf, ecx\
|
|
|
|
__asm mov df, edx\
|
|
|
|
} while(0)
|
|
|
|
#else
|
|
|
|
#define x86_cpuid(func,af,bf,cf,df) \
|
|
|
|
__asm__ __volatile ("cpuid":\
|
|
|
|
"=a" (af), "=b" (bf), "=c" (cf), "=d" (df) : "a" (func));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static char hex[] = "0123456789ABCDEF";
|
2010-08-26 06:20:16 -05:00
|
|
|
//Signum function
|
|
|
|
#ifdef WIN32
|
2010-08-27 07:01:20 -05:00
|
|
|
extern _inline int isign(float i);
|
2010-08-26 06:20:16 -05:00
|
|
|
#else
|
2010-08-27 07:01:20 -05:00
|
|
|
extern inline int isign(float i);
|
2010-08-26 06:20:16 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
extern _inline unsigned clamp_flt(float f, float min, float max);
|
|
|
|
#else
|
|
|
|
extern inline unsigned clamp_flt(float f, float min, float max);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
extern _inline float restrict_flt(float f, float min, float max);
|
|
|
|
#else
|
|
|
|
extern inline float restrict_flt(float f, float min, float max);
|
|
|
|
#endif
|
|
|
|
|
2010-08-27 07:01:20 -05:00
|
|
|
char *mystrdup(char *s);
|
|
|
|
|
2010-08-29 04:25:53 -05:00
|
|
|
struct strlist
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
struct strlist *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
void strlist_add(struct strlist **list, char *str);
|
|
|
|
|
|
|
|
int strlist_find(struct strlist **list, char *str);
|
|
|
|
|
|
|
|
void strlist_free(struct strlist **list);
|
|
|
|
|
2010-08-29 07:10:58 -05:00
|
|
|
void save_presets(int do_update);
|
|
|
|
|
|
|
|
void load_presets(void);
|
|
|
|
|
|
|
|
void save_string(FILE *f, char *str);
|
|
|
|
|
|
|
|
int load_string(FILE *f, char *str, int max);
|
|
|
|
|
2010-09-01 05:40:29 -05:00
|
|
|
void strcaturl(char *dst, char *src);
|
|
|
|
|
2010-09-13 16:36:43 -05:00
|
|
|
void strappend(char *dst, char *src);
|
|
|
|
|
2010-09-01 05:40:29 -05:00
|
|
|
void *file_load(char *fn, int *size);
|
|
|
|
|
|
|
|
int cpu_check(void);
|
|
|
|
|
2010-08-26 06:20:16 -05:00
|
|
|
#endif
|