+// function::registered_functions() is protected, but we need to access it
+class registered_functions_hack : public function
+{
+public:
+ static const std::vector<function_options>& get_registered_functions()
+ {
+ return function::registered_functions();
+ }
+private:
+ registered_functions_hack();
+ registered_functions_hack(const registered_functions_hack&);
+ registered_functions_hack& operator=(const registered_functions_hack&);
+};
+
+// Encode an integer into a pointer to a function. Since functions
+// are aligned (the minimal alignment depends on CPU architecture)
+// we can distinguish between pointers and integers.
+static reader_func encode_serial_as_reader_func(unsigned serial)
+{
+ uintptr_t u = (uintptr_t)serial;
+ u = (u << 1) | (uintptr_t)1;
+ reader_func ptr = (reader_func)((void *)u);
+ return ptr;
+}
+