Some C++/RTL questions


Topic author
mberryman
Active Contributor
Posts: 43
Joined: Sat Sep 02, 2023 1:31 pm
Reputation: 0
Location: Colorado Springs, CO, USA
Status: Offline

Some C++/RTL questions

Post by mberryman » Wed Dec 27, 2023 12:51 pm

In working on the MariaDB port, I have encountered the following issues:
  • The mkostemp function is documented as accepting additional flags for the open call. In fact, the documentation I have states that the only flags acceptable to this call are O_APPEND, O_SHLOCK, O_EXLOCK and O_CLOEXEC. However, the current VMS implementation requires that all of the flags needed by open be specified.
    • mkostemp(fn, O_CLOEXEC) vs.
    • mkostemp(fn, O_EXCL | O_CREAT | O_RDWR | O_CLOEXEC)
    Will this be changed?
  • Both mkostemp and open accept the O_CLOEXEC flag but do not honor it. Closing a channel opened this way does not delete the file.
  • Many of the open source packages I have worked with open a temporary file (usually with mkstemp) and then call fdopen to get a file pointer. Usually, this call includes the 'b' flag but VMS does not currently open temporary files in binary mode so the fdopen fails. A way to specify binary mode would be greatly appreciated. Something like allowing mkostemp(flags, rms settings) would seem to be ideal.
  • Systems that support O_CLOEXEC also seem to support an 'e' flag (the equivalent of O_CLOEXEC) on calls that take the 'rwb+' flags. Can such support be added?
And a couple of programming questions.

MariaDB is a mix of C and C++ code. It needs to all be compiled with clang because the routines share structures that include both long and size_t items. Standard atomic instructions work fine in C++ code, but what atomic instructions are available for C code? So far, all of my attempts to search for documentation only return results for C++ code. At the moment, all I need are equivalent functions for __LOCK_LONG and __UNLOCK_LONG.

How do I make the following work:
inline void mtr_t::memset(const buf_block_t *b, ulint ofs, ulint len, byte val)
{
lib$signal(SS$_DEBUG);
ut_ad(ofs <= ulint(srv_page_size));
ut_ad(ofs + len <= ulint(srv_page_size));
::memset(ofs + b->page.frame, val, len);
memset(*b, ofs, len, val);
}

While the code compiles fine, it generates a mangled name that resolves to lib$signal(int) which, of course, does not exist in the RTL. I've explicitly defined the function as extern "C" but I haven't been able to convince the compiler to generate a reference to lib$signal instead of _Z10lib$signali.

Any answers or hints anyone can provide will be greatly appreciated.


crgnz
Member
Posts: 7
Joined: Thu Apr 13, 2023 4:42 pm
Reputation: 0
Location: Auckland, New Zealand
Status: Offline

Re: Some C++/RTL questions

Post by crgnz » Wed May 22, 2024 6:31 pm

Is the VMS port of Postgres available as open source? I'm interested to learn about those variants of the vfork/exec routines...

I downloaded the postgresql-16.3 source code but couldn't spot anything obvious...


pustovetov
VSI Expert
Active Contributor
Posts: 43
Joined: Thu Sep 14, 2023 1:26 am
Reputation: 0
Status: Offline

Re: Some C++/RTL questions

Post by pustovetov » Mon May 27, 2024 2:24 am

crgnz wrote:
Wed May 22, 2024 6:31 pm
Is the VMS port of Postgres available as open source? I'm interested to learn about those variants of the vfork/exec routines...
Sorry, we haven't finished this port yet (primarily because of incomplete SSIO). We were transferred to other projects.
We didn't use the vfork/exec from the CRTL, but we called lib$spawn directly. In the future, it would probably be better to change all this to calling the posix_spawn function.
I downloaded the postgresql-16.3 source code but couldn't spot anything obvious...
In these sources, you can find the code for Windows. Windows doesn't have the fork() function either, so they did pretty much the same thing we did.

User avatar

arne_v
Senior Member
Posts: 531
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: Some C++/RTL questions

Post by arne_v » Mon May 27, 2024 9:02 am

Is posix_spawn available in C 7.5 / VMS 9.2-2 ?
Arne
arne@vajhoej.dk
VMS user since 1986


soutbarr
Active Contributor
Posts: 40
Joined: Wed Mar 13, 2024 4:45 pm
Reputation: 1
Status: Offline

Re: Some C++/RTL questions

Post by soutbarr » Mon May 27, 2024 10:06 am

There's no <spawn.h> which would be required to do that with cc.


jreagan
VSI Expert
Master
Posts: 215
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: Some C++/RTL questions

Post by jreagan » Wed Jun 05, 2024 12:08 pm

No, posix_spawn isn't in V9.2-2. I'll check my notes on when we are planning that.

Post Reply