diff --git a/.gitignore b/.gitignore index 725117f..4d92ce7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ CMakeLists.txt.user -.DS_Store \ No newline at end of file +.DS_Store +platforms/vms-general/alpha/ +platforms/vms-general/ia64/ +platforms/vms-general/x86_64/ \ No newline at end of file diff --git a/platforms/vms-general/README.md b/platforms/vms-general/README.md index 9bbfc85..99606ed 100644 --- a/platforms/vms-general/README.md +++ b/platforms/vms-general/README.md @@ -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) @@ -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: @@ -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 diff --git a/platforms/vms-general/build_vms.com b/platforms/vms-general/build_vms.com index ce5e95c..d63dc9a 100644 --- a/platforms/vms-general/build_vms.com +++ b/platforms/vms-general/build_vms.com @@ -1,7 +1,8 @@ $! $! Copyright 2011, Richard Levitte $! Copyright 2014, John Malmberg -$! Copyright 2016-2018, Alexander Saprykin +$! Copyright 2016-2024, Alexander Saprykin +$! Copyright 2023, William H. Cox $! $! Permission to use, copy, modify, and/or distribute this software for any $! purpose with or without fee is hereby granted, provided that the above @@ -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 @@ -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 @@ -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 @@ -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. " " @@ -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 diff --git a/src/patomic-decc.c b/src/patomic-decc.c index 180fe69..a8e2514 100644 --- a/src/patomic-decc.c +++ b/src/patomic-decc.c @@ -31,7 +31,7 @@ # include #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), \ diff --git a/src/pmacroscompiler.h b/src/pmacroscompiler.h index 565a24f..6de8fc8 100644 --- a/src/pmacroscompiler.h +++ b/src/pmacroscompiler.h @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (C) 2017-2023 Alexander Saprykin + * Copyright (C) 2017-2024 Alexander Saprykin * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -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)) diff --git a/tests/pmacros_test.cpp b/tests/pmacros_test.cpp index b832657..9a240c8 100644 --- a/tests/pmacros_test.cpp +++ b/tests/pmacros_test.cpp @@ -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 @@ -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 diff --git a/tests/ptypes_test.cpp b/tests/ptypes_test.cpp index 8508561..5b04579 100644 --- a/tests/ptypes_test.cpp +++ b/tests/ptypes_test.cpp @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (C) 2014-2023 Alexander Saprykin + * Copyright (C) 2014-2024 Alexander Saprykin * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -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 (); @@ -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 (); @@ -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); @@ -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); @@ -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); @@ -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);