root/ompi/mca/mtl/portals4/mtl_portals4_message.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. ompi_mtl_portals4_message_alloc
  2. ompi_mtl_portals4_message_free

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2012      Sandia National Laboratories.  All rights reserved.
   4  * Copyright (c) 2015      Los Alamos National Security, LLC. All rights
   5  *                         reserved.
   6  * $COPYRIGHT$
   7  *
   8  * Additional copyrights may follow
   9  *
  10  * $HEADER$
  11  */
  12 
  13 #ifndef MTL_PORTALS4_MESSAGE_H
  14 #define MTL_PORTALS4_MESSAGE_H
  15 
  16 struct ompi_mtl_portals4_message_t {
  17     opal_free_list_item_t super;
  18     ptl_event_t ev;
  19     void *buffer;
  20 };
  21 typedef struct ompi_mtl_portals4_message_t ompi_mtl_portals4_message_t;
  22 OBJ_CLASS_DECLARATION(ompi_mtl_portals4_message_t);
  23 
  24 
  25 static inline ompi_mtl_portals4_message_t*
  26 ompi_mtl_portals4_message_alloc(const ptl_event_t *ev)
  27 {
  28     opal_free_list_item_t *tmp;
  29     ompi_mtl_portals4_message_t* message;
  30 
  31     tmp = opal_free_list_get (&ompi_mtl_portals4.fl_message);
  32     if (NULL == tmp) return NULL;
  33 
  34     message = (ompi_mtl_portals4_message_t*) tmp;
  35 
  36     message->ev = *ev;
  37 
  38     if (0 == ev->mlength) {
  39         message->buffer = NULL;
  40     } else {
  41         /* once we've finished processing the event, an AUTO_FREE
  42            event might be next, rendering the data in ev.start
  43            invalid.  Copy it away... */
  44         memcpy(message->buffer, ev->start, ev->mlength);
  45         message->ev.start = message->buffer;
  46     }
  47 
  48     return message;
  49 }
  50 
  51 static inline void
  52 ompi_mtl_portals4_message_free(ompi_mtl_portals4_message_t *message)
  53 {
  54     opal_free_list_return (&ompi_mtl_portals4.fl_message,
  55                            &message->super);
  56 }
  57 
  58 #endif

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