[build] Add MONO_RT_EXTERNAL_ONLY macro to the public API.
authorRodrigo Kumpera <kumpera@gmail.com>
Wed, 27 Jan 2016 19:55:47 +0000 (14:55 -0500)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 27 Jan 2016 19:55:47 +0000 (14:55 -0500)
This macro should be used to decorate functions that are part of the public API but the runtime is
not supposed to call.

This is to allow us to keep them around but not go crazy with commit reintroducing their usage.

configure.ac
mono/utils/mono-publib.h

index 600ad4c6d28222ffac3a2ddeb8d6a59c0963ecc6..33c4d28a82c79afa098002da4647ab30f0bde372 100644 (file)
@@ -3651,6 +3651,9 @@ AC_SUBST(CFLAGS)
 AC_SUBST(CPPFLAGS)
 AC_SUBST(LDFLAGS)
 
+#This must always be defined when building the runtime
+AC_DEFINE(MONO_INSIDE_RUNTIME,1, [Disable banned functions from being used by the runtime])
+
 mono_build_root=`pwd`
 AC_SUBST(mono_build_root)
 
index c9becb2bf5e24f5e99c4b2e9d54d6284511dbf8a..30c807043998a61ef995c29c63f3ffe1ac79524d 100644 (file)
@@ -73,6 +73,22 @@ MONO_API void mono_free (void *);
 
 #define MONO_CONST_RETURN const
 
+
+#if defined (MONO_INSIDE_RUNTIME)
+
+#if defined (__clang__)
+#define MONO_RT_EXTERNAL_ONLY __attribute__ ((unavailable("The mono runtime must not call this function")))
+#elif defined (__GNUC__)
+#define MONO_RT_EXTERNAL_ONLY __attribute__ ((error("The mono runtime must not call this function")))
+#else
+#define MONO_RT_EXTERNAL_ONLY
+#endif /* __clang__ */
+
+#else
+#define MONO_RT_EXTERNAL_ONLY
+#endif /* MONO_INSIDE_RUNTIME */
+
+
 MONO_END_DECLS
 
 #endif /* __MONO_PUBLIB_H__ */