Page 1 of 1

getrusage on OpenVMS Alpha

Posted: Wed Sep 01, 2021 6:19 am
by fausap
Hello,

I'm trying to write some code using the getrusage C function.
According the VSI reference manual (https://vmssoftware.com/docs/VSI_CRTL_REF.pdf), this function should be available for 64bit systems.
Even if I include the resource.h file, I still have this function implicit declared and looking at the header file, there's no mention about that function. Also the symbol RUSAGE_SELF is not declared, and according the reference guide, it should be present.

I'm currently using VSI C V7.4-002 on OpenVMS Alpha V8.4-2L1

Is there any update package for the C library?

thanks a lot,
Fausto Saporito

Re: getrusage on OpenVMS Alpha

Posted: Wed Sep 01, 2021 10:45 am
by jonesd
I recently had to change my code to support the CRTL-provided getrusage instead of providing my own substitute.

I changed the test
#ifndef RUSAGE_SELF
/* Implement substitute getrusage here, including defining RUSAGE_SELF */

to
#if __CRTL_VER < 80500000
/* implement substitute getrusage */

In other words, the run-time has getrusage() with CRTL version 8.5 or later.

Re: getrusage on OpenVMS Alpha

Posted: Wed Sep 01, 2021 11:16 am
by fausap
jonesd wrote:
Wed Sep 01, 2021 10:45 am
In other words, the run-time has getrusage() with CRTL version 8.5 or later.
Thanks for the hint. I have, indeed, version 8.4

Is there any way to update the CRTL?

In this version also other functions are missing, related to wide-char handling, like wsprintf, wmemcopy.
So it seems the documentation available on the web site is not aligned with the CRTL shipped with the actual OpenVMS version, at least for the alpha platform.

thanks,
Fausto

Re: getrusage on OpenVMS Alpha

Posted: Thu Sep 02, 2021 7:29 am
by madsweeney
The CRTL updates are only available on VSI versions of OpenVMS, V8.4-1H1 or later. HPE no longer releases any updates, including defect repair, for OpenVMS V8.4. There are no incompatible changes between V8.4 and VSI versions. Is there any technical reason not to upgrade?

Re: getrusage on OpenVMS Alpha

Posted: Sun Sep 05, 2021 4:52 pm
by fausap
madsweeney wrote:
Thu Sep 02, 2021 7:29 am
The CRTL updates are only available on VSI versions of OpenVMS, V8.4-1H1 or later. HPE no longer releases any updates, including defect repair, for OpenVMS V8.4. There are no incompatible changes between V8.4 and VSI versions. Is there any technical reason not to upgrade?
I have no problem updating the CRTL, I don't know where to download or how to request the update package.
I am using OpenVMS V8.4-2L1, so I suppose the update is available for that OpenVMS version, correct?
To clarify, I installed the C compiler using the kit found in the AVMS842L2LP2 iso image downloaded from the vsiftp site, using the ACOMMUNITY account.
The installed C compiler is marked as VSI C, but the version is 7.4-002 not 7.4-1 (as described in the pdf manual).

Re: getrusage on OpenVMS Alpha

Posted: Mon Sep 06, 2021 12:31 pm
by madsweeney
Hello,

Please you provide more details on the software you are writing.

Thank You,

Re: getrusage on OpenVMS Alpha

Posted: Mon Sep 06, 2021 1:50 pm
by fausap
madsweeney wrote:
Mon Sep 06, 2021 12:31 pm
Hello,

Please you provide more details on the software you are writing.

Thank You,
Sure. The code is a sequence generator. The getrusage function is used to measure the time used by the printing function.
I have also problem with wchar.h and wmemchr (not used in this code), because even it's described in the CRTL manual, in my CRTL is missing.

Code: Select all

#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <locale.h>
#include <wchar.h>

#if defined(__VMS)
#define timersub(a, b, result)                          \
  do {                                                  \
    (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;       \
    (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;    \
    if ((result)->tv_usec < 0) {                        \
      --(result)->tv_sec;                               \
      (result)->tv_usec += 1000000;                     \
    }                                                   \
  } while (0)
#endif

static struct timeval epoch;

static void init_times(void)
{
    gettimeofday(&epoch, 0);
}

static long times_real(void)
{
    struct timeval tv;
    struct rusage ru;
    gettimeofday(&tv, 0);
    getrusage(RUSAGE_SELF, &ru);
    timersub(&tv, &epoch, &tv);
    long real= tv.tv_sec * 1000 + tv.tv_usec / 1000;
    long user= ru.ru_utime.tv_sec * 1000 + ru.ru_utime.tv_usec / 1000;
    long syst= ru.ru_stime.tv_sec * 1000 + ru.ru_stime.tv_usec / 1000;
    return real;
}

int main()
{
    init_times();
    setlocale(LC_CTYPE, "");
    for (int i=1;i<10000;i++) {
        printf("%d -> ",i);
        for (int j=2;j<i;j++) {
            if ((i % j)==0) printf("%ld ",(long) i*j/(i+j));
            if ((i % j)==0) wprintf(L"%lc ",(wchar_t) (i+j));
        }
        printf("\n");
    }
    printf("\nreal: %ld\n",times_real());
    return 0;
}

Re: getrusage on OpenVMS Alpha

Posted: Tue Sep 07, 2021 7:16 am
by madsweeney
Let me clarify my request for information on the software. Access to VSI OpenVMS CRTL updates and ECO patches require you to supply a valid VSI software support service number, VSN or VON. You get a VSN number by having a support contract or being an approved software partner developing commercial or OpenSource software.

Contact isv@vmssoftware.com to register as a partner or sales@vmssoftware,com for information on support options or academic options.

Re: getrusage on OpenVMS Alpha

Posted: Wed Sep 08, 2021 1:22 am
by fausap
madsweeney wrote:
Tue Sep 07, 2021 7:16 am
Let me clarify my request for information on the software. Access to VSI OpenVMS CRTL updates and ECO patches require you to supply a valid VSI software support service number, VSN or VON. You get a VSN number by having a support contract or being an approved software partner developing commercial or OpenSource software.

Contact isv@vmssoftware.com to register as a partner or sales@vmssoftware,com for information on support options or academic options.
ok, I'll try that, thanks.