[Info-vax] Help wanted : Porting code from Linux to VMS
John E. Malmberg
wb8tyw at qsl.net_work
Wed Jan 23 08:41:47 EST 2019
On 1/22/2019 2:44 PM, Marc Van Dyck wrote:
> My job today is mainly system administration. But I have done software
> development in the past, and still enjoy doing some programming when the
> opportunity arises. What I have been asked to do today is however a bit
> more challenging for me than usual.
>
> It'll basically consist of porting C code written for a linux platform
> to OpenVMS. And it won't be the trivial 'copy the code and recompile'
> job :
>
> 1) it contains several system calls which I'll need to find an adequate
> equivalent for. I think I can manage that one, even if I know nothing
> about Linux.
You need to use a search engine to find "The Open Group" and the syscall
name and look up the description of the call, and possibly the Linux
System Base.
The Open Group definitions on how the syscalls are suppose to work is
the "Official" standard. But beware, there are bugs in the way of
omissions in "The Open Group" documents, and some system calls are Linux
extensions. And the Linux System Base is very hard to read, because it
makes you follow lots of links to look up things.
And some Linux/Unix syscalls are not documented enough to know how to
simulate them on VMS. You basically have to look at the Linux source to
see what Linux did to implement them.
Many of the system calls do behave exactly as expected from their names.
Most software does not notice these special "features", but others
depend on them.
The VMS CRTL attempts to be compatible with "The Open Group". It is not
fully compatible at this time.
One issue with the VMS CRTL seen in porting programs that use TCPIP is
that Linux/Unix expects the socket related syscalls to work on all
compatible devices such as terminals and pipes, and the VMS CRTL only
supports them on sockets. This is commonly seen in client applications
ported from Linux. For server applications ported from Linux, usually
they expect fork() and get*uid()/set*uid() to work exactly as on Linux.
> 2) I will port the code from C to Pascal, which is the only language I
> feel comfortable with. Not afraid by that one, have done it several
> times already.
These days being able to write C code is almost a standard requirement
for program development.
> 3) The code contains a good dose of TCP/IP programming. And there I'm
> somewhat lost, because I never touched that in the past. So I'd
> appreciate a bit of help to get me started...
>
> Hence the following questions :
>
> 1) Is there any documentation about that ? How to write, on OpenVMS,
> code to establish a TCP/IP communication with another host ? Like what
> you would do with DECnet non transparent task to task communication ?
That is in the HP TCP/IP documentation. The C and $QIO implementation
is documented in the same volume. The Process TCP/IP implements an
equivalent shared library and may have some extensions. I have not
compared the two of them.
But as others have pointed out, many sites are now requiring that all
TCP/IP traffic be encrypted, so instead of making syscalls on sockets or
$QIO calls you have to use an encryption library. And most of those
only have a documented C interface.
Now Pascal can call C code on VMS. Which also means that you should be
able to actually call CRTL routines from Pascal once you setup the
definitions.
Very old C code would have different link instructions for various
TCP/IP vendors for VMS. These days, no special linking is usually needed.
Fortunately there is almost a 1:1 correspondence for the C "socket" API
and the $QIO implementations. This was probably done to simplify
writing the C implementation.
If you encounter the writev() and readv() system calls in the original
code, these are not in the $QIO interface.
While they are in the VMS C library, they should be avoided if you are
trying to get the best throughput.
In Linux/Unix they pass a list of buffers to the TCP/IP driver that can
be used for DMA from the network device. This is so that you can setup
big transfers.
The last time I looked at the VMS CRTL, it simulated them by copying
them into or from a larger single buffer, which adds more delay to the
operation.
> 2) Any coding examples availabe somewhere, or that someone would agree
> to share ? Preferably in Pascal, but I'll understand if only C is
> available...
Have not done Pascal programming since late 80's.
> 3) Are the TCP/IP calls definitions that I'll need to use available
> in pascal environment files somewhere ? Or SDL definitions that I
> could translate and compile ?
Don't know.
Regards,
-John
More information about the Info-vax
mailing list