Skip to content

Commit

Permalink
Merge pull request #108 from whcox603/VMS_x86
Browse files Browse the repository at this point in the history
Add support for OpenVMS on X86-64
  • Loading branch information
saprykin authored May 15, 2024
2 parents d263761 + 5238817 commit 6fe14a1
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
CMakeLists.txt.user
.DS_Store
.DS_Store
platforms/vms-general/alpha/
platforms/vms-general/ia64/
platforms/vms-general/x86_64/
13 changes: 11 additions & 2 deletions platforms/vms-general/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This directory contains mainly a build script for OpenVMS.

## Requirements

* OpenVMS 8.4 or later (Alpha or IA64), VAX is not supported
* OpenVMS 8.4 or later (Alpha, IA64 or x86-64), VAX is not supported
* DEC CC 6.5 or later
* DEC CXX 7.1 or later (for tests only)

Expand All @@ -23,7 +23,8 @@ all of them.
Object library (.OLB) and shareable image (.EXE) are built. An object
library acts like a widely-known static library, and a shareable image
acts like a shared library. All libraries and tests are placed inside the
`[.ALPHA]` or `[.IA64]` directory depending on a host architecture.
`[.ALPHA]`, `[.IA64]` or `[.X86_64]` directory depending on a host
architecture.

Do not forget to define a logical name for a shareable image of the library
before running programs which use it:
Expand All @@ -41,6 +42,14 @@ the tests.
* `@build_vms.com NOLIB RUN_TESTS` only runs already built tests.
* `@build_vms.com CLEAN` cleans all the files produced during a build.

## Notes for x86-64

When using the compiled library with the C++ compiler, special care is
required to handle data types derived from `long` (i.e., `plong` or
`pulong`). A new, Clang-based, C++ compiler always treats types like
`long`, `size_t`, `nullptr_t` and `ptrdiff_t` as 64-bits wide; while
classic DEC C compiler treats `long` as 32-bits wide.

## More

OpenVMS can mangle long (> 31 characters) symbol names in a compiled object
Expand Down
20 changes: 15 additions & 5 deletions platforms/vms-general/build_vms.com
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
$!
$! Copyright 2011, Richard Levitte <[email protected]>
$! Copyright 2014, John Malmberg <[email protected]>
$! Copyright 2016-2018, Alexander Saprykin <[email protected]>
$! Copyright 2016-2024, Alexander Saprykin <[email protected]>
$! Copyright 2023, William H. Cox <[email protected]>
$!
$! Permission to use, copy, modify, and/or distribute this software for any
$! purpose with or without fee is hereby granted, provided that the above
Expand Down Expand Up @@ -92,7 +93,7 @@ $!
$! Define the architecture-specific destination directory name
$! -----------------------------------------------------------
$!
$ if (f$getsyi("HW_MODEL") .lt. 1024)
$ if (f$getsyi("ARCH_TYPE") .eq. 1)
$ then
$ 'vo_c' "%PLIBSYS-F-NOTSUP, VAX platform is not supported, sorry :("
$ goto common_exit
Expand All @@ -109,7 +110,7 @@ $ min_ver_patch = f$element(1, ".", version_patch)
$ min_ver = f$element(0, "-", min_ver_patch)
$ patch = f$element(1, "-", min_ver_patch)
$!
$ if maj_ver .lts. "8" .or. min_ver .lts. "4"
$ if (maj_ver .lts. "8") .or. (maj_ver .eqs. "8" .and. min_ver .lts. "4")
$ then
$ 'vo_c' "%PLIBSYS-F-NOTSUP, only OpenVMS 8.4 and above are supported, sorry :("
$ goto common_exit
Expand Down Expand Up @@ -189,7 +190,7 @@ $ test_list_val = f$element(1, "=", arg_val) - "(" - ")"
$ test_list_val = f$edit(test_list_val, "COLLAPSE")
$ test_list_counter = 0
$
$ test_list_loop:
$ test_list_loop:
$ next_test_val = f$element (test_list_counter, ",", test_list_val)
$ if next_test_val .nes. "" .and. next_test_val .nes. ","
$ then
Expand Down Expand Up @@ -515,6 +516,15 @@ $ then
$ cxx_params = cxx_params + "/DEBUG/NOOPTIMIZE/LIST/SHOW=ALL"
$ endif
$!
$! OpenVMS 9.x on x86 uses LINK command instead of CXXLINK
$!
$ if f$getsyi("ARCH_TYPE") .eq. 4
$ then
$ link_cmd := "link"
$ else
$ link_cmd := "cxxlink"
$ endif
$!
$ test_loop:
$ next_test = f$element (test_counter, " ", plibsys_tests)
$ if next_test .nes. "" .and. next_test .nes. " "
Expand All @@ -524,7 +534,7 @@ $ 'vo_c' "[CXX ] ''next_test'.cpp"
$ cxx [---.tests]'next_test'.cpp 'cxx_params'
$!
$ 'vo_c' "[CXXLINK] ''next_test'.obj"
$ cxxlink 'next_test'.obj,'objdir'plibsys_link.opt/OPTION /THREADS_ENABLE
$ 'link_cmd' 'next_test'.obj,'objdir'plibsys_link.opt/OPTION /THREADS_ENABLE
$!
$ if f$search("CXX_REPOSITORY.DIR") .nes. ""
$ then
Expand Down
2 changes: 1 addition & 1 deletion src/patomic-decc.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# include <machine/builtins.h>
#endif

