root/oshmem/mca/atomic/basic/atomic_basic_cswap.c

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

DEFINITIONS

This source file includes following definitions.
  1. mca_atomic_basic_cswap

   1 /*
   2  * Copyright (c) 2013      Mellanox Technologies, Inc.
   3  *                         All rights reserved.
   4  * $COPYRIGHT$
   5  *
   6  * Additional copyrights may follow
   7  *
   8  * $HEADER$
   9  */
  10 
  11 #include "oshmem_config.h"
  12 #include <stdio.h>
  13 #include <stdlib.h>
  14 
  15 #include "oshmem/constants.h"
  16 #include "oshmem/mca/spml/spml.h"
  17 #include "oshmem/mca/atomic/atomic.h"
  18 #include "oshmem/mca/atomic/base/base.h"
  19 #include "atomic_basic.h"
  20 
  21 int mca_atomic_basic_cswap(shmem_ctx_t ctx,
  22                            void *target,
  23                            uint64_t *prev,
  24                            uint64_t cond,
  25                            uint64_t value,
  26                            size_t nlong,
  27                            int pe)
  28 {
  29     int rc = OSHMEM_SUCCESS;
  30 
  31     if (!prev) {
  32         rc = OSHMEM_ERROR;
  33     }
  34 
  35     if (rc == OSHMEM_SUCCESS) {
  36         atomic_basic_lock(ctx, pe);
  37 
  38         rc = MCA_SPML_CALL(get(ctx, target, nlong, prev, pe));
  39 
  40         if ((rc == OSHMEM_SUCCESS) && (!cond || !memcmp(prev, &cond, nlong))) {
  41             rc = MCA_SPML_CALL(put(ctx, target, nlong, (void*)&value, pe));
  42             shmem_quiet();
  43         }
  44 
  45         atomic_basic_unlock(ctx, pe);
  46     }
  47 
  48     return rc;
  49 }

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