/*
 * Copyright (c) 2014-2015, Siemens AG. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

// This file is used as a template, it is not a normal header file!
// Do not include it as a header! It is used for generating methods
// for all atomic types.

#define EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_PARAMETER_POSTFIX, \
  EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, \
  EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, \
  EMBB_ATOMIC_PARAMETER_TYPE_SIZE \
  ) \
  EMBB_CAT2(EMBB_ATOMIC_INTERNAL_DEFINE_, EMBB_ATOMIC_PARAMETER_POSTFIX)\
  (EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, \
  EMBB_ATOMIC_PARAMETER_TYPE_SIZE)

#ifdef EMBB_CHAR_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC(EMBB_ATOMIC_METHOD_TO_GENERATE, \
  char, char, EMBB_CHAR_TYPE_SIZE)
#endif
#ifdef EMBB_SHORT_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_METHOD_TO_GENERATE, \
  short, short, EMBB_SHORT_TYPE_SIZE)
#endif
#ifdef EMBB_UNSIGNED_SHORT_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_METHOD_TO_GENERATE, \
  unsigned short, unsigned_short, EMBB_UNSIGNED_SHORT_TYPE_SIZE)
#endif
#ifdef EMBB_INT_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_METHOD_TO_GENERATE, \
  int, int, EMBB_INT_TYPE_SIZE)
#endif
#ifdef EMBB_UNSIGNED_INT_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_METHOD_TO_GENERATE, \
  unsigned int, unsigned_int, EMBB_UNSIGNED_INT_TYPE_SIZE)
#endif
#ifdef EMBB_LONG_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_METHOD_TO_GENERATE, \
  long, long, EMBB_LONG_TYPE_SIZE)
#endif
#ifdef EMBB_UNSIGNED_LONG_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_METHOD_TO_GENERATE, \
  unsigned long, unsigned_long, EMBB_UNSIGNED_LONG_TYPE_SIZE)
#endif
#ifdef EMBB_LONG_LONG_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_METHOD_TO_GENERATE, \
  long long, long_long, EMBB_LONG_LONG_TYPE_SIZE)
#endif
#ifdef EMBB_UNSIGNED_LONG_LONG_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_METHOD_TO_GENERATE, \
  unsigned long long, unsigned_long_long, EMBB_UNSIGNED_LONG_LONG_TYPE_SIZE)
#endif
#ifdef EMBB_INTPTR_T_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_METHOD_TO_GENERATE, \
  intptr_t, intptr_t, EMBB_INTPTR_T_TYPE_SIZE)
#endif
#ifdef EMBB_UINTPTR_T_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_METHOD_TO_GENERATE, \
  uintptr_t, uintptr_t, EMBB_UINTPTR_T_TYPE_SIZE)
#endif
#ifdef EMBB_SIZE_T_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_METHOD_TO_GENERATE, \
  size_t, size_t, EMBB_SIZE_T_TYPE_SIZE)
#endif
#ifdef EMBB_PTRDIFF_T_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_METHOD_TO_GENERATE, \
  ptrdiff_t, ptrdiff_t, EMBB_PTRDIFF_T_TYPE_SIZE)
#endif
#ifdef EMBB_UINTMAX_T_TYPE_IS_ATOMIC
EMBB_GENERATE_ATOMIC_FUNC( EMBB_ATOMIC_METHOD_TO_GENERATE, \
  uintmax_t, uintmax_t, EMBB_UINTMAX_T_TYPE_SIZE)
#endif
