Blame src/include/mpir_status.h

Packit Service c5cf8c
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit Service c5cf8c
/*
Packit Service c5cf8c
 *  (C) 2001 by Argonne National Laboratory.
Packit Service c5cf8c
 *      See COPYRIGHT in top-level directory.
Packit Service c5cf8c
 *
Packit Service c5cf8c
 */
Packit Service c5cf8c
Packit Service c5cf8c
#ifndef MPIR_STATUS_H_INCLUDED
Packit Service c5cf8c
#define MPIR_STATUS_H_INCLUDED
Packit Service c5cf8c
Packit Service c5cf8c
/* We use bits from the "count_lo" and "count_hi_and_cancelled" fields
Packit Service c5cf8c
 * to represent the 'count' and 'cancelled' objects.  The LSB of the
Packit Service c5cf8c
 * "count_hi_and_cancelled" field represents the 'cancelled' object.
Packit Service c5cf8c
 * The 'count' object is split between the "count_lo" and
Packit Service c5cf8c
 * "count_hi_and_cancelled" fields, with the lower order bits going
Packit Service c5cf8c
 * into the "count_lo" field, and the higher order bits goin into the
Packit Service c5cf8c
 * "count_hi_and_cancelled" field.  This gives us 2N-1 bits for the
Packit Service c5cf8c
 * 'count' object, where N is the size of int.  However, the value
Packit Service c5cf8c
 * returned to the user is bounded by the definition on MPI_Count. */
Packit Service c5cf8c
/* NOTE: The below code assumes that the count value is never
Packit Service c5cf8c
 * negative.  For negative values, right-shifting can have weird
Packit Service c5cf8c
 * implementation specific consequences. */
Packit Service c5cf8c
#define MPIR_STATUS_SET_COUNT(status_, count_)                          \
Packit Service c5cf8c
    {                                                                   \
Packit Service c5cf8c
        (status_).count_lo = ((int) count_);                            \
Packit Service c5cf8c
        (status_).count_hi_and_cancelled &= 1;                          \
Packit Service c5cf8c
        (status_).count_hi_and_cancelled |= (int) (((MPIR_Ucount) count_) >> (8 * SIZEOF_INT) << 1); \
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
#define MPIR_STATUS_GET_COUNT(status_)                                  \
Packit Service c5cf8c
    ((MPI_Count) ((((MPIR_Ucount) (((unsigned int) (status_).count_hi_and_cancelled) >> 1)) << (8 * SIZEOF_INT)) + (unsigned int) (status_).count_lo))
Packit Service c5cf8c
Packit Service c5cf8c
#define MPIR_STATUS_SET_CANCEL_BIT(status_, cancelled_) \
Packit Service c5cf8c
    {                                                   \
Packit Service c5cf8c
        (status_).count_hi_and_cancelled &= ~1;         \
Packit Service c5cf8c
        (status_).count_hi_and_cancelled |= cancelled_; \
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
#define MPIR_STATUS_GET_CANCEL_BIT(status_) ((status_).count_hi_and_cancelled & 1)
Packit Service c5cf8c
Packit Service c5cf8c
/* Do not set MPI_ERROR (only set if ERR_IN_STATUS is returned */
Packit Service c5cf8c
#define MPIR_Status_set_empty(status_)                          \
Packit Service c5cf8c
    {                                                           \
Packit Service c5cf8c
        if ((status_) != MPI_STATUS_IGNORE)                     \
Packit Service c5cf8c
        {                                                       \
Packit Service c5cf8c
            (status_)->MPI_SOURCE = MPI_ANY_SOURCE;             \
Packit Service c5cf8c
            (status_)->MPI_TAG = MPI_ANY_TAG;                   \
Packit Service c5cf8c
            MPIR_STATUS_SET_COUNT(*(status_), 0);               \
Packit Service c5cf8c
            MPIR_STATUS_SET_CANCEL_BIT(*(status_), FALSE);      \
Packit Service c5cf8c
        }                                                       \
Packit Service c5cf8c
    }
Packit Service c5cf8c
/* See MPI 1.1, section 3.11, Null Processes */
Packit Service c5cf8c
/* Do not set MPI_ERROR (only set if ERR_IN_STATUS is returned */
Packit Service c5cf8c
#define MPIR_Status_set_procnull(status_)                       \
Packit Service c5cf8c
    {                                                           \
Packit Service c5cf8c
        if ((status_) != MPI_STATUS_IGNORE)                     \
Packit Service c5cf8c
        {                                                       \
Packit Service c5cf8c
            (status_)->MPI_SOURCE = MPI_PROC_NULL;              \
Packit Service c5cf8c
            (status_)->MPI_TAG = MPI_ANY_TAG;                   \
Packit Service c5cf8c
            MPIR_STATUS_SET_COUNT(*(status_), 0);               \
Packit Service c5cf8c
            MPIR_STATUS_SET_CANCEL_BIT(*(status_), FALSE);      \
Packit Service c5cf8c
        }                                                       \
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
#endif /* MPIR_STATUS_H_INCLUDED */