f. OpenVMS FAQ -&- page 16)b @5z

HP OpenVMS Systems Documentation

 q> $"b,
Content starts here"D

The OpenVMS Frequently Asked Questions (FAQ)


 l n  
PreviousContentsIndex



GPermit structure members to be naturally aligned whenever possible, and>avoid using /NOMEMBER_ALIGNMENT. If you need to disable member?alignment, use the equivilent #pragma to designate the specificGstructures. The alignment of structure members normally only comes intoEplay with specific unaligned data structures---such as the sys$creprcFquota itemlist---and with data structures that are using data that was?organized by a system using byte or other non-member alignment.

CVersions of HP C such as V6.0 include the capability to extract theBcontents of the standard header libraries into directories such asESYS$SYSROOT:[DECC$LIB...], and provide various logical names that canBbe defined to control library searches. With HP C versions such asFV6.0, the default operations of the compiler match the expectations of>most OpenVMS programmers, without requiring any definitions ofDsite-specific library-related logical names. (And logical names leftCfrom older DEC C versions can sometimes cause the compiler troubleslocating header files.)

GHP C V5.6 and later include a backport library, a mechanism by which HP@C running on older OpenVMS releases can gain access to newer RTLGroutines added to the RTL in later OpenVMS releases---the language RTLs5ship with OpenVMS itself, and not with the compilers.

DExample C code is available in SYS$EXAMPLES:, in DECW$EXAMPLES (whenFthe DECwindows examples are installed), in TCPIP$SERVICES (or on olderEreleases, UCX$EXAMPLES) when HP TCP/IP Services is installed), on the*Freeware CD-ROMs, and at web sites such as



GFor additional information on the OpenVMS Ask The Wizard (ATW) area andAfor a pointer to the available ATW Wizard.zip archive, please see@Section 3.8.<

10.22.1 Other common C issues



AThe localtime() function and various other functions maintain theGnumber of years since 1900 in the "struct tm" structure member tm_year.FThis field will contain a value of 100 in the year 2000, 101 for 2001,@etc., and the yearly incrementation of this field is expected to continue.

FThe C epoch typically uses a longword (known as time_t) to contain theFnumber of seconds since midnight on 1-Jan-1970. At the current rate ofCconsumption of seconds, this longword is expected to overflow (whenFinterpreted as a signed longword) circa 03:14:07 on 19-Jan-2038 (GMT),Das this time is circa 0x7FFFFFFF seconds since the C base date. (The>most common solution is to ensure that time_t is an unsigned.)

DIf C does not correctly handle the display of the local system time,Ethen check the UTC configuration on OpenVMS---the most common symptomDof this is a skew of one hour (or whatever the local daylight savingGtime change might be). This skew can be caused by incorrect handling ofCthe "is_dst" setting in the application program, or by an incorrect;OpenVMS UTC configuration on the local system. (See sectionASection 4.4.)

