ywkaras commented on a change in pull request #7382: URL: https://github.com/apache/trafficserver/pull/7382#discussion_r540484846
########## File path: include/tscore/ver_ptr.h ########## @@ -0,0 +1,286 @@ +/** @file + + Provides a "versioned pointer" data type. + + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#pragma once + +#include <cstdint> +#include <cstring> +#include <atomic> + +namespace ts +{ +namespace detail +{ + namespace versioned_ptr + { + // This is true if pointers are 64 bits but the two most significant bytes are not used, except for the + // most significant bit. + // + bool const Ptr64bits15unused = +#if defined(__x86_64__) || defined(__ia64__) || defined(__powerpc64__) || defined(__aarch64__) || defined(__mips64) + true +#else + false +#endif + ; + +#if TS_HAS_128BIT_CAS + + bool const CAE128 = true; + + using Bits128_type = __int128_t; + + static_assert(sizeof(Bits128_type) == 16); + + // This static assert is commented out because it fails. It seems that our Automake voodoo sets + // TS_HAS_128BIT_CAS to 1 even if there is no lock-free 128-bit CAS available. See + // https://godbolt.org/z/ncYsv9 . Looking at the generated assembly code, the 128-bit CAS operations + // cause calls into the run-time library, which may mean that are not actually lock-free. + // See also + // + // static_assert(std::atomic<Bits128_type>::is_always_lock_free); Review comment: I have to rewrite this comment. The best way to tell if TS is using HW 128-bit CAS is to run objdump on src/tscore/.libs/ink_queue.o . I've seen the instruction generated, even though this assert fails. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
