src/os/unix/ngx_sunpro_atomic_sparc64.h - nginx-1.7.10

Functions defined

Macros defined

Source code


  1. /*
  2. * Copyright (C) Igor Sysoev
  3. * Copyright (C) Nginx, Inc.
  4. */


  5. #if (NGX_PTR_SIZE == 4)
  6. #define NGX_CASA  ngx_casa
  7. #else
  8. #define NGX_CASA  ngx_casxa
  9. #endif


  10. ngx_atomic_uint_t
  11. ngx_casa(ngx_atomic_uint_t set, ngx_atomic_uint_t old, ngx_atomic_t *lock);

  12. ngx_atomic_uint_t
  13. ngx_casxa(ngx_atomic_uint_t set, ngx_atomic_uint_t old, ngx_atomic_t *lock);

  14. /* the code in src/os/unix/ngx_sunpro_sparc64.il */


  15. static ngx_inline ngx_atomic_uint_t
  16. ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
  17.     ngx_atomic_uint_t set)
  18. {
  19.     set = NGX_CASA(set, old, lock);

  20.     return (set == old);
  21. }


  22. static ngx_inline ngx_atomic_int_t
  23. ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add)
  24. {
  25.     ngx_atomic_uint_t  old, res;

  26.     old = *value;

  27.     for ( ;; ) {

  28.         res = old + add;

  29.         res = NGX_CASA(res, old, value);

  30.         if (res == old) {
  31.             return res;
  32.         }

  33.         old = res;
  34.     }
  35. }


  36. #define ngx_memory_barrier()                                                  \
  37.         __asm (".volatile");                                                  \
  38.         __asm ("membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad");   \
  39.         __asm (".nonvolatile")

  40. #define ngx_cpu_pause()