![]() |
|
|||
0001 /** 0002 * @brief Enduro/X Atomic API 0003 * 0004 * @file exatomic.h 0005 */ 0006 /* ----------------------------------------------------------------------------- 0007 * Enduro/X Middleware Platform for Distributed Transaction Processing 0008 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0009 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0010 * This software is released under one of the following licenses: 0011 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0012 * See LICENSE file for full text. 0013 * ----------------------------------------------------------------------------- 0014 * AGPL license: 0015 * 0016 * This program is free software; you can redistribute it and/or modify it under 0017 * the terms of the GNU Affero General Public License, version 3 as published 0018 * by the Free Software Foundation; 0019 * 0020 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0022 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0023 * for more details. 0024 * 0025 * You should have received a copy of the GNU Affero General Public License along 0026 * with this program; if not, write to the Free Software Foundation, Inc., 0027 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0028 * 0029 * ----------------------------------------------------------------------------- 0030 * A commercial use license is available from Mavimax, Ltd 0031 * contact@mavimax.com 0032 * ----------------------------------------------------------------------------- 0033 */ 0034 #ifndef EXATOMIC_H_ 0035 #define EXATOMIC_H_ 0036 0037 #if defined(__cplusplus) 0038 extern "C" { 0039 #endif 0040 0041 /*---------------------------Includes-----------------------------------*/ 0042 #include <ndrx_config.h> 0043 0044 #ifdef EX_HAVE_STDATOMIC 0045 #include <stdatomic.h> 0046 #endif 0047 0048 /*---------------------------Externs------------------------------------*/ 0049 /*---------------------------Macros-------------------------------------*/ 0050 0051 #ifdef EX_HAVE_STDATOMIC 0052 #define ndrx_atomic _Atomic volatile 0053 #else 0054 #define ndrx_atomic volatile 0055 #endif 0056 /** 0057 * Increment value atomically (where platform allows this) 0058 * @param OBJ value to increment (pointer to) 0059 * @param ARG increment by 0060 */ 0061 #if defined(EX_HAVE_STDATOMIC) 0062 0063 #define NDRX_ATOMIC_STORE(OBJ, ARG) atomic_store((OBJ), (ARG)) 0064 #define NDRX_ATOMIC_ADD(OBJ, ARG) atomic_fetch_add((OBJ), (ARG)) 0065 #define NDRX_ATOMIC_LOAD(OBJ) atomic_load((OBJ)) 0066 0067 #elif defined(EX_HAVE_SYNCFETCHADD) 0068 0069 #define NDRX_ATOMIC_STORE(OBJ, ARG) __sync_lock_test_and_set((OBJ), (ARG)) 0070 #define NDRX_ATOMIC_ADD(OBJ, ARG) __sync_fetch_and_add((OBJ), (ARG)) 0071 #define NDRX_ATOMIC_LOAD(OBJ) __sync_fetch_and_add((OBJ), 0) 0072 0073 #else 0074 0075 #define NDRX_ATOMIC_STORE(OBJ, ARG) *(OBJ) = (ARG) 0076 #define NDRX_ATOMIC_ADD(OBJ, ARG) *(OBJ) = *(OBJ) + (ARG) 0077 #define NDRX_ATOMIC_LOAD(OBJ) *(OBJ) 0078 0079 #endif 0080 0081 /*---------------------------Enums--------------------------------------*/ 0082 /*---------------------------Typedefs-----------------------------------*/ 0083 /*---------------------------Globals------------------------------------*/ 0084 /*---------------------------Statics------------------------------------*/ 0085 /*---------------------------Prototypes---------------------------------*/ 0086 0087 #if defined(__cplusplus) 0088 } 0089 #endif 0090 0091 #endif 0092 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |