Nife version Beta
您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字

9 年之前
10 年之前
10 年之前
10 年之前
10 年之前
10 年之前
10 年之前
10 年之前
10 年之前
10 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /* Copyright (C) 2011-2015 Patrick H. E. Foubet - S.E.R.I.A.N.E.
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or any
  5. later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>
  12. *******************************************************************/
  13. /* mth.h : for multi-threading implementation */
  14. extern void TH_init(void);
  15. #ifndef __NIFE_MTH_H__
  16. #define __NIFE_MTH_H__
  17. #include <stdio.h>
  18. #include <stdint.h>
  19. #include <setjmp.h>
  20. #include <pthread.h>
  21. #define LSTACKL 512
  22. #define LSTACKC 512
  23. #define MAXSTRING 512
  24. #define NBTRSUITE 10
  25. #define LBUF 512
  26. #define VIDE ((void*)NULL)
  27. #ifdef _MULTI_THREADING_
  28. extern pthread_key_t k_Base, k_StkN, k_FIns, k_NetK, k_NLig, k_NTab, k_Vars,
  29. k_FTyp, k_Doub, k_Echo, k_StkL, k_iStL, k_StkC, k_iStC, k_bufC, k_Run,
  30. k_WPid, k_fEnC, k_sEnC, k_inSP, k_iTs, k_FdIn, k_bufP, k_bufP2, k_trSu,
  31. k_EnvI, k_modPr;
  32. #define StackN *((void**)pthread_getspecific(k_StkN))
  33. #define _MODIF_STACKN_(x) *((void**)pthread_getspecific(k_StkN))=x
  34. #define _ADDR_STACKN_ (void**)pthread_getspecific(k_StkN)
  35. #define DOUBLE *((bool*)pthread_getspecific(k_Doub))
  36. #define _MODIF_DOUBLE_(x) *((bool*)pthread_getspecific(k_Doub))=x
  37. #define MODEPR *((bool*)pthread_getspecific(k_modPr))
  38. #define _MODIF_MODEPR_(x) *((bool*)pthread_getspecific(k_modPr))=x
  39. #define ECHOOFF *((bool*)pthread_getspecific(k_Echo))
  40. #define _MODIF_ECHOOFF_(x) *((bool*)pthread_getspecific(k_Echo))=x
  41. #define NBLIG *((short*)pthread_getspecific(k_NLig))
  42. #define _MODIF_NBLIG_(x) *((short*)pthread_getspecific(k_NLig))=x
  43. #define NBTAB *((short*)pthread_getspecific(k_NTab))
  44. #define _MODIF_NBTAB_(x) *((short*)pthread_getspecific(k_NTab))=x
  45. #define VARS *((short*)pthread_getspecific(k_Vars))
  46. #define _MODIF_VARS_(x) *((short*)pthread_getspecific(k_Vars))=x
  47. #define FCT_TYP *((short*)pthread_getspecific(k_FTyp))
  48. #define _MODIF_FCT_TYP_(x) *((short*)pthread_getspecific(k_FTyp))=x
  49. #define FCT_INST *((void**)pthread_getspecific(k_FIns))
  50. #define _MODIF_FCT_INST_(x) *((void**)pthread_getspecific(k_FIns))=x
  51. #define NetKey *((uint32_t*)pthread_getspecific(k_NetK))
  52. #define _MODIF_NetKey_(x) *((uint32_t*)pthread_getspecific(k_NetK))=x
  53. #define _ADDV_NetKey_ pthread_getspecific(k_NetK)
  54. #define stackL ((bool*)pthread_getspecific(k_StkL))
  55. #define i_StackL *((int*)pthread_getspecific(k_iStL))
  56. #define _MODIF_i_StackL_(x) *((int*)pthread_getspecific(k_iStL))=x
  57. #define stackC ((char**)pthread_getspecific(k_StkC))
  58. #define i_StackC *((int*)pthread_getspecific(k_iStC))
  59. #define _MODIF_i_StackC_(x) *((int*)pthread_getspecific(k_iStC))=x
  60. #define bufC ((char*)pthread_getspecific(k_bufC))
  61. #define bufP ((char*)pthread_getspecific(k_bufP))
  62. #define bufP2 ((char*)pthread_getspecific(k_bufP2))
  63. #define traiteSuite ((PFC*)pthread_getspecific(k_trSu))
  64. #define RUN *((bool*)pthread_getspecific(k_Run))
  65. #define _MODIF_RUN_(x) *((bool*)pthread_getspecific(k_Run))=x
  66. #define WAITPID *((bool*)pthread_getspecific(k_WPid))
  67. #define _MODIF_WAITPID_(x) *((bool*)pthread_getspecific(k_WPid))=x
  68. #define stringEnCours *((bool*)pthread_getspecific(k_sEnC))
  69. #define _MODIF_stringEnCours_(x) *((bool*)pthread_getspecific(k_sEnC))=x
  70. #define fctEnCours *((bool*)pthread_getspecific(k_fEnC))
  71. #define _MODIF_fctEnCours_(x) *((bool*)pthread_getspecific(k_fEnC))=x
  72. #define inSonProc *((bool*)pthread_getspecific(k_inSP))
  73. #define _MODIF_inSonProc_(x) *((bool*)pthread_getspecific(k_inSP))=x
  74. #define FD_IN *((int*)pthread_getspecific(k_FdIn))
  75. #define _MODIF_FD_IN_(x) *((int*)pthread_getspecific(k_FdIn))=x
  76. #define iTS *((int*)pthread_getspecific(k_iTs))
  77. #define _MODIF_iTS_(x) *((int*)pthread_getspecific(k_iTs))=x
  78. #define ENV_INT (jmp_buf*)pthread_getspecific(k_EnvI)
  79. #else /* *************** NOT _MULTI_THREADING_ ******************** */
  80. extern void * G_StackN;
  81. extern int G_Double;
  82. extern short G_ModePr;
  83. extern int G_EchoOff;
  84. extern int G_NBTAB;
  85. extern int G_NBLIG;
  86. extern short G_VARS;
  87. extern short G_FCT_TYP;
  88. extern void * G_F_INS;
  89. extern uint32_t G_NetKey;
  90. extern bool G_stackL[];
  91. extern int G_i_stackL;
  92. extern char * G_stackC[];
  93. extern int G_i_stackC;
  94. extern char G_bufC[];
  95. extern short G_Run;
  96. extern short G_WAITPID;
  97. extern short G_strEnCours;
  98. extern short G_fctEnCours;
  99. extern short G_inSonProc;
  100. extern int G_FD_IN;
  101. extern int G_iTS;
  102. extern char G_bufP[];
  103. extern char G_bufP2[];
  104. extern PFC G_traiteSuite[];
  105. /* a regler */
  106. extern jmp_buf G_ENV_INT;
  107. #define RUN G_Run
  108. #define _MODIF_RUN_(x) G_Run=(x)
  109. #define WAITPID G_WAITPID
  110. #define _MODIF_WAITPID_(x) G_WAITPID=(x)
  111. #define stringEnCours G_strEnCours
  112. #define _MODIF_stringEnCours_(x) G_strEnCours=(x)
  113. #define fctEnCours G_fctEnCours
  114. #define _MODIF_fctEnCours_(x) G_fctEnCours=(x)
  115. #define inSonProc G_inSonProc
  116. #define _MODIF_inSonProc_(x) G_inSonProc=(x)
  117. #define FD_IN G_FD_IN
  118. #define _MODIF_FD_IN_(x) G_FD_IN=(x)
  119. #define iTS G_iTS
  120. #define _MODIF_iTS_(x) G_iTS=(x)
  121. #define stackL G_stackL
  122. #define i_StackL G_i_stackL
  123. #define _MODIF_i_StackL_(x) G_i_stackL=(x)
  124. #define stackC G_stackC
  125. #define i_StackC G_i_stackC
  126. #define _MODIF_i_StackC_(x) G_i_stackC=(x)
  127. #define bufC G_bufC
  128. #define bufP G_bufP
  129. #define bufP2 G_bufP2
  130. #define traiteSuite G_traiteSuite
  131. #define StackN G_StackN
  132. #define _MODIF_STACKN_(x) G_StackN=(x)
  133. #define _ADDR_STACKN_ &G_StackN
  134. #define DOUBLE G_Double
  135. #define _MODIF_DOUBLE_(x) G_Double=(x)
  136. #define MODEPR G_ModePr
  137. #define _MODIF_MODEPR_(x) G_ModePr=(x)
  138. #define ECHOOFF G_EchoOff
  139. #define _MODIF_ECHOOFF_(x) G_EchoOff=(x)
  140. #define NBLIG G_NBLIG
  141. #define _MODIF_NBLIG_(x) G_NBLIG=(x)
  142. #define NBTAB G_NBTAB
  143. #define _MODIF_NBTAB_(x) G_NBTAB=(x)
  144. #define VARS G_VARS
  145. #define _MODIF_VARS_(x) G_VARS=(x)
  146. #define FCT_TYP G_FCT_TYP
  147. #define _MODIF_FCT_TYP_(x) G_FCT_TYP=(x)
  148. #define FCT_INST G_F_INS
  149. #define _MODIF_FCT_INST_(x) G_F_INS=(x)
  150. #define NetKey G_NetKey
  151. #define _MODIF_NetKey_(x) G_NetKey=(x)
  152. #define _ADDV_NetKey_ (void*)&G_NetKey
  153. #define ENV_INT G_ENV_INT
  154. #endif /* _MULTI_THREADING_ */
  155. #endif