#ifdef __ia64
#if defined(__ia64) || defined(__x86_64)
# define PATOMIC_DECC_CAS_LONG(atomic_src, oldval, newval, atomic_dst) \
__CMP_SWAP_LONG ((volatile void *) (atomic_src), \
(pint) (oldval), \
Expand Down
4 changes: 2 additions & 2 deletions src/pmacroscompiler.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License
*
* Copyright (C) 2017-2023 Alexander Saprykin <[email protected]>
* Copyright (C) 2017-2024 Alexander Saprykin <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -221,7 +221,7 @@
# define P_CC_CLANG
#elif defined(__HP_cc) || defined(__HP_aCC)
# define P_CC_HP
#elif defined (__DECC) || defined(__DECCXX)
#elif defined (__DECC) || defined(__DECCXX) || defined(__VMS)
# define P_CC_DEC
#elif (defined(__sgi) || defined(sgi)) && \
(defined(_COMPILER_VERSION) || defined(_SGI_COMPILER_VERSION))
Expand Down
4 changes: 2 additions & 2 deletions tests/pmacros_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ P_TEST_CASE_BEGIN (pmacros_general_test)

/* Test for CPU architecture detection macros */
#if defined (P_OS_VMS)
# if !defined (P_CPU_ALPHA) && !defined (P_CPU_IA64)
# if !defined (P_CPU_ALPHA) && !defined (P_CPU_IA64) && !defined (P_CPU_X86_64)
P_TEST_CHECK (false);
# endif
#endif
Expand Down Expand Up @@ -385,7 +385,7 @@ P_TEST_CASE_BEGIN (pmacros_general_test)
#endif

#if defined (P_CC_DEC)
# if !defined (P_CPU_ALPHA) && !defined (P_CPU_IA64)
# if !defined (P_CPU_ALPHA) && !defined (P_CPU_IA64) && !defined (P_CPU_X86_64)
P_TEST_CHECK (false);
# endif
#endif
Expand Down
17 changes: 16 additions & 1 deletion tests/ptypes_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License
*
* Copyright (C) 2014-2023 Alexander Saprykin <[email protected]>
* Copyright (C) 2014-2024 Alexander Saprykin <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -60,8 +60,15 @@ P_TEST_CASE_BEGIN (ptypes_general_test)
P_TEST_CHECK (sizeof (puintptr) == PLIBSYS_SIZEOF_VOID_P);
P_TEST_CHECK (sizeof (psize) == PLIBSYS_SIZEOF_SIZE_T);
P_TEST_CHECK (sizeof (pssize) == PLIBSYS_SIZEOF_SIZE_T);
#if !defined(P_OS_VMS) || !defined(P_CPU_X86_64)
P_TEST_CHECK (sizeof (plong) == PLIBSYS_SIZEOF_LONG);
P_TEST_CHECK (sizeof (pulong) == PLIBSYS_SIZEOF_LONG);
#else
/* OpenVMS on x86 has C++ compiler with size of long different from
* defined in C compiler */
P_TEST_CHECK (sizeof (plong) == 8);
P_TEST_CHECK (sizeof (pulong) == 8);
#endif
P_TEST_CHECK (sizeof (poffset) == 8);

p_libsys_shutdown ();
Expand Down Expand Up @@ -113,21 +120,25 @@ P_TEST_CASE_BEGIN (ptypes_min_max_test)
P_TEST_CHECK (P_MAXSSIZE == P_MAXINT64);
P_TEST_CHECK (P_MAXSIZE == P_MAXUINT64);

#if !defined(P_OS_VMS) || !defined(P_CPU_X86_64)
if (PLIBSYS_SIZEOF_LONG == 8) {
P_TEST_CHECK (P_MINSSIZE == P_MINLONG);
P_TEST_CHECK (P_MAXSSIZE == P_MAXLONG);
P_TEST_CHECK (P_MAXSIZE == P_MAXULONG);
}
#endif
} else {
P_TEST_CHECK (P_MINSSIZE == P_MININT32);
P_TEST_CHECK (P_MAXSSIZE == P_MAXINT32);
P_TEST_CHECK (P_MAXSIZE == P_MAXUINT32);

#if !defined(P_OS_VMS) || !defined(P_CPU_X86_64)
if (PLIBSYS_SIZEOF_LONG == 4) {
P_TEST_CHECK (P_MINSSIZE == P_MINLONG);
P_TEST_CHECK (P_MAXSSIZE == P_MAXLONG);
P_TEST_CHECK (P_MAXSIZE == P_MAXULONG);
}
#endif
}

