35 #define PATHSEPSTRING "\\" 36 #define PATHLISTSEP ';' 37 #define PATHLISTSEPSTRING ";" 38 #define ISPATHSEP(c) ((c)=='\\' || (c)=='/') 41 #define PATHSEPSTRING "/" 42 #define PATHLISTSEP ':' 43 #define PATHLISTSEPSTRING ":" 44 #define ISPATHSEP(c) ((c)=='/') 50 #define ENDLINE "\r\n" 57 #if !defined(FOX_BIGENDIAN) 59 #if defined(__BYTE_ORDER__) 60 #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) 61 #define FOX_BIGENDIAN 0 63 #define FOX_BIGENDIAN 1 66 #error "FOX_BIGENDIAN macro not set" 68 #elif defined(_MSC_VER) 69 #define FOX_BIGENDIAN 0 71 #error "FOX_BIGENDIAN macro not set" 80 #define FXEXPORT __attribute__ ((dllexport)) 81 #define FXIMPORT __attribute__ ((dllimport)) 84 #define FXEXPORT __declspec(dllexport) 85 #define FXIMPORT __declspec(dllimport) 88 #if defined(__GNUC__) && (__GNUC__ >= 4) 89 #define FXLOCAL __attribute__((visibility("hidden"))) 90 #define FXEXPORT __attribute__((visibility("default"))) 91 #define FXIMPORT __attribute__((visibility("default"))) 102 #ifdef FOXDLL_EXPORTS 103 #define FXAPI FXEXPORT 104 #define FXTEMPLATE_EXTERN 106 #define FXAPI FXIMPORT 107 #define FXTEMPLATE_EXTERN extern 111 #define FXTEMPLATE_EXTERN 116 #if defined(__GNUC__) 117 #define __align(x) __attribute__((aligned(x))) 118 #elif defined(_MSC_VER) 119 #define __align(x) __declspec(align(x)) 125 #define __alignment(p,b) (((FXival)(p))&((b)-1)) 128 #define __isaligned(p,b) (__alignment(p,b)==0) 131 #define __alignto(p,b) ((void*)((((FXival)(p))+((FXival)((b)-1)))&~((FXival)((b)-1)))) 135 #if defined(__GNUC__) 136 #define __threadlocal __thread 137 #elif defined(_MSC_VER) 138 #define __threadlocal __declspec(thread) 140 #define __threadlocal 144 #if defined(__GNUC__) 145 #define __noreturn __attribute__((__noreturn__)) 146 #elif (_MSC_VER >= 1400) 147 #define __noreturn __declspec(noreturn) 154 #define __likely(cond) __builtin_expect(!!(cond),1) 155 #define __unlikely(cond) __builtin_expect(!!(cond),0) 157 #define __likely(cond) (!!(cond)) 158 #define __unlikely(cond) (!!(cond)) 163 #define __assume(expr) __attribute__((__assume__(expr))) 164 #elif (__clang__ >= 14) 165 #define __assume(expr) __builtin_assume(expr) 166 #elif !defined(_MSC_VER) 167 #define __assume(expr) 172 #define __unreachable() __builtin_unreachable() 173 #elif defined(_MSC_VER) 174 #define __unreachable() __assume(false) 176 #define __unreachable() 180 #if defined(__GNUC__) 181 #define __restrict __restrict__ 182 #elif !defined(_MSC_VER) 187 #if (__GNUC__ >= 4) && (defined(__i386__) || defined(__x86_64__)) 188 #define __prefetch(addr) __builtin_prefetch((addr),0) 189 #define __prefetchw(addr) __builtin_prefetch((addr),1) 191 #define __prefetch(addr) 192 #define __prefetchw(addr) 198 #define CALLBACK __stdcall 205 #define CDECL __cdecl 214 #if defined(_CC_GNU_) || defined(__GNUG__) || defined(__GNUC__) 215 #define FX_PRINTF(fmt,arg) __attribute__((format(printf,fmt,arg))) 216 #define FX_SCANF(fmt,arg) __attribute__((format(scanf,fmt,arg))) 217 #define FX_FORMAT(arg) __attribute__((format_arg(arg))) 219 #define FX_PRINTF(fmt,arg) 220 #define FX_SCANF(fmt,arg) 221 #define FX_FORMAT(arg) 225 #if defined(_MSC_VER) || defined(__MINGW32__) // Windows 227 #define LLP64 1 // Long longs and pointers are 64 bit 229 #define ILP32 1 // Ints, longs, and pointers are 32 bit 231 #elif defined(__LP64__) || defined(_LP64) || (_MIPS_SZLONG == 64) || (__WORDSIZE == 64) 232 #define LP64 1 // Longs and pointers are 64 bit 234 #define ILP32 1 // Longs, integers, and pointers are 32 bit 239 #define FXLONG(c) c ## L // Long suffix for 64 bit 240 #define FXULONG(c) c ## UL 241 #elif defined(_MSC_VER) && (_MSC_VER < 1900) 242 #define FXLONG(c) c ## i64 // Special suffix for 64 bit 243 #define FXULONG(c) c ## ui64 245 #define FXLONG(c) c ## LL // Long long suffix for 64 bit 246 #define FXULONG(c) c ## ULL 271 typedef signed char FXschar;
272 typedef unsigned char FXuchar;
274 typedef unsigned short FXushort;
275 typedef short FXshort;
276 typedef unsigned int FXuint;
278 typedef float FXfloat;
279 typedef double FXdouble;
281 typedef unsigned int FXwchar;
282 #if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED) 283 typedef unsigned short FXnchar;
284 #elif defined(__WATCOMC__) && !defined(_WCHAR_T_DEFINED) 285 typedef long char FXnchar;
287 typedef wchar_t FXnchar;
290 typedef wchar_t FXwchar;
291 typedef unsigned short FXnchar;
295 typedef unsigned long FXulong;
296 #elif defined(_MSC_VER) && (_MSC_VER < 1900) 297 typedef __int64 FXlong;
298 typedef unsigned __int64 FXulong;
300 typedef long long FXlong;
301 typedef unsigned long long FXulong;
305 #if defined(LP64) || defined(ILP32) // Long for LP64 and ILP32 models 307 typedef unsigned long FXuval;
308 #elif defined(LLP64) // Long long for LLP64 models 309 #if defined(_MSC_VER) && (_MSC_VER < 1900) 310 typedef __int64 FXival;
311 typedef unsigned __int64 FXuval;
313 typedef long long FXival;
314 typedef unsigned long long FXuval;
326 typedef unsigned long FXID;
330 typedef FXlong FXTime;
333 typedef unsigned long FXPixel;
336 typedef FXuint FXColor;
339 typedef FXuint FXHotKey;
343 typedef void* FXInputHandle;
345 typedef FXint FXInputHandle;
350 typedef void* FXProcessID;
352 typedef int FXProcessID;
357 typedef void* FXThreadID;
359 typedef unsigned long FXThreadID;
363 typedef FXuval FXThreadStorageKey;
367 typedef tagMSG FXRawEvent;
369 typedef _XEvent FXRawEvent;
375 typedef FXushort FXDragType;
377 typedef FXID FXDragType;
385 const FXTime forever=FXLONG(9223372036854775807);
394 SEARCH_IGNORECASE = 8,
404 #define FXBIT(val,b) (((val)>>(b))&1) 407 #define FXABS(val) (((val)>=0)?(val):-(val)) 410 #define FXSGN(val) (((val)<0)?-1:1) 413 #define FXSGNZ(val) ((val)<0?-1:(val)>0?1:0) 416 #define FXSGNX(x,b) (((FXint)((x)<<(32-(b))))>>(32-(b))) 419 #define FXMAX(a,b) (((a)>(b))?(a):(b)) 422 #define FXMIN(a,b) (((a)>(b))?(b):(a)) 425 #define FXMIN3(x,y,z) ((x)<(y)?FXMIN(x,z):FXMIN(y,z)) 428 #define FXMAX3(x,y,z) ((x)>(y)?FXMAX(x,z):FXMAX(y,z)) 431 #define FXMIN4(x,y,z,w) (FXMIN(FXMIN(x,y),FXMIN(z,w))) 434 #define FXMAX4(x,y,z,w) (FXMAX(FXMAX(x,y),FXMAX(z,w))) 437 #define FXMINMAX(lo,hi,a,b) ((a)<(b)?((lo)=(a),(hi)=(b)):((lo)=(b),(hi)=(a))) 440 #define FXCLAMP(lo,x,hi) ((x)<(lo)?(lo):((x)>(hi)?(hi):(x))) 443 #define FXSWAP(a,b,t) ((t)=(a),(a)=(b),(b)=(t)) 446 #define FXLERP(a,b,f) ((a)+((b)-(a))*(f)) 449 #define STRUCTOFFSET(str,member) (((char *)(&(((str *)0)->member)))-((char *)0)) 452 #define ARRAYNUMBER(array) (sizeof(array)/sizeof(array[0])) 455 #define CONTAINER(ptr,str,mem) ((str*)(((char*)(ptr))-STRUCTOFFSET(str,mem))) 458 #define MKUINT(l,h) ((((FX::FXuint)(l))&0xffff) | (((FX::FXuint)(h))<<16)) 461 #define FXSEL(type,id) ((((FX::FXuint)(id))&0xffff) | (((FX::FXuint)(type))<<16)) 464 #define FXSELTYPE(s) ((FX::FXushort)(((s)>>16)&0xffff)) 467 #define FXSELID(s) ((FX::FXushort)((s)&0xffff)) 470 #define FXAVGCOLOR(ca,cb) (((ca)&(cb))+((((ca)^(cb))&0xFEFEFEFE)>>1)) 474 #if FOX_BIGENDIAN == 1 477 #define FXRGBA(r,g,b,a) (((FX::FXuint)(FX::FXuchar)(a)) | ((FX::FXuint)(FX::FXuchar)(r)<<8) | ((FX::FXuint)(FX::FXuchar)(g)<<16) | ((FX::FXuint)(FX::FXuchar)(b)<<24)) 480 #define FXRGB(r,g,b) (((FX::FXuint)(FX::FXuchar)(r)<<8) | ((FX::FXuint)(FX::FXuchar)(g)<<16) | ((FX::FXuint)(FX::FXuchar)(b)<<24) | 0x000000ff) 483 #define FXREDVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff)) 486 #define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff)) 489 #define FXBLUEVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff)) 492 #define FXALPHAVAL(rgba) ((FX::FXuchar)((rgba)&0xff)) 495 #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((comp)<<3))&0xff)) 498 #define FXCOLORREF2RGB(ref) (FX::FXuint)((((ref)<<8)&0xff000000) | (((ref)<<8)&0xff0000) | (((ref)<<8)&0xff00) | 0x000000ff) 501 #define FXRGB2COLORREF(rgb) (FX::FXuint)((((rgb)>>8)&0xff0000) | (((rgb)>>8)&0xff00) | (((rgb)>>8)&0xff)) 507 #if FOX_BIGENDIAN == 0 510 #define FXRGBA(r,g,b,a) (((FX::FXuint)(FX::FXuchar)(a)<<24) | ((FX::FXuint)(FX::FXuchar)(r)<<16) | ((FX::FXuint)(FX::FXuchar)(g)<<8) | ((FX::FXuint)(FX::FXuchar)(b))) 513 #define FXRGB(r,g,b) (((FX::FXuint)(FX::FXuchar)(r)<<16) | ((FX::FXuint)(FX::FXuchar)(g)<<8) | ((FX::FXuint)(FX::FXuchar)(b)) | 0xff000000) 516 #define FXREDVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff)) 519 #define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff)) 522 #define FXBLUEVAL(rgba) ((FX::FXuchar)((rgba)&0xff)) 525 #define FXALPHAVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff)) 528 #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((3-(comp))<<3))&0xff)) 531 #define FXCOLORREF2RGB(ref) (FX::FXuint)((((ref)>>16)&0xff) | ((ref)&0xff00) | (((ref)<<16)&0xff0000) | 0xff000000) 534 #define FXRGB2COLORREF(rgb) (FX::FXuint)((((rgb)<<16)&0xff0000) | ((rgb)&0xff00) | (((rgb)>>16)&0xff)) 546 #define FXASSERT(exp) (__likely(exp)?((void)0):(void)FX::fxassert(#exp,__FILE__,__LINE__)) 548 #define FXASSERT(exp) ((void)0) 560 #define FXVERIFY(exp) (__likely(exp)?((void)0):(void)FX::fxverify(#exp,__FILE__,__LINE__)) 562 #define FXVERIFY(exp) ((void)(exp)) 572 #if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) 573 #define FXASSERT_STATIC(expr) static_assert(expr,#expr) 575 #define FXASSERT_STATIC(expr) FXASSERT(expr) 595 #define FXTRACE(arguments) FX::fxtrace arguments 597 #define FXTRACE(arguments) ((void)0) 606 #define FXMALLOC(ptr,type,no) (FX::fxmalloc((void **)(ptr),sizeof(type)*(no))) 614 #define FXCALLOC(ptr,type,no) (FX::fxcalloc((void **)(ptr),sizeof(type)*(no))) 625 #define FXRESIZE(ptr,type,no) (FX::fxresize((void **)(ptr),sizeof(type)*(no))) 634 #define FXMEMDUP(ptr,src,type,no) (FX::fxmemdup((void **)(ptr),(const void*)(src),sizeof(type)*(no))) 642 #define FXFREE(ptr) (FX::fxfree((void **)(ptr))) 647 template <
typename to_type>
648 static inline to_type* alias_cast(
void* ptr){
649 union UNI { to_type dst[1]; };
650 return reinterpret_cast<UNI*
>(ptr)->dst;
654 template <
typename to_type>
655 static inline const to_type* alias_cast(
const void* ptr){
656 union UNI { to_type dst[1]; };
657 return reinterpret_cast<const UNI*
>(ptr)->dst;
661 extern FXAPI FXbool fxmalloc(
void** ptr,FXuval size);
664 extern FXAPI FXbool fxcalloc(
void** ptr,FXuval size);
667 extern FXAPI FXbool fxresize(
void** ptr,FXuval size);
670 extern FXAPI
void fxfree(
void** ptr);
673 extern FXAPI FXbool fxmemdup(
void** ptr,
const void* src,FXuval size);
676 extern FXAPI __noreturn
void fxerror(
const FXchar* format,...) FX_PRINTF(1,2) ;
679 extern FXAPI
void fxwarning(const FXchar* format,...) FX_PRINTF(1,2) ;
682 extern FXAPI
void fxmessage(const FXchar* format,...) FX_PRINTF(1,2) ;
685 extern FXAPI
void fxassert(const FXchar* expression,const FXchar* filename,
unsigned int lineno);
688 extern FXAPI
void fxverify(const FXchar* expression,const FXchar* filename,
unsigned int lineno);
691 extern FXAPI
void fxtrace(FXuint level,const FXchar* format,...) FX_PRINTF(2,3) ;
694 extern FXAPI FXbool fxtoDOS(FXchar*&
string,FXint& len);
697 extern FXAPI FXbool fxfromDOS(FXchar*&
string,FXint& len);
700 extern FXAPI FXchar *fxstrdup(const FXchar* str);
703 extern FXAPI FXuint fxstrhash(const FXchar* str);
706 extern FXAPI FXival fxstrlcpy(FXchar* dst,const FXchar* src,FXival len);
709 extern FXAPI FXival fxstrlcat(FXchar* dst,const FXchar* src,FXival len);
712 extern FXAPI
void fxrgb_to_hsv(FXfloat& h,FXfloat& s,FXfloat& v,FXfloat r,FXfloat g,FXfloat b);
715 extern FXAPI
void fxhsv_to_rgb(FXfloat& r,FXfloat& g,FXfloat& b,FXfloat h,FXfloat s,FXfloat v);
718 extern FXAPI
void fxrgb_to_hsl(FXfloat& h,FXfloat& s,FXfloat& l,FXfloat r,FXfloat g,FXfloat b);
721 extern FXAPI
void fxhsl_to_rgb(FXfloat& r,FXfloat& g,FXfloat& b,FXfloat h,FXfloat s,FXfloat l);
724 extern FXchar* fxencode64(FXchar* dst,FXchar* dstend,const FXchar* src,const FXchar* srcend);
727 extern FXchar* fxdecode64(FXchar* dst,FXchar* dstend,const FXchar* src,const FXchar* srcend);
730 extern FXchar* fxencode85(FXchar* dst,FXchar* dstend,const FXchar* src,const FXchar* srcend);
733 extern FXchar* fxdecode85(FXchar* dst,FXchar* dstend,const FXchar* src,const FXchar* srcend);
736 extern FXAPI FXwchar fxkeysym2ucs(FXwchar sym);
739 extern FXAPI FXwchar fxucs2keysym(FXwchar ucs);
742 extern FXAPI FXint fxparsegeometry(const FXchar *
string,FXint& x,FXint& y,FXint& w,FXint& h);
745 extern FXAPI FXbool fxisconsole(const FXchar *path);
748 extern FXAPI const FXuchar fxversion[3];
751 extern FXAPI FXbool getTraceTopic(FXuint topic);
754 extern FXAPI
void setTraceTopic(FXuint topic,FXbool flag=true);
757 extern FXAPI
void setTraceLevel(FXuint level,FXbool flag=true);
769 extern FXAPI FXbool setTraceTopics(const FXchar* topics,FXbool flag=true);
772 extern FXAPI FXival fxosversion(FXchar version[],FXival len);
Definition: FX4Splitter.h:28