Add support for the IO manager thread on Windows
[ghc-base.git] / include / HsBase.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The University of Glasgow 2001-2004
4  *
5  * Definitions for package `base' which are visible in Haskell land.
6  *
7  * ---------------------------------------------------------------------------*/
8
9 #ifndef __HSBASE_H__
10 #define __HSBASE_H__
11
12 #include "HsBaseConfig.h"
13
14 /* ultra-evil... */
15 #undef PACKAGE_BUGREPORT
16 #undef PACKAGE_NAME
17 #undef PACKAGE_STRING
18 #undef PACKAGE_TARNAME
19 #undef PACKAGE_VERSION
20
21 /* Needed to get the macro version of errno on some OSs (eg. Solaris).
22    We must do this, because these libs are only compiled once, but
23    must work in both single-threaded and multi-threaded programs. */
24 #define _REENTRANT 1
25
26 #include "HsFFI.h"
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <math.h>
31
32 #if HAVE_SYS_TYPES_H
33 #include <sys/types.h>
34 #endif
35 #if HAVE_UNISTD_H
36 #include <unistd.h>
37 #endif
38 #if HAVE_SYS_STAT_H
39 #include <sys/stat.h>
40 #endif
41 #if HAVE_FCNTL_H
42 # include <fcntl.h>
43 #endif
44 #if HAVE_TERMIOS_H
45 #include <termios.h>
46 #endif
47 #if HAVE_SIGNAL_H
48 #include <signal.h>
49 /* Ultra-ugly: OpenBSD uses broken macros for sigemptyset and sigfillset (missing casts) */
50 #if __OpenBSD__
51 #undef sigemptyset
52 #undef sigfillset
53 #endif
54 #endif
55 #if HAVE_ERRNO_H
56 #include <errno.h>
57 #endif
58 #if HAVE_STRING_H
59 #include <string.h>
60 #endif
61 #if HAVE_DIRENT_H
62 #include <dirent.h>
63 #endif
64 #if HAVE_UTIME_H
65 #include <utime.h>
66 #endif
67 #if HAVE_SYS_UTSNAME_H
68 #include <sys/utsname.h>
69 #endif
70 #if HAVE_GETTIMEOFDAY
71 #  if HAVE_SYS_TIME_H
72 #   include <sys/time.h>
73 #  endif
74 #elif HAVE_GETCLOCK
75 # if HAVE_SYS_TIMERS_H
76 #  define POSIX_4D9 1
77 #  include <sys/timers.h>
78 # endif
79 #endif
80 #if HAVE_TIME_H
81 #include <time.h>
82 #endif
83 #if HAVE_SYS_TIMEB_H
84 #include <sys/timeb.h>
85 #endif
86 #if HAVE_WINDOWS_H
87 #include <windows.h>
88 #endif
89 #if HAVE_SYS_TIMES_H
90 #include <sys/times.h>
91 #endif
92 #if HAVE_WINSOCK_H && defined(__MINGW32__)
93 #include <winsock.h>
94 #endif
95 #if HAVE_LIMITS_H
96 #include <limits.h>
97 #endif
98 #if HAVE_WCTYPE_H
99 #include <wctype.h>
100 #endif
101 #if HAVE_INTTYPES_H
102 # include <inttypes.h>
103 #elif HAVE_STDINT_H
104 # include <stdint.h>
105 #endif
106
107 #if !defined(__MINGW32__) && !defined(irix_HOST_OS)
108 # if HAVE_SYS_RESOURCE_H
109 #  include <sys/resource.h>
110 # endif
111 #endif
112
113 #if !HAVE_GETRUSAGE && HAVE_SYS_SYSCALL_H
114 # include <sys/syscall.h>
115 # if defined(SYS_GETRUSAGE)     /* hpux_HOST_OS */
116 #  define getrusage(a, b)  syscall(SYS_GETRUSAGE, a, b)
117 #  define HAVE_GETRUSAGE 1
118 # endif
119 #endif
120
121 /* For System */
122 #if HAVE_SYS_WAIT_H
123 #include <sys/wait.h>
124 #endif
125 #if HAVE_VFORK_H
126 #include <vfork.h>
127 #endif
128 #include "lockFile.h"
129 #include "dirUtils.h"
130 #include "WCsubst.h"
131
132 #include "runProcess.h"
133
134 #if defined(__MINGW32__)
135 /* in Win32Utils.c */
136 extern void maperrno (void);
137 extern HsInt getTicksOfDay(void);
138 #endif
139
140 #if defined(__MINGW32__)
141 #include <io.h>
142 #include <fcntl.h>
143 #include "timeUtils.h"
144 #include <shlobj.h>
145 #include <share.h>
146 #endif
147
148 #if HAVE_SYS_SELECT_H
149 #include <sys/select.h>
150 #endif
151
152 /* in inputReady.c */
153 int inputReady(int fd, int msecs, int isSock);
154
155 /* in Signals.c */
156 extern HsInt nocldstop;
157
158 #if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_WIN32)
159 /* in execvpe.c */
160 extern int execvpe(char *name, char *const argv[], char **envp);
161 extern void pPrPr_disableITimers (void);
162 #endif
163
164 /* -----------------------------------------------------------------------------
165    64-bit operations, defined in longlong.c
166    -------------------------------------------------------------------------- */
167
168 #ifdef SUPPORT_LONG_LONGS
169
170 StgInt stg_gtWord64 (StgWord64, StgWord64);
171 StgInt stg_geWord64 (StgWord64, StgWord64);
172 StgInt stg_eqWord64 (StgWord64, StgWord64);
173 StgInt stg_neWord64 (StgWord64, StgWord64);
174 StgInt stg_ltWord64 (StgWord64, StgWord64);
175 StgInt stg_leWord64 (StgWord64, StgWord64);
176
177 StgInt stg_gtInt64 (StgInt64, StgInt64);
178 StgInt stg_geInt64 (StgInt64, StgInt64);
179 StgInt stg_eqInt64 (StgInt64, StgInt64);
180 StgInt stg_neInt64 (StgInt64, StgInt64);
181 StgInt stg_ltInt64 (StgInt64, StgInt64);
182 StgInt stg_leInt64 (StgInt64, StgInt64);
183
184 StgWord64 stg_remWord64  (StgWord64, StgWord64);
185 StgWord64 stg_quotWord64 (StgWord64, StgWord64);
186
187 StgInt64 stg_remInt64    (StgInt64, StgInt64);
188 StgInt64 stg_quotInt64   (StgInt64, StgInt64);
189 StgInt64 stg_negateInt64 (StgInt64);
190 StgInt64 stg_plusInt64   (StgInt64, StgInt64);
191 StgInt64 stg_minusInt64  (StgInt64, StgInt64);
192 StgInt64 stg_timesInt64  (StgInt64, StgInt64);
193
194 StgWord64 stg_and64  (StgWord64, StgWord64);
195 StgWord64 stg_or64   (StgWord64, StgWord64);
196 StgWord64 stg_xor64  (StgWord64, StgWord64);
197 StgWord64 stg_not64  (StgWord64);
198
199 StgWord64 stg_uncheckedShiftL64   (StgWord64, StgInt);
200 StgWord64 stg_uncheckedShiftRL64  (StgWord64, StgInt);
201 StgInt64  stg_uncheckedIShiftL64  (StgInt64, StgInt);
202 StgInt64  stg_uncheckedIShiftRL64 (StgInt64, StgInt);
203 StgInt64  stg_uncheckedIShiftRA64 (StgInt64, StgInt);
204
205 StgInt64  stg_intToInt64    (StgInt);
206 StgInt    stg_int64ToInt    (StgInt64);
207 StgWord64 stg_int64ToWord64 (StgInt64);
208
209 StgWord64 stg_wordToWord64  (StgWord);
210 StgWord   stg_word64ToWord  (StgWord64);
211 StgInt64  stg_word64ToInt64 (StgWord64);
212
213 StgInt64  stg_integerToInt64 (StgInt sa, StgByteArray /* Really: mp_limb_t* */ da);
214 StgWord64 stg_integerToWord64 (StgInt sa, StgByteArray /* Really: mp_limb_t* */ da);
215
216 #endif /* SUPPORT_LONG_LONGS */
217
218 /* -----------------------------------------------------------------------------
219    INLINE functions.
220
221    These functions are given as inlines here for when compiling via C,
222    but we also generate static versions into the cbits library for
223    when compiling to native code.
224    -------------------------------------------------------------------------- */
225
226 #ifndef INLINE
227 # if defined(_MSC_VER)
228 #  define INLINE extern __inline
229 # elif defined(__GNUC__)
230 #  define INLINE extern inline
231 # else
232 #  define INLINE inline
233 # endif
234 #endif
235
236 INLINE int __hscore_get_errno(void) { return errno; }
237 INLINE void __hscore_set_errno(int e) { errno = e; }
238
239 #if !defined(_MSC_VER)
240 INLINE int __hscore_s_isreg(m)  { return S_ISREG(m);  }
241 INLINE int __hscore_s_isdir(m)  { return S_ISDIR(m);  }
242 INLINE int __hscore_s_isfifo(m) { return S_ISFIFO(m); }
243 INLINE int __hscore_s_isblk(m)  { return S_ISBLK(m);  }
244 INLINE int __hscore_s_ischr(m)  { return S_ISCHR(m);  }
245 #ifdef S_ISSOCK
246 INLINE int __hscore_s_issock(m) { return S_ISSOCK(m); }
247 #endif
248 #endif
249
250 #if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_WIN32)
251 INLINE int
252 __hscore_sigemptyset( sigset_t *set )
253 { return sigemptyset(set); }
254
255 INLINE int
256 __hscore_sigfillset( sigset_t *set )
257 { return sigfillset(set); }
258
259 INLINE int
260 __hscore_sigaddset( sigset_t * set, int s )
261 { return sigaddset(set,s); }
262
263 INLINE int
264 __hscore_sigdelset( sigset_t * set, int s )
265 { return sigdelset(set,s); }
266
267 INLINE int
268 __hscore_sigismember( sigset_t * set, int s )
269 { return sigismember(set,s); }
270 #endif
271
272 INLINE void *
273 __hscore_memcpy_dst_off( char *dst, int dst_off, char *src, size_t sz )
274 { return memcpy(dst+dst_off, src, sz); }
275
276 INLINE void *
277 __hscore_memcpy_src_off( char *dst, char *src, int src_off, size_t sz )
278 { return memcpy(dst, src+src_off, sz); }
279
280 INLINE HsBool
281 __hscore_supportsTextMode()
282 {
283 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
284   return HS_BOOL_FALSE;
285 #else
286   return HS_BOOL_TRUE;
287 #endif
288 }
289
290 INLINE HsInt
291 __hscore_bufsiz()
292 {
293   return BUFSIZ;
294 }
295
296 INLINE HsInt
297 __hscore_seek_cur()
298 {
299   return SEEK_CUR;
300 }
301
302 INLINE HsInt
303 __hscore_o_binary()
304 {
305 #if defined(_MSC_VER)
306   return O_BINARY;
307 #else
308   return CONST_O_BINARY;
309 #endif
310 }
311
312 INLINE int
313 __hscore_o_rdonly()
314 {
315 #ifdef O_RDONLY
316   return O_RDONLY;
317 #else
318   return 0;
319 #endif
320 }
321
322 INLINE int
323 __hscore_o_wronly( void )
324 {
325 #ifdef O_WRONLY
326   return O_WRONLY;
327 #else
328   return 0;
329 #endif
330 }
331
332 INLINE int
333 __hscore_o_rdwr( void )
334 {
335 #ifdef O_RDWR
336   return O_RDWR;
337 #else
338   return 0;
339 #endif
340 }
341
342 INLINE int
343 __hscore_o_append( void )
344 {
345 #ifdef O_APPEND
346   return O_APPEND;
347 #else
348   return 0;
349 #endif
350 }
351
352 INLINE int
353 __hscore_o_creat( void )
354 {
355 #ifdef O_CREAT
356   return O_CREAT;
357 #else
358   return 0;
359 #endif
360 }
361
362 INLINE int
363 __hscore_o_excl( void )
364 {
365 #ifdef O_EXCL
366   return O_EXCL;
367 #else
368   return 0;
369 #endif
370 }
371
372 INLINE int
373 __hscore_o_trunc( void )
374 {
375 #ifdef O_TRUNC
376   return O_TRUNC;
377 #else
378   return 0;
379 #endif
380 }
381
382 INLINE int
383 __hscore_o_noctty( void )
384 {
385 #ifdef O_NOCTTY
386   return O_NOCTTY;
387 #else
388   return 0;
389 #endif
390 }
391
392 INLINE int
393 __hscore_o_nonblock( void )
394 {
395 #ifdef O_NONBLOCK
396   return O_NONBLOCK;
397 #else
398   return 0;
399 #endif
400 }
401
402 INLINE HsInt
403 __hscore_seek_set( void )
404 {
405   return SEEK_SET;
406 }
407
408 INLINE HsInt
409 __hscore_seek_end( void )
410 {
411   return SEEK_END;
412 }
413
414 INLINE int
415 __hscore_ftruncate( int fd, off_t where )
416 {
417 #if defined(HAVE_FTRUNCATE)
418   return ftruncate(fd,where);
419 #elif defined(HAVE__CHSIZE)
420   return _chsize(fd,where);
421 #else
422 #error at least ftruncate or _chsize functions are required to build
423 #endif
424 }
425
426 INLINE HsInt
427 __hscore_setmode( HsInt fd, HsBool toBin )
428 {
429 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
430   return setmode(fd,(toBin == HS_BOOL_TRUE) ? _O_BINARY : _O_TEXT);
431 #else
432   return 0;
433 #endif
434 }
435
436 #if __GLASGOW_HASKELL__
437
438 INLINE HsInt
439 __hscore_PrelHandle_write( HsInt fd, HsAddr ptr, HsInt off, int sz )
440 {
441   return write(fd,(char *)ptr + off, sz);
442 }
443
444 INLINE HsInt
445 __hscore_PrelHandle_read( HsInt fd, HsAddr ptr, HsInt off, int sz )
446 {
447   return read(fd,(char *)ptr + off, sz);
448
449 }
450
451 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
452 INLINE HsInt
453 __hscore_PrelHandle_send( HsInt fd, HsAddr ptr, HsInt off, int sz )
454 {
455     return send(fd,(char *)ptr + off, sz, 0);
456 }
457
458 INLINE HsInt
459 __hscore_PrelHandle_recv( HsInt fd, HsAddr ptr, HsInt off, int sz )
460 {
461     return recv(fd,(char *)ptr + off, sz, 0);
462 }
463 #endif
464
465 #endif /* __GLASGOW_HASKELL__ */
466
467 INLINE HsInt
468 __hscore_mkdir( HsAddr pathName, HsInt mode )
469 {
470 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
471   return mkdir(pathName);
472 #else
473   return mkdir(pathName,mode);
474 #endif
475 }
476
477 INLINE HsInt
478 __hscore_lstat( HsAddr fname, HsAddr st )
479 {
480 #if HAVE_LSTAT
481   return lstat((const char*)fname, (struct stat*)st);
482 #else
483   return stat((const char*)fname, (struct stat*)st);
484 #endif
485 }
486
487 #ifdef PATH_MAX
488 /* A size that will contain many path names, but not necessarily all
489  * (PATH_MAX is not defined on systems with unlimited path length,
490  * e.g. the Hurd).
491  */
492 INLINE HsInt __hscore_long_path_size() { return PATH_MAX; }
493 #else
494 INLINE HsInt __hscore_long_path_size() { return 4096; }
495 #endif
496
497 #ifdef R_OK
498 INLINE mode_t __hscore_R_OK() { return R_OK; }
499 #endif
500 #ifdef W_OK
501 INLINE mode_t __hscore_W_OK() { return W_OK; }
502 #endif
503 #ifdef X_OK
504 INLINE mode_t __hscore_X_OK() { return X_OK; }
505 #endif
506
507 #ifdef S_IRUSR
508 INLINE mode_t __hscore_S_IRUSR() { return S_IRUSR; }
509 #endif
510 #ifdef S_IWUSR
511 INLINE mode_t __hscore_S_IWUSR() { return S_IWUSR; }
512 #endif
513 #ifdef S_IXUSR
514 INLINE mode_t __hscore_S_IXUSR() { return S_IXUSR; }
515 #endif
516
517 INLINE HsAddr
518 __hscore_d_name( struct dirent* d )
519 {
520   return (HsAddr)(d->d_name);
521 }
522
523 INLINE HsInt
524 __hscore_end_of_dir( void )
525 {
526   return READDIR_ERRNO_EOF;
527 }
528
529 INLINE void
530 __hscore_free_dirent(HsAddr dEnt)
531 {
532 #if HAVE_READDIR_R
533   free(dEnt);
534 #endif
535 }
536
537 INLINE HsInt
538 __hscore_sizeof_stat( void )
539 {
540   return sizeof(struct stat);
541 }
542
543 INLINE time_t __hscore_st_mtime ( struct stat* st ) { return st->st_mtime; }
544 INLINE off_t  __hscore_st_size  ( struct stat* st ) { return st->st_size; }
545 #if !defined(_MSC_VER)
546 INLINE mode_t __hscore_st_mode  ( struct stat* st ) { return st->st_mode; }
547 #endif
548
549 #if HAVE_TERMIOS_H
550 INLINE tcflag_t __hscore_lflag( struct termios* ts ) { return ts->c_lflag; }
551
552 INLINE void
553 __hscore_poke_lflag( struct termios* ts, tcflag_t t ) { ts->c_lflag = t; }
554
555 INLINE unsigned char*
556 __hscore_ptr_c_cc( struct termios* ts )
557 { return (unsigned char*) &ts->c_cc; }
558
559 INLINE HsInt
560 __hscore_sizeof_termios( void )
561 {
562 #ifndef __MINGW32__
563   return sizeof(struct termios);
564 #else
565   return 0;
566 #endif
567 }
568 #endif
569
570 #if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_WIN32)
571 INLINE HsInt
572 __hscore_sizeof_sigset_t( void )
573 {
574   return sizeof(sigset_t);
575 }
576 #endif
577
578 INLINE int
579 __hscore_echo( void )
580 {
581 #ifdef ECHO
582   return ECHO;
583 #else
584   return 0;
585 #endif
586
587 }
588
589 INLINE int
590 __hscore_tcsanow( void )
591 {
592 #ifdef TCSANOW
593   return TCSANOW;
594 #else
595   return 0;
596 #endif
597
598 }
599
600 INLINE int
601 __hscore_icanon( void )
602 {
603 #ifdef ICANON
604   return ICANON;
605 #else
606   return 0;
607 #endif
608 }
609
610 INLINE int __hscore_vmin( void )
611 {
612 #ifdef VMIN
613   return VMIN;
614 #else
615   return 0;
616 #endif
617 }
618
619 INLINE int __hscore_vtime( void )
620 {
621 #ifdef VTIME
622   return VTIME;
623 #else
624   return 0;
625 #endif
626 }
627
628 INLINE int __hscore_sigttou( void )
629 {
630 #ifdef SIGTTOU
631   return SIGTTOU;
632 #else
633   return 0;
634 #endif
635 }
636
637 INLINE int __hscore_sig_block( void )
638 {
639 #ifdef SIG_BLOCK
640   return SIG_BLOCK;
641 #else
642   return 0;
643 #endif
644 }
645
646 INLINE int __hscore_sig_setmask( void )
647 {
648 #ifdef SIG_SETMASK
649   return SIG_SETMASK;
650 #else
651   return 0;
652 #endif
653 }
654
655 INLINE int
656 __hscore_f_getfl( void )
657 {
658 #ifdef F_GETFL
659   return F_GETFL;
660 #else
661   return 0;
662 #endif
663 }
664
665 INLINE int
666 __hscore_f_setfl( void )
667 {
668 #ifdef F_SETFL
669   return F_SETFL;
670 #else
671   return 0;
672 #endif
673 }
674
675 // defined in rts/RtsStartup.c.
676 extern void* __hscore_get_saved_termios(int fd);
677 extern void __hscore_set_saved_termios(int fd, void* ts);
678
679 INLINE int __hscore_hs_fileno (FILE *f) { return fileno (f); }
680
681 INLINE int __hscore_open(char *file, int how, mode_t mode) {
682 #ifdef __MINGW32__
683         if ((how & O_WRONLY) || (how & O_RDWR) || (how & O_APPEND))
684           return _sopen(file,how,_SH_DENYRW,mode);
685         else
686           return _sopen(file,how,_SH_DENYWR,mode);
687 #else
688         return open(file,how,mode);
689 #endif
690 }
691
692 // These are wrapped because on some OSs (eg. Linux) they are
693 // macros which redirect to the 64-bit-off_t versions when large file
694 // support is enabled.
695 //
696 INLINE off_t __hscore_lseek(int fd, off_t off, int whence) {
697         return (lseek(fd,off,whence));
698 }
699
700 INLINE int __hscore_stat(char *file, struct stat *buf) {
701         return (stat(file,buf));
702 }
703
704 INLINE int __hscore_fstat(int fd, struct stat *buf) {
705         return (fstat(fd,buf));
706 }
707
708 // select-related stuff
709
710 #if !defined(__MINGW32__)
711 INLINE int  hsFD_SETSIZE(void) { return FD_SETSIZE; }
712 INLINE void hsFD_CLR(int fd, fd_set *fds) { FD_CLR(fd, fds); }
713 INLINE int  hsFD_ISSET(int fd, fd_set *fds) { return FD_ISSET(fd, fds); }
714 INLINE void hsFD_SET(int fd, fd_set *fds) { FD_SET(fd, fds); }
715 INLINE int  sizeof_fd_set(void) { return sizeof(fd_set); }
716 extern void hsFD_ZERO(fd_set *fds);
717 #endif
718
719 // gettimeofday()-related
720
721 #if !defined(__MINGW32__)
722 #define TICK_FREQ  50
723
724 INLINE HsInt sizeofTimeVal(void) { return sizeof(struct timeval); }
725
726 INLINE HsInt getTicksOfDay(void)
727 {
728     struct timeval tv;
729     gettimeofday(&tv, (struct timezone *) NULL);
730     return (tv.tv_sec * TICK_FREQ +
731             tv.tv_usec * TICK_FREQ / 1000000);
732 }
733
734 INLINE void setTimevalTicks(struct timeval *p, HsInt ticks)
735 {
736     p->tv_sec  = ticks / TICK_FREQ;
737     p->tv_usec = (ticks % TICK_FREQ) * (1000000 / TICK_FREQ);
738 }
739 #endif /* !defined(__MINGW32__) */
740
741 // Directory-related
742
743 #if defined(__MINGW32__)
744
745 /* Make sure we've got the reqd CSIDL_ constants in scope;
746  * w32api header files are lagging a bit in defining the full set.
747  */
748 #if !defined(CSIDL_APPDATA)
749 #define CSIDL_APPDATA 0x001a
750 #endif
751 #if !defined(CSIDL_PERSONAL)
752 #define CSIDL_PERSONAL 0x0005
753 #endif
754 #if !defined(CSIDL_PROFILE)
755 #define CSIDL_PROFILE 0x0028
756 #endif
757 #if !defined(CSIDL_WINDOWS)
758 #define CSIDL_WINDOWS 0x0024
759 #endif
760
761 INLINE int __hscore_CSIDL_PROFILE()  { return CSIDL_PROFILE;  }
762 INLINE int __hscore_CSIDL_APPDATA()  { return CSIDL_APPDATA;  }
763 INLINE int __hscore_CSIDL_WINDOWS()  { return CSIDL_WINDOWS;  }
764 INLINE int __hscore_CSIDL_PERSONAL() { return CSIDL_PERSONAL; }
765 #endif
766
767 #if defined(__MINGW32__)
768 INLINE unsigned int __hscore_get_osver(void) { return _osver; }
769 #endif
770
771 /* ToDo: write a feature test that doesn't assume 'environ' to
772  *    be in scope at link-time. */
773 extern char** environ;
774 INLINE char **__hscore_environ() { return environ; }
775
776 /* lossless conversions between pointers and integral types */
777 INLINE void *    __hscore_from_uintptr(uintptr_t n) { return (void *)n; }
778 INLINE void *    __hscore_from_intptr (intptr_t n)  { return (void *)n; }
779 INLINE uintptr_t __hscore_to_uintptr  (void *p)     { return (uintptr_t)p; }
780 INLINE intptr_t  __hscore_to_intptr   (void *p)     { return (intptr_t)p; }
781
782 #endif /* __HSBASE_H__ */
783