1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
/*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2010 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2010 IBM Corporation. All rights reserved.
* Copyright (c) 2010-2011 Los Alamos National Security, LLC.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* shmem (shared memory backing facility) framework types, convenience macros,
* etc.
*/
#ifndef OPAL_SHMEM_TYPES_H
#define OPAL_SHMEM_TYPES_H
#include "opal_config.h"
BEGIN_C_DECLS
/* ////////////////////////////////////////////////////////////////////////// */
/**
* ds_buf: pointer to opal_shmem_ds_t typedef'd struct
*/
/**
* flag indicating the state (valid/invalid) of the shmem data structure
* 0x0* - reserved for non-internal flags
*/
#define OPAL_SHMEM_DS_FLAGS_VALID 0x01
/**
* 0x1* - reserved for internal flags. that is, flags that will NOT be
* propagated via ds_copy during inter-process information sharing.
*/
/**
* masks out internal flags
*/
#define OPAL_SHMEM_DS_FLAGS_INTERNAL_MASK 0x0F
/**
* invalid id value
*/
#define OPAL_SHMEM_DS_ID_INVALID -1
/**
* macro that sets all bits in flags to 0
*/
#define OPAL_SHMEM_DS_RESET_FLAGS(ds_buf) \
do { \
(ds_buf)->flags = 0x00; \
} while (0)
/**
* sets valid bit in flags to 1
*/
#define OPAL_SHMEM_DS_SET_VALID(ds_buf) \
do { \
(ds_buf)->flags |= OPAL_SHMEM_DS_FLAGS_VALID; \
} while (0)
#define OPAL_SHMEM_DS_SET_CREATOR(ds_buf) \
do { \
(ds_buf)->flags |= OPAL_SHMEM_DS_FLAGS_CREATOR; \
} while (0)
/**
* sets valid bit in flags to 0
*/
#define OPAL_SHMEM_DS_INVALIDATE(ds_buf) \
do { \
(ds_buf)->flags &= ~OPAL_SHMEM_DS_FLAGS_VALID; \
} while (0)
/**
* evaluates to 1 if the valid bit in flags is set to 1. evaluates to 0
* otherwise.
*/
#define OPAL_SHMEM_DS_IS_VALID(ds_buf) \
( (ds_buf)->flags & OPAL_SHMEM_DS_FLAGS_VALID )
#define OPAL_SHMEM_DS_IS_CREATOR(ds_buf) \
( (ds_buf)->flags & OPAL_SHMEM_DS_FLAGS_CREATOR )
/* ////////////////////////////////////////////////////////////////////////// */
typedef uint8_t opal_shmem_ds_flag_t;
/* shared memory segment header */
struct opal_shmem_seg_hdr_t {
/* segment lock */
opal_atomic_lock_t lock;
/* pid of the segment creator */
pid_t cpid;
};
typedef struct opal_shmem_seg_hdr_t opal_shmem_seg_hdr_t;
struct opal_shmem_ds_t {
/* owner pid of the opal_shmem_ds_t */
pid_t opid;
/* state flags */
opal_shmem_ds_flag_t flags;
/* pid of the shared memory segment creator */
pid_t seg_cpid;
/* ds id */
int seg_id;
/* size of shared memory segment */
size_t seg_size;
/* path to backing store */
char seg_name[OPAL_PATH_MAX];
/* base address of shared memory segment */
unsigned char *seg_base_addr;
};
typedef struct opal_shmem_ds_t opal_shmem_ds_t;
END_C_DECLS
#endif /* OPAL_SHMEM_TYPES_H */
|