Subversion Repositories QNX 8.QNX8 IFS tool

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /* ACC -- Automatic Compiler Configuration
  2.  
  3.    Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
  4.    All Rights Reserved.
  5.  
  6.    This software is a copyrighted work licensed under the terms of
  7.    the GNU General Public License. Please consult the file "ACC_LICENSE"
  8.    for details.
  9.  
  10.    Markus F.X.J. Oberhumer
  11.    <markus@oberhumer.com>
  12.    http://www.oberhumer.com/
  13.  */
  14.  
  15.  
  16. #ifndef __ACC_LIB_H_INCLUDED
  17. #define __ACC_LIB_H_INCLUDED 1
  18.  
  19.  
  20. #if !defined(__ACCLIB_FUNCNAME)
  21. #  define __ACCLIB_FUNCNAME(f)  f
  22. #endif
  23. #if !defined(ACCLIB_EXTERN)
  24. #  define ACCLIB_EXTERN(r,f)    extern r __ACCLIB_FUNCNAME(f)
  25. #endif
  26.  
  27.  
  28. #if !defined(__ACCLIB_CONST_CAST_RETURN)
  29. #if (ACC_CC_GNUC)
  30. #  define __ACCLIB_CONST_CAST_RETURN(type,var) \
  31.         { union { type a; const type b; } u; u.b = (var); return u.a; }
  32. #else
  33. #  define __ACCLIB_CONST_CAST_RETURN(type,var) return (type) (var);
  34. #endif
  35. #endif
  36.  
  37.  
  38. #if (ACC_OS_WIN64)
  39. #  define acclib_handle_t       acc_int64l_t
  40. #  define acclib_uhandle_t      acc_uint64l_t
  41. #elif (ACC_ARCH_IA32 && ACC_CC_MSC && (_MSC_VER >= 1300))
  42.    typedef __w64 long           acclib_handle_t;
  43.    typedef __w64 unsigned long  acclib_uhandle_t;
  44. #  define acclib_handle_t       acclib_handle_t
  45. #  define acclib_uhandle_t      acclib_uhandle_t
  46. #else
  47. #  define acclib_handle_t       long
  48. #  define acclib_uhandle_t      unsigned long
  49. #endif
  50.  
  51.  
  52. /*************************************************************************
  53. // wrap <ctype.h>
  54. **************************************************************************/
  55.  
  56. #if 0
  57. ACCLIB_EXTERN(int, acc_ascii_digit)   (int);
  58. ACCLIB_EXTERN(int, acc_ascii_islower) (int);
  59. ACCLIB_EXTERN(int, acc_ascii_isupper) (int);
  60. ACCLIB_EXTERN(int, acc_ascii_tolower) (int);
  61. ACCLIB_EXTERN(int, acc_ascii_toupper) (int);
  62. ACCLIB_EXTERN(int, acc_ascii_utolower) (int);
  63. ACCLIB_EXTERN(int, acc_ascii_utoupper) (int);
  64. #endif
  65.  
  66. #define acc_ascii_isdigit(c)    (((unsigned)(c) - 48) < 10)
  67. #define acc_ascii_islower(c)    (((unsigned)(c) - 97) < 26)
  68. #define acc_ascii_isupper(c)    (((unsigned)(c) - 65) < 26)
  69. #define acc_ascii_tolower(c)    ((int)(c) + (acc_ascii_isupper(c) << 5))
  70. #define acc_ascii_toupper(c)    ((int)(c) - (acc_ascii_islower(c) << 5))
  71.  
  72. #define acc_ascii_utolower(c)   acc_ascii_tolower((unsigned char)(c))
  73. #define acc_ascii_utoupper(c)   acc_ascii_toupper((unsigned char)(c))
  74.  
  75.  
  76. /*************************************************************************
  77. // huge pointer layer
  78. **************************************************************************/
  79.  
  80. #ifndef acc_hsize_t
  81. #if (ACC_HAVE_MM_HUGE_PTR)
  82. #  define acc_hsize_t  unsigned long
  83. #  define acc_hvoid_p  void __huge *
  84. #  define acc_hchar_p  char __huge *
  85. #  define acc_hchar_pp char __huge * __huge *
  86. #  define acc_hbyte_p  unsigned char __huge *
  87. #else
  88. #  define acc_hsize_t  size_t
  89. #  define acc_hvoid_p  void *
  90. #  define acc_hchar_p  char *
  91. #  define acc_hchar_pp char **
  92. #  define acc_hbyte_p  unsigned char *
  93. #endif
  94. #endif
  95. #ifndef ACC_FILE_P
  96. #define ACC_FILE_P FILE *
  97. #endif
  98.  
  99. /* halloc */
  100. ACCLIB_EXTERN(acc_hvoid_p, acc_halloc) (acc_hsize_t);
  101. ACCLIB_EXTERN(void, acc_hfree) (acc_hvoid_p);
  102.  
  103. /* dos_alloc */
  104. #if (ACC_OS_DOS16 || ACC_OS_OS216)
  105. ACCLIB_EXTERN(void __far*, acc_dos_alloc) (unsigned long);
  106. ACCLIB_EXTERN(int, acc_dos_free) (void __far*);
  107. #endif
  108.  
  109. /* string */
  110. ACCLIB_EXTERN(int, acc_hmemcmp) (const acc_hvoid_p, const acc_hvoid_p, acc_hsize_t);
  111. ACCLIB_EXTERN(acc_hvoid_p, acc_hmemcpy) (acc_hvoid_p, const acc_hvoid_p, acc_hsize_t);
  112. ACCLIB_EXTERN(acc_hvoid_p, acc_hmemmove) (acc_hvoid_p, const acc_hvoid_p, acc_hsize_t);
  113. ACCLIB_EXTERN(acc_hvoid_p, acc_hmemset) (acc_hvoid_p, int, acc_hsize_t);
  114.  
  115. /* string */
  116. ACCLIB_EXTERN(acc_hsize_t, acc_hstrlen) (const acc_hchar_p);
  117. ACCLIB_EXTERN(int, acc_hstrcmp) (const acc_hchar_p, const acc_hchar_p);
  118. ACCLIB_EXTERN(int, acc_hstrncmp)(const acc_hchar_p, const acc_hchar_p, acc_hsize_t);
  119. ACCLIB_EXTERN(int, acc_ascii_hstricmp) (const acc_hchar_p, const acc_hchar_p);
  120. ACCLIB_EXTERN(int, acc_ascii_hstrnicmp)(const acc_hchar_p, const acc_hchar_p, acc_hsize_t);
  121. ACCLIB_EXTERN(int, acc_ascii_hmemicmp) (const acc_hvoid_p, const acc_hvoid_p, acc_hsize_t);
  122. ACCLIB_EXTERN(acc_hchar_p, acc_hstrstr) (const acc_hchar_p, const acc_hchar_p);
  123. ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstristr) (const acc_hchar_p, const acc_hchar_p);
  124. ACCLIB_EXTERN(acc_hvoid_p, acc_hmemmem) (const acc_hvoid_p, acc_hsize_t, const acc_hvoid_p, acc_hsize_t);
  125. ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemimem) (const acc_hvoid_p, acc_hsize_t, const acc_hvoid_p, acc_hsize_t);
  126. ACCLIB_EXTERN(acc_hchar_p, acc_hstrcpy) (acc_hchar_p, const acc_hchar_p);
  127. ACCLIB_EXTERN(acc_hchar_p, acc_hstrcat) (acc_hchar_p, const acc_hchar_p);
  128. ACCLIB_EXTERN(acc_hsize_t, acc_hstrlcpy) (acc_hchar_p, const acc_hchar_p, acc_hsize_t);
  129. ACCLIB_EXTERN(acc_hsize_t, acc_hstrlcat) (acc_hchar_p, const acc_hchar_p, acc_hsize_t);
  130. ACCLIB_EXTERN(int, acc_hstrscpy) (acc_hchar_p, const acc_hchar_p, acc_hsize_t);
  131. ACCLIB_EXTERN(int, acc_hstrscat) (acc_hchar_p, const acc_hchar_p, acc_hsize_t);
  132. ACCLIB_EXTERN(acc_hchar_p, acc_hstrccpy) (acc_hchar_p, const acc_hchar_p, int);
  133. ACCLIB_EXTERN(acc_hvoid_p, acc_hmemccpy) (acc_hvoid_p, const acc_hvoid_p, int, acc_hsize_t);
  134. ACCLIB_EXTERN(acc_hchar_p, acc_hstrchr)  (const acc_hchar_p, int);
  135. ACCLIB_EXTERN(acc_hchar_p, acc_hstrrchr) (const acc_hchar_p, int);
  136. ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrichr) (const acc_hchar_p, int);
  137. ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrrichr) (const acc_hchar_p, int);
  138. ACCLIB_EXTERN(acc_hvoid_p, acc_hmemchr)  (const acc_hvoid_p, int, acc_hsize_t);
  139. ACCLIB_EXTERN(acc_hvoid_p, acc_hmemrchr) (const acc_hvoid_p, int, acc_hsize_t);
  140. ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemichr) (const acc_hvoid_p, int, acc_hsize_t);
  141. ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemrichr) (const acc_hvoid_p, int, acc_hsize_t);
  142. ACCLIB_EXTERN(acc_hsize_t, acc_hstrspn)  (const acc_hchar_p, const acc_hchar_p);
  143. ACCLIB_EXTERN(acc_hsize_t, acc_hstrrspn) (const acc_hchar_p, const acc_hchar_p);
  144. ACCLIB_EXTERN(acc_hsize_t, acc_hstrcspn)  (const acc_hchar_p, const acc_hchar_p);
  145. ACCLIB_EXTERN(acc_hsize_t, acc_hstrrcspn) (const acc_hchar_p, const acc_hchar_p);
  146. ACCLIB_EXTERN(acc_hchar_p, acc_hstrpbrk)  (const acc_hchar_p, const acc_hchar_p);
  147. ACCLIB_EXTERN(acc_hchar_p, acc_hstrrpbrk) (const acc_hchar_p, const acc_hchar_p);
  148. ACCLIB_EXTERN(acc_hchar_p, acc_hstrsep)  (acc_hchar_pp, const acc_hchar_p);
  149. ACCLIB_EXTERN(acc_hchar_p, acc_hstrrsep) (acc_hchar_pp, const acc_hchar_p);
  150. ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrlwr) (acc_hchar_p);
  151. ACCLIB_EXTERN(acc_hchar_p, acc_ascii_hstrupr) (acc_hchar_p);
  152. ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemlwr) (acc_hvoid_p, acc_hsize_t);
  153. ACCLIB_EXTERN(acc_hvoid_p, acc_ascii_hmemupr) (acc_hvoid_p, acc_hsize_t);
  154.  
  155. /* stdio */
  156. ACCLIB_EXTERN(acc_hsize_t, acc_hfread) (ACC_FILE_P, acc_hvoid_p, acc_hsize_t);
  157. ACCLIB_EXTERN(acc_hsize_t, acc_hfwrite) (ACC_FILE_P, const acc_hvoid_p, acc_hsize_t);
  158.  
  159. /* io */
  160. #if (ACC_HAVE_MM_HUGE_PTR)
  161. ACCLIB_EXTERN(long, acc_hread) (int, acc_hvoid_p, long);
  162. ACCLIB_EXTERN(long, acc_hwrite) (int, const acc_hvoid_p, long);
  163. #endif
  164. ACCLIB_EXTERN(long, acc_safe_hread) (int, acc_hvoid_p, long);
  165. ACCLIB_EXTERN(long, acc_safe_hwrite) (int, const acc_hvoid_p, long);
  166.  
  167.  
  168. /*************************************************************************
  169. // wrap filename limits
  170. **************************************************************************/
  171.  
  172. /* maximum length of full pathname (excl. '\0') */
  173. #if !defined(ACC_FN_PATH_MAX)
  174. #if (ACC_OS_DOS16 || ACC_OS_WIN16)
  175. #  define ACC_FN_PATH_MAX   143
  176. #elif (ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN32 || ACC_OS_WIN64)
  177. #  define ACC_FN_PATH_MAX   259
  178. #elif (ACC_OS_TOS)
  179. #  define ACC_FN_PATH_MAX   259
  180. #endif
  181. #endif
  182. #if !defined(ACC_FN_PATH_MAX)
  183.    /* arbitrary limit for acclib implementation */
  184. #  define ACC_FN_PATH_MAX   1024
  185. #endif
  186.  
  187. /* maximum length of a filename (a single path component) (excl. '\0') */
  188. #if !defined(ACC_FN_NAME_MAX)
  189. #if (ACC_OS_DOS16 || ACC_OS_WIN16)
  190. #  define ACC_FN_NAME_MAX   12
  191. #elif (ACC_OS_TOS && (ACC_CC_PUREC || ACC_CC_TURBOC))
  192. #  define ACC_FN_NAME_MAX   12
  193. #elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
  194. #elif (ACC_OS_DOS32)
  195. #  define ACC_FN_NAME_MAX   12
  196. #endif
  197. #endif
  198. #if !defined(ACC_FN_NAME_MAX)
  199. #  define ACC_FN_NAME_MAX   ACC_FN_PATH_MAX
  200. #endif
  201.  
  202.  
  203. #define ACC_FNMATCH_NOESCAPE        1
  204. #define ACC_FNMATCH_PATHNAME        2
  205. #define ACC_FNMATCH_PATHSTAR        4
  206. #define ACC_FNMATCH_PERIOD          8
  207. #define ACC_FNMATCH_ASCII_CASEFOLD  16
  208. ACCLIB_EXTERN(int, acc_fnmatch) (const acc_hchar_p, const acc_hchar_p, int);
  209.  
  210.  
  211. /*************************************************************************
  212. // wrap <dirent.h>
  213. **************************************************************************/
  214.  
  215. #undef __ACCLIB_USE_OPENDIR
  216. #if (HAVE_DIRENT_H || ACC_CC_WATCOMC)
  217. #  define __ACCLIB_USE_OPENDIR 1
  218. #  if (ACC_OS_DOS32 && defined(__BORLANDC__))
  219. #  elif (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
  220. #  elif (ACC_OS_OS2 || ACC_OS_OS216)
  221. #  elif (ACC_OS_TOS && ACC_CC_GNUC)
  222. #  elif (ACC_OS_WIN32 && !defined(ACC_HAVE_WINDOWS_H))
  223. #  elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_TOS || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
  224. #    undef __ACCLIB_USE_OPENDIR
  225. #  endif
  226. #endif
  227.  
  228.  
  229. typedef struct
  230. {
  231. #if defined(__ACCLIB_USE_OPENDIR)
  232.     void *u_dirp; /* private */
  233. # if (ACC_CC_WATCOMC)
  234.     unsigned short f_time;
  235.     unsigned short f_date;
  236.     unsigned long f_size;
  237. # endif
  238.     char f_name[ACC_FN_NAME_MAX+1];
  239. #elif (ACC_OS_WIN32 || ACC_OS_WIN64)
  240.     acclib_handle_t u_handle; /* private */
  241.     unsigned f_attr;
  242.     unsigned f_size_low;
  243.     unsigned f_size_high;
  244.     char f_name[ACC_FN_NAME_MAX+1];
  245. #elif (ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_TOS || ACC_OS_WIN16)
  246.     char u_dta[21]; /* private */
  247.     unsigned char f_attr;
  248.     unsigned short f_time;
  249.     unsigned short f_date;
  250.     unsigned short f_size_low;
  251.     unsigned short f_size_high;
  252.     char f_name[ACC_FN_NAME_MAX+1];
  253.     char u_dirp; /* private */
  254. #else
  255.     void *u_dirp; /* private */
  256.     char f_name[ACC_FN_NAME_MAX+1];
  257. #endif
  258. } acc_dir_t;
  259.  
  260. #ifndef acc_dir_p
  261. #define acc_dir_p acc_dir_t *
  262. #endif
  263.  
  264. ACCLIB_EXTERN(int, acc_opendir)  (acc_dir_p, const char*);
  265. ACCLIB_EXTERN(int, acc_readdir)  (acc_dir_p);
  266. ACCLIB_EXTERN(int, acc_closedir) (acc_dir_p);
  267.  
  268.  
  269. /*************************************************************************
  270. // wrap misc
  271. **************************************************************************/
  272.  
  273. #if (ACC_CC_GNUC) && (defined(__CYGWIN__) || defined(__MINGW32__))
  274. #  define acc_alloca(x)     __builtin_alloca((x))
  275. #elif (ACC_CC_BORLANDC) && defined(__linux__)
  276.   /* FIXME: alloca does not work */
  277. #elif (HAVE_ALLOCA)
  278. #  define acc_alloca(x)     alloca((x))
  279. #endif
  280.  
  281. #if (ACC_OS_DOS32 && ACC_CC_GNUC) && defined(__DJGPP__)
  282. #  define acc_stackavail()  stackavail()
  283. #elif (ACC_ARCH_IA16 && ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0410))
  284. #  define acc_stackavail()  stackavail()
  285. #elif (ACC_ARCH_IA16 && ACC_CC_BORLANDC && (__BORLANDC__ >= 0x0400))
  286. #  if (ACC_OS_WIN16) && (ACC_MM_TINY || ACC_MM_SMALL || ACC_MM_MEDIUM)
  287. #  else
  288. #    define acc_stackavail()  stackavail()
  289. #  endif
  290. #elif ((ACC_ARCH_IA16 || ACC_ARCH_IA32) && (ACC_CC_DMC || ACC_CC_SYMANTECC))
  291. #  define acc_stackavail()  stackavail()
  292. #elif ((ACC_ARCH_IA16) && ACC_CC_MSC && (_MSC_VER >= 700))
  293. #  define acc_stackavail()  _stackavail()
  294. #elif ((ACC_ARCH_IA16) && ACC_CC_MSC)
  295. #  define acc_stackavail()  stackavail()
  296. #elif ((ACC_ARCH_IA16 || ACC_ARCH_IA32) && ACC_CC_TURBOC && (__TURBOC__ >= 0x0450))
  297. #  define acc_stackavail()  stackavail()
  298. #elif (ACC_ARCH_IA16 && ACC_CC_TURBOC && (__TURBOC__ >= 0x0400))
  299.    ACC_EXTERN_C size_t __cdecl stackavail(void);
  300. #  define acc_stackavail()  stackavail()
  301. #elif ((ACC_ARCH_IA16 || ACC_ARCH_IA32) && (ACC_CC_WATCOMC))
  302. #  define acc_stackavail()  stackavail()
  303. #elif (ACC_ARCH_IA16 && ACC_CC_ZORTECHC)
  304. #  define acc_stackavail()  _chkstack()
  305. #endif
  306.  
  307. ACCLIB_EXTERN(acclib_handle_t, acc_get_osfhandle) (int);
  308. ACCLIB_EXTERN(int, acc_isatty) (int);
  309. ACCLIB_EXTERN(int, acc_mkdir) (const char*, unsigned);
  310. ACCLIB_EXTERN(int, acc_response) (int*, char***);
  311. ACCLIB_EXTERN(int, acc_set_binmode) (int, int);
  312.  
  313. ACCLIB_EXTERN(acc_int32l_t, acc_muldiv32) (acc_int32l_t, acc_int32l_t, acc_int32l_t);
  314. ACCLIB_EXTERN(acc_uint32l_t, acc_umuldiv32) (acc_uint32l_t, acc_uint32l_t, acc_uint32l_t);
  315.  
  316. ACCLIB_EXTERN(void, acc_wildargv) (int*, char***);
  317.  
  318.  
  319. /*************************************************************************
  320. // uclock (real, i.e. "wall" clock)
  321. **************************************************************************/
  322.  
  323. #if defined(acc_int32e_t)
  324. ACCLIB_EXTERN(int, acc_tsc_read) (acc_uint32e_t*);
  325. ACCLIB_EXTERN(int, acc_tsc_read_add) (acc_uint32e_t*);
  326. #endif
  327.  
  328.  
  329. typedef struct { /* all private */
  330.     acclib_handle_t h;
  331.     int mode;
  332. #if (ACC_HAVE_WINDOWS_H) && defined(acc_int64l_t)
  333.     double qpf;
  334. #endif
  335. } acc_uclock_handle_t;
  336.  
  337. typedef struct { /* all private */
  338.     union {
  339.         acc_uint32l_t t32;
  340. #if !(ACC_OS_DOS16 || ACC_OS_WIN16)
  341.         double td;
  342. #  if defined(acc_int64l_t)
  343.         acc_int64l_t t64;
  344. #  endif
  345. #endif
  346.     } ticks;
  347. #if (ACC_HAVE_WINDOWS_H) && defined(acc_int64l_t)
  348.     acc_int64l_t qpc;
  349. #endif
  350. } acc_uclock_t;
  351.  
  352. #ifndef acc_uclock_handle_p
  353. #define acc_uclock_handle_p acc_uclock_handle_t *
  354. #endif
  355. #ifndef acc_uclock_p
  356. #define acc_uclock_p acc_uclock_t *
  357. #endif
  358.  
  359. ACCLIB_EXTERN(int, acc_uclock_open)  (acc_uclock_handle_p);
  360. ACCLIB_EXTERN(int, acc_uclock_close) (acc_uclock_handle_p);
  361. ACCLIB_EXTERN(void, acc_uclock_read) (acc_uclock_handle_p, acc_uclock_p);
  362. ACCLIB_EXTERN(double, acc_uclock_get_elapsed) (acc_uclock_handle_p, const acc_uclock_p, const acc_uclock_p);
  363.  
  364.  
  365. /*************************************************************************
  366. // performance counters (virtual clock)
  367. **************************************************************************/
  368.  
  369. #if defined(acc_int64l_t)
  370.  
  371. typedef struct { /* all private */
  372.     void* h;
  373.     unsigned cpu_type, cpu_features, cpu_khz, cpu_nrctrs;
  374.     const char* cpu_name;
  375. } acc_perfctr_handle_t;
  376.  
  377. typedef struct {
  378.     acc_uint64l_t tsc;
  379. #if (ACC_OS_POSIX_LINUX)
  380.     acc_uint64l_t pmc[18];
  381. #else
  382.     acc_uint64l_t pmc[1];
  383. #endif
  384. } acc_perfctr_clock_t;
  385.  
  386. #ifndef acc_perfctr_handle_p
  387. #define acc_perfctr_handle_p acc_perfctr_handle_t *
  388. #endif
  389. #ifndef acc_perfctr_clock_p
  390. #define acc_perfctr_clock_p acc_perfctr_clock_t *
  391. #endif
  392.  
  393. ACCLIB_EXTERN(int, acc_perfctr_open)  (acc_perfctr_handle_p);
  394. ACCLIB_EXTERN(int, acc_perfctr_close) (acc_perfctr_handle_p);
  395. ACCLIB_EXTERN(void, acc_perfctr_read) (acc_perfctr_handle_p, acc_perfctr_clock_p);
  396. ACCLIB_EXTERN(double, acc_perfctr_get_elapsed) (acc_perfctr_handle_p, const acc_perfctr_clock_p, const acc_perfctr_clock_p);
  397. ACCLIB_EXTERN(double, acc_perfctr_get_elapsed_tsc) (acc_perfctr_handle_p, acc_uint64l_t);
  398.  
  399. #endif
  400.  
  401.  
  402. /*************************************************************************
  403. // Big Endian / Little Endian
  404. **************************************************************************/
  405.  
  406. ACCLIB_EXTERN(unsigned, acc_get_be16) (const acc_hvoid_p);
  407. ACCLIB_EXTERN(acc_uint32l_t, acc_get_be24) (const acc_hvoid_p);
  408. ACCLIB_EXTERN(acc_uint32l_t, acc_get_be32) (const acc_hvoid_p);
  409. ACCLIB_EXTERN(void, acc_set_be16) (acc_hvoid_p, unsigned);
  410. ACCLIB_EXTERN(void, acc_set_be24) (acc_hvoid_p, acc_uint32l_t);
  411. ACCLIB_EXTERN(void, acc_set_be32) (acc_hvoid_p, acc_uint32l_t);
  412. ACCLIB_EXTERN(unsigned, acc_get_le16) (const acc_hvoid_p);
  413. ACCLIB_EXTERN(acc_uint32l_t, acc_get_le24) (const acc_hvoid_p);
  414. ACCLIB_EXTERN(acc_uint32l_t, acc_get_le32) (const acc_hvoid_p);
  415. ACCLIB_EXTERN(void, acc_set_le16) (acc_hvoid_p, unsigned);
  416. ACCLIB_EXTERN(void, acc_set_le24) (acc_hvoid_p, acc_uint32l_t);
  417. ACCLIB_EXTERN(void, acc_set_le32) (acc_hvoid_p, acc_uint32l_t);
  418. #if defined(acc_uint64l_t)
  419. ACCLIB_EXTERN(acc_uint64l_t, acc_get_be64) (const acc_hvoid_p);
  420. ACCLIB_EXTERN(void, acc_set_be64) (acc_hvoid_p, acc_uint64l_t);
  421. ACCLIB_EXTERN(acc_uint64l_t, acc_get_le64) (const acc_hvoid_p);
  422. ACCLIB_EXTERN(void, acc_set_le64) (acc_hvoid_p, acc_uint64l_t);
  423. #endif
  424.  
  425. /* inline versions */
  426. #if (ACC_ARCH_AMD64 || ACC_ARCH_IA32)
  427. #  define ACC_GET_LE16(p)       (* (const unsigned short *) (p))
  428. #  define ACC_GET_LE32(p)       (* (const acc_uint32e_t *) (p))
  429. #  define ACC_SET_LE16(p,v)     (* (unsigned short *) (p) = (unsigned short) (v))
  430. #  define ACC_SET_LE32(p,v)     (* (acc_uint32e_t *) (p) = (acc_uint32e_t) (v))
  431. #endif
  432. #if (ACC_ARCH_AMD64)
  433. #  define ACC_GET_LE64(p)       (* (const acc_uint64l_t *) (p))
  434. #  define ACC_SET_LE64(p,v)     (* (acc_uint64l_t *) (p) = (acc_uint64l_t) (v))
  435. #endif
  436.  
  437.  
  438. /*************************************************************************
  439. // getopt
  440. **************************************************************************/
  441.  
  442. typedef struct {
  443.     const char* name;
  444.     int has_arg;
  445.     int* flag;
  446.     int val;
  447. } acc_getopt_longopt_t;
  448. #ifndef acc_getopt_longopt_p
  449. #define acc_getopt_longopt_p acc_getopt_longopt_t *
  450. #endif
  451.  
  452. typedef struct {
  453.     int go_argc;
  454.     char** go_argv;
  455.     const char* go_shortopts;
  456.     const acc_getopt_longopt_p longopts;
  457. #if (ACC_BROKEN_CDECL_ALT_SYNTAX)
  458.     int __acc_cdecl_va (*go_error)(const char *, ...);
  459. #else
  460.     int (__acc_cdecl_va *go_error)(const char *, ...);
  461. #endif
  462. } acc_getopt_t;
  463. #ifndef acc_getopt_p
  464. #define acc_getopt_p acc_getopt_t *
  465. #endif
  466.  
  467. ACCLIB_EXTERN(void, acc_getopt_init) (acc_getopt_p);
  468. ACCLIB_EXTERN(int, acc_getopt) (acc_getopt_p);
  469. ACCLIB_EXTERN(void, acc_getopt_close)(acc_getopt_p);
  470.  
  471.  
  472. /*************************************************************************
  473. // rand
  474. **************************************************************************/
  475.  
  476. typedef struct { /* all private */
  477.     acc_uint32l_t seed;
  478. } acc_rand31_t;
  479. #ifndef acc_rand31_p
  480. #define acc_rand31_p acc_rand31_t *
  481. #endif
  482. ACCLIB_EXTERN(void, acc_srand31) (acc_rand31_p, acc_uint32l_t);
  483. ACCLIB_EXTERN(acc_uint32l_t, acc_rand31) (acc_rand31_p);
  484.  
  485. #if defined(acc_uint64l_t)
  486. typedef struct { /* all private */
  487.     acc_uint64l_t seed;
  488. } acc_rand48_t;
  489. #ifndef acc_rand48_p
  490. #define acc_rand48_p acc_rand48_t *
  491. #endif
  492. ACCLIB_EXTERN(void, acc_srand48) (acc_rand48_p, acc_uint32l_t);
  493. ACCLIB_EXTERN(acc_uint32l_t, acc_rand48) (acc_rand48_p);
  494. ACCLIB_EXTERN(acc_uint32l_t, acc_rand48_r32) (acc_rand48_p);
  495. #endif
  496.  
  497. #if defined(acc_uint64l_t)
  498. typedef struct { /* all private */
  499.     acc_uint64l_t seed;
  500. } acc_rand64_t;
  501. #ifndef acc_rand64_p
  502. #define acc_rand64_p acc_rand64_t *
  503. #endif
  504. ACCLIB_EXTERN(void, acc_srand64) (acc_rand64_p, acc_uint64l_t);
  505. ACCLIB_EXTERN(acc_uint32l_t, acc_rand64) (acc_rand64_p);
  506. ACCLIB_EXTERN(acc_uint32l_t, acc_rand64_r32) (acc_rand64_p);
  507. #endif
  508.  
  509. typedef struct { /* all private */
  510.     unsigned n;
  511.     acc_uint32l_t s[624];
  512. } acc_randmt_t;
  513. #ifndef acc_randmt_p
  514. #define acc_randmt_p acc_randmt_t *
  515. #endif
  516. ACCLIB_EXTERN(void, acc_srandmt) (acc_randmt_p, acc_uint32l_t);
  517. ACCLIB_EXTERN(acc_uint32l_t, acc_randmt) (acc_randmt_p);
  518. ACCLIB_EXTERN(acc_uint32l_t, acc_randmt_r32) (acc_randmt_p);
  519.  
  520.  
  521. #endif /* already included */
  522.  
  523.  
  524. /*
  525. vi:ts=4:et
  526. */
  527.