1 /*
2 * nonposix.h --- definitions needed on non-POSIX systems.
3 */
4
5 /*
6 * Copyright (C) 2012, 2013, 2016, 2017, 2018, 2019, 2022
7 * the Free Software Foundation, Inc.
8 *
9 * This file is part of GAWK, the GNU implementation of the
10 * AWK Programming Language.
11 *
12 * GAWK is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * GAWK is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27 /*
28 * This is for fake directory file descriptors on systems that don't
29 * allow to open() a directory.
30 */
31
32 #define FAKE_FD_VALUE 42
33
34 #ifdef __MINGW32__
35 /* Replacements for sys/wait.h macros. */
36 # define WEXITSTATUS(stv) (((unsigned)(stv)) & ~0xC0000000)
37 /* MS-Windows programs that crash due to a fatal exception exit with
38 an exit code whose 2 MSB bits are set. */
39 # define WIFEXITED(stv) ((((unsigned)(stv)) & 0xC0000000) == 0)
40 # define WIFSIGNALED(stv) ((((unsigned)(stv)) & 0xC0000000) == 0xC0000000)
41 # define WTERMSIG(stv) w32_status_to_termsig ((unsigned)stv)
42 # define WIFSTOPPED(stv) (0)
43 # define WSTOPSIG(stv) (0)
44
45 int w32_status_to_termsig (unsigned);
46
47 /* Prototypes of for Posix functions for which we define replacements
48 in pc/ files. */
49
50 /* getid.c */
51 unsigned int getuid (void);
52 unsigned int geteuid (void);
53 unsigned int getgid (void);
54 unsigned int getegid (void);
55
56 /* gawkmisc.pc */
57 int unsetenv (const char *);
58 int setenv (const char *, const char *, int);
59 char *w32_setlocale (int, const char *);
60 /* libintl.h from GNU gettext defines setlocale to redirect that to
61 its own function. Note: this will have to be revisited if MinGW
62 Gawk will support ENABLE_NLS at some point. */
63 #ifdef setlocale
64 # undef setlocale
65 #endif
66 #define setlocale(c,v) w32_setlocale(c,v)
67
68 char *strsignal (int);
69
70 #endif /* __MINGW32__ */
71
72 #if defined(VMS) || defined(__MINGW32__)
73 int getpgrp(void);
74 #endif
75
76 #if defined(__MINGW32__)
77 int getppid(void);
78 #endif