mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 07:00:53 +00:00
build: fallback to __sync_synchronize()
If we're running on a GCC older than 4.9, then we won't have the stdatomic.h available. We can just use a full barrier instead using __sync_synchronize() to get the same effect, albeit slower.
This commit is contained in:
@ -181,7 +181,7 @@ foreach link_arg: test_link_args
|
|||||||
endforeach
|
endforeach
|
||||||
add_project_link_arguments(global_link_args, language: 'c')
|
add_project_link_arguments(global_link_args, language: 'c')
|
||||||
|
|
||||||
if not cc.links('''
|
if cc.links('''
|
||||||
#include <stdatomic.h>
|
#include <stdatomic.h>
|
||||||
int main(void) {
|
int main(void) {
|
||||||
atomic_thread_fence(memory_order_acquire);
|
atomic_thread_fence(memory_order_acquire);
|
||||||
@ -189,7 +189,7 @@ int main(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
error('Sysprof requires a C compiler with stdatomic support such as GCC 4.9 or newer')
|
config_h.set10('HAVE_STDATOMIC_H', 1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
subdir('src')
|
subdir('src')
|
||||||
|
|||||||
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdatomic.h>
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|||||||
@ -42,7 +42,9 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <gio/gunixfdlist.h>
|
#include <gio/gunixfdlist.h>
|
||||||
#include <stdatomic.h>
|
#ifdef HAVE_STDATOMIC_H
|
||||||
|
# include <stdatomic.h>
|
||||||
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
@ -219,7 +221,11 @@ sysprof_perf_counter_flush (SysprofPerfCounter *self,
|
|||||||
tail = info->tail;
|
tail = info->tail;
|
||||||
head = info->map->data_head;
|
head = info->map->data_head;
|
||||||
|
|
||||||
|
#ifdef HAVE_STDATOMIC_H
|
||||||
atomic_thread_fence (memory_order_acquire);
|
atomic_thread_fence (memory_order_acquire);
|
||||||
|
#elif G_GNUC_CHECK_VERSION(3, 0)
|
||||||
|
__sync_synchronize ();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (head < tail)
|
if (head < tail)
|
||||||
tail = head;
|
tail = head;
|
||||||
@ -285,7 +291,12 @@ sysprof_perf_counter_flush (SysprofPerfCounter *self,
|
|||||||
|
|
||||||
info->tail = tail;
|
info->tail = tail;
|
||||||
|
|
||||||
|
#ifdef HAVE_STDATOMIC_H
|
||||||
atomic_thread_fence (memory_order_seq_cst);
|
atomic_thread_fence (memory_order_seq_cst);
|
||||||
|
#elif G_GNUC_CHECK_VERSION(3, 0)
|
||||||
|
__sync_synchronize ();
|
||||||
|
#endif
|
||||||
|
|
||||||
info->map->data_tail = tail;
|
info->map->data_tail = tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user