p_libsys_shutdown ();
Expand Down Expand Up @@ -259,6 +270,7 @@ P_TEST_CASE_BEGIN (ptypes_host_network_test)
P_TEST_CHECK (PUINT_TO_LE (puint_val) == (puint) 0x00040000);
P_TEST_CHECK (PUINT_FROM_LE (puint_val) == (puint) 0x00040000);

#if !defined(P_OS_VMS) || !defined(P_CPU_X86_64)
if (PLIBSYS_SIZEOF_LONG == 8) {
plong plong_val = PLONG_TO_BE (0xFFFFFFFFFFFFF800LL);
P_TEST_CHECK (plong_val == (plong) 0x00F8FFFFFFFFFFFFLL);
Expand All @@ -284,6 +296,7 @@ P_TEST_CASE_BEGIN (ptypes_host_network_test)
P_TEST_CHECK (PULONG_TO_LE (pulong_val) == (pulong) 0x00080000);
P_TEST_CHECK (PULONG_FROM_LE (pulong_val) == (pulong) 0x00080000);
}
#endif

if (PLIBSYS_SIZEOF_SIZE_T == 8) {
psize psize_val = PSIZE_TO_BE (0x0000000000001000ULL);
Expand Down Expand Up @@ -367,6 +380,7 @@ P_TEST_CASE_BEGIN (ptypes_host_network_test)
P_TEST_CHECK (PUINT_TO_BE (puint_val) == (puint) 0x00040000);
P_TEST_CHECK (PUINT_FROM_BE (puint_val) == (puint) 0x00040000);

#if !defined(P_OS_VMS) || !defined(P_CPU_X86_64)
if (PLIBSYS_SIZEOF_LONG == 8) {
plong plong_val = PLONG_TO_LE (0xFFFFFFFFFFFFF800LL);
P_TEST_CHECK (plong_val == (plong) 0x00F8FFFFFFFFFFFFLL);
Expand All @@ -392,6 +406,7 @@ P_TEST_CASE_BEGIN (ptypes_host_network_test)
P_TEST_CHECK (PULONG_TO_BE (pulong_val) == (pulong) 0x00080000);
P_TEST_CHECK (PULONG_FROM_BE (pulong_val) == (pulong) 0x00080000);
}
#endif

if (PLIBSYS_SIZEOF_SIZE_T == 8) {
psize psize_val = PSIZE_TO_LE (0x0000000000001000ULL);
Expand Down

0 comments on commit 6fe14a1

Please sign in to comment.