[Figure 1]: Program example to get system-specific page size.

/*
 * Abstract:
 *	This is a program to get the page size of the current system at
 *	run-time and display it to the user.
 *
 * Inputs:
 *	None
 *
 * Outputs:
 *	Page size is written to SYS$OUTPUT.
 *
 * Return Value:
 *	Status of $GETSYI system service
 *
 * Special Notes:
 *	The SYI$_PAGE_SIZE is not supported on OpenVMS VAX versions
 *	prior version V5.4-2.
 *	
 */
#include <stdio.h>
#include <ssdef.h>
#include <starlet.h>
#include <syidef.h>

    /* If VAX C V3.2 or earlier, then define the SYI$_PAGE_SIZE
     * item code.
     */
#ifndef	SYI$_PAGE_SIZE
#   define	SYI$_PAGE_SIZE	4452
#endif

main( )
{
    long page_size;
    char node_name[64];
    register long status;

    struct
    {
	unsigned short	buflen;	
	unsigned short	item_code;
	char		*bufadr;
	unsigned short	*retlen;
    } itmlst[3];

    itmlst[0].buflen = sizeof( page_size );
    itmlst[0].item_code = SYI$_PAGE_SIZE;
    itmlst[0].bufadr = (char *)&page_size;
    itmlst[0].retlen = NULL;
    itmlst[1].buflen = sizeof( node_name );
    itmlst[1].item_code = SYI$_NODENAME;
    itmlst[1].bufadr = node_name;
    itmlst[1].retlen = NULL;
    itmlst[2].buflen = 0;
    itmlst[2].item_code = 0;

    status = sys$getsyi( 0, NULL, NULL, itmlst, NULL, NULL, 0 );
    if ( !(status & 1) )
	return ( status );

    fprintf( stdout, "%s's page size: %d\n", node_name, page_size );

    return ( SS$_NORMAL );
}


[Figure 3]: Program example showing page size dependence when 
            setting protection.

/*
 * Abstract:
 *	This program demonstrates how an existing VAX application
 *	may change the page protection on a piece of memory, but when
 *	recompiled and linked on an Alpha AXP system, will not run without
 *	modification.
 *
 * Inputs:
 *	None
 *
 * Outputs:
 *	Writes the address range returned from the $SETPRT system service
 *	to SYS$OUTPUT.
 *
 * Return Value:
 *	Error status from $SETPRT or SS$_NORMAL
 *
 */
#include <stdio.h>
#include <prtdef.h>
#include <psldef.h>
#include <ssdef.h>
#include <starlet.h>
#include <syidef.h>

main( )
{
    static char data[10000];

    void *inadr[2];
    void *retadr[2];

    register long int status;

	/* initialize to input address
	 */
    inadr[0] = (void *)&data[0x310];
    inadr[1] = (void *)&data[0x620];

    status = sys$setprt( inadr, retadr, PSL$C_USER, PRT$C_NA, NULL );
    if ( !(status & 1) )
	return ( status );

    printf( "inadr[0:1]  = %X,%X\n", inadr[0], inadr[1] );
    printf( "retadr[0:1] = %X,%X\n", retadr[0], retadr[1] );

	/* This reference will cause an access violation on Alpha AXP
	 * systems, but will work correctly on a VAX system.
	 */
    data[4000] = 0xFF;

    return ( SS$_NORMAL );
}
