root/maint/gnulib/lib/simple-atomic.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /* Simple atomic operations for multithreading.
   2    Copyright (C) 2021 Free Software Foundation, Inc.
   3 
   4    This file is free software: you can redistribute it and/or modify
   5    it under the terms of the GNU Lesser General Public License as
   6    published by the Free Software Foundation; either version 2.1 of the
   7    License, or (at your option) any later version.
   8 
   9    This file is distributed in the hope that it will be useful,
  10    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12    GNU Lesser General Public License for more details.
  13 
  14    You should have received a copy of the GNU Lesser General Public License
  15    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
  16 
  17 /* Written by Bruno Haible <bruno@clisp.org>, 2021.  */
  18 
  19 #ifndef _SIMPLE_ATOMIC_H
  20 #define _SIMPLE_ATOMIC_H
  21 
  22 #include <stdint.h>
  23 
  24 #ifdef __cplusplus
  25 extern "C" {
  26 #endif
  27 
  28 /* Guarantees that memory stores that are in code before this call
  29    are finished before this call, and that memory loads that are in code
  30    after this call are started after this call.  */
  31 extern void memory_barrier (void);
  32 
  33 /* Stores NEWVAL in *VP if the old value *VP is == CMP.
  34    Returns the old value.  */
  35 extern unsigned int atomic_compare_and_swap (unsigned int volatile *vp,
  36                                              unsigned int cmp,
  37                                              unsigned int newval);
  38 
  39 /* Stores NEWVAL in *VP if the old value *VP is == CMP.
  40    Returns the old value.  */
  41 extern uintptr_t atomic_compare_and_swap_ptr (uintptr_t volatile *vp,
  42                                               uintptr_t cmp,
  43                                               uintptr_t newval);
  44 
  45 #ifdef __cplusplus
  46 }
  47 #endif
  48 
  49 #endif /* _SIMPLE_ATOMIC_H */

/* [previous][next][first][last][top][bottom][index][help] */