root/ompi/mca/io/romio321/romio/mpi-io/ioreq_c2f.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPIO_Request_c2f
  2. MPIO_Request_c2f

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *
   4  *   Copyright (C) 1997 University of Chicago. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "mpioimpl.h"
   9 
  10 #ifdef HAVE_WEAK_SYMBOLS
  11 
  12 #if defined(HAVE_PRAGMA_WEAK)
  13 #pragma weak MPIO_Request_c2f = PMPIO_Request_c2f
  14 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
  15 #pragma _HP_SECONDARY_DEF PMPIO_Request_c2f MPIO_Request_c2f
  16 #elif defined(HAVE_PRAGMA_CRI_DUP)
  17 #pragma _CRI duplicate MPIO_Request_c2f as PMPIO_Request_c2f
  18 /* end of weak pragmas */
  19 #endif
  20 
  21 /* Include mapping from MPI->PMPI */
  22 #define MPIO_BUILD_PROFILING
  23 #include "mpioprof.h"
  24 #endif
  25 #include "adio_extern.h"
  26 
  27 /*@
  28     MPIO_Request_c2f - Translates a C I/O-request handle to a 
  29                        Fortran I/O-request handle
  30 
  31 Input Parameters:
  32 . request - C I/O-request handle (handle)
  33 
  34 Return Value:
  35   Fortran I/O-request handle (integer)
  36 @*/
  37 #ifdef HAVE_MPI_GREQUEST
  38 MPI_Fint MPIO_Request_c2f(MPIO_Request request)
  39 {
  40     return ((MPI_Fint)request);
  41 }
  42 #else
  43 
  44 MPI_Fint MPIO_Request_c2f(MPIO_Request request)
  45 {
  46 #ifndef INT_LT_POINTER
  47     return (MPI_Fint) request;
  48 #else
  49     int i;
  50     MPID_THREADPRIV_DECL;
  51 
  52     /* We can make this test outside of the GLOBAL mutex because it does
  53        not access any shared data */
  54     if ((request <= (MPIO_Request) 0) || (request->cookie != ADIOI_REQ_COOKIE))
  55     {
  56             return (MPI_Fint) 0;
  57     }
  58 
  59     ROMIO_THREAD_CS_ENTER();
  60     if (!ADIOI_Reqtable) {
  61         ADIOI_Reqtable_max = 1024;
  62         ADIOI_Reqtable = (MPIO_Request *)
  63             ADIOI_Malloc(ADIOI_Reqtable_max*sizeof(MPIO_Request)); 
  64         ADIOI_Reqtable_ptr = 0;  /* 0 can't be used though, because 
  65                                   MPIO_REQUEST_NULL=0 */
  66         for (i=0; i<ADIOI_Reqtable_max; i++) ADIOI_Reqtable[i] = MPIO_REQUEST_NULL;
  67     }
  68     if (ADIOI_Reqtable_ptr == ADIOI_Reqtable_max-1) {
  69         ADIOI_Reqtable = (MPIO_Request *) ADIOI_Realloc(ADIOI_Reqtable, 
  70                            (ADIOI_Reqtable_max+1024)*sizeof(MPIO_Request));
  71         for (i=ADIOI_Reqtable_max; i<ADIOI_Reqtable_max+1024; i++) 
  72             ADIOI_Reqtable[i] = MPIO_REQUEST_NULL;
  73         ADIOI_Reqtable_max += 1024;
  74     }
  75     ADIOI_Reqtable_ptr++;
  76     ADIOI_Reqtable[ADIOI_Reqtable_ptr] = request;
  77 
  78     ROMIO_THREAD_CS_EXIT();
  79     return (MPI_Fint) ADIOI_Reqtable_ptr;
  80 #endif
  81 }
  82 #endif

/* [<][>][^][v][top][bottom][index][help] */