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