std_macros.bas 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. FPRINT Outfile,""
  2. FPRINT Outfile,"// *************************************************"
  3. FPRINT Outfile,"// " + $BCX_STR_STD_MACROS
  4. FPRINT Outfile,"// *************************************************"
  5. FPRINT Outfile,""
  6. IF Use_BcxSplitPath THEN
  7. FPRINT Outfile,"#define FDRV 2"
  8. FPRINT Outfile,"#define FPATH 4"
  9. FPRINT Outfile,"#define FNAME 8"
  10. FPRINT Outfile,"#define FEXT 16"
  11. END IF
  12. IF Use_Cbool THEN
  13. FPRINT Outfile,"#define CBOOL(A)(A!=0)?1:0"
  14. END IF
  15. IF Use_Isptr THEN
  16. FPRINT Outfile,"#define IsPtr(a)((DWORD)a)"
  17. END IF
  18. IF Use_Band THEN
  19. FPRINT Outfile,"#define BAND &"
  20. END IF
  21. IF Use_Bor THEN
  22. FPRINT Outfile,"#define BOR |"
  23. END IF
  24. IF Use_Bnot THEN
  25. FPRINT Outfile,"#define BNOT ~(int)"
  26. END IF
  27. IF Use_Ubound THEN
  28. FPRINT Outfile,"#define ubound(T)(sizeof((T))/sizeof((T[0]))-1)"
  29. END IF
  30. IF Use_Clear THEN
  31. FPRINT Outfile,"#define Clear(arg)memset(&arg,0,sizeof(arg))"
  32. END IF
  33. IF Use_Imod THEN
  34. FPRINT Outfile,"#define imod(a,b)((a)%(b))"
  35. END IF
  36. IF Use_Get THEN
  37. FPRINT Outfile,"#define GET(A,B,C) F_GetVal=fread(B,1,C,A)"
  38. CALL AddGlobal("F_GetVal", vt_INTEGER , 0,"",0,0,0,0)
  39. END IF
  40. IF Use_Put THEN
  41. FPRINT Outfile,"#define PUT(A,B,C) F_PutVal=fwrite(B,1,C,A)"
  42. CALL AddGlobal("F_PutVal", vt_INTEGER , 0,"",0,0,0,0)
  43. END IF
  44. IF Use_Strptr THEN
  45. FPRINT Outfile,"#define STRPTR(A)((char*)&(A))"
  46. END IF
  47. IF Use_Val THEN
  48. FPRINT Outfile,"#define VAL(a)(double)atof(a)"
  49. END IF
  50. IF Use_Vall THEN
  51. FPRINT Outfile,"#define VALL(a) (long double)strtold(a,(char**)NULL)"
  52. END IF
  53. IF Use_Fint THEN
  54. FPRINT Outfile,"#define FINT(a)floor(a)"
  55. END IF
  56. IF Use_Frac THEN
  57. FPRINT Outfile,"#define FRAC(a)(double)(a-FIX(a))"
  58. Use_Fix = TRUE
  59. END IF
  60. IF Use_Fracl THEN
  61. FPRINT Outfile,"#define FRACL(a)(long double)(a-FIX(a))"
  62. Use_Fix = TRUE
  63. END IF
  64. IF Use_Fix THEN
  65. FPRINT Outfile,"#define FIX(a)(int)((a))"
  66. END IF
  67. IF Use_Csng THEN
  68. FPRINT Outfile,"#define CSNG(a)((float)(a))"
  69. END IF
  70. IF Use_Cdbl THEN
  71. FPRINT Outfile,"#define CDBL(a)((double)(a))"
  72. END IF
  73. IF Use_Cldbl THEN
  74. FPRINT Outfile,"#define CLDBL(a)((long double)(a))"
  75. END IF
  76. IF Use_Threads THEN
  77. FPRINT Outfile,"#define BCX_THREAD(fn,arg) ({ pthread_t tid; pthread_create(&tid, NULL, (void*(*)(void*))fn, arg); tid;})"
  78. FPRINT Outfile,"#define BCX_THREADWAIT(a) pthread_join(a, NULL)"
  79. FPRINT Outfile,"#define BCX_INITLOCK(a) pthread_mutex_init(a, NULL)"
  80. FPRINT Outfile,"#define BCX_THREADLOCK(a) pthread_mutex_lock (a)"
  81. FPRINT Outfile,"#define BCX_THREADUNLOCK(a) pthread_mutex_unlock (a)"
  82. FPRINT Outfile,"#define BCX_THREADKILL(t) pthread_cancel(t)"
  83. FPRINT Outfile,"#define BCX_THREADEND pthread_exit(0)"
  84. END IF