3 * Wrapper for the VMS exit() command to translate UNIX codes to be
4 * encoded for POSIX, but also have VMS severity levels.
5 * The posix_exit() variant only sets a severity level for status code 1.
7 * Author: John E. Malmberg
10 /* Copyright (C) 2014-2022 Free Software Foundation, Inc.
12 GNU Make is free software; you can redistribute it and/or modify it under the
13 terms of the GNU General Public License as published by the Free Software
14 Foundation; either version 3 of the License, or (at your option) any later
17 GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
18 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License along with
22 this program. If not, see <https://www.gnu.org/licenses/>. */
25 /* Per copyright assignment agreement with the Free Software Foundation
26 this software may be available under under other license agreements
33 decc$exit (int status);
35 # define C_FACILITY_NO 0x350000
38 /* Lowest legal non-success VMS exit code is 8 */
39 /* GNU make only defines codes 0, 1, 2 */
40 /* So assume any exit code > 8 is a VMS exit code */
42 #ifndef MAX_EXPECTED_EXIT_CODE
43 # define MAX_EXPECTED_EXIT_CODE 7
46 /* Build a Posix Exit with VMS severity */
51 /* Fake the __posix_exit with severity added */
52 /* Undocumented correct way to do this. */
55 /* The default DECC definition is not compatible with doing a POSIX_EXIT */
57 if (status == EXIT_FAILURE)
58 status = MAKE_FAILURE;
60 /* Trivial case exit success */
62 decc$exit (STS$K_SUCCESS);
64 /* Is this a VMS status then just take it */
65 if (status > MAX_EXPECTED_EXIT_CODE)
67 /* Make sure that the message inhibit is set since message has */
68 /* already been displayed. */
69 vms_status = status | STS$M_INHIB_MSG;
70 decc$exit (vms_status);
73 /* Unix status codes are limited to 1 byte, so anything larger */
74 /* is a probably a VMS exit code and needs to be passed through */
75 /* A lower value can be set for a macro. */
76 /* Status 0 is always passed through as it is converted to SS$_NORMAL */
77 /* Always set the message inhibit bit */
78 vms_status = C_FACILITY_NO | 0xA000 | STS$M_INHIB_MSG;
79 vms_status |= (status << 3);
81 /* STS$K_ERROR is for status that stops makefile that a simple */
82 /* Rerun of the makefile will not fix. */
84 if (status == MAKE_FAILURE)
85 vms_status |= STS$K_ERROR;
86 else if (status == MAKE_TROUBLE)
88 /* Make trouble is for when make was told to do nothing and */
89 /* found that a target was not up to date. Since a second */
90 /* of make will produce the same condition, this is of */
92 vms_status |= STS$K_ERROR;
94 decc$exit (vms_status);