Clean up C linkage specific to the C++ migration
[charm.git] / src / ck-core / middle-conv.h
blob0adcd1335b6347e03447d91696976762cbed9bea
1 #ifndef _MIDDLE_CONV_H_
2 #define _MIDDLE_CONV_H_
4 #include "converse.h"
6 #define CkpvDeclare CpvDeclare
7 #define CkpvExtern CpvExtern
8 #define CkpvStaticDeclare CpvStaticDeclare
9 #define CkpvInitialize CpvInitialize
10 #define CkpvInitialized CpvInitialized
11 #define CkpvAccess CpvAccess
12 #define CkpvAccessOther CpvAccessOther
14 #define CksvDeclare CsvDeclare
15 #define CksvExtern CsvExtern
16 #define CksvStaticDeclare CsvStaticDeclare
17 #define CksvInitialize CsvInitialize
18 #define CksvAccess CsvAccess
20 #define CkReduce CmiReduce
22 #undef CkMyPe
23 #undef CkNumPes
25 #define CkRegisterHandler(x) CmiRegisterHandler((CmiHandler)x)
26 #define CkRegisterHandlerEx(x, p) CmiRegisterHandlerEx((CmiHandlerEx)x, p)
27 #define CkNumberHandler(n, x) CmiNumberHandler(n, (CmiHandler)x)
28 #define CkNumberHandlerEx(n, x, p) CmiNumberHandlerEx(n, (CmiHandlerEx)x, p)
30 #undef CmiSyncSend
31 #undef CmiSyncSendAndFree
32 #undef CmiSyncBroadcast
33 #undef CmiSyncBroadcastAndFree
34 #undef CmiSyncBroadcastAll
35 #undef CmiSyncBroadcastAllAndFree
36 #undef CmiSyncListSend
37 #undef CmiSyncListSendAndFree
38 #undef CmiSyncMulticast
39 #undef CmiSyncMulticastAndFree
41 #define CksdScheduler CsdScheduler
42 #define CksdExitScheduler CsdExitScheduler
43 #define CkDeliverMsgs CmiDeliverMsgs
45 #define CkVTimer(x) 0
46 #define CkElapse(x)
48 #if CMK_CHARMDEBUG
49 int ConverseDeliver(int pe);
50 #else
51 #define ConverseDeliver(pe) 1
52 #endif
54 namespace Converse {
56 static inline int CkMyPe() { return CmiMyPe(); }
57 static inline int CkNumPes() { return CmiNumPes(); }
59 static inline void CmiSyncSend(int x, int y, char *z)
61 if (ConverseDeliver(x)) CmiSyncSendFn(x, y, z);
63 static inline void CmiSyncSendAndFree(int x, int y, char *z)
65 if (ConverseDeliver(x)) CmiFreeSendFn(x, y, z);
67 static inline void CmiSyncBroadcast(int x, char *y)
69 if (ConverseDeliver(x)) CmiSyncBroadcastFn(x, y);
71 static inline void CmiSyncBroadcastAndFree(int x, char *y)
73 if (ConverseDeliver(x)) CmiFreeBroadcastFn(x, y);
75 static inline void CmiSyncBroadcastAll(int x, char *y)
77 if (ConverseDeliver(x)) CmiSyncBroadcastAllFn(x, y);
79 static inline void CmiSyncBroadcastAllAndFree(int x, char *y)
81 if (ConverseDeliver(x)) CmiFreeBroadcastAllFn(x, y);
83 static inline void CmiSyncListSend(int x, int *y, int w, char *z)
85 if (ConverseDeliver(-1)) CmiSyncListSendFn(x, y, w, z);
87 static inline void CmiSyncListSendAndFree(int x, int *y, int w, char *z)
89 if (ConverseDeliver(-1)) CmiFreeListSendFn(x, y, w, z);
91 static inline void CmiSyncMulticast(CmiGroup x, int y, char *z)
93 if (ConverseDeliver(-1)) CmiSyncMulticastFn(x, y, z);
95 static inline void CmiSyncMulticastAndFree(CmiGroup x, int y, char *z)
97 if (ConverseDeliver(-1)) CmiFreeMulticastFn(x, y, z);
100 #if 0
101 template <class d>
102 class Cpv {
103 public:
104 #if CMK_SHARED_VARS_UNAVAILABLE
105 d data;
106 #else
107 d *data;
108 #endif
109 public:
110 void init(void) {
112 d& operator = (d& val) {data = val.data;}
114 #endif
120 #define CpvDeclare(t, v) Cpv<t> v
121 #define CpvExtern(t,v) extern Cpv<t> v
122 #define CpvStaticDeclare(t,v) static Cpv<t> v
123 #define CpvInitialize(t,v) v.init()
124 #define CpvAccess(v) v.data
129 #endif