"Terrence Enger" <tenger@xxxxxxxxxxxxxxxx> wrote in message news:18.104.22.168.20030904125417.00f3ddf4@xxxxxxxxxxxxxx > Hmm. The bit "- (char*)_LSPCO(p)", if I understand it, > caters for the possibility that the value of the space > origin is not a multiple of page size. Am I reading the > code correctly? Is such a thing possible? The code makes > no comparable allowance for page size being other than a > power of two. _LSPCO returns a pointer to the space origin, which is the address of the first addressable byte in the space located by the given pointer. It's possible that the space origin is not a multiple of a page size. The reason for subtracting the space origin from the original pointer value is to obtain the space offset associated with the pointer. A second way of obtaining the space offset (associated with a space pointer) is to convert the pointer to an integer. So, you could rewrite NEXT_PAGE as follows: #define NEXT_PAGE(p) ( (char *)_LSPCO(p) \ + ( (int)p + (PAGESIZE-1) ) & (~(PAGESIZE-1))) ) As you observed, this assumes that PAGESIZE is a power of two. If p is a null pointer value, the expression p - _LSPCO(p) might behave differently than (int)p , but I haven't tested that. Also, if p is a pointer to Teraspace, the offset may require more than 32 bits to represent it. Therefore, it is safer to convert the pointer to a long long instead of an int. > Along the way to this followup question, I worked my way to > <http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/mi/index.htm>, > expecting that the definition of LSPCO would tell me > something about space origins, but I do not see LSPCO there. > Can you suggest any other readings? Sorry, but I couldn't find a description either. - Bob
As an Amazon Associate we earn from qualifying purchases.
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.