Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8255040

Replace __sync_add_and_fetch with __atomic_add_fetch to avoid build errors with clang

XMLWordPrintable

    • b22

      Build errors with clang were observed due to the use of __sync_add_and_fetch, which is legacy and will be deprecated in the future.
      It can be reproduced by building macos-x86-zero or linux-x86-zero with clang.
      ------------------------------------------------------------------
      /jdk/src/hotspot/os_cpu/bsd_zero/atomic_bsd_zero.hpp:199:37: error: cannot initialize a parameter of type 'char *' with an lvalue of type 'unsigned long'
        return __sync_add_and_fetch(dest, add_value);
                                          ^~~~~~~~~
      /jdk/src/hotspot/os_cpu/bsd_zero/atomic_bsd_zero.hpp:170:12: note: in instantiation of function template specialization 'Atomic::PlatformAdd<8>::add_and_fetch<char *, unsigned long>' requested here
          return add_and_fetch(dest, add_value, order) - add_value;
                 ^
      ./src/hotspot/share/runtime/atomic.hpp:706:38: note: in instantiation of function template specialization 'Atomic::PlatformAdd<8>::fetch_and_add<char *, unsigned long>' requested here
          return PlatformAdd<sizeof(P*)>().fetch_and_add(dest, scale_addend(addend), order);
                                           ^
         ... (rest of output omitted)
      ------------------------------------------------------------------

            jiefu Jie Fu
            jiefu Jie Fu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: