× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



At 13:07 2003-09-03 -0500, "Bob Donovan" <rjd@xxxxxxxxxx> wrote:
> Page alignment can be important to performance.
>
> If your program is created with options STGMDL(*SNGLVL) and DTAMDL(*P128)

This, the default, is my situation.

> [these are the defaults and they instruct the compiler to build a program
> that allocates its working storage from single-level storage and uses
> 16-byte pointers], you must calculate an increment and add it to the
> pointer.  For example, to round a pointer up to the next page boundary, you
> can try something like this:
>
> #include <mih/lspco.h>  /* _LSPCO -- load space origin  */
>
> #define NEXT_PAGE(p) ( (char *)_LSPCO(p) \
>              + (((p - (char*)_LSPCO(p)) + (PAGESIZE-1)) &
> (~(PAGESIZE-1))) )
>

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.

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?

> The page size is 4096 on current AS/400 and iSeries models, but it can also
> be materialized with the MATRMD MI instruction.

Thank you.  Since I guess I care after all, those would have
been my next two questions!

>
> If your program is created with options TERASPACE(*YES) STGMDL(*TERASPACE)
> DTAMDL(*LLP64) [these instruct the compiler to build a program that
> allocates its working storage from Teraspace and uses 8-byte pointers], you
> can effectively treat the pointer like an integer, although pointers are the
> same size as "long long" integers.
>
> To round an 8-byte pointer up to the next page boundary, you can try
> something like this:
>
> #define NEXT_PAGE(p) \
>          (char*)( (long long)( (char*)p + (PAGESIZE-1) ) & (~(PAGESIZE-1)) )
>
>
>
> "Terrence Enger" <tenger@xxxxxxxxxxxxxxxx> wrote in
> message news:3.0.3.32.20030901191529.00ce4c50@xxxxxxxxxxxxxx
> > If so, is there a portable type which defines an integer at least large
> > enough to hold an address?  Can I cast an integer expression to a pointer,
> > or do I have to calculate an increment and add it to the pointer?
>



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.