-
Notifications
You must be signed in to change notification settings - Fork 0
/
sysdep-win.h
181 lines (157 loc) · 5.8 KB
/
sysdep-win.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/* sysdep-win.h -*-C++-*-
*
*************************************************************************
*
* Copyright (C) 2009-2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *********************************************************************
*
* PLEASE NOTE: This file is a downstream copy of a file mainitained in
* a repository at cilkplus.org. Changes made to this file that are not
* submitted through the contribution process detailed at
* http://www.cilkplus.org/submit-cilk-contribution will be lost the next
* time that a new version is released. Changes only submitted to the
* GNU compiler collection or posted to the git repository at
* https://bitbucket.org/intelcilkplusruntime/itnel-cilk-runtime.git are
* not tracked.
*
* We welcome your contributions to this open source project. Thank you
* for your assistance in helping us improve Cilk Plus.
**************************************************************************/
/**
* @file sysdep-win.h
*
* @brief Windows implementation of OS-specific functionality.
*/
#ifndef INCLUDED_SYSDEP_WIN_DOT_H
#define INCLUDED_SYSDEP_WIN_DOT_H
#include <cilk/common.h>
#include <internal/abi.h>
#include "rts-common.h"
#include "full_frame.h"
#include "windows-clean.h"
__CILKRTS_BEGIN_EXTERN_C
/**
* OS-dependent worker information - Windows implementation
*/
typedef struct __cilkrts_worker_sysdep_state
{
#ifdef _WIN64
/// Exception record for "throw;" - rethrow the last exception
EXCEPTION_RECORD *pRethrowExceptionRecord;
unsigned long long last_stackwalk_rbp;
# endif /* _WIN64 */
/// Processor group the worker thread should run on.
int processor_group;
} __cilkrts_worker_sysdep_state;
/** HMODULE for the Cilk RunTime System DLL */
extern HMODULE g_hmodCilkrts;
/**
* Windows-specific function to set the name of a thread. The name will be
* displayed by Inspector and the Visual Studio debugger. Only system worker
* threads are named. User workers retain whatever name the OS or user gave
* them.
*
* @param w The __cilkrts_worker bound to the thread.
* @param fiber The fiber we're running on. Only used for debug builds.
*/
NON_COMMON
void SetWorkerThreadName (__cilkrts_worker *w, void *fiber);
/**
* Windows-specific function to return the base of the stack we're currently
* running on.
*
* @return The base address of the stack.
*/
NON_COMMON
void *GetStackBase(void);
/**
* Called by the Windows exception handling code if we're given any exception
* other than a C++ exception. This function will generate a fatal error and
* abort the application.
*
* @param exception SEH exception that has been caught by the Windows
* exception handing code.
*/
NON_COMMON
NORETURN
__cilkrts_report_seh_exception(struct _EXCEPTION_RECORD *exception);
/**
* Returns the OS fiber from a cilk_fiber.
*
* @param fiber The input cilk_fiber.
*
* @return The OS fiber for the cilk_fiber.
*/
NON_COMMON
void *__cilkrts_get_os_fiber(cilk_fiber* fiber);
/**
* Validate that a value is in the currently executing stack.
*
* @param w The worker we're currently running on. Used for debugging
* information.
* @param value The value that must be within the stack we're running
* on.
* @param description Description of the value we're verifying. Displayed
* as part of the bug message displayed if the value is not in the stack.
*/
NON_COMMON
void verify_within_stack (__cilkrts_worker *w,
char *value,
char *description);
/**
* Macro to only check that values are within the stack for debug builds.
*/
#ifdef _DEBUG
# define VERIFY_WITHIN_STACK(w, v, d) verify_within_stack(w, v, d)
#else
# define VERIFY_WITHIN_STACK(w, v, d)
#endif
/**
* Returns the cilk_fiber for a worker.
*
* @param w The worker to get the cilk_fiber for.
*
* @return The cilk_fiber for the worker.
* @return NULL if we can't find the cilk_fiber.
*/
NON_COMMON
cilk_fiber *GetWorkerFiberObject(__cilkrts_worker *w);
NON_COMMON void sysdep_init_module(); // May move to sysdep.h
#if defined (_WIN32) && !defined(_WIN64)
/** Win32 jump buffer */
typedef struct __JUMP_BUFFER win_jmp_buffer;
#else
/** Win64 jump buffer */
typedef struct _JUMP_BUFFER win_jmp_buffer;
#endif
__CILKRTS_END_EXTERN_C
#endif // ! defined(INCLUDED_SYSDEP_WIN_DOT_H)