atomic_native.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (C) 2006 iptelorg GmbH
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. /**
  17. * @file
  18. * @brief Native (asm) atomic operations and memory barriers
  19. *
  20. * Native (assembler) atomic operations and memory barriers.
  21. * \warning atomic ops do not include memory barriers, see atomic_ops.h for
  22. * more info. Expects atomic_t to be defined (#include "atomic_common.h")
  23. *
  24. * Config defines:
  25. * - CC_GCC_LIKE_ASM - the compiler support gcc style inline asm
  26. * - NOSMP - the code will be a little faster, but not SMP safe
  27. * - __CPU_i386, __CPU_x86_64, X86_OOSTORE - see atomic_x86.h
  28. * - __CPU_mips, __CPU_mips2, __CPU_mips64, MIPS_HAS_LLSC - see atomic_mip2.h
  29. * - __CPU_ppc, __CPU_ppc64 - see atomic_ppc.h
  30. * - __CPU_sparc - see atomic_sparc.h
  31. * - __CPU_sparc64, SPARC64_MODE - see atomic_sparc64.h
  32. * - __CPU_arm, __CPU_arm6 - see atomic_arm.h
  33. * - __CPU_alpha - see atomic_alpha.h
  34. * @ingroup atomic
  35. */
  36. /*
  37. * History:
  38. * --------
  39. * 2006-03-08 created by andrei
  40. * 2007-05-13 split from atomic_ops.h (andrei)
  41. */
  42. #ifndef __atomic_native
  43. #define __atomic_native
  44. #ifdef CC_GCC_LIKE_ASM
  45. #if defined __CPU_i386 || defined __CPU_x86_64
  46. #include "atomic_x86.h"
  47. #elif defined __CPU_mips2 || defined __CPU_mips64 || \
  48. ( defined __CPU_mips && defined MIPS_HAS_LLSC )
  49. #include "atomic_mips2.h"
  50. #elif defined __CPU_ppc || defined __CPU_ppc64
  51. #include "atomic_ppc.h"
  52. #elif defined __CPU_sparc64
  53. #include "atomic_sparc64.h"
  54. #elif defined __CPU_sparc
  55. #include "atomic_sparc.h"
  56. #elif defined __CPU_arm || defined __CPU_arm6
  57. #include "atomic_arm.h"
  58. #elif defined __CPU_alpha
  59. #include "atomic_alpha.h"
  60. #endif /* __CPU_xxx => no known cpu */
  61. #endif /* CC_GCC_LIKE_ASM */
  62. #endif