### 例 5-3　拡張された仮想アドレス空間へのセクションのマッピング

         #include  <ssdef.h>
         #include  <string.h>
         #include  <stdlib.h>
         #include  <stdio.h>
         #include  <stsdef.h>
         #include  <descrip.h>
         #include  <dvidef.h>
         #include  <rms.h>
         #include  <secdef.h>

         struct FAB fab;

         char _align(page) buffer[1024];
         char *filename = "maptest.dat";

         main( argc, argv )
         int argc;
         char *argv[];
         {

              int    status = 0;
              long   flags = SEC$M_EXPREG;
              long   inadr[2];
              long   retadr[2];
              int    fileChannel;

         /********  create disk file to be mapped *************/

              fab = cc$rms_fab;
              fab.fab$l_fna = filename;
              fab.fab$b_fns = strlen( filename );
              fab.fab$l_fop = FAB$M_CIF | FAB$M_UFO;  /* must be UFO */

              status = sys$create( &fab );

              if( status & STS$M_SUCCESS )
                 printf("%s opened\n",filename);
              else
              {
                 exit( status );
              }
              fileChannel = fab.fab$l_stv;

         /**********  create and map the section  ****************/

              inadr[0] = &buffer[0];
              inadr[1] = &buffer[0];

              status = SYS$CRMPSC( inadr, /* inadr=address target for map */
                                 &retadr, /* retadr= what was actually mapped */
                                       0, /* acmode  */
                                   flags, /* flags, with SEC$M_EXPREG bit set */
                                       0, /* gsdnam, only for global sections */
                                       0, /* ident, only for global sections */
                                       0, /* relpag, only for global sections */
                             fileChannel, /* returned by SYS$CREATE */
                                       0, /* pagcnt = size of sect. file used */
                                       0, /* vbn = first block of file used */
                                       0, /* prot = default okay */
                                       0); /* page fault cluster size */

              if( status & STS$M_SUCCESS )
              {
                   printf("section mapped\n");
                   printf("retadr[0]=%u,retadr[1]=%u\n",retadr[0],retadr[1]);
              }
              else
              {
                   printf("map failed\n");
                   exit( status );
              }
         }

[ 本文に戻る ]