| 1 | /* vms_exit.c
|
|---|
| 2 | *
|
|---|
| 3 | * Wrapper for the VMS exit() command to tranlate 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.
|
|---|
| 6 | *
|
|---|
| 7 | * Author: John E. Malmberg
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | /* Copyright (C) 2014-2016 Free Software Foundation, Inc.
|
|---|
| 11 |
|
|---|
| 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
|
|---|
| 15 | version.
|
|---|
| 16 |
|
|---|
| 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.
|
|---|
| 20 |
|
|---|
| 21 | You should have received a copy of the GNU General Public License along with
|
|---|
| 22 | this program. If not, see <http://www.gnu.org/licenses/>. */
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 | /* Per copyright assignment agreement with the Free Software Foundation
|
|---|
| 26 | this software may be available under under other license agreements
|
|---|
| 27 | and copyrights. */
|
|---|
| 28 |
|
|---|
| 29 | #include <makeint.h>
|
|---|
| 30 |
|
|---|
| 31 | #include <stsdef.h>
|
|---|
| 32 | void
|
|---|
| 33 | decc$exit (int status);
|
|---|
| 34 | #ifndef C_FACILITY_NO
|
|---|
| 35 | # define C_FACILITY_NO 0x350000
|
|---|
| 36 | #endif
|
|---|
| 37 |
|
|---|
| 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 */
|
|---|
| 41 |
|
|---|
| 42 | #ifndef MAX_EXPECTED_EXIT_CODE
|
|---|
| 43 | # define MAX_EXPECTED_EXIT_CODE 7
|
|---|
| 44 | #endif
|
|---|
| 45 |
|
|---|
| 46 | /* Build a Posix Exit with VMS severity */
|
|---|
| 47 | void
|
|---|
| 48 | vms_exit (int status)
|
|---|
| 49 | {
|
|---|
| 50 | int vms_status;
|
|---|
| 51 | /* Fake the __posix_exit with severity added */
|
|---|
| 52 | /* Undocumented correct way to do this. */
|
|---|
| 53 | vms_status = 0;
|
|---|
| 54 |
|
|---|
| 55 | /* The default DECC definition is not compatible with doing a POSIX_EXIT */
|
|---|
| 56 | /* So fix it. */
|
|---|
| 57 | if (status == EXIT_FAILURE)
|
|---|
| 58 | status = MAKE_FAILURE;
|
|---|
| 59 |
|
|---|
| 60 | /* Trivial case exit success */
|
|---|
| 61 | if (status == 0)
|
|---|
| 62 | decc$exit (STS$K_SUCCESS);
|
|---|
| 63 |
|
|---|
| 64 | /* Is this a VMS status then just take it */
|
|---|
| 65 | if (status > MAX_EXPECTED_EXIT_CODE)
|
|---|
| 66 | {
|
|---|
| 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);
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 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);
|
|---|
| 80 |
|
|---|
| 81 | /* STS$K_ERROR is for status that stops makefile that a simple */
|
|---|
| 82 | /* Rerun of the makefile will not fix. */
|
|---|
| 83 |
|
|---|
| 84 | if (status == MAKE_FAILURE)
|
|---|
| 85 | vms_status |= STS$K_ERROR;
|
|---|
| 86 | else if (status == MAKE_TROUBLE)
|
|---|
| 87 | {
|
|---|
| 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 */
|
|---|
| 91 | /* Error severity */
|
|---|
| 92 | vms_status |= STS$K_ERROR;
|
|---|
| 93 | }
|
|---|
| 94 | decc$exit (vms_status);
|
|---|
| 95 | }
|
|---|