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 115 #if defined(_MSC_VER) && defined(_WIN32) 116 #define FXDEPRECATED __declspec(deprecated) 117 #elif defined(__GNUC__) 118 #define FXDEPRECATED __attribute__((deprecated)) 124 #if defined(__GNUC__) 125 #define __align(x) __attribute__((aligned(x))) 126 #elif defined(_MSC_VER) 127 #define __align(x) __declspec(align(x)) 133 #define __alignment(p,b) (((FXival)(p))&((b)-1)) 136 #define __isaligned(p,b) (__alignment(p,b)==0) 139 #define __alignto(p,b) ((void*)((((FXival)(p))+((FXival)((b)-1)))&~((FXival)((b)-1)))) 143 #if defined(__GNUC__) 144 #define __threadlocal __thread 145 #elif defined(_MSC_VER) 146 #define __threadlocal __declspec(thread) 148 #define __threadlocal 152 #if defined(__GNUC__) 153 #define __noreturn __attribute__((__noreturn__)) 154 #elif (_MSC_VER >= 1400) 155 #define __noreturn __declspec(noreturn) 162 #define __likely(cond) __builtin_expect(!!(cond),1) 163 #define __unlikely(cond) __builtin_expect(!!(cond),0) 165 #define __likely(cond) (!!(cond)) 166 #define __unlikely(cond) (!!(cond)) 171 #define __assume(expr) __attribute__((__assume__(expr))) 172 #elif (__clang__ >= 14) 173 #define __assume(expr) __builtin_assume(expr) 174 #elif !defined(_MSC_VER) 175 #define __assume(expr) 180 #define __unreachable() __builtin_unreachable() 181 #elif defined(_MSC_VER) 182 #define __unreachable() __assume(false) 184 #define __unreachable() 188 #if defined(__GNUC__) 189 #define __restrict __restrict__ 190 #elif !defined(_MSC_VER) 195 #if (__GNUC__ >= 4) && (defined(__i386__) || defined(__x86_64__)) 196 #define __prefetch(addr) __builtin_prefetch((addr),0) 197 #define __prefetchw(addr) __builtin_prefetch((addr),1) 199 #define __prefetch(addr) 200 #define __prefetchw(addr) 206 #define CALLBACK __stdcall 213 #define CDECL __cdecl 222 #define FXUNUSED(prm) (void)(prm) 225 #if defined(_CC_GNU_) || defined(__GNUG__) || defined(__GNUC__) 226 #define FX_PRINTF(fmt,arg) __attribute__((format(printf,fmt,arg))) 227 #define FX_SCANF(fmt,arg) __attribute__((format(scanf,fmt,arg))) 228 #define FX_FORMAT(arg) __attribute__((format_arg(arg))) 230 #define FX_PRINTF(fmt,arg) 231 #define FX_SCANF(fmt,arg) 232 #define FX_FORMAT(arg) 236 #if defined(_MSC_VER) || defined(__MINGW32__) // Windows 238 #define LLP64 1 // Long longs and pointers are 64 bit 240 #define ILP32 1 // Ints, longs, and pointers are 32 bit 242 #elif defined(__LP64__) || defined(_LP64) || (_MIPS_SZLONG == 64) || (__WORDSIZE == 64) 243 #define LP64 1 // Longs and pointers are 64 bit 245 #define ILP32 1 // Longs, integers, and pointers are 32 bit 250 #define FXLONG(c) c ## L // Long suffix for 64 bit 251 #define FXULONG(c) c ## UL 252 #elif defined(_MSC_VER) && (_MSC_VER < 1900) 253 #define FXLONG(c) c ## i64 // Special suffix for 64 bit 254 #define FXULONG(c) c ## ui64 256 #define FXLONG(c) c ## LL // Long long suffix for 64 bit 257 #define FXULONG(c) c ## ULL 282 typedef signed char FXschar;
283 typedef unsigned char FXuchar;
285 typedef unsigned short FXushort;
286 typedef short FXshort;
287 typedef unsigned int FXuint;
289 typedef float FXfloat;
290 typedef double FXdouble;
292 typedef unsigned int FXwchar;
293 #if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED) 294 typedef unsigned short FXnchar;
295 #elif defined(__WATCOMC__) && !defined(_WCHAR_T_DEFINED) 296 typedef long char FXnchar;
298 typedef wchar_t FXnchar;
301 typedef wchar_t FXwchar;
302 typedef unsigned short FXnchar;
306 typedef unsigned long FXulong;
307 #elif defined(_MSC_VER) && (_MSC_VER < 1900) 308 typedef __int64 FXlong;
309 typedef unsigned __int64 FXulong;
311 typedef long long FXlong;
312 typedef unsigned long long FXulong;
316 #if defined(LP64) || defined(ILP32) // Long for LP64 and ILP32 models 318 typedef unsigned long FXuval;
319 #elif defined(LLP64) // Long long for LLP64 models 320 #if defined(_MSC_VER) && (_MSC_VER < 1900) 321 typedef __int64 FXival;
322 typedef unsigned __int64 FXuval;
324 typedef long long FXival;
325 typedef unsigned long long FXuval;
337 typedef unsigned long FXID;
341 typedef FXlong FXTime;
344 typedef unsigned long FXPixel;
347 typedef FXuint FXColor;
350 typedef FXuint FXHotKey;
354 typedef void* FXInputHandle;
356 typedef FXint FXInputHandle;
361 typedef void* FXProcessID;
363 typedef int FXProcessID;
368 typedef void* FXThreadID;
370 typedef unsigned long FXThreadID;
374 typedef FXuval FXThreadStorageKey;
378 typedef tagMSG FXRawEvent;
380 typedef _XEvent FXRawEvent;
386 typedef FXushort FXDragType;
388 typedef FXID FXDragType;
396 const FXTime forever=FXLONG(9223372036854775807);
405 SEARCH_IGNORECASE = 8,
415 #define FXBIT(val,b) (((val)>>(b))&1) 418 #define FXABS(val) (((val)>=0)?(val):-(val)) 421 #define FXSGN(val) (((val)<0)?-1:1) 424 #define FXSGNZ(val) ((val)<0?-1:(val)>0?1:0) 427 #define FXSGNX(x,b) (((FXint)((x)<<(32-(b))))>>(32-(b))) 430 #define FXMAX(a,b) (((a)>(b))?(a):(b)) 433 #define FXMIN(a,b) (((a)>(b))?(b):(a)) 436 #define FXMIN3(x,y,z) ((x)<(y)?FXMIN(x,z):FXMIN(y,z)) 439 #define FXMAX3(x,y,z) ((x)>(y)?FXMAX(x,z):FXMAX(y,z)) 442 #define FXMIN4(x,y,z,w) (FXMIN(FXMIN(x,y),FXMIN(z,w))) 445 #define FXMAX4(x,y,z,w) (FXMAX(FXMAX(x,y),FXMAX(z,w))) 448 #define FXMINMAX(lo,hi,a,b) ((a)<(b)?((lo)=(a),(hi)=(b)):((lo)=(b),(hi)=(a))) 451 #define FXCLAMP(lo,x,hi) ((x)<(lo)?(lo):((x)>(hi)?(hi):(x))) 454 #define FXSWAP(a,b,t) ((t)=(a),(a)=(b),(b)=(t)) 457 #define FXLERP(a,b,f) ((a)+((b)-(a))*(f)) 460 #define STRUCTOFFSET(str,member) (((char *)(&(((str *)0)->member)))-((char *)0)) 463 #define ARRAYNUMBER(array) (sizeof(array)/sizeof(array[0])) 466 #define CONTAINER(ptr,str,mem) ((str*)(((char*)(ptr))-STRUCTOFFSET(str,mem))) 469 #define MKUINT(l,h) ((((FX::FXuint)(l))&0xffff) | (((FX::FXuint)(h))<<16)) 472 #define FXSEL(type,id) ((((FX::FXuint)(id))&0xffff) | (((FX::FXuint)(type))<<16)) 475 #define FXSELTYPE(s) ((FX::FXushort)(((s)>>16)&0xffff)) 478 #define FXSELID(s) ((FX::FXushort)((s)&0xffff)) 481 #define FXAVGCOLOR(ca,cb) (((ca)&(cb))+((((ca)^(cb))&0xFEFEFEFE)>>1)) 485 #if FOX_BIGENDIAN == 1 488 #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)) 491 #define FXRGB(r,g,b) (((FX::FXuint)(FX::FXuchar)(r)<<8) | ((FX::FXuint)(FX::FXuchar)(g)<<16) | ((FX::FXuint)(FX::FXuchar)(b)<<24) | 0x000000ff) 494 #define FXREDVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff)) 497 #define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff)) 500 #define FXBLUEVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff)) 503 #define FXALPHAVAL(rgba) ((FX::FXuchar)((rgba)&0xff)) 506 #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((comp)<<3))&0xff)) 509 #define FXCOLORREF2RGB(ref) (FX::FXuint)((((ref)<<8)&0xff000000) | (((ref)<<8)&0xff0000) | (((ref)<<8)&0xff00) | 0x000000ff) 512 #define FXRGB2COLORREF(rgb) (FX::FXuint)((((rgb)>>8)&0xff0000) | (((rgb)>>8)&0xff00) | (((rgb)>>8)&0xff)) 518 #if FOX_BIGENDIAN == 0 521 #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))) 524 #define FXRGB(r,g,b) (((FX::FXuint)(FX::FXuchar)(r)<<16) | ((FX::FXuint)(FX::FXuchar)(g)<<8) | ((FX::FXuint)(FX::FXuchar)(b)) | 0xff000000) 527 #define FXREDVAL(rgba) ((FX::FXuchar)(((rgba)>>16)&0xff)) 530 #define FXGREENVAL(rgba) ((FX::FXuchar)(((rgba)>>8)&0xff)) 533 #define FXBLUEVAL(rgba) ((FX::FXuchar)((rgba)&0xff)) 536 #define FXALPHAVAL(rgba) ((FX::FXuchar)(((rgba)>>24)&0xff)) 539 #define FXRGBACOMPVAL(rgba,comp) ((FX::FXuchar)(((rgba)>>((3-(comp))<<3))&0xff)) 542 #define FXCOLORREF2RGB(ref) (FX::FXuint)((((ref)>>16)&0xff) | ((ref)&0xff00) | (((ref)<<16)&0xff0000) | 0xff000000) 545 #define FXRGB2COLORREF(rgb) (FX::FXuint)((((rgb)<<16)&0xff0000) | ((rgb)&0xff00) | (((rgb)>>16)&0xff)) 557 #define FXASSERT(exp) (__likely(exp)?((void)0):(void)FX::fxassert(#exp,__FILE__,__LINE__)) 559 #define FXASSERT(exp) ((void)0) 571 #define FXVERIFY(exp) (__likely(exp)?((void)0):(void)FX::fxverify(#exp,__FILE__,__LINE__)) 573 #define FXVERIFY(exp) ((void)(exp)) 583 #if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) 584 #define FXASSERT_STATIC(expr) static_assert(expr,#expr) 586 #define FXASSERT_STATIC(expr) FXASSERT(expr) 593 #define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL(__VA_ARGS__,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) 594 #define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20_21,_22,_23,_24,_25,_26,_27,_28,_29,_30,_31,_32,N,...) N 613 #define FXTRACE(arguments) FX::fxtrace arguments 615 #define FXTRACE(arguments) ((void)0) 624 #define FXMALLOC(ptr,type,no) (FX::fxmalloc((void **)(ptr),sizeof(type)*(no))) 632 #define FXCALLOC(ptr,type,no) (FX::fxcalloc((void **)(ptr),sizeof(type)*(no))) 643 #define FXRESIZE(ptr,type,no) (FX::fxresize((void **)(ptr),sizeof(type)*(no))) 652 #define FXMEMDUP(ptr,src,type,no) (FX::fxmemdup((void **)(ptr),(const void*)(src),sizeof(type)*(no))) 660 #define FXFREE(ptr) (FX::fxfree((void **)(ptr))) 665 template <
typename to_type>
666 static inline to_type* alias_cast(
void* ptr){
667 union UNI { to_type dst[1]; };
668 return reinterpret_cast<UNI*
>(ptr)->dst;
672 template <
typename to_type>
673 static inline const to_type* alias_cast(
const void* ptr){
674 union UNI { to_type dst[1]; };
675 return reinterpret_cast<const UNI*
>(ptr)->dst;
679 extern FXAPI FXbool fxmalloc(
void** ptr,FXuval size);
682 extern FXAPI FXbool fxcalloc(
void** ptr,FXuval size);
685 extern FXAPI FXbool fxresize(
void** ptr,FXuval size);
688 extern FXAPI
void fxfree(
void** ptr);
691 extern FXAPI FXbool fxmemdup(
void** ptr,
const void* src,FXuval size);
694 extern FXAPI __noreturn
void fxerror(
const FXchar* format,...) FX_PRINTF(1,2) ;
697 extern FXAPI
void fxwarning(const FXchar* format,...) FX_PRINTF(1,2) ;
700 extern FXAPI
void fxmessage(const FXchar* format,...) FX_PRINTF(1,2) ;
703 extern FXAPI
void fxassert(const FXchar* expression,const FXchar* filename,
unsigned int lineno);
706 extern FXAPI
void fxverify(const FXchar* expression,const FXchar* filename,
unsigned int lineno);
709 extern FXAPI
void fxtrace(FXuint level,const FXchar* format,...) FX_PRINTF(2,3) ;
712 extern FXAPI FXbool fxtoDOS(FXchar*&
string,FXint& len);
715 extern FXAPI FXbool fxfromDOS(FXchar*&
string,FXint& len);
718 extern FXAPI FXchar *fxstrdup(const FXchar* str);
721 extern FXAPI FXuint fxstrhash(const FXchar* str);
724 extern FXAPI FXival fxstrlcpy(FXchar* dst,const FXchar* src,FXival len);
727 extern FXAPI FXival fxstrlcat(FXchar* dst,const FXchar* src,FXival len);
730 extern FXAPI
void fxrgb_to_hsv(FXfloat& h,FXfloat& s,FXfloat& v,FXfloat r,FXfloat g,FXfloat b);
733 extern FXAPI
void fxhsv_to_rgb(FXfloat& r,FXfloat& g,FXfloat& b,FXfloat h,FXfloat s,FXfloat v);
736 extern FXAPI
void fxrgb_to_hsl(FXfloat& h,FXfloat& s,FXfloat& l,FXfloat r,FXfloat g,FXfloat b);
739 extern FXAPI
void fxhsl_to_rgb(FXfloat& r,FXfloat& g,FXfloat& b,FXfloat h,FXfloat s,FXfloat l);
742 extern FXchar* fxencode64(FXchar* dst,FXchar* dstend,const FXchar* src,const FXchar* srcend);
745 extern FXchar* fxdecode64(FXchar* dst,FXchar* dstend,const FXchar* src,const FXchar* srcend);
748 extern FXchar* fxencode85(FXchar* dst,FXchar* dstend,const FXchar* src,const FXchar* srcend);
751 extern FXchar* fxdecode85(FXchar* dst,FXchar* dstend,const FXchar* src,const FXchar* srcend);
754 extern FXAPI FXwchar fxkeysym2ucs(FXwchar sym);
757 extern FXAPI FXwchar fxucs2keysym(FXwchar ucs);
760 extern FXAPI FXint fxparsegeometry(const FXchar *
string,FXint& x,FXint& y,FXint& w,FXint& h);
763 extern FXAPI FXbool fxisconsole(const FXchar *path);
766 extern FXAPI const FXuchar fxversion[3];
769 extern FXAPI FXbool getTraceTopic(FXuint topic);
772 extern FXAPI
void setTraceTopic(FXuint topic,FXbool flag=true);
775 extern FXAPI
void setTraceLevel(FXuint level,FXbool flag=true);
787 extern FXAPI FXbool setTraceTopics(const FXchar* topics,FXbool flag=true);
790 extern FXAPI FXival fxosversion(FXchar version[],FXival len);
Definition: FX4Splitter.h:28