root/ompi/mca/osc/pt2pt/osc_pt2pt_pending_frag.h

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

DEFINITIONS

This source file includes following definitions.
  1. ompi_osc_pt2pt_pending_frag_create
  2. ompi_osc_pt2pt_pending_frag_destroy

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2013      Sandia National Laboratories.  All rights reserved.
   4  * Copyright (c) 2014      Los Alamos National Security, LLC. All rights
   5  *                         reserved.
   6  * $COPYRIGHT$
   7  *
   8  * Additional copyrights may follow
   9  *
  10  * $HEADER$
  11  *
  12  * Pending frags are fragments that have been received on the target,
  13  * but can not yet be processed (because ordering is turned on).
  14  * Because receive memory descriptors are precious resources, rather
  15  * than keeping a descriptor until the right sequence number, we
  16  * instead malloc a buffer (as part of the pending frag) and copy the
  17  * message.
  18  */
  19 
  20 #ifndef OSC_PT2PT_PENDING_FRAG_H
  21 #define OSC_PT2PT_PENDING_FRAG_H
  22 
  23 /** Incoming fragment that has to be queued */
  24 struct ompi_osc_pt2pt_pending_frag_t {
  25     opal_list_item_t super;
  26 
  27     /* This is a pointer to the top of the fragment (which is always
  28        the header).  Save as a header to make the casting a bit less
  29        onerous during sequence number lookups. */
  30     ompi_osc_pt2pt_frag_header_t *header;
  31 };
  32 typedef struct ompi_osc_pt2pt_pending_frag_t ompi_osc_pt2pt_pending_frag_t;
  33 OBJ_CLASS_DECLARATION(ompi_osc_pt2pt_pending_frag_t);
  34 
  35 /*
  36  * Note: module lock must be held during this operation
  37  */
  38 static inline ompi_osc_pt2pt_pending_frag_t*
  39 ompi_osc_pt2pt_pending_frag_create(ompi_osc_pt2pt_module_t *module,
  40                                   void *ptr,
  41                                   size_t size)
  42 {
  43     size_t total_size = sizeof(ompi_osc_pt2pt_pending_frag_t) + size;
  44     ompi_osc_pt2pt_pending_frag_t *ret =
  45         (ompi_osc_pt2pt_pending_frag_t*) malloc(total_size);
  46     if (NULL == ret) return NULL;
  47 
  48     OBJ_CONSTRUCT(&ret, ompi_osc_pt2pt_pending_frag_t);
  49     memcpy(ret->header, ptr, size);
  50 
  51     return ret;
  52 }
  53 
  54 
  55 /*
  56  * Note: module lock must be held for this operation
  57  */
  58 static inline int
  59 ompi_osc_pt2pt_pending_frag_destroy(ompi_osc_pt2pt_module_t *module,
  60                                    ompi_osc_pt2pt_pending_frag_t* frag)
  61 {
  62     OBJ_DESTRUCT(&frag);
  63     free(frag);
  64 
  65     return OMPI_SUCCESS;
  66 }
  67 
  68 #endif

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