git.iko.soy/rowtype-yoga/purescript-native
on ebbc4e4 help sign in
38 lines 1.1 kB history raw
1///////////////////////////////////////////////////////////////////////////////
2//
3// Module : purescript.hh
4// Copyright : (c) Andy Arvanitis 2016
5// License : MIT
6//
7// Maintainer : Andy Arvanitis <andy.arvanitis@gmail.com>
8// Stability : experimental
9// Portability :
10//
11// Includes and macros for garbage collection options
12//
13///////////////////////////////////////////////////////////////////////////////
14//
15#ifndef PureScript_GC_HH
16#define PureScript_GC_HH
18#if defined(USE_GC)
19 #define GC_THREADS
20 #include <gc/gc_cpp.h>
21 #include <gc/gc_allocator.h>
22 #define WITH_ALLOCATOR(T) , traceable_allocator<T>
23 #define SHARED_TYPE(T) T*
24 #define MAKE_SHARED(T) new (GC) T
25 #define IS_POINTER_TYPE(T) std::is_pointer<T>
26 #define POINTER_FROM_MEMBER(P) P
27 #define INITIALIZE_GC(_) GC_INIT()
28#else
29 #include <memory>
30 #define WITH_ALLOCATOR(_)
31 #define SHARED_TYPE(T) std::shared_ptr<T>
32 #define MAKE_SHARED(T) std::make_shared<T>
33 #define IS_POINTER_TYPE(T) std::is_assignable<shared<void>,T>
34 #define POINTER_FROM_MEMBER(P) P.get()
35 #define INITIALIZE_GC(_)
36#endif
38#endif // PureScript_GC_HH