×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




Page alignment can be important to performance.

If your program is created with options STGMDL(*SNGLVL) and DTAMDL(*P128)
[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))) )

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

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-2026 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.