[OpenVMS, Alpha, IA64, HP C] Calling $CRMPSC on OpenVMS Alpha
PRODUCT: HP C Version 7.2-022 or above
OP/SYS: OpenVMS Alpha Version 8.4 OpenVMS IA64 Version 8.3-1H1 or above
COMPONENT: $CRMPSC
SOURCE: Philippe Vouters Fontainebleau/France
HIGH QUALITY MOBILES+TABLETS: http://android-land.fr
OVERVIEW: This article contains a program which shows how to use the $CRMPSC system service specifying the inadr argument for a page or disk file section. Because this code declares a non static variable named dummy_array_for_offsets at module level, this variable is turned to a psect which is combined with the g_sns_common psect to form an image cluster. Because the VMS Linker orders psects alphabetically within the same cluster, the g_sns_common psect is combined with the dummy_array_for_offsets psect and does not start on CPU pagesize boundary, causing the computed inadr[0] to not be a multiple of the CPU pagesize. Hence the COLLECT added Linker's option so that the g_sns_common psect correctly starts on a CPU pagesize boundary.
*** CAUTION *** This sample program has been tested using HP C V7.2-022 on OpenVMS IA64 V8.3-1H1. However, we cannot guarantee its effectiveness because of the possibility of error in transmitting or implementing it. It is meant to be used as a template for writing your own program, and may require modification for use on your system.
PROGRAM NOTES: Compilation and link commands: $ CC/DEBUG/NOOPT CRMPSC.C $! On IA64, suppress the PIC PSECT_ATTR argument. $! Otherwise you incur a Linker's warning. $ LINK/DEBUG CRMPSC,SYS$INPUT/OPT PSECT_ATTR=G_SNS_COMMON,PIC,NOEXE,SHR COLLECT=G_SNS,G_SNS_COMMON The successful execution of this program requires the following minimal privileges: TMPMBX, NETMBX, SYSGBL
PROGRAM EXECUTION: $ set proc/priv=(noall,tmpmbx,netmbx,sysgbl) $ run crmpsc OpenVMS I64 Debug64 Version X8.3-015 %DEBUG-I-INITIAL, Language: C, Module: CRMPSC %DEBUG-I-NOTATMAIN, Type GO to reach MAIN program DBG> go break at routine CRMPSC\main 32113: char *filename = "IARRAY.DAT"; DBG> set break %line 32173 DBG> go break at CRMPSC\main\%LINE 32173 32173: return status; DBG> exa/cond status CRMPSC\main\status: %SYSTEM-S-CREATED, file or section did not exist; has been created DBG> quit $ sho sys/noproc OpenVMS V8.3-1H1 on node THESEE 31-MAY-2011 13:10:59.36 Uptime 334 18:17:31
PROGRAM: /* COPYRIGHT (C) 1998-2011 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD MASSACHUSETTS. ALL RIGHTS RESERVED. THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED. THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION. DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY DIGITAL. NO RESPONSIBILITY IS ASSUMED FOR THE USE OR RELIABILITY OF SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY DIGITAL EQUIPMENT CORPORATION. SUPPORT FOR THIS SOFTWARE IS NOT COVERED UNDER ANY DIGITAL SOFTWARE PRODUCT SUPPORT CONTRACT, BUT MAY BE PROVIDED UNDER THE TERMS OF THE CONSULTING AGREEMENT UNDER WHICH THIS SOFTWARE WAS DEVELOPED. */ #include <string.h> #include <stdlib.h> #include <starlet.h> /* For the usage of sys$crmpsc */ #include <descrip.h> /* Because we need the macro $DESCRIPTOR */ #include <secdef.h> /* For the SEC$M_ flags */ #include <rms.h> #include <lib$routines.h> #include <psldef.h> #include <syidef.h> #define PAGELET_SIZE 512 /* CRMPSC, for the flags we use, counts in number * of pagelets, so define the size of a pagelet. */ int dummy_array_for_offsets [10]; #pragma extern_model save #pragma extern_model common_block struct { int starting; int ending; } g_sns_common; #pragma extern_model restore typedef struct { unsigned short buflen; unsigned short item_code; void *buffer; unsigned int *retadr; } item_t; main(){ unsigned long inadr[2]; unsigned long retadr[2]; struct FAB fab; item_t *itmlst; unsigned int pagesize; char *filename = "IARRAY.DAT"; int pagcount,flags,status; $DESCRIPTOR (global_section_name_descriptor,"IARRAY"); itmlst = calloc(2,sizeof(item_t)); /* * Get the CPU specific page size. */ itmlst[0].buflen = sizeof(unsigned int); itmlst[0].item_code = SYI$_PAGE_SIZE; itmlst[0].buffer = &pagesize; itmlst[0].retadr = NULL; status = sys$getsyiw(0,0,0,itmlst,0,0,0); if (!(status & 1)) lib$signal (status); /* * Compute the starting and ending addresses to the next CPU-specific * page boundary,because we are on an Alpha/IA64 System and we do NOT * use SEC$M_EXPREG in the flags argument. */ inadr[0] = (unsigned long)&g_sns_common.starting; inadr[1] = (unsigned long)((char *)&g_sns_common.ending + sizeof(int)+pagesize)/pagesize*pagesize - 1; pagcount = (inadr[1]-inadr[0])/PAGELET_SIZE; /* * As we are mapping a new page file section, create the file with $ create. */ fab = cc$rms_fab; fab.fab$l_alq = pagcount; fab.fab$b_fac = FAB$M_GET | FAB$M_PUT; fab.fab$l_fna = filename; fab.fab$b_fns = strlen(filename); fab.fab$l_fop = FAB$M_UFO | FAB$M_CIF; status = sys$create(&fab); if (!(status&1)) lib$stop(status); /* * Specify the desired flags */ flags = SEC$M_GBL | SEC$M_WRT | SEC$M_SYSGBL | SEC$M_DZRO; /* Now create the global section */ status = sys$crmpsc ( inadr, retadr, PSL$C_USER /* acmod not specified */, flags, &global_section_name_descriptor, 0 /* ident not specified */, 0 /* relpag not specified */ , fab.fab$l_stv /* file channel returned by $create */, pagcount, 0 /* vbn not specified */, 0 /* prot not specified */, 0 /* pfc not specified */); /* With the debugger check status with an EXAMINE/CONDITION status Examine in hexadecimal retadr Still with the debugger, type SPAWN and with the VMS prompt, enter INSTAL. Under INSTAL type LIST/GLOBAL. Locate the section IARRAY. Is the number of pagelets rounded up to next machine page size correct for our section ? */ return status; }
REFERENCE: $CRMPSC OpenVMS System service on-line description at: http://h71000.www7.hp.com/doc/83final/4527/4527pro_027.html