TESTS_ENVIRONMENT = $(PYTHON) $(srcdir)/run-testcase.py --with-gcc=$(CC) \
--with-ia-lib-dir=$(top_builddir)/src/.libs \
--with-ia-src-dir=$(top_srcdir) --with-tests-dir=$(srcdir)
-TESTS = int-types.xml
+TESTS = int-types.xml float-types.xml
endif
--- /dev/null
+#include <stdio.h>
+
+void _advice_all(const char *func, double n1, double n2)
+{
+ printf("ALL advice in %s (%.20f, %.20f)\n", func, n1, n2);
+}
+
+void _advice_32(const char *func, float n1, float n2)
+{
+ printf("32 advice in %s (%.20f, %.20f)\n", func, (double)n1, (float)n2);
+}
+
+void _advice_64(const char *func, double n1, double n2)
+{
+ printf("64 advice in %s (%.20f, %.20f)\n", func, n1, n2);
+}
+
+void _advice_128(const char *func, long double n1, long double n2)
+{
+ printf("128 advice in %s (%.20Lf, %.20Lf)\n", func, n1, n2);
+}
--- /dev/null
+#include <stdio.h>
+
+void binary32(float n)
+{
+ printf("single:\t%.20f\n", (double)n);
+}
+
+void binary64(double n)
+{
+ printf("double:\t%.20f\n", n);
+}
+
+void binary128(long double n)
+{
+ printf("quad:\t%.20Lf\n", n);
+}
+
+void run_test()
+{
+ binary32((float)1/3);
+ binary64((double)1/3);
+ binary128((long double)1/3);
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE testcase SYSTEM "testcase.dtd">
+<testcase name="Float Types">
+ <plugin id="plugin-float-types" source="plugin-float-types.c" />
+ <run name="Float parameter captures" target="float-types-target.c" hooks="float-types-hooks.c">
+ <using plugin="plugin-float-types" />
+ <output>
+ ALL advice in binary32 (0.33333334326744079590, 0.33333334326744079590)
+ 32 advice in binary32 (0.33333334326744079590, 0.33333334326744079590)
+ single: 0.33333334326744079590
+ ALL advice in binary64 (0.33333333333333331483, 0.33333333333333331483)
+ 64 advice in binary64 (0.33333333333333331483, 0.33333333333333331483)
+ double: 0.33333333333333331483
+ 128 advice in binary128 (0.33333333333333333334, 0.33333333333333333334)
+ quad: 0.33333333333333333334
+ </output>
+ </run>
+</testcase>
--- /dev/null
+#include <aop.h>
+#include <stdio.h>
+#include <string.h>
+
+AOP_I_AM_GPL_COMPATIBLE();
+
+static void plugin_join_on_call(struct aop_joinpoint *jp, void *data)
+{
+ const char *advice_name = data;
+ const char *name;
+ struct aop_dynval *n;
+
+ name = aop_capture_called_function_name(jp);
+ n = aop_capture_param(jp, 0);
+ aop_insert_advice(jp, advice_name, AOP_INSERT_BEFORE, AOP_STR_CST(name), AOP_DYNVAL(n), AOP_DYNVAL(n), AOP_TERM_ARG);
+}
+
+static unsigned int plugin_float()
+{
+ struct aop_pointcut *pc;
+
+ pc = aop_match_function_call();
+ aop_filter_call_pc_by_param(pc, 0, aop_t_all_fp());
+ aop_join_on(pc, plugin_join_on_call, "_advice_all");
+
+ pc = aop_match_function_call();
+ aop_filter_call_pc_by_param(pc, 0, aop_t_float32());
+ aop_join_on(pc, plugin_join_on_call, "_advice_32");
+
+ pc = aop_match_function_call();
+ aop_filter_call_pc_by_param(pc, 0, aop_t_float64());
+ aop_join_on(pc, plugin_join_on_call, "_advice_64");
+
+ pc = aop_match_function_call();
+ aop_filter_call_pc_by_param(pc, 0, aop_t_float128());
+ aop_join_on(pc, plugin_join_on_call, "_advice_128");
+
+ return 0;
+}
+
+AOP_MAIN_PROTO aop_main()
+{
+ aop_register_pass("float", plugin_float);
+}