Nife version Beta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

211 lines
6.0 KiB

  1. /* Copyright (C) 2011-2013 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;
  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 ECHOOFF *((bool*)pthread_getspecific(k_Echo))
  38. #define _MODIF_ECHOOFF_(x) *((bool*)pthread_getspecific(k_Echo))=x
  39. #define NBLIG *((short*)pthread_getspecific(k_NLig))
  40. #define _MODIF_NBLIG_(x) *((short*)pthread_getspecific(k_NLig))=x
  41. #define NBTAB *((short*)pthread_getspecific(k_NTab))
  42. #define _MODIF_NBTAB_(x) *((short*)pthread_getspecific(k_NTab))=x
  43. #define VARS *((short*)pthread_getspecific(k_Vars))
  44. #define _MODIF_VARS_(x) *((short*)pthread_getspecific(k_Vars))=x
  45. #define FCT_TYP *((short*)pthread_getspecific(k_FTyp))
  46. #define _MODIF_FCT_TYP_(x) *((short*)pthread_getspecific(k_FTyp))=x
  47. #define FCT_INST *((void**)pthread_getspecific(k_FIns))
  48. #define _MODIF_FCT_INST_(x) *((void**)pthread_getspecific(k_FIns))=x
  49. #define NetKey *((uint32_t*)pthread_getspecific(k_NetK))
  50. #define _MODIF_NetKey_(x) *((uint32_t*)pthread_getspecific(k_NetK))=x
  51. #define _ADDV_NetKey_ pthread_getspecific(k_NetK)
  52. #define stackL ((bool*)pthread_getspecific(k_StkL))
  53. #define i_StackL *((int*)pthread_getspecific(k_iStL))
  54. #define _MODIF_i_StackL_(x) *((int*)pthread_getspecific(k_iStL))=x
  55. #define stackC ((char**)pthread_getspecific(k_StkC))
  56. #define i_StackC *((int*)pthread_getspecific(k_iStC))
  57. #define _MODIF_i_StackC_(x) *((int*)pthread_getspecific(k_iStC))=x
  58. #define bufC ((char*)pthread_getspecific(k_bufC))
  59. #define bufP ((char*)pthread_getspecific(k_bufP))
  60. #define bufP2 ((char*)pthread_getspecific(k_bufP2))
  61. #define traiteSuite ((PFC*)pthread_getspecific(k_trSu))
  62. #define RUN *((bool*)pthread_getspecific(k_Run))
  63. #define _MODIF_RUN_(x) *((bool*)pthread_getspecific(k_Run))=x
  64. #define WAITPID *((bool*)pthread_getspecific(k_WPid))
  65. #define _MODIF_WAITPID_(x) *((bool*)pthread_getspecific(k_WPid))=x
  66. #define stringEnCours *((bool*)pthread_getspecific(k_sEnC))
  67. #define _MODIF_stringEnCours_(x) *((bool*)pthread_getspecific(k_sEnC))=x
  68. #define fctEnCours *((bool*)pthread_getspecific(k_fEnC))
  69. #define _MODIF_fctEnCours_(x) *((bool*)pthread_getspecific(k_fEnC))=x
  70. #define inSonProc *((bool*)pthread_getspecific(k_inSP))
  71. #define _MODIF_inSonProc_(x) *((bool*)pthread_getspecific(k_inSP))=x
  72. #define FD_IN *((int*)pthread_getspecific(k_FdIn))
  73. #define _MODIF_FD_IN_(x) *((int*)pthread_getspecific(k_FdIn))=x
  74. #define iTS *((int*)pthread_getspecific(k_iTs))
  75. #define _MODIF_iTS_(x) *((int*)pthread_getspecific(k_iTs))=x
  76. #define ENV_INT (jmp_buf*)pthread_getspecific(k_EnvI)
  77. #else /* *************** NOT _MULTI_THREADING_ ******************** */
  78. extern void * G_StackN;
  79. extern int G_Double;
  80. extern int G_EchoOff;
  81. extern int G_NBTAB;
  82. extern int G_NBLIG;
  83. extern short G_VARS;
  84. extern short G_FCT_TYP;
  85. extern void * G_F_INS;
  86. extern uint32_t G_NetKey;
  87. extern bool G_stackL[];
  88. extern int G_i_stackL;
  89. extern char * G_stackC[];
  90. extern int G_i_stackC;
  91. extern char G_bufC[];
  92. extern short G_Run;
  93. extern short G_WAITPID;
  94. extern short G_strEnCours;
  95. extern short G_fctEnCours;
  96. extern short G_inSonProc;
  97. extern int G_FD_IN;
  98. extern int G_iTS;
  99. extern char G_bufP[];
  100. extern char G_bufP2[];
  101. extern PFC G_traiteSuite[];
  102. /* a regler */
  103. extern jmp_buf G_ENV_INT;
  104. #define RUN G_Run
  105. #define _MODIF_RUN_(x) G_Run=(x)
  106. #define WAITPID G_WAITPID
  107. #define _MODIF_WAITPID_(x) G_WAITPID=(x)
  108. #define stringEnCours G_strEnCours
  109. #define _MODIF_stringEnCours_(x) G_strEnCours=(x)
  110. #define fctEnCours G_fctEnCours
  111. #define _MODIF_fctEnCours_(x) G_fctEnCours=(x)
  112. #define inSonProc G_inSonProc
  113. #define _MODIF_inSonProc_(x) G_inSonProc=(x)
  114. #define FD_IN G_FD_IN
  115. #define _MODIF_FD_IN_(x) G_FD_IN=(x)
  116. #define iTS G_iTS
  117. #define _MODIF_iTS_(x) G_iTS=(x)
  118. #define stackL G_stackL
  119. #define i_StackL G_i_stackL
  120. #define _MODIF_i_StackL_(x) G_i_stackL=(x)
  121. #define stackC G_stackC
  122. #define i_StackC G_i_stackC
  123. #define _MODIF_i_StackC_(x) G_i_stackC=(x)
  124. #define bufC G_bufC
  125. #define bufP G_bufP
  126. #define bufP2 G_bufP2
  127. #define traiteSuite G_traiteSuite
  128. #define StackN G_StackN
  129. #define _MODIF_STACKN_(x) G_StackN=(x)
  130. #define _ADDR_STACKN_ &G_StackN
  131. #define DOUBLE G_Double
  132. #define _MODIF_DOUBLE_(x) G_Double=(x)
  133. #define ECHOOFF G_EchoOff
  134. #define _MODIF_ECHOOFF_(x) G_EchoOff=(x)
  135. #define NBLIG G_NBLIG
  136. #define _MODIF_NBLIG_(x) G_NBLIG=(x)
  137. #define NBTAB G_NBTAB
  138. #define _MODIF_NBTAB_(x) G_NBTAB=(x)
  139. #define VARS G_VARS
  140. #define _MODIF_VARS_(x) G_VARS=(x)
  141. #define FCT_TYP G_FCT_TYP
  142. #define _MODIF_FCT_TYP_(x) G_FCT_TYP=(x)
  143. #define FCT_INST G_F_INS
  144. #define _MODIF_FCT_INST_(x) G_F_INS=(x)
  145. #define NetKey G_NetKey
  146. #define _MODIF_NetKey_(x) G_NetKey=(x)
  147. #define _ADDV_NetKey_ (void*)&G_NetKey
  148. #define ENV_INT G_ENV_INT
  149. #endif /* _MULTI_THREADING_ */
  150. #endif