1#ifndef ROUTING_KIT_EMULATE_GCC_BUILTIN_H
2#define ROUTING_KIT_EMULATE_GCC_BUILTIN_H
3#ifdef ROUTING_KIT_NO_GCC_EXTENSIONS
8#define __builtin_expect(x, y) (x)
12 unsigned emulated_builtin_popcountll(
unsigned long long x){
14 for(
unsigned long long i=1; i!=0; i<<=1)
21 unsigned emulated_builtin_popcount(
unsigned x){
22 return emulated_builtin_popcountll(x);
26 unsigned emulated_builtin_ffsll(
unsigned long long x){
28 for(
unsigned long long i=1; i!=0; i<<=1, ++n)
35 bool emulated_sync_bool_compare_and_swap(T*var, T comp_value, T new_value){
37 std::lock_guard<std::mutex> lock(m);
39 std::atomic_thread_fence(std::memory_order_seq_cst);
41 if(*var == comp_value){
44 std::atomic_thread_fence(std::memory_order_seq_cst);
53#define __builtin_popcount(x) ::RoutingKit::detail::emulated_builtin_popcount(x)
55#define __builtin_popcountll(x) ::RoutingKit::detail::emulated_builtin_popcountll(x)
57#define __builtin_ffsll(x) ::RoutingKit::detail::emulated_builtin_ffsll(x)
59#define __sync_bool_compare_and_swap(x, y, z) ::RoutingKit::detail::emulated_sync_bool_compare_and_swap(x, y, z)