Commit fda1c8ce authored by Pavan Balaji's avatar Pavan Balaji
Browse files

Fix bit manipulation in the MPI_Status object.



In C, left-shift has well-defined behavior, but right-shift does not
for signed integers.  The implementation is free to pad the shifted
bits with 0's or 1's.  In this patch, we type-cast the values to
unsigned integers to make the behavior well-defined.
Signed-off-by: Rob Latham's avatarRob Latham <robl@mcs.anl.gov>
parent 11e1e075
......@@ -5755,6 +5755,7 @@ AS_IF([test "$MPI_SIZEOF_AINT" -gt "$MPI_SIZEOF_OFFSET"],
AC_SUBST([MPI_COUNT])
AC_SUBST([COUNT_KIND])
AC_DEFINE_UNQUOTED([MPIR_COUNT_MAX],[$MPIR_COUNT_MAX],[limits.h _MAX constant for MPI_Count])
AC_DEFINE_UNQUOTED(MPIR_Ucount,unsigned $MPI_COUNT,[MPIR_Ucount is an unsigned MPI_Count-sized integer])
AS_CASE([$MPI_SIZEOF_COUNT],
[4], [len_mpi_count=04],
......
......@@ -2318,11 +2318,11 @@ void MPIR_Err_print_stack(FILE *, int);
{ \
(status_).count_lo = ((int) count_); \
(status_).count_hi_and_cancelled &= 1; \
(status_).count_hi_and_cancelled |= (int) ((MPI_Count) count_ >> MPIR_BITS_IN_INT << 1); \
(status_).count_hi_and_cancelled |= (int) ((MPIR_Ucount) count_ >> MPIR_BITS_IN_INT << 1); \
}
#define MPIR_STATUS_GET_COUNT(status_) \
((MPI_Count) ((((MPI_Count) (status_).count_hi_and_cancelled) >> 1 << MPIR_BITS_IN_INT) + (status_).count_lo))
((MPI_Count) ((((MPIR_Ucount) (((unsigned int) (status_).count_hi_and_cancelled) >> 1)) << MPIR_BITS_IN_INT) + (unsigned int) (status_).count_lo))
#define MPIR_STATUS_SET_CANCEL_BIT(status_, cancelled_) \
{ \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment