cds_copyto(rgid,offset,buffer,btype,cnvrsn)Here, offset describes the number of bytes from the beginning of the CDS region where the copy is to begin, buffer describes the location in process memory where the copy is to begin, and btype describes how the copy is to take place, as described below. cnvrsn denotes a conversion table which describes how different types of data are to be converted and/or aligned during the copy. A cnvrsn value of zero may be supplied to suppress conversion (i.e. implement a straight copy), but useful values of cnvrsn can also be obtained from another CDS function, cds_transtab, which takes two CDS process IDs and returns the appropriate conversion table to convert between their respective data representations.
cds_copyfm(rgid,offset,buffer,btype,cnvrsn)
For copytofm, which copies between two CDS regions, buffer is not used, and instead two offsets are specified, one for each buffer:
cds_copytofm(rgid1,offset1,rgid2,offset2,btype,cnvrsn)One other function,
cds_typlen(btype,cnvrsn,offset)returns the number of bytes which would be copied to or from the region if the given arguments were used on a copy operation (assuming that there is sufficient room in the region to accomodate them).
The routines described here don't technically do anything that the programmer can't do entirely outside of CDS, but in a subsequent section (on message passing), having a well-defined copy interface within CDS becomes important.
[+o][/]t[*n](The brackets enclose optional fields and are not actually part of the type.) o is an integer representing an offset (assumed zero if omitted), the slash is an optional copy suppressor, n is an integer replicator (assumed 1 if omitted), and t is either an atomic datatype from the set {int, float, longint, char} or another CDS type (i.e. a list of type elements) in parentheses.
Type conversion starts with a user-space pointer u beginning at buffer and a region-space pointer r beginning at the the beginning of the region or message (plus offset bytes if an offset argument is available in the specific function). Then, the type elements are processed in order.
For each type element
retval = cds_type(tstring, tterm, btype, btsize)where tstring is the sequence of characters representing the CDS type, tterm is the character which terminates tstring, btype is an integer vector to contain the result, and btsize is the number of elements in btype. btsize should be a multiple of 3 because, in general, each type element will take 3 elements in btype. The function returns the number of elements actually needed in btype (always a multiple of 3) negated if btsize was too small to accomodate this. (Thus, it is possible to use this function first to query how large btype should be by calling with btsize equal to 0.)
t * 3integers from the beginning of the current triple.)
Example 1. To copy a record having the following C struct type
struct {int vec[10];except for the field named flag:
char flag;
float x, y;}
retval = cds_type("int*10 /char float*2", '/0', btype, 20);would return the value 9 in retval and the following values in btype
0, CDS_TINT, 10,Example 2. To copy just the left-most and bottom-most elements from a 10 by 10 array of floats in C (i.e. stored by row):
0, CDS_CHAR | CDS_TSUPP, 1,
CDS_TEND, CDS_TFLT, 2
retval = cds_type("(float /float*9)*9 float*10", '/0', btype, 12);would return the value 12 in retval and the following values in btype:
0, 2 | CDS_TNEST, 9,
CDS_TEND, CDS_TFLT, 10,
0, CDS_TFLT, 1,
CDS_TEND, CDS_TFLT | CDS_TSUPP, 9
Copyright 2000 © elepar All rights reserved