gtpc2m46 | C/C++ Language Support User's Guide |
This function copies the modification data to the specified TPF global
field or record.
Format
#include <tpfglbl.h>
#include <c$globz.h>
int glob_modify(unsigned int tagname, void *dstptr,
const void *srcptr, int length);
- tagname
- This argument, which is defined in header file
c$globz.h, uniquely identifies the TPF global field or
record to be accessed.
- dstptr
- The address of the data in the global field or record to be
modified.
- srcptr
- The address of the data used to modify the global field or record.
- length
- The length of the modified data.
Normal Return
- GLOB_RC_OK
- The global field or record was updated successfully.
Error Return
- GLOB_RC_LENGTH_ERROR
- The length parameter was not a positive integer, or would have extended
the overlay past the end of the global being modified (as specified by the
tagname parameter).
- GLOB_RC_RANGE_ERROR
- The dstptr parameter was outside the range of addresses containing the
global area as specified by the tagname parameter.
- GLOB_RC_DIRECTORY_ERROR
- The global record directory field specified by the tagname parameter is a
file address. (This return applies only to global records.)
- GLOB_RC_KEY_ERROR
- The storage protection KEY for the global record being modified does not
match the KEY for either GLOBAL1, GLOBAL2, or GLOBAL3. (This return
applies only to global records.)
- GLOB_RC_OVERLAP_ERROR
- The global area to be modified and the modification data overlap.
Programming Considerations
- The argument coded as tagname must be defined in header file
c$globz.h. Results will be unpredictable if this
restriction is not heeded.
- A program should not give up control (by calling an I/O function, such as
finwc) between accessing and updating a TPF global field or
record. If it does, the data that the program accesses may have already
been updated by another program by the time the program decides to update
it. Use of the locking facility (see glob_lock-Lock and Access Synchronizable TPF Global Field or Record) provides additional security when updating
synchronizable global fields.
- No additional functions are performed against the global field or record
(keypointing, processor synchronization, and others). To perform
additional functions, you must either use the glob_update function,
or subsequently call glob_keypoint or glob_sync.
- If the global field or record can be synchronized, glob_lock
must be called before calling glob_modify.
- This function gets the appropriate global PSW key before updating the
global area specified by tagname, and returns the PSW key to the working
storage key before returning to the caller.
Examples
The following example modifies a synchronizable global record.
#include <tpfglbl.h>
#include <c$globz.h>
·
·
·
{
/******************************************************************/
/* Increment data element mysdata in synchronizable global record */
/* _mysglob. */
/******************************************************************/
struct mysglbrec **msgrptrptr = glob_lock(_mysglob);
struct mysglbrec *msgrptr = *msgrptrptr;
long newdata = msgrptr->mysdata + 1;
glob_modify(_mysglob, &msgrptr->mysdata, &newdata,
sizeof msgrptr->mysdata);
glob_sync(_mysglob);
}
Related Information