summaryrefslogtreecommitdiff
path: root/vms_exit.c
diff options
context:
space:
mode:
authorJohn Malmberg <wb8tyw@qsl.net>2014-09-13 20:20:22 -0500
committerPaul Smith <psmith@gnu.org>2014-10-20 01:28:46 -0400
commit894ee7f6c8b96ed89d4672da6cde4105c15cbf31 (patch)
tree1d10c4e86225e29358467266a4eb8b8e9a9ade1a /vms_exit.c
parente75662bc6a96571f041bdad799eb557ff580135c (diff)
downloadgunmake-894ee7f6c8b96ed89d4672da6cde4105c15cbf31.tar.gz
[SV 42447]: VMS simulate exporting symbols
This also includes fixing the most of the exit handling code for VMS. Self tests: Previously about 94 Tests in 36 categories fail. Now about 45 tests in 22 categories fail. Because some tests do not properly clean up, the number of tests that fail can vary by one or two test cases between consecutive runs. * Makefile.am: Add new VMS files. * job.c: add prototype for vms_strsignal(). * job.c: (child_error): Remove VMS specific code as no longer needed. * job.c: (reap_children): The VMS specific code was setting the status to 0 instead of setting it to the proper exit status. * job.h: Add vms_launch_status to struct child. * main.c: (main): Use environment variables for options to use MCR * instead of a foreign command, and to always use command files for subprocesses. For VMS use (set_program_name) routine which is common to ports of other GNU packages to VMS to set the program name used internally. Use (vms_putenv_symbol) to set up symbols to be visible in child programs, including recursive make launched by execve() Start of Bash shell detection code for VMS. * makefile.com: Need nested_include=none for building on VMS search lists. Add vms_progname, vms_exit, and vms_export_symbol. * makefile.vms: Need nested_include=none for building on VMS search lists. Add vms_progname, vms_exit, vms_export_symbol. * makeint.h: Make sure non-standard "VMS" macro is defined. Add prototypes for new VMS routines. Remove VMS-specific failure codes. * vmsjobs.c: Add VMS POSIX exit code constants. (_is_unixy_shell): Detect Bash shell. (vms_strsignal): simulate strsignal() on VMS. (vmsHandleChildTerm): fix to properly report failed LIB$SPAWN() exit status codes. Remove code that duplicated code in job.c. (child_execute_job): Export environment symbols before spawning a child and restore afterward unless option to use command files for subprocesses is set. Improve handling of UNIX null commands ":". * vms_exit.c: Provides vms_exit() to detect if an exit code is UNIX or VMS, and converts the UNIX code into a VMS exit code. * vms_export_symbol.c: Routines to create DCL symbols that work like shell aliases or exported shell symbols and clean them up on exit. * vms_export_symbol_test.com: Unit test for vms_export_symbol.c * vms_progname.c: New file: VMS specific replace for progname.c that is used in some GNU projects.
Diffstat (limited to 'vms_exit.c')
-rw-r--r--vms_exit.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/vms_exit.c b/vms_exit.c
new file mode 100644
index 0000000..050550a
--- /dev/null
+++ b/vms_exit.c
@@ -0,0 +1,95 @@
+/* vms_exit.c
+ *
+ * Wrapper for the VMS exit() command to tranlate UNIX codes to be
+ * encoded for POSIX, but also have VMS severity levels.
+ * The posix_exit() variant only sets a severity level for status code 1.
+ *
+ * Author: John E. Malmberg
+ */
+
+/* Copyright (C) 2014 Free Software Foundation, Inc.
+
+GNU Make is free software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the Free Software
+Foundation; either version 3 of the License, or (at your option) any later
+version.
+
+GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+/* Per copyright assignment agreement with the Free Software Foundation
+ this software may be available under under other license agreements
+ and copyrights. */
+
+#include <makeint.h>
+
+#include <stsdef.h>
+void
+decc$exit (int status);
+#ifndef C_FACILITY_NO
+# define C_FACILITY_NO 0x350000
+#endif
+
+/* Lowest legal non-success VMS exit code is 8 */
+/* GNU make only defines codes 0, 1, 2 */
+/* So assume any exit code > 8 is a VMS exit code */
+
+#ifndef MAX_EXPECTED_EXIT_CODE
+# define MAX_EXPECTED_EXIT_CODE 7
+#endif
+
+/* Build a Posix Exit with VMS severity */
+void
+vms_exit (int status)
+{
+ int vms_status;
+ /* Fake the __posix_exit with severity added */
+ /* Undocumented correct way to do this. */
+ vms_status = 0;
+
+ /* The default DECC definition is not compatible with doing a POSIX_EXIT */
+ /* So fix it. */
+ if (status == EXIT_FAILURE)
+ status = MAKE_FAILURE;
+
+ /* Trivial case exit success */
+ if (status == 0)
+ decc$exit (STS$K_SUCCESS);
+
+ /* Is this a VMS status then just take it */
+ if (status > MAX_EXPECTED_EXIT_CODE)
+ {
+ /* Make sure that the message inhibit is set since message has */
+ /* already been displayed. */
+ vms_status = status | STS$M_INHIB_MSG;
+ decc$exit (vms_status);
+ }
+
+ /* Unix status codes are limited to 1 byte, so anything larger */
+ /* is a probably a VMS exit code and needs to be passed through */
+ /* A lower value can be set for a macro. */
+ /* Status 0 is always passed through as it is converted to SS$_NORMAL */
+ /* Always set the message inhibit bit */
+ vms_status = C_FACILITY_NO | 0xA000 | STS$M_INHIB_MSG;
+ vms_status |= (status << 3);
+
+ /* STS$K_ERROR is for status that stops makefile that a simple */
+ /* Rerun of the makefile will not fix. */
+
+ if (status == MAKE_FAILURE)
+ vms_status |= STS$K_ERROR;
+ else if (status == MAKE_TROUBLE)
+ {
+ /* Make trouble is for when make was told to do nothing and */
+ /* found that a target was not up to date. Since a second */
+ /* of make will produce the same condition, this is of */
+ /* Error severity */
+ vms_status |= STS$K_ERROR;
+ }
+ decc$exit (vms_status);
+}