Allow synchronous win32 I/O to be interrupted, too
[sbcl.git] / src / runtime / win32-os.h
1 /*
2  * This software is part of the SBCL system. See the README file for
3  * more information.
4  *
5  * This software is derived from the CMU CL system, which was
6  * written at Carnegie Mellon University and released into the
7  * public domain. The software is in the public domain and is
8  * provided with absolutely no warranty. See the COPYING and CREDITS
9  * files for more information.
10  */
11
12 #ifndef SBCL_INCLUDED_WIN32_OS_H
13 #define SBCL_INCLUDED_WIN32_OS_H
14
15 #define WIN32_LEAN_AND_MEAN
16 #include <windows.h>
17 #include <winsock2.h>
18
19 #include <stdlib.h>
20 #include <stdint.h>
21 #include <stdio.h>
22 #include <sys/types.h>
23 #include <string.h>
24 #include <sys/time.h>
25 #include <sys/stat.h>
26 #include <unistd.h>
27
28 #include "target-arch-os.h"
29 #include "target-arch.h"
30
31 #ifdef LISP_FEATURE_SB_THREAD
32 #include "pthreads_win32.h"
33 /* prevent inclusion of a mingw semaphore.h */
34 #define CANNOT_USE_POSIX_SEM_T
35 typedef sem_t os_sem_t;
36 #else
37 typedef void *siginfo_t;
38 #endif
39
40 /* Note: This typedef will moved to runtime.h when AMD64 changes are being
41  * merged. */
42 typedef unsigned long uword_t;
43
44 typedef LPVOID os_vm_address_t;
45 typedef uword_t os_vm_size_t;
46 typedef intptr_t os_vm_offset_t;
47 typedef int os_vm_prot_t;
48
49 /* These are used as bitfields, but Win32 doesn't work that way, so we do a translation. */
50 #define OS_VM_PROT_READ    1
51 #define OS_VM_PROT_WRITE   2
52 #define OS_VM_PROT_EXECUTE 4
53
54 #define os_open_core(file,mode) win32_open_for_mmap(file)
55 #define HAVE_os_open_core
56
57 #define os_fopen_runtime(file,mode) win32_fopen_runtime()
58 #define HAVE_os_fopen_runtime
59
60 extern int os_number_of_processors;
61 #define HAVE_os_number_of_processors
62
63 extern int win32_open_for_mmap(const char* file);
64 extern FILE* win32_fopen_runtime();
65
66 #define OUR_TLS_INDEX 63
67 #define SIG_MEMORY_FAULT SIGSEGV
68
69 #define SIG_STOP_FOR_GC (SIGRTMIN+1)
70 #define SIG_DEQUEUE (SIGRTMIN+2)
71 #define SIG_THREAD_EXIT (SIGRTMIN+3)
72
73 #define FPU_STATE_SIZE 27
74
75 struct lisp_exception_frame {
76     struct lisp_exception_frame *next_frame;
77     void *handler;
78     lispobj *bindstack_pointer;
79 };
80
81 void wos_install_interrupt_handlers(struct lisp_exception_frame *handler);
82 char *dirname(char *path);
83
84 void os_invalidate_free(os_vm_address_t addr, os_vm_size_t len);
85
86 boolean win32_maybe_interrupt_io(void* thread);
87
88 #define bcopy(src,dest,n) memmove(dest,src,n)
89
90 struct thread;
91 void** os_get_csp(struct thread* th);
92
93
94 #endif  /* SBCL_INCLUDED_WIN32_OS_H */