EFloating point is prohibited in OpenVMS Alpha inner-mode (privileged)Fcode, and in any process or other execution context that does not haveAfloating point enabled. C programmers developing and working withCOpenVMS Alpha high-IPL kernel-mode code such as device drivers willGwant to become familiar with the floating point processing available in2the environment, and with the C compiler qualifierE/INSTRUCTION_SET=[NO]FLOATING_POINT. Device drivers and other similar(kernel-mode C code must be compiled with@/INSTRUCTION_SET=FLOATING_POINT and /EXTERN_MODEL=STRICT_REFDEF.

EAdditionally, the SYS$LIBRARY:SYS$LIB_C.TLB/LIBRARY parameter will beGneeded to be appended to the module specification or declared via the CEcompiler's include library logical name mechanism when the C compilerFis resolving kernel-mode data structures and definitions. This library@contains OpenVMS kernel-mode and other system declaractions, andDparticularly a mixture of undocumented definitions and declarations,Aand particularly definitions and declarations that are subject to=change (and that can accordingly lead to requirements for the#recompilation of application code).

FIn addition to the user-mode C Run-Time Library (RTL) mentioned in the{OpenVMS C RTL documentation and referenced over in Section 3.9, thereEis a second and parallel kernel-mode RTL accessable to device driversGand other kernel code on OpenVMS Alpha and OpenVMS I64. The most commonEtime this second C library is noticed is when C code is (erroneously)Flinked with /SYSEXE/SYSLIB, and duplicate symbol errors typically then@arise. As code running in supervisor-, executive- or kernel-modeGcontext cannot call out a user-mode RTL or other user-mode library, youFwill want to respecify the command as LINK /SYSEXE/NOSYSLIB. This willAeliminate the duplicate symbol errors, since only the kernel-modeGlibrary will be referenced, and it will also avoid calling out into theuser-mode libraries.

FWhen sharing variables with other languages, here is some example HP Ccode...

 

"
	      ...      #pragma extern_model save(      #pragma extern_model strict_refdef!      extern int   VMS$GL_FLAVOR;"      #pragma extern_model restore	      ...




1and here is some associated example Bliss code...

 

"
	      ...      EXTERNAL         VMS$GL_FLAVOR,
      ....


?

10.22.2 Other common C++ issues



DHP C++ (a separate compiler from HP C) provides both symbol manglingAand symbol decoration. Some of the details of working with longerEsymbol names and the resulting symbol name mangling in mixed languageGenvironments are listed in the shareable image cookbook, and in the C++@documentation. Symbol name decoration permits the overloading ofGfunctions (by adding characters to the external symbol for the function@to indicate the function return type and the argument data typesGinvolved), and mixed-language external references can and often do needDto disable this decoration via the extern "C" declaration mechanism:

 

"
      extern "C"	        {(        extern int ExternSymbol(void *);-        extern int OtherExternSymbol(void *);	        }




pAlso see Section 14.7 for information on /ARCHITECTURE and/OPTIMIZE=TUNE.

xSee Section 10.15 for information on the C system and the lib$spawncall in CAPTIVE environments.

DConstructs such as the order of incrementation or decrementation and@the order of argument processing within an argument list are allDimplementation-defined. This means that C coding constructs such as:

 

"
    i = i++;    a[i] = i++;    foo( i, i++, --i);




Dare undefined and can have (adverse) implications when porting the CBcode to another C compiler or to another platform. In general, anyGcombination of ++, --, =, +=, -=, *=, etc operators that will cause theEsame value to be modified multiple times (between what the ANSI/ISO C7standard calls "sequence points") produce undefined and implementation-specific results.

EWithin C, the following are the "sequence points": the ";" at the endCof a C statment, the ||, &&, ?:, and comma operators, and aEcall to a function. Note specifically that = is NOT a sequence point,Fand that the individual arguments contained within a function argumentGlist can be processed from right to left, from left to right, or at any random whim.

@HP C for OpenVMS VAX (formerly DEC C) and VAX C do differ in therelated processing.

DSo you are looking for OpenVMS-specific definitions (include files)?

EUCBDEF.H, PCBDEF.H and other OpenVMS-specific definitions---these areCconsidered part of OpenVMS and not part of the C compiler kit---are/available on all recent OpenVMS Alpha releases.

1To reference the version-dependent symbol libraryCsys$share:sys$lib_c.tlb, use a command similar to the following for compilation:

 

"
&$ CC sourcea+SYS$LIBRARY:SYS$LIB_C/LIB




?You can also define DECC$TEXT_LIBRARY to reference the library.

<You will want to review the Programming Concepts manual, and-specifically take a quick look at Chapter 21.

BAnd some general background: the STARLET definitions (and thus theGsys$starlet_c.tlb library) contain the symbols and the definitions thatEare independent of the OpenVMS version. The LIB definitions (and thusGsys$lib_c) contain symbols and definitions that can be dependent on theEOpenVMS version. You won't need to rebuild your code after an OpenVMSFupgrade if you have included definitions from STARLET. The same cannotFbe said for some of the definitions in LIB---you might need to rebuildAyour code. (The UCB structure can and has changed from release torelease, for instance.)

ERecent versions of C automatically search sys$starlet_c.tlb. Explicit+specification of sys$lib_c.tlb is required.

FAlso see the Ask The Wizard website topics (2486), (3803), and (1661):



GFor additional information on the OpenVMS Ask The Wizard (ATW) area andAfor a pointer to the available ATW Wizard.zip archive, please see@Section 3.8.

xSee Section 9.5 for information on the C off_t limitations, resolvedBin OpenVMS V7.3-1 and later and in ECO kits available for specific;OpenVMS releases. The use of a longword for off_t restrictsGapplications using native C I/O to file sizes of two gigabytes or less,Cor these applications must use native RMS or XQP calls for specific operations.j

10.23 Status of Programming Tools on OpenVMS VAX?



HDECthreads V7.3 and the HP C compiler (also known as Compaq C and DEC C)?V6.4 are presently expected to be the last updates and the lastBreleases of these development packages for use on OpenVMS VAX. TheDrun-time support for both DECthreads (CMA$RTL) and for C (DECC$CRTL)will continue to beGmaintained, and will continue to be available on OpenVMS VAX. The VAX CFV3.2 compiler is the final VAX C compiler release for OpenVMS VAX, andHthe VAX C Run-Time Library (VAXCRTL) will also continue to be available.

FNew development and new features and product enhancements continue forCthe OpenVMS Alpha and the OpenVMS IA-64 DECthreads and C compilers.s

10.24 Choosing a Version Number for Application Code?



FOne of the common rules-of-thumb used for choosing a displayed versionGnumber string for a new version of a layered product or an application,Eits implications, and its expected effects on client applications andusers, follows:

    @
  • No functional and no application-visible changes, bugfixesE only---the edit number is incremented. These tend to be very small,F very isolated, or ECO-level changes. These can also be distributionsH for specific hardware configurations or platforms, as is the case with, an OpenVMS Limited Hardware Release (LHR).FApplication rebuilds are not expected, and there is an assumption thatEgeneral user-provided application-related regression testing will not be required.@
  • Minimal functional and very few user-visible changes---theH maintenance number is incremented. These tend to be very small or evenF ECO-level changes, though somewhat larger than an edit-level change.H Application rebuilds are not expected, and there is an assumption thatB user-provided application-related regression testing will not be required.H
  • Various small and upward-compatible functional changes---the minorF version number is incremented. The changes are user-visible, and areE intended to be user-visible. Application rebuilds are not expected.F Some application programmers may choose to perform regression tests.G
  • Large and/or potentially incompatible changes---the major versionD number is incremented. Some applications might need to be rebuilt.I Various application programmers will choose to perform regression tests# of their respective applications.


AFor additional version-numbering materials and for information on ;assigning module generation numbers, please see the OpenVMSwF(POLYCENTER) Software Product Installation Utility---variously referedCto by acronyms including PCSI and SPIA---reference manual availablea%within the OpenVMS documentation set.crj

r>Of course, all of this is obviously subject to interpretation,Gparticularly around the distinction between large and small changes and Gsuch. The scale of the application is also a factor, as larger and more"Fcomplex applications will tend toward smaller increments and will tend@to see the maintenance number incremented, while new releases ofCsmaller applications will tend to see the minor version incrementedfsomewhat more frequently.

eGThe goal of all this is to provide a guide to relative scale of changesgDand the associated effort involved in an upgrade for the user and/orfor the application programmer.le

10.25 Selecting a Process Dump Directory?

l

iBYou can customize the device and directory for the process dump byEdefining the logical names SYS$PROCDMP and SYS$PROTECTED_PROCDMP. The=Dformer is for non-privileged dumps, while the latter is the location@where privileged image dumps are written, and preferably an area0protected against untrusted access. For example:

t 
a
"
"$ define SYS$PROCDMP SYS$ERRORLOG:2$ define /exec SYS$PROTECTED_PROCDMP SYS$ERRORLOG:

m
he

aBThe abouve presumes that the SYS$ERRORLOG logical name points to avalid location.

tDThere is presently no means to change the name of the generated dump;file from IMAGENAME.DMP to something else. Accordingly, you in?will want to use different target directories for this purpose,f=particularly if there is more than one application or processt"potentially writing process dumps.^

10.26 Access to Itanium Assembler?



sEIf you are interested in accessing the native Intel Itanium assemblern=within the OpenVMS I64 GNV environment---and since the iasi64YpF assembler is a Unix program and GNV is a Unix environment for OpenVMSF I64---you can simply copy iasi64.ext into your gnu:[bin] directory in5 place of "as.", and of "AS.EXE".m

iFAlternately and probably also better, you can write an "as."Bscript to invoke the iasi64.exe image from its particular preferedlocation on the local system.e

a1A typical "as." script looks like this:n

 
d
"
path/iasi64.exe $1 $2 $3 $4 $5

a
b

10.27 Kernel-mode coding restrictions?



nEFloating point is prohibited in OpenVMS Alpha inner-mode (privileged)tEcode, and within any process or other execution context that does not *have floating point enabled and available.slw

w>Programmers developing and working with OpenVMS Alpha high-IPLEkernel-mode code, such as device drivers, will further want to becomenCfamiliar with the floating-point processing and the instruction setdGemulation available in the particular target environment (if any). When8Cworking with C, inner-mode programmers will want to become familiar.Bwith the C compiler qualifier /INSTRUCTION_SET=[NO]FLOATING_POINT.i

hDDevice drivers and other similar kernel-mode C code must be compiledEwith /INSTRUCTION_SET=FLOATING_POINT and /EXTERN_MODEL=STRICT_REFDEF.r

GAdditionally, inner-mode code cannot call out to the user-mode languageeGrun-time libraries nor to any of the OpenVMS system run-time libraries.nFIn particular, this prohibition prevents pages of inner-mode-protectedFmemory from being allocated and interspersed within the user-mode heap(or other such user-mode data structures.

3DThe prohibtion on user libraries also generally means that such code@must be linked with LINK /NOSYSLIB, and quite probably also withC/SYSEXE. The former causes the linker to avoid searching the systemeEshareable image libraries (via IMAGELIB.OLB), while the latter brings Cin symbols typically only known to or otherwise accessable from the OpenVMS executuve.is

_CTo include kernel-mode C programming definitions, macros and system )constants within a C compilation, include CSYS$LIBRARY:SYS$LIB_C.TLB/LIBRARY on the C compilation. (Constructsd(or within its C equivalent SYS$LIB_C.TLBof the compilation, the following is a typical C device drivercompilation command:

x 

"
L$   CC /STANDARD=RELAXED_ANSI89/INSTRUCTION=NOFLOATING_POINT/EXTERN=STRICT -F        'DEBUG_CC_DQ_OPT' 'ARCH_CC_OPT' 'CHECK_CC_OPT' 'SHOW_CC_OPT' -;        /LIS=LIS$:xxDRIVER/MACHINE_CODE/OBJ=OBJ$:xxDRIVER -N9        SRC$:xxDRIVER.C+SYS$LIBRARY:SYS$LIB_C.TLB/LIBRARYs

h


TCAdditionally, code running in executive mode in an AST or in kernel9Gmode cannot call RMS services, or routines which directly or indirectlyn call RMS.xn

hGFor related kernel-mode programming materials and driver documentation,nFplease see the Writing OpenVMS Alpha Device Driversin C book,ISBN 1-55558-133-1.mn

10.28 Decoding an Access Violation (ACCVIO) Error?



SETo decode the virtual addresses returned by an access violation or byeFanother similar OpenVMS display, you need to have created and retained=a listings file---preferably one with machine code generationnenabled---and a full link map.

hEStarting with the virtual address reported by the error, use the linkBmap to find the module that contributed the code that contains theGvirtual address range. Calculate the offset from the base of the range,uFby subtracting the base of the range from teh failing virtual address.@Then use the compiler listings for the particular component thatEcontributed the code to locate the offset of the failing instruction.

i?If the map and listings information was not maintained, workingi@backwards is far more difficult---you are left to use the binaryCinstruction data around the failure to locate the associated sourceBcode, and this process is far more involved. This usually involvesFmatching up blocks of decoded instructions around the failing code, orGthe direct analog involving matching up ranges of decoded instructions.7Keep the maps and listing files around, in other words.g

tFRather easier than an approach based on virtual address arithmetic andGfar easier than working backwards from the instruction stream is to use>integrated debugging---this inclusion is arguably an essentialAcomponent of any non-trivial application---and to use the OpenVMSv Debugger.p

xDThe OpenVMS Debugger in particular can be used to examine the source>code, to examine the stack, and can even be programmed to wait?patiently for the incidence of a particular value or failure orAcondition, and this is far easier than working backwards from the Einstruction stream is to use integrated debugging---this inclusion isLGarguably an essential component of any non-trivial application---and tonAuse the OpenVMS Debugger. The debugger can also be activated fromDwithin a signal handler, and commands to generate a traceback can beGgenerated directly, or through the invocation of a procedure containingba series of debugger commands.

mDDetails on the debugger are in the OpenVMS Debugger Manual, and also<see the discussion of dyanmically activating the Debugger inCSection 10.19.oc

10.29 Generating an AUTODIN-II CRC32?

s

v8The following code can be used to generate an AUTODIN-IIolA32-bit Cyclic Redundency Check (CRC32) value from an input stringo=descriptor, similar to that used by the HP C compiler for itsrG/NAMES=SHORTENED mechanism, and by various other applications requiring;a CRC32.

iFThe routine uses the OpenVMS library routine lib$crc_table to generateFa sixteen longword array of data from the specified encoded polynomialDcoefficient (AUTODIN-II, in this case), and then lib$crc to generate2the CRC32 value from the array and the input data.id

b 
s
"
>static int CreateCRC32( struct dsc$descriptor *InputDataDesc )  {e  uint32 AUTODIN2;  uint32 Seed = ~0UL;a%  uint32 Coefficient = 0x0EDB88320UL;  uint32 CRCArray[16];"  lib$establish( lib$sig_to_ret );@  lib$crc_table( (void *) &Coefficient, (void *) CRCArray );M  AUTODIN2 = lib$crc( (void *) CRCArray, (void *) &Seed, InputDataDesc );i  AUTODIN2 ^= Seed;e  return AUTODIN2;  }i


X

10.30 Enabling built-in tracing?



r 
t
"
$ RUN SYS$SYSTEM:SYSMANd<SYSMAN> SYS_LOAD ADD TR$DEBUG TR$DEBUG/LOAD_STEP=INIT/LOGSYSMAN> Exitl#$ @SYS$UPDATE:VMS$SYSTEM_IMAGES.COM"

f


e%To stop it from loading early in boots

 
u
"
$  RUN SYS$SYSTEM:SYSMAN0SYSMAN> SYS_LOAD REMOVE TR$DEBUG TR$DEBUG/LOGSYSMAN> Exitr#$ @SYS$UPDATE:VMS$SYSTEM_IMAGES.COM

S


C>The first occurance of the name TR$DEBUG within the command isCconsidered the "product" and the second is considered the?"image" that should exist within SYS$LOADABLE_IMAGES.-

rDWhen TR$DEBUG loads in the init phase, it will automatically turn ontracing.

aAlso see the SDA TR extension.v

n


 i rl n  e
PreviousNextContentsIndex

 

S#$6anndent of the OpenVMS version. The LIB definitions (and thusGsys$lib_c) cot write-shared by all;processes on the system. If you do want write-sharing, use:a

v 

"
CDEC$ PSECT common-name=SHR 




fEin the Fortran source code (the CDEC$ must be begin in column 1) or a5@linker options file PSECT_ATTR statement to set the COMMON PSECTattribute to SHR.n

e/For further information, see the Linker manual.l 

u


 r Y \ ^  b
PreviousNextContentsIndex

 

o#u6aether than RMS, of course), contact,the database vendor directly for assistance.w

9.10 If my disks are shown as VIOC Compatible, am I using XFC?



Yes, you are using XFC caching.

CDisks that are using XFC caching use communication and coordinatio3 .2CB(y筗99o >1.HTML;BEAVIS DISK$WEB3 .2CB(y筗::o >2.HTML;BEAVIS DISK$WEB3 .2CB(y筗;;o >3.HTML;BEAVIS DISK$WEB3 .2CB(y筗<<o >4.HTML;BEAVIS DISK$WEB3 .2CB(y筗==o >5.HTML;BEAVIS DISK$WEB3 .2CB(y筗>>o >8.HTML;BEAVIS DISK$WEB3 .2CB(y筗??o >9.HTML;BEAVIS DISK$WEB3 .2CB(y筗@@o ?60.HTML;BEAVIS DISK$WEB3 .2CB(y筗AAo >1.HTML;BEAVIS DISK$WEB3  .2CB(y筗BBo >2.HTML;BEAVIS DISK$WEB3 .2CB(y筗CCo >4.HTML;BEAVIS DISK$WEB3 .2CB(y筗DDo >5.HTML;BEAVIS DISK$WEB3 .2CB(y筗EEo >6.HTML;BEAVIS DISK$WEB3 .2CB(y筗FFo >7.HTML;BEAVIS DISK$WEB3 .2CB(y筗GGo >8.HTML;BEAVIS DISK$WEB3 .2CB(y筗HHo >9.HTML;BEAVIS DISK$WEB3 .2CB(y筗IIo ?70.HTML;BEAVIS DISK$WEB3 .2CB(y筗JJo >1.HTML;BEAVIS DISK$WEB3 .2CB(y筗KKo >2.HTML;BEAVIS DISK$WEB3 .2CB(y筗LLo >3.HTML;BEAVIS DISK$WEB3 .2CB(y筗MMo >4.HTML;BEAVIS DISK$WEB3 .2CB(y筗NNo >5.HTML;BEAVIS DISK$WEB3 .2CB(y筗OOo >6.HTML;BEAVIS DISK$WEB3 .2CB(y筗PPo >8.HTML;BEAVIS DISK$WEB3 .2CB(y筗QQo >9.HTML;BEAVIS DISK$WEB3 .2CB(y筗RRo ?80.HTML;BEAVIS DISK$WEB3 .2CB(y筗 RR{ S { T0.HTDOCS.WIZARD'WIZ_1681.HTML;BEAVIS DISK$WEB3 .2CB(y筗{ >2.HTML;BEAVIS DISK$WEB3 .2CB(y筗{ >3.HTML;BEAVIS DISK$WEB3 .2CB(y筗{ >5.HTML;BEAVIS DISK$WEB3 .2CB(y筗{ >6.HTML;BEAVIS DISK$WEB3 .2CB(y筗{ >7.HTML;BEAVIS DISK$WEB3 .2CB(y筗{ >8.HTML;BEAVIS DISK$WEB3 .2CB(y筗{ >9.HTML;BEAVIS DISK$WEB3 .2CB(y筗 { ?90.HTML;BEAVIS DISK$WEB3 .2CB(y筗 { >1.HTML;BEAVIS DISK$WEB3 .2CB(y筗 { >2.HTML;BEAVIS DISK$WEB3 .2CB(y筗 { >3.HTML;BEAVIS DISK$WEB3 .2CB(y筗 { >4.HTML;BEAVIS DISK$WEB3 .2CB(y筗{ >5.HTML;BEAVIS DISK$WEB3