Fix iOS 5.0 issue (file descriptors for regular files can't be put in nonblocking...
[gambit-c.git] / lib / os.h
blobfa6e64d4809dca2b00374b2b711444b6e0a5ffab
1 /* File: "os.h" */
3 /* Copyright (c) 1994-2012 by Marc Feeley, All Rights Reserved. */
5 #ifndef ___OS_H
6 #define ___OS_H
9 /*---------------------------------------------------------------------------*/
11 /* Determine subsystems to debug. */
13 #define ___DEBUG_not
14 #define ___DEBUG_TTY_not
15 #define ___DEBUG_ALLOC_MEM_TRACE_not
18 /*---------------------------------------------------------------------------*/
20 /* Determine which line editing features to enable. */
22 #define USE_LINEEDITOR
23 #define LINEEDITOR_WITH_NONBLOCKING_IO
24 #define LINEEDITOR_SUPPORT_F5_TO_F12
25 #define LINEEDITOR_SUPPORT_ALTERNATE_ESCAPES
26 #define LINEEDITOR_WITH_LOCAL_CLIPBOARD
27 #define LINEEDITOR_REPORT_CHAR_ENCODING_ERRORS
30 /*---------------------------------------------------------------------------*/
32 /* Determine if we are using POSIX or WIN32. */
34 #ifdef ___OS_WIN32
35 #define USE_WIN32
36 #endif
38 #ifdef HAVE_WAITPID
41 * Heuristic: if waitpid is available then this is probably a POSIX system.
44 #define USE_POSIX
46 #endif
48 #ifndef USE_WIN32
49 #ifndef USE_POSIX
52 * If this is not a WIN32 or POSIX system, the OS is generic.
55 #define USE_GENERIC_OS
57 #endif
58 #endif
60 /*---------------------------------------------------------------------------*/
63 * We assume that the following basic features are available
64 * regardless of the operating-system... otherwise we are in real
65 * trouble!
68 #define USE_errno
69 #define USE_malloc
70 #define USE_memmove
74 * The following basic features are used if they are available.
77 #ifdef HAVE_GETENV
78 #define USE_getenv
79 #endif
81 #ifdef HAVE_SETENV
82 #define USE_setenv
83 #endif
85 #ifdef HAVE_UNSETENV
86 #define USE_unsetenv
87 #endif
90 /* Operating-system specific features we require */
92 #ifdef USE_POSIX
94 #define USE_open
96 /* Select features based on availability */
98 #ifdef HAVE_ENVIRON
99 #define USE_environ
100 #else
101 #ifdef HAVE__NSGETENVIRON
102 #define USE_environ
103 #endif
104 #endif
106 #ifdef HAVE_PIPE
107 #define USE_pipe
108 #else
109 #ifdef HAVE_SOCKETPAIR
110 #define USE_socketpair
111 #endif
112 #endif
114 #ifdef HAVE_CHDIR
115 #define USE_chdir
116 #endif
118 #ifdef HAVE_EXECVP
119 #define USE_execvp
120 #endif
122 #ifdef HAVE_GETGRNAM
123 #define USE_getgrnam
124 #endif
126 #ifdef HAVE_GETPID
127 #define USE_getpid
128 #endif
130 #ifdef HAVE_GETPPID
131 #define USE_getppid
132 #endif
134 #ifdef HAVE_GETPWNAM
135 #define USE_getpwnam
136 #endif
138 #ifdef HAVE_IOCTL
139 #define USE_ioctl
140 #endif
142 #ifdef HAVE_LINK
143 #define USE_link
144 #endif
146 #ifdef HAVE_MKDIR
147 #define USE_mkdir
148 #endif
150 #ifdef HAVE_MKFIFO
151 #define USE_mkfifo
152 #endif
154 #ifdef HAVE_OPENDIR
155 #define USE_opendir
156 #endif
158 #ifdef HAVE_RENAME
159 #define USE_rename
160 #endif
162 #ifdef HAVE_RMDIR
163 #define USE_rmdir
164 #endif
166 #ifdef HAVE_SOCKET
167 #define USE_socket
168 #define USE_NETWORKING
169 #endif
171 #if defined(HAVE_STAT64) && defined(HAVE_STRUCT_STAT64) && !(defined(__MACOSX__) || (defined(__APPLE__) && defined(__MACH__)))
172 #define USE_stat
173 #define ___struct_stat struct stat64
174 #define ___stat stat64
175 #define ___lstat lstat64
176 #define ___fstat fstat64
177 #else
178 #ifdef HAVE_STAT
179 #define USE_stat
180 #define ___struct_stat struct stat
181 #define ___stat stat
182 #define ___lstat lstat
183 #define ___fstat fstat
184 #endif
185 #endif
187 #define USE_NONBLOCKING_FILE_IO
189 #ifdef HAVE_TARGETCONDITIONALS_H
190 #include <TargetConditionals.h>
191 #ifdef TARGET_OS_IPHONE
192 #if TARGET_OS_IPHONE == 1
193 #undef USE_NONBLOCKING_FILE_IO
194 #endif
195 #endif
196 #endif
198 #ifdef HAVE_STRERROR
199 #define USE_strerror
200 #endif
202 #ifdef HAVE_SYMLINK
203 #define USE_symlink
204 #endif
206 #ifdef HAVE_SYSCONF
207 #define USE_sysconf
208 #endif
210 #ifdef HAVE_TCGETATTR
211 #define USE_tcgetattr
212 #endif
214 #ifdef HAVE_UNLINK
215 #define USE_unlink
216 #endif
218 #ifdef HAVE_WAITPID
219 #define USE_waitpid
220 #endif
222 #ifdef HAVE_MMAP
223 #define USE_mmap
224 #endif
226 #if 0
229 * This code is now commented out as it seems to be causing trouble on
230 * CYGWIN and the problem it was trying to solve no longer seems to
231 * exist (perhaps the bug in CYGWIN has since been repaired).
234 #ifdef __CYGWIN__
236 * Cygwin's timer implementation does not support ITIMER_VIRTUAL and
237 * ITIMER_REAL causes dynamic loading to fail. Why? I don't know!
238 * Use WIN32's CreateThread instead.
240 #undef HAVE_SETITIMER
241 #define HAVE_CREATETHREAD 1
242 #define USE_GetLastError
243 #define HAVE_WINDOWS_H 1
244 #define INCLUDE_windows_h
245 #endif
247 #endif
249 #endif
252 #ifdef USE_WIN32
255 * WIN32 does not support "Unix style" nonblocking I/O. This can be
256 * simulated using pumps.
259 #define USE_PUMPS
261 #undef LINEEDITOR_WITH_LOCAL_CLIPBOARD
263 #define USE_ioctl
264 #define USE_CopyFile
265 #define USE_CreateDirectory
266 #define USE_CreateProcess
267 #define USE_DeleteFile
268 #define USE_FindFirstFile
269 #define USE_FormatMessage
270 #define USE_GetCurrentProcessId
271 #define USE_GetEnvironmentStrings
272 #define USE_GetEnvironmentVariable
273 #define USE_GetFileAttributesEx
274 #define USE_GetLastError
275 #define USE_MoveFile
276 #define USE_RemoveDirectory
277 #define USE_SetCurrentDirectory
278 #define USE_SetEnvironmentVariable
279 #define USE_WSAGetLastError
280 #define USE_GetConsoleWindow
281 #define USE_GetModuleFileName
282 #define USE_VirtualAlloc
284 #define HAVE_CLOCK 1
285 #define HAVE_CREATETHREAD 1
286 #define HAVE_GETPROCESSTIMES 1
287 #define HAVE_GETSYSTEMTIME 1
288 #define HAVE_LOADLIBRARY 1
289 #define HAVE_MSGWAITFORMULTIPLEOBJECTS 1
290 #define HAVE_Sleep 1
292 #define HAVE_GETHOSTNAME 1
293 #define HAVE_GETPEERNAME 1
294 #define HAVE_GETSOCKNAME 1
295 #undef HAVE_INET_PTON
296 #define HAVE_GETADDRINFO 1
297 #define HAVE_GETHOSTBYNAME 1
298 #define HAVE_GETHOSTBYADDR 1
299 #define HAVE_GETSERVBYNAME 1
300 #define HAVE_GETSERVBYPORT 1
301 #define HAVE_GETPROTOBYNAME 1
302 #define HAVE_GETPROTOBYNUMBER 1
303 #define HAVE_GETNETBYNAME 1
305 #define HAVE_WINDOWS_H 1
306 #define INCLUDE_windows_h
307 #define HAVE_WINSOCK2_H 1
308 #define INCLUDE_winsock2_h
309 #define HAVE_WS2TCPIP_H 1
310 #define INCLUDE_ws2tcpip_h
311 #define USE_NETWORKING
313 #define HAVE_IO_H 1
314 #define INCLUDE_io_h
316 #define HAVE_TCHAR_H 1
317 #define INCLUDE_tchar_h
319 #define HAVE_ERRNO_H 1
321 #ifdef __WATCOMC__
322 #define HAVE_STDINT_H 1
323 #define INCLUDE_stdint_h
324 #endif
326 #endif
329 /*---------------------------------------------------------------------------*/
331 /* Determine which function for getting real time is most precise. */
333 #ifdef HAVE_CLOCK_GETTIME
334 #define USE_clock_gettime
335 #else
336 #ifdef HAVE_GETCLOCK
337 #define USE_getclock
338 #else
339 #ifdef HAVE_GETSYSTEMTIME
340 #define USE_GetSystemTime
341 #else
342 #ifdef HAVE_GETTIMEOFDAY
343 #define USE_gettimeofday
344 #else
345 #ifdef HAVE_FTIME
346 #define USE_ftime
347 #else
348 #ifdef HAVE_TIME
349 #define USE_time
350 #endif
351 #endif
352 #endif
353 #endif
354 #endif
355 #endif
358 /* Determine which function for sleeping is most precise. */
360 #ifdef HAVE_NANOSLEEP
361 #define USE_nanosleep
362 #else
363 #ifdef HAVE_Sleep
364 #define USE_Sleep
365 #else
366 #ifdef HAVE_SLEEP
367 #define USE_sleep
368 #endif
369 #endif
370 #endif
373 /* Determine which function for getting process time is most precise. */
375 #ifdef HAVE_GETPROCESSTIMES
376 #define USE_GetProcessTimes
377 #else
378 #ifdef HAVE_GETRUSAGE
379 #define USE_getrusage
380 #else
381 #ifdef HAVE_TIMES
382 #define USE_times
383 #else
384 #ifdef HAVE_CLOCK
385 #define USE_clock
386 #else
387 #ifdef HAVE_DOSQUERYSYSINFO
388 #define USE_DosQuerySysInfo
389 #endif
390 #endif
391 #endif
392 #endif
393 #endif
396 /* Determine which heartbeat timer interface to use. */
398 #ifdef HAVE_SETITIMER
399 #define USE_setitimer
400 #else
401 #ifdef HAVE_DOS_SETVECT
402 #define USE_dos_setvect
403 #else
404 #ifdef HAVE_DOSSTARTTIMER
405 #define USE_DosStartTimer
406 #else
407 #ifdef HAVE_VINSTALL
408 #define USE_VInstall
409 #else
410 #ifdef HAVE_CREATETHREAD
411 #define USE_CreateThread
412 #endif
413 #endif
414 #endif
415 #endif
416 #endif
419 /* Determine which signal interface to use. */
421 #ifdef HAVE_SIGACTION
422 #define USE_sigaction
423 #ifndef HAVE_SIGEMPTYSET
424 #undef USE_sigaction
425 #endif
426 #ifndef HAVE_SIGADDSET
427 #undef USE_sigaction
428 #endif
429 #ifndef HAVE_SIGPROCMASK
430 #undef USE_sigaction
431 #endif
432 #endif
434 #ifndef USE_sigaction
435 #ifdef HAVE_SIGNAL
436 #define USE_signal
437 #endif
438 #endif
441 /* Determine which dynamic loading interface to use. */
443 #ifdef HAVE_SHL_LOAD
444 #define USE_shl_load
445 #else
446 #ifdef HAVE_LOADLIBRARY
447 #define USE_LoadLibrary
448 #else
449 #ifdef HAVE_DOSLOADMODULE
450 #define USE_DosLoadModule
451 #else
452 #ifdef HAVE_DXE_LOAD
453 #define USE_dxe_load
454 #else
455 #ifdef HAVE_GETDISKFRAGMENT
456 #define USE_GetDiskFragment
457 #else
458 #ifdef HAVE_DLOPEN
459 #define USE_dlopen
460 #else
461 #ifdef HAVE_NSLINKMODULE
462 #define USE_NSLinkModule
463 #endif
464 #endif
465 #endif
466 #endif
467 #endif
468 #endif
469 #endif
472 /* Determine which function to use for miscellaneous networking features. */
474 #ifdef HAVE_GETHOSTNAME
475 #define USE_gethostname
476 #endif
478 #ifdef HAVE_GETPEERNAME
479 #define USE_getpeername
480 #endif
482 #ifdef HAVE_GETSOCKNAME
483 #define USE_getsockname
484 #endif
486 #ifdef HAVE_INET_PTON
487 #define USE_inet_pton
488 #endif
490 #ifdef HAVE_GETADDRINFO
491 #define USE_getaddrinfo
492 #endif
494 #ifdef HAVE_GETHOSTBYNAME
495 #define USE_gethostbyname
496 #endif
498 #ifdef HAVE_GETHOSTBYADDR
499 #define USE_gethostbyaddr
500 #endif
502 #ifdef HAVE_GETSERVBYNAME
503 #define USE_getservbyname
504 #endif
506 #ifdef HAVE_GETSERVBYPORT
507 #define USE_getservbyport
508 #endif
510 #ifdef HAVE_GETPROTOBYNAME
511 #define USE_getprotobyname
512 #endif
514 #ifdef HAVE_GETPROTOBYNUMBER
515 #define USE_getprotobynumber
516 #endif
518 #ifdef HAVE_GETNETBYNAME
519 #define USE_getnetbyname
520 #endif
523 /* Determine which select interface to use. */
525 #ifdef HAVE_SELECT
526 #define USE_select
527 #else
528 #ifdef HAVE_MSGWAITFORMULTIPLEOBJECTS
529 #define USE_MsgWaitForMultipleObjects
530 #endif
531 #endif
534 /* Determine which curses interface should be used. */
536 #if 1
539 * We use our own curses implementation to avoid depending on the OS's
540 * curses library, which is difficult to link to on some systems.
543 #define USE_CURSES
545 #else
547 #ifdef HAVE_TGETSTR
548 #define USE_TERMCAP
549 #define USE_CURSES
550 #else
551 #ifdef HAVE_TIGETSTR
552 #define USE_TERMINFO
553 #define USE_CURSES
554 #endif
555 #endif
557 #endif
560 /* Determine which pty interface should be used. */
562 #ifdef HAVE_OPENPTY
563 #define USE_openpty
564 #else
565 #ifdef HAVE_GETPT
566 #define USE_getpt
567 #endif
568 #ifdef HAVE_PTSNAME
569 #define USE_ptsname
570 #endif
571 #endif
574 /* Determine which error interface should be used. */
576 #ifdef HAVE_HSTRERROR
577 #define USE_hstrerror
578 #endif
581 /* Determine which floating point configuration interface should be used. */
583 #ifdef HAVE_GET_FPC_CSR
584 #define USE_get_fpc_csr
585 #endif
588 /*---------------------------------------------------------------------------*/
590 /* Determine which header files to include. */
592 #ifdef USE_malloc
593 #undef INCLUDE_stdlib_h
594 #define INCLUDE_stdlib_h
595 #endif
597 #ifdef USE_environ
598 #ifdef HAVE_ENVIRON
599 ___BEGIN_C_LINKAGE
600 extern char **environ;
601 ___END_C_LINKAGE
602 #else
603 #ifdef HAVE__NSGETENVIRON
604 #define environ (*_NSGetEnviron())
605 #undef INCLUDE_crt_externs_h
606 #define INCLUDE_crt_externs_h
607 #endif
608 #endif
609 #endif
611 #ifdef USE_getenv
612 #undef INCLUDE_stdlib_h
613 #define INCLUDE_stdlib_h
614 #endif
616 #ifdef USE_setenv
617 #undef INCLUDE_stdlib_h
618 #define INCLUDE_stdlib_h
619 #endif
621 #ifdef USE_unsetenv
622 #undef INCLUDE_stdlib_h
623 #define INCLUDE_stdlib_h
624 #endif
626 #ifdef USE_open
627 #undef INCLUDE_sys_types_h
628 #define INCLUDE_sys_types_h
629 #undef INCLUDE_sys_stat_h
630 #define INCLUDE_sys_stat_h
631 #undef INCLUDE_fcntl_h
632 #define INCLUDE_fcntl_h
633 #endif
635 #ifdef USE_opendir
636 #undef INCLUDE_sys_types_h
637 #define INCLUDE_sys_types_h
638 #undef INCLUDE_dirent_h
639 #define INCLUDE_dirent_h
640 #endif
642 #ifdef USE_stat
643 #undef INCLUDE_sys_types_h
644 #define INCLUDE_sys_types_h
645 #undef INCLUDE_sys_stat_h
646 #define INCLUDE_sys_stat_h
647 #undef INCLUDE_unistd_h
648 #define INCLUDE_unistd_h
649 #endif
651 #ifdef USE_ioctl
652 #undef INCLUDE_sys_ioctl_h
653 #define INCLUDE_sys_ioctl_h
654 #endif
656 #ifdef USE_getpwnam
657 #undef INCLUDE_sys_types_h
658 #define INCLUDE_sys_types_h
659 #undef INCLUDE_pwd_h
660 #define INCLUDE_pwd_h
661 #endif
663 #ifdef USE_getgrnam
664 #undef INCLUDE_sys_types_h
665 #define INCLUDE_sys_types_h
666 #undef INCLUDE_grp_h
667 #define INCLUDE_grp_h
668 #endif
670 #ifdef USE_errno
671 #undef INCLUDE_errno_h
672 #define INCLUDE_errno_h
673 #endif
675 #ifdef USE_strerror
676 #undef INCLUDE_string_h
677 #define INCLUDE_string_h
678 #endif
680 #ifdef USE_memmove
681 #undef INCLUDE_string_h
682 #define INCLUDE_string_h
683 #endif
685 #ifdef USE_hstrerror
686 #undef INCLUDE_netdb_h
687 #define INCLUDE_netdb_h
688 #endif
690 #ifdef USE_time
691 #undef INCLUDE_time_h
692 #define INCLUDE_time_h
693 #endif
695 #ifdef USE_ftime
696 #undef INCLUDE_sys_types_h
697 #define INCLUDE_sys_types_h
698 #undef INCLUDE_sys_timeb_h
699 #define INCLUDE_sys_timeb_h
700 #endif
702 #ifdef USE_gettimeofday
703 #undef INCLUDE_sys_time_h
704 #define INCLUDE_sys_time_h
705 #endif
707 #ifdef USE_setitimer
708 #undef INCLUDE_sys_time_h
709 #define INCLUDE_sys_time_h
710 #endif
712 #ifdef USE_nanosleep
713 #undef INCLUDE_time_h
714 #define INCLUDE_time_h
715 #endif
717 #ifdef USE_sleep
718 #undef INCLUDE_unistd_h
719 #define INCLUDE_unistd_h
720 #endif
722 #ifdef USE_times
723 #undef INCLUDE_sys_times_h
724 #define INCLUDE_sys_times_h
725 #endif
727 #ifdef USE_clock_gettime
728 #undef INCLUDE_time_h
729 #define INCLUDE_time_h
730 #endif
732 #ifdef USE_getclock
733 #undef INCLUDE_sys_timers_h
734 #define INCLUDE_sys_timers_h
735 #endif
737 #ifdef USE_getrusage
738 #undef INCLUDE_sys_time_h
739 #define INCLUDE_sys_time_h
740 #undef INCLUDE_sys_resource_h
741 #define INCLUDE_sys_resource_h
742 #undef INCLUDE_unistd_h
743 #define INCLUDE_unistd_h
744 #endif
746 #ifdef USE_dlopen
747 #undef INCLUDE_dlfcn_h
748 #define INCLUDE_dlfcn_h
749 #endif
751 #ifdef USE_shl_load
752 #undef INCLUDE_dl_h
753 #define INCLUDE_dl_h
754 #endif
756 #ifdef USE_dxe_load
757 #undef INCLUDE_sys_dxe_h
758 #define INCLUDE_sys_dxe_h
759 #endif
761 #ifdef USE_NSLinkModule
762 #undef INCLUDE_mach_o_dyld_h
763 #define INCLUDE_mach_o_dyld_h
764 #endif
766 #ifdef USE_signal
767 #undef INCLUDE_signal_h
768 #define INCLUDE_signal_h
769 #endif
771 #ifdef USE_sigaction
772 #undef INCLUDE_signal_h
773 #define INCLUDE_signal_h
774 #endif
776 #ifdef USE_socket
777 #undef INCLUDE_sys_types_h
778 #define INCLUDE_sys_types_h
779 #undef INCLUDE_sys_socket_h
780 #define INCLUDE_sys_socket_h
781 #endif
783 #ifdef USE_execvp
784 #undef INCLUDE_unistd_h
785 #define INCLUDE_unistd_h
786 #endif
788 #ifdef USE_waitpid
789 #undef INCLUDE_sys_types_h
790 #define INCLUDE_sys_types_h
791 #undef INCLUDE_sys_wait_h
792 #define INCLUDE_sys_wait_h
793 #endif
795 #ifdef USE_mmap
796 #undef INCLUDE_sys_types_h
797 #define INCLUDE_sys_types_h
798 #undef INCLUDE_sys_mman_h
799 #define INCLUDE_sys_mman_h
800 #endif
802 #ifdef USE_gethostname
803 #undef INCLUDE_unistd_h
804 #define INCLUDE_unistd_h
805 #endif
807 #ifdef USE_getpeername
808 #undef INCLUDE_sys_socket_h
809 #define INCLUDE_sys_socket_h
810 #endif
812 #ifdef USE_getsockname
813 #undef INCLUDE_sys_socket_h
814 #define INCLUDE_sys_socket_h
815 #endif
817 #ifdef HAVE_INET_PTON
818 #undef INCLUDE_sys_types_h
819 #define INCLUDE_sys_types_h
820 #undef INCLUDE_sys_socket_h
821 #define INCLUDE_sys_socket_h
822 #undef INCLUDE_netinet_in_h
823 #define INCLUDE_netinet_in_h
824 #undef INCLUDE_arpa_inet_h
825 #define INCLUDE_arpa_inet_h
826 #endif
828 #ifdef USE_getaddrinfo
829 #undef INCLUDE_sys_types_h
830 #define INCLUDE_sys_types_h
831 #undef INCLUDE_sys_socket_h
832 #define INCLUDE_sys_socket_h
833 #undef INCLUDE_netdb_h
834 #define INCLUDE_netdb_h
835 #endif
837 #ifdef USE_gethostbyname
838 #undef INCLUDE_sys_socket_h
839 #define INCLUDE_sys_socket_h
840 #undef INCLUDE_netinet_in_h
841 #define INCLUDE_netinet_in_h
842 #undef INCLUDE_netdb_h
843 #define INCLUDE_netdb_h
844 #endif
846 #ifdef USE_gethostbyaddr
847 #undef INCLUDE_sys_socket_h
848 #define INCLUDE_sys_socket_h
849 #undef INCLUDE_netinet_in_h
850 #define INCLUDE_netinet_in_h
851 #undef INCLUDE_netdb_h
852 #define INCLUDE_netdb_h
853 #endif
855 #ifdef USE_getservbyname
856 #undef INCLUDE_sys_socket_h
857 #define INCLUDE_sys_socket_h
858 #undef INCLUDE_netinet_in_h
859 #define INCLUDE_netinet_in_h
860 #undef INCLUDE_netdb_h
861 #define INCLUDE_netdb_h
862 #endif
864 #ifdef USE_getservbyport
865 #undef INCLUDE_sys_socket_h
866 #define INCLUDE_sys_socket_h
867 #undef INCLUDE_netinet_in_h
868 #define INCLUDE_netinet_in_h
869 #undef INCLUDE_netdb_h
870 #define INCLUDE_netdb_h
871 #endif
873 #ifdef USE_getprotobyname
874 #undef INCLUDE_sys_socket_h
875 #define INCLUDE_sys_socket_h
876 #undef INCLUDE_netinet_in_h
877 #define INCLUDE_netinet_in_h
878 #undef INCLUDE_netdb_h
879 #define INCLUDE_netdb_h
880 #endif
882 #ifdef USE_getprotobynumber
883 #undef INCLUDE_sys_socket_h
884 #define INCLUDE_sys_socket_h
885 #undef INCLUDE_netinet_in_h
886 #define INCLUDE_netinet_in_h
887 #undef INCLUDE_netdb_h
888 #define INCLUDE_netdb_h
889 #endif
891 #ifdef USE_getnetbyname
892 #undef INCLUDE_sys_socket_h
893 #define INCLUDE_sys_socket_h
894 #undef INCLUDE_netinet_in_h
895 #define INCLUDE_netinet_in_h
896 #undef INCLUDE_netdb_h
897 #define INCLUDE_netdb_h
898 #endif
900 #ifdef USE_getgrnam
901 #undef INCLUDE_grp_h
902 #define INCLUDE_grp_h
903 #endif
905 #ifdef USE_fullpath
906 #undef INCLUDE_sys_stat_h
907 #define INCLUDE_sys_stat_h
908 #endif
910 #ifdef USE_control87
911 #undef INCLUDE_float_h
912 #define INCLUDE_float_h
913 #endif
915 #ifdef USE__FPU_SETCW
916 #undef INCLUDE_fpu_control_h
917 #define INCLUDE_fpu_control_h
918 #endif
920 #ifdef USE_get_fpc_csr
921 #undef INCLUDE_sys_fpu_h
922 #define INCLUDE_sys_fpu_h
923 #endif
925 #ifdef USE_t_fork
926 #undef INCLUDE_tfork_h
927 #define INCLUDE_tfork_h
928 #undef INCLUDE_sys_wait_h
929 #define INCLUDE_sys_wait_h
930 #endif
932 #ifdef USE_openpty
933 #undef INCLUDE_pty_h
934 #define INCLUDE_pty_h
935 #undef INCLUDE_util_h
936 #define INCLUDE_util_h
937 #endif
939 #ifdef USE_getpt
940 #undef INCLUDE_stdlib_h
941 #define INCLUDE_stdlib_h
942 #undef INCLUDE_stropts_h
943 #define INCLUDE_stropts_h
944 #endif
946 #ifdef USE_ptsname
947 #undef INCLUDE_stdlib_h
948 #define INCLUDE_stdlib_h
949 #undef INCLUDE_stropts_h
950 #define INCLUDE_stropts_h
951 #endif
953 #ifdef USE_tcgetattr
954 #undef INCLUDE_termios_h
955 #define INCLUDE_termios_h
956 #undef INCLUDE_unistd_h
957 #define INCLUDE_unistd_h
958 #endif
960 #ifdef USE_TERMCAP
961 #undef INCLUDE_curses_h
962 #define INCLUDE_curses_h
963 #endif
965 #ifdef USE_TERMINFO
966 #undef INCLUDE_curses_h
967 #define INCLUDE_curses_h
968 #endif
970 /*---------------------------------------------------------------------------*/
972 /* Inclusion of header files. */
974 #ifdef INCLUDE_errno_h
975 #ifdef HAVE_ERRNO_H
976 #include <errno.h>
977 #endif
978 #endif
980 #ifdef INCLUDE_unistd_h
981 #ifdef HAVE_UNISTD_H
982 #include <unistd.h>
983 #endif
984 #endif
986 #ifdef INCLUDE_pwd_h
987 #ifdef HAVE_PWD_H
988 #include <pwd.h>
989 #endif
990 #endif
992 #ifdef INCLUDE_dirent_h
993 #ifdef HAVE_DIRENT_H
994 #include <dirent.h>
995 #endif
996 #endif
998 #ifdef INCLUDE_dlfcn_h
999 #ifdef HAVE_DLFCN_H
1000 #include <dlfcn.h>
1001 #endif
1002 #endif
1004 #ifdef INCLUDE_dl_h
1005 #ifdef HAVE_DL_H
1006 #include <dl.h>
1007 #endif
1008 #endif
1010 #ifdef INCLUDE_sys_dxe_h
1011 #ifdef HAVE_SYS_DXE_H
1012 #include <sys/dxe.h>
1013 #endif
1014 #endif
1016 #ifdef INCLUDE_mach_o_dyld_h
1017 #ifdef HAVE_MACH_O_DYLD_H
1018 #include <mach-o/dyld.h>
1019 #endif
1020 #endif
1022 #ifdef INCLUDE_sys_types_h
1023 #ifdef HAVE_SYS_TYPES_H
1024 #include <sys/types.h>
1025 #endif
1026 #endif
1028 #ifdef INCLUDE_sys_time_h
1029 #ifdef HAVE_SYS_TIME_H
1030 #include <sys/time.h>
1031 #endif
1032 #endif
1034 #ifdef INCLUDE_sys_times_h
1035 #ifdef HAVE_SYS_TIMES_H
1036 #include <sys/times.h>
1037 #endif
1038 #endif
1040 #ifdef INCLUDE_sys_timeb_h
1041 #ifdef HAVE_SYS_TIMEB_H
1042 #include <sys/timeb.h>
1043 #endif
1044 #endif
1046 #ifdef INCLUDE_sys_timers_h
1047 #ifdef HAVE_SYS_TIMERS_H
1048 #include <sys/timers.h>
1049 #endif
1050 #endif
1052 #ifdef INCLUDE_time_h
1053 #ifdef HAVE_TIME_H
1054 #include <time.h>
1055 #endif
1056 #endif
1058 #ifdef INCLUDE_sys_resource_h
1059 #ifdef HAVE_SYS_RESOURCE_H
1060 #include <sys/resource.h>
1061 #endif
1062 #endif
1064 #ifdef INCLUDE_sys_stat_h
1065 #ifdef HAVE_SYS_STAT_H
1066 /* the following defines are useful on Linux to map stat to stat64 */
1067 #define __USE_LARGEFILE64
1068 #define __USE_FILE_OFFSET64
1069 #include <sys/stat.h>
1070 #endif
1071 #endif
1073 #ifdef INCLUDE_sys_wait_h
1074 #ifdef HAVE_SYS_WAIT_H
1075 #include <sys/wait.h>
1076 #endif
1077 #endif
1079 #ifdef INCLUDE_sys_mman_h
1080 #ifdef HAVE_SYS_MMAN_H
1081 #include <sys/mman.h>
1082 #endif
1083 #endif
1085 #ifdef INCLUDE_stat_h
1086 #ifdef HAVE_STAT_H
1087 #include <stat.h>
1088 #endif
1089 #endif
1091 #ifdef INCLUDE_signal_h
1092 #ifdef HAVE_SIGNAL_H
1093 #include <signal.h>
1094 #endif
1095 #endif
1097 #ifdef INCLUDE_netdb_h
1098 #ifdef HAVE_NETDB_H
1099 #ifdef _AIX
1100 /* AIX weirdness */
1101 #define _USE_IRS
1102 #endif
1103 #include <netdb.h>
1104 #define USE_h_errno
1105 #ifdef __hpux
1106 /* HP-UX weirdness */
1107 extern int h_errno;
1108 #ifndef NETDB_SUCCESS
1109 #define NETDB_SUCCESS 0
1110 #endif
1111 #ifndef NETDB_INTERNAL
1112 #ifdef NO_RECOVERY
1113 #define NETDB_INTERNAL NO_RECOVERY
1114 #endif
1115 #endif
1116 #endif
1117 #endif
1118 #endif
1120 #ifdef INCLUDE_grp_h
1121 #ifdef HAVE_GRP_H
1122 #include <grp.h>
1123 #endif
1124 #endif
1126 #ifdef INCLUDE_windows_h
1127 #ifdef HAVE_WINDOWS_H
1128 #include <windows.h>
1129 #endif
1130 #endif
1132 #ifdef INCLUDE_winsock2_h
1133 #ifdef HAVE_WINSOCK2_H
1134 #include <winsock2.h>
1135 #endif
1136 #endif
1138 #ifdef INCLUDE_ws2tcpip_h
1139 #ifdef HAVE_WS2TCPIP_H
1140 #include <ws2tcpip.h>
1141 #endif
1142 #endif
1144 #ifdef INCLUDE_io_h
1145 #ifdef HAVE_IO_H
1146 #include <io.h>
1147 #endif
1148 #endif
1150 #ifdef INCLUDE_tchar_h
1151 #ifdef HAVE_TCHAR_H
1152 #include <tchar.h>
1153 #endif
1154 #endif
1156 #ifdef INCLUDE_float_h
1157 #ifdef HAVE_FLOAT_H
1158 #include <float.h>
1159 #endif
1160 #endif
1162 #ifdef INCLUDE_fpu_control_h
1163 #ifdef HAVE_FPU_CONTROL_H
1164 #include <fpu_control.h>
1165 #else
1167 * Some Linux distributions don't have the file "fpu_control.h".
1168 * Instead of including that file we explicitly define the macros we
1169 * need.
1171 #ifndef _FPU_CONTROL_H
1172 #define _FPU_CONTROL_H
1173 #define _FPU_MASK_IM 0x01
1174 #define _FPU_MASK_DM 0x02
1175 #define _FPU_MASK_ZM 0x04
1176 #define _FPU_MASK_OM 0x08
1177 #define _FPU_MASK_UM 0x10
1178 #define _FPU_MASK_PM 0x20
1179 #define _FPU_DOUBLE 0x200
1180 #define _FPU_RC_NEAREST 0x0
1181 typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
1182 #define _FPU_SETCW(cw) __asm__ ("fldcw %0" : : "m" (*&cw))
1183 #endif
1184 #endif
1185 #endif
1187 #ifdef INCLUDE_os2_h
1188 #ifdef HAVE_OS2_H
1189 #include <os2.h>
1190 #endif
1191 #endif
1193 #ifdef INCLUDE_dos_h
1194 #ifdef HAVE_DOS_H
1195 #include <dos.h>
1196 #endif
1197 #endif
1199 #ifdef INCLUDE_direct_h
1200 #ifdef HAVE_DIRECT_H
1201 #include <direct.h>
1202 #endif
1203 #endif
1205 #ifdef INCLUDE_Retrace_h
1206 #ifdef HAVE_RETRACE_H
1207 #include <Retrace.h>
1208 #endif
1209 #endif
1211 #ifdef INCLUDE_Files_h
1212 #ifdef HAVE_FILES_H
1213 #include <Files.h>
1214 #endif
1215 #endif
1217 #ifdef INCLUDE_Finder_h
1218 #ifdef HAVE_FINDER_H
1219 #include <Finder.h>
1220 #endif
1221 #endif
1223 #ifdef INCLUDE_Errors_h
1224 #ifdef HAVE_ERRORS_H
1225 #include <Errors.h>
1226 #endif
1227 #endif
1229 #ifdef INCLUDE_Folders_h
1230 #ifdef HAVE_FOLDERS_H
1231 #include <Folders.h>
1232 #endif
1233 #endif
1235 #ifdef INCLUDE_OSUtils_h
1236 #ifdef HAVE_OSUTILS_H
1237 #include <OSUtils.h>
1238 #endif
1239 #endif
1241 #ifdef INCLUDE_Power_h
1242 #ifdef HAVE_POWER_H
1243 #include <Power.h>
1244 #endif
1245 #endif
1247 #ifdef INCLUDE_CodeFragments_h
1248 #ifdef HAVE_CODEFRAGMENTS_H
1249 #include <CodeFragments.h>
1250 #endif
1251 #endif
1253 #ifdef INCLUDE_SIOUX_h
1254 #ifdef HAVE_SIOUX_H
1255 #include <SIOUX.h>
1256 #endif
1257 #endif
1259 #ifdef INCLUDE_mac_gui_h
1260 #ifdef HAVE_MAC_GUI_H
1261 #include "mac_gui.h"
1262 #endif
1263 #endif
1265 #ifdef INCLUDE_unix_h
1266 #ifdef HAVE_UNIX_H
1267 #include <unix.h>
1268 #endif
1269 #endif
1271 #ifdef INCLUDE_wdefwin_h
1272 #ifdef HAVE_WDEFWIN_H
1273 #include <wdefwin.h>
1274 #endif
1275 #endif
1277 #ifdef INCLUDE_tfork_h
1278 #ifdef HAVE_TFORK_H
1279 #include <tfork.h>
1280 #endif
1281 #endif
1283 #ifdef INCLUDE_curses_h
1284 #ifdef HAVE_CURSES_H
1285 #include <curses.h>
1286 #endif
1287 #endif
1289 #ifdef INCLUDE_ncurses_h
1290 #ifdef HAVE_NCURSES_H
1291 #include <ncurses.h>
1292 #endif
1293 #endif
1295 #ifdef INCLUDE_netinet_in_h
1296 #ifdef HAVE_NETINET_IN_H
1297 #include <netinet/in.h>
1298 #endif
1299 #endif
1301 #ifdef INCLUDE_arpa_inet_h
1302 #ifdef HAVE_ARPA_INET_H
1303 #include <arpa/inet.h>
1304 #endif
1305 #endif
1307 #ifdef INCLUDE_termios_h
1308 #ifdef HAVE_TERMIOS_H
1309 #include <termios.h>
1310 #endif
1311 #endif
1313 #ifdef INCLUDE_term_h
1314 #ifdef HAVE_TERM_H
1315 #include <term.h>
1316 #endif
1317 #endif
1319 #ifdef INCLUDE_pty_h
1320 #ifdef HAVE_PTY_H
1321 #include <pty.h>
1322 #endif
1323 #endif
1325 #ifdef INCLUDE_stropts_h
1326 #ifdef HAVE_STROPTS_H
1327 #include <stropts.h>
1328 #endif
1329 #endif
1331 #ifdef INCLUDE_libutil_h
1332 #ifdef HAVE_LIBUTIL_H
1333 #include <libutil.h>
1334 #endif
1335 #endif
1337 #ifdef INCLUDE_util_h
1338 #ifdef HAVE_UTIL_H
1339 #include <util.h>
1340 #endif
1341 #endif
1343 #ifdef INCLUDE_sys_fpu_h
1344 #ifdef HAVE_SYS_FPU_H
1345 #include <sys/fpu.h>
1346 #endif
1347 #endif
1349 #ifdef INCLUDE_fenv_h
1350 #ifdef HAVE_FENV_H
1351 #include <fenv.h>
1352 #endif
1353 #endif
1355 #ifdef INCLUDE_fcntl_h
1356 #ifdef HAVE_FCNTL_H
1357 #include <fcntl.h>
1358 #endif
1359 #endif
1361 #ifdef INCLUDE_sys_ioctl_h
1362 #ifdef HAVE_SYS_IOCTL_H
1363 #include <sys/ioctl.h>
1364 #endif
1365 #endif
1367 #ifdef INCLUDE_sys_socket_h
1368 #ifdef HAVE_SYS_SOCKET_H
1369 #include <sys/socket.h>
1370 #endif
1371 #endif
1373 #ifdef INCLUDE_stdint_h
1374 #ifdef HAVE_STDINT_H
1375 #include <stdint.h>
1376 #endif
1377 #endif
1379 #ifdef INCLUDE_stdlib_h
1380 #ifdef HAVE_STDLIB_H
1381 #include <stdlib.h>
1382 #endif
1383 #endif
1385 #ifdef INCLUDE_string_h
1386 #ifdef HAVE_STRING_H
1387 #include <string.h>
1388 #endif
1389 #endif
1391 #ifdef INCLUDE_strings_h
1392 #ifdef HAVE_STRINGS_H
1393 #include <strings.h>
1394 #endif
1395 #endif
1397 #ifdef INCLUDE_memory_h
1398 #ifdef HAVE_MEMORY_H
1399 #include <memory.h>
1400 #endif
1401 #endif
1403 #ifdef INCLUDE_crt_externs_h
1404 #ifdef HAVE_CRT_EXTERNS_H
1405 #include <crt_externs.h>
1406 #endif
1407 #endif
1410 * Use the process-time timer unless only the real-time timer is
1411 * available (e.g. DJGPP). Note that on some systems (e.g. MkLinux)
1412 * ITIMER_VIRTUAL is an enum type, not a macro.
1415 #if defined(__CYGWIN__) || defined(__MACOSX__) || (defined(__APPLE__) && defined(__MACH__))
1416 /* ITIMER_VIRTUAL is broken under CYGWIN and MacOS X... use ITIMER_REAL */
1417 #undef ITIMER_VIRTUAL
1418 #endif
1420 #ifdef ITIMER_VIRTUAL
1421 #define HEARTBEAT_ITIMER ITIMER_VIRTUAL
1422 #define HEARTBEAT_SIG SIGVTALRM
1423 #else
1424 #ifdef ITIMER_REAL
1425 #define HEARTBEAT_ITIMER ITIMER_REAL
1426 #define HEARTBEAT_SIG SIGALRM
1427 #else
1428 #define HEARTBEAT_ITIMER ITIMER_VIRTUAL
1429 #define HEARTBEAT_SIG SIGVTALRM
1430 #endif
1431 #endif
1434 /*---------------------------------------------------------------------------*/
1436 #define ___CHAR_TYPE(ce) \
1437 ce(___ISO_8859_1,char,___UCS_2,___UCS_4,___WCHAR,char)
1439 #define ___STRING_TYPE(ce) \
1440 ce(___ISO_8859_1STRING,___UTF_8STRING,___UCS_2STRING,___UCS_4STRING,___WCHARSTRING,char*)
1442 #define ___CE(ce) \
1443 ce(___CHAR_ENCODING_ISO_8859_1, \
1444 ___CHAR_ENCODING_UTF_8, \
1445 ___CHAR_ENCODING_UCS_2, \
1446 ___CHAR_ENCODING_UCS_4, \
1447 ___CHAR_ENCODING_WCHAR, \
1448 ___CHAR_ENCODING_NATIVE)
1451 extern ___SCMOBJ ___setup_os_interrupt_handling ___PVOID;
1453 extern void ___cleanup_os_interrupt_handling ___PVOID;
1455 extern void ___disable_os_interrupts ___PVOID;
1457 extern void ___enable_os_interrupts ___PVOID;
1460 /*---------------------------------------------------------------------------*/
1462 /* Virtual memory statistics. */
1464 extern void ___vm_stats
1465 ___P((long *minflt,
1466 long *majflt),
1467 ());
1470 /* Formatting of source code position. */
1472 extern char *___format_filepos
1473 ___P((char *path,
1474 long filepos,
1475 ___BOOL pinpoint),
1476 ());
1479 /* System type information. */
1481 extern char **___os_system_type ___PVOID;
1482 extern char *___os_system_type_string ___PVOID;
1483 extern char *___os_configure_command_string ___PVOID;
1486 /* C compilation environment information. */
1488 extern char *___os_obj_extension_string ___PVOID;
1489 extern char *___os_exe_extension_string ___PVOID;
1490 extern char *___os_bat_extension_string ___PVOID;
1493 /* OS initialization/finalization. */
1495 extern ___SCMOBJ ___setup_os ___PVOID;
1496 extern void ___cleanup_os ___PVOID;
1499 /* Utilities for machine encoding of characters. */
1502 * For now an ISO-8859-1 encoding of characters is assumed for
1503 * 'unsigned char'. This means that the mapping to and from the
1504 * Unicode character set is the identity function. To support other
1505 * machine representations, e.g. EBCDIC, these macros would have to
1506 * actually translate the characters.
1509 #define UCS_4_to_uchar(u)u
1510 #define uchar_to_UCS_4(c)c
1513 /*---------------------------------------------------------------------------*/
1515 #endif