Mercurial > hg > octave-kai > gnulib-hg
annotate lib/msvc-inval.c @ 16214:ec738d6aeef5
Talk about "native Windows API", not "Win32".
* lib/classpath.c: Update comments to mention native Windows.
* lib/csharpexec.c: Likewise.
* lib/dup2.c: Likewise.
* lib/error.c: Likewise.
* lib/fcntl.c: Likewise.
* lib/filename.h: Likewise.
* lib/findprog.c: Likewise.
* lib/get-rusage-as.c: Likewise.
* lib/get-rusage-data.c: Likewise.
* lib/getpagesize.c: Likewise.
* lib/javaexec.c: Likewise.
* lib/msvc-inval.c: Likewise.
* lib/msvc-nothrow.c: Likewise.
* lib/nanosleep.c: Likewise.
* lib/nonblocking.c: Likewise.
* lib/printf-parse.c: Likewise.
* lib/setlocale.c: Likewise.
* lib/sigaction.c: Likewise.
* lib/strerror_r.c: Likewise.
* lib/tmpdir.c: Likewise.
* lib/vasnprintf.c: Likewise.
* lib/w32spawn.h: Likewise.
* lib/waitpid.c: Likewise.
* lib/stdio.in.h (fdopen, fopen, freopen): Likewise.
* m4/locale-ar.m4: Likewise.
* m4/locale-fr.m4: Likewise.
* m4/locale-ja.m4: Likewise.
* m4/locale-tr.m4: Likewise.
* m4/locale-zh.m4: Likewise.
* m4/printf.m4: Likewise.
* tests/test-cloexec.c: Likewise.
* tests/test-copy-acl.sh: Likewise.
* tests/test-copy-file.sh: Likewise.
* tests/test-file-has-acl.sh: Likewise.
* tests/test-set-mode-acl.sh: Likewise.
* tests/test-dup-safer.c: Likewise.
* tests/test-dup2.c: Likewise.
* tests/test-dup3.c: Likewise.
* tests/test-fcntl.c: Likewise.
* tests/test-nonblocking-pipe.h: Likewise.
* tests/test-nonblocking-socket.h: Likewise.
* tests/test-pipe.c: Likewise.
* tests/test-pipe2.c: Likewise.
* tests/test-spawn-pipe-child.c: Likewise.
* doc/acl-resources.txt: Likewise.
* lib/getaddrinfo.c (WINDOWS_NATIVE): Renamed from WIN32_NATIVE.
* tests/test-poll.c (WINDOWS_NATIVE): Likewise.
* tests/test-select.h (WINDOWS_NATIVE): Likewise.
* lib/localcharset.c: Update comments to mention native Windows.
(WINDOWS_NATIVE): Renamed from WIN32_NATIVE.
* lib/localename.c: Likewise.
* lib/progreloc.c: Likewise.
* lib/relocatable.c: Likewise.
* lib/poll.c (WINDOWS_NATIVE): Renamed from WIN32_NATIVE.
(windows_compute_revents): Renamed from win32_compute_revents.
(windows_compute_revents_socket): Renamed from
win32_compute_revents_socket.
* lib/select.c: Update comments to mention native Windows.
(windows_poll_handle): Renamed from win32_poll_handle.
* m4/threadlib.m4: Update comments to mention native Windows.
(gl_THREADLIB_EARLY_BODY, gl_THREADLIB_BODY): Expect
--enable-threads=windows instead of --enable-threads=win32. Set
USE_WINDOWS_THREADS, not USE_WIN32_THREADS.
* lib/glthread/lock.h: Update comments to mention native Windows.
(USE_WINDOWS_THREADS): Renamed from USE_WIN32_THREADS.
* lib/glthread/lock.c (USE_WINDOWS_THREADS): Renamed from
USE_WIN32_THREADS.
* lib/glthread/cond.h (USE_WINDOWS_THREADS): Likewise.
* lib/glthread/cond.c (USE_WINDOWS_THREADS): Likewise.
* lib/glthread/thread.h (USE_WINDOWS_THREADS): Likewise.
* lib/glthread/thread.c (USE_WINDOWS_THREADS): Likewise.
* lib/glthread/tls.h (USE_WINDOWS_THREADS): Likewise.
* lib/glthread/tls.c (USE_WINDOWS_THREADS): Likewise.
* lib/glthread/yield.h (USE_WINDOWS_THREADS): Likewise.
* tests/test-cond.c (USE_WINDOWS_THREADS): Likewise.
* tests/test-thread_create.c (USE_WINDOWS_THREADS): Likewise.
* tests/test-lock.c (USE_WINDOWS_THREADS): Likewise.
(TEST_WINDOWS_THREADS): Renamed from TEST_WIN32_THREADS.
* tests/test-tls.c: Likewise.
Rationale:
Microsoft renamed the "Win32 API" to "Windows API", as it is available
on both 32-bit and 64-bit Windows systems.
But in gnulib, we treat Cygwin like a Unix platform, therefore the main
line of distinction is between "native Windows" on one side and Unix/
POSIX systems on the other side. More details in
<https://lists.gnu.org/archive/html/bug-gnulib/2012-01/msg00027.html>.
Suggested by Paul Eggert.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 04 Jan 2012 14:31:33 +0100 |
parents | 8250f2777afc |
children | bb182ee4a09d |
rev | line source |
---|---|
15645 | 1 /* Invalid parameter handler for MSVC runtime libraries. |
16201
8250f2777afc
maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents:
15786
diff
changeset
|
2 Copyright (C) 2011-2012 Free Software Foundation, Inc. |
15645 | 3 |
4 This program is free software; you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 2, or (at your option) | |
7 any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License along | |
15 with this program; if not, write to the Free Software Foundation, | |
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | |
17 | |
18 #include <config.h> | |
19 | |
20 /* Specification. */ | |
21 #include "msvc-inval.h" | |
22 | |
15786
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
23 #if HAVE_MSVC_INVALID_PARAMETER_HANDLER \ |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
24 && !(MSVC_INVALID_PARAMETER_HANDLING == SANE_LIBRARY_HANDLING) |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
25 |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
26 /* Get _invalid_parameter_handler type and _set_invalid_parameter_handler |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
27 declaration. */ |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
28 # include <stdlib.h> |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
29 |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
30 # if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
31 |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
32 static void cdecl |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
33 gl_msvc_invalid_parameter_handler (const wchar_t *expression, |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
34 const wchar_t *function, |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
35 const wchar_t *file, |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
36 unsigned int line, |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
37 uintptr_t dummy) |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
38 { |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
39 } |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
40 |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
41 # else |
15645 | 42 |
16214
ec738d6aeef5
Talk about "native Windows API", not "Win32".
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
43 /* Get declarations of the native Windows API functions. */ |
15786
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
44 # define WIN32_LEAN_AND_MEAN |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
45 # include <windows.h> |
15645 | 46 |
15786
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
47 # if defined _MSC_VER |
15645 | 48 |
49 static void cdecl | |
50 gl_msvc_invalid_parameter_handler (const wchar_t *expression, | |
51 const wchar_t *function, | |
52 const wchar_t *file, | |
53 unsigned int line, | |
54 uintptr_t dummy) | |
55 { | |
56 RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL); | |
57 } | |
58 | |
15786
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
59 # else |
15784
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
60 |
15785
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
61 /* An index to thread-local storage. */ |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
62 static DWORD tls_index; |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
63 static int tls_initialized /* = 0 */; |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
64 |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
65 /* Used as a fallback only. */ |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
66 static struct gl_msvc_inval_per_thread not_per_thread; |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
67 |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
68 struct gl_msvc_inval_per_thread * |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
69 gl_msvc_inval_current (void) |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
70 { |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
71 if (!tls_initialized) |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
72 { |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
73 tls_index = TlsAlloc (); |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
74 tls_initialized = 1; |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
75 } |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
76 if (tls_index == TLS_OUT_OF_INDEXES) |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
77 /* TlsAlloc had failed. */ |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
78 return ¬_per_thread; |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
79 else |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
80 { |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
81 struct gl_msvc_inval_per_thread *pointer = |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
82 (struct gl_msvc_inval_per_thread *) TlsGetValue (tls_index); |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
83 if (pointer == NULL) |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
84 { |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
85 /* First call. Allocate a new 'struct gl_msvc_inval_per_thread'. */ |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
86 pointer = |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
87 (struct gl_msvc_inval_per_thread *) |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
88 malloc (sizeof (struct gl_msvc_inval_per_thread)); |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
89 if (pointer == NULL) |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
90 /* Could not allocate memory. Use the global storage. */ |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
91 pointer = ¬_per_thread; |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
92 TlsSetValue (tls_index, pointer); |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
93 } |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
94 return pointer; |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
95 } |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
96 } |
15784
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
97 |
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
98 static void cdecl |
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
99 gl_msvc_invalid_parameter_handler (const wchar_t *expression, |
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
100 const wchar_t *function, |
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
101 const wchar_t *file, |
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
102 unsigned int line, |
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
103 uintptr_t dummy) |
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
104 { |
15785
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
105 struct gl_msvc_inval_per_thread *current = gl_msvc_inval_current (); |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
106 if (current->restart_valid) |
5e020d269ce6
msvc-inval: Make handler multithread-safe.
Bruno Haible <bruno@clisp.org>
parents:
15784
diff
changeset
|
107 longjmp (current->restart, 1); |
15784
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
108 else |
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
109 /* An invalid parameter notification from outside the gnulib code. |
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
110 Give the caller a chance to intervene. */ |
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
111 RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL); |
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
112 } |
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
113 |
15786
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
114 # endif |
104b4f91678d
msvc-inval: Allow three invalid parameter handling modes.
Bruno Haible <bruno@clisp.org>
parents:
15785
diff
changeset
|
115 |
15784
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
116 # endif |
f1e8251b45f3
msvc-inval: Install handler globally.
Bruno Haible <bruno@clisp.org>
parents:
15645
diff
changeset
|
117 |
15645 | 118 static int gl_msvc_inval_initialized /* = 0 */; |
119 | |
120 void | |
121 gl_msvc_inval_ensure_handler (void) | |
122 { | |
123 if (gl_msvc_inval_initialized == 0) | |
124 { | |
125 _set_invalid_parameter_handler (gl_msvc_invalid_parameter_handler); | |
126 gl_msvc_inval_initialized = 1; | |
127 } | |
128 } | |
129 | |
130 #endif |