1 /* logging.c -- "Dummy" functions logging calls to real mpc functions.
3 Copyright (C) 2011 INRIA
5 This file is part of GNU MPC.
7 GNU MPC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU Lesser General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
12 GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see http://www.gnu.org/licenses/ .
24 #ifdef HAVE_INTTYPES_H
31 #define __MPC_LIBRARY_BUILD
32 /* to indicate we are inside the library build; needed here since mpc-log.h
33 includes mpc.h and not mpc-impl.h */
40 typedef int (*c_c_func_ptr
) (mpc_ptr
, mpc_srcptr
, mpc_rnd_t
);
41 typedef int (*c_cc_func_ptr
) (mpc_ptr
, mpc_srcptr
, mpc_srcptr
, mpc_rnd_t
);
42 typedef int (*c_ccc_func_ptr
) (mpc_ptr
, mpc_srcptr
, mpc_srcptr
, mpc_srcptr
, mpc_rnd_t
);
43 typedef int (*cc_c_func_ptr
) (mpc_ptr
, mpc_ptr
, mpc_srcptr
, mpc_rnd_t
, mpc_rnd_t
);
45 #define MPC_LOGGING_OUT_PREC(z) \
47 fprintf (stderr, " %li %li", (long) mpfr_get_prec (mpc_realref (z)), \
48 (long) mpfr_get_prec (mpc_imagref (z))); \
51 #define MPC_LOGGING_OUT_C(z) \
53 MPC_LOGGING_OUT_PREC (z); \
54 fprintf (stderr, " "); \
55 mpc_out_str (stderr, 16, 0, z, MPC_RNDNN); \
58 #define MPC_LOGGING_FUNC_TYPE(funcname, type) \
60 fprintf (stderr, "mpc_"#funcname" "#type); \
63 #define MPC_LOGGING_C_C(funcname) \
64 __MPC_DECLSPEC int mpc_log_##funcname (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd) \
66 static c_c_func_ptr func = NULL; \
68 func = (c_c_func_ptr) (intptr_t) dlsym (NULL, "mpc_"#funcname); \
69 MPC_LOGGING_FUNC_TYPE (funcname, c_c); \
70 MPC_LOGGING_OUT_PREC (rop); \
71 MPC_LOGGING_OUT_C (op); \
72 fprintf (stderr, "\n"); \
73 return func (rop, op, rnd); \
76 #define MPC_LOGGING_C_CC(funcname) \
77 __MPC_DECLSPEC int mpc_log_##funcname (mpc_ptr rop, mpc_srcptr op1, mpc_srcptr op2, mpc_rnd_t rnd) \
79 static c_cc_func_ptr func = NULL; \
81 func = (c_cc_func_ptr) (intptr_t) dlsym (NULL, "mpc_"#funcname); \
82 MPC_LOGGING_FUNC_TYPE (funcname, c_cc); \
83 MPC_LOGGING_OUT_PREC (rop); \
84 MPC_LOGGING_OUT_C (op1); \
85 MPC_LOGGING_OUT_C (op2); \
86 fprintf (stderr, "\n"); \
87 return func (rop, op1, op2, rnd); \
90 #define MPC_LOGGING_C_CCC(funcname) \
91 __MPC_DECLSPEC int mpc_log_##funcname (mpc_ptr rop, mpc_srcptr op1, mpc_srcptr op2, mpc_srcptr op3, mpc_rnd_t rnd) \
93 static c_ccc_func_ptr func = NULL; \
95 func = (c_ccc_func_ptr) (intptr_t) dlsym (NULL, "mpc_"#funcname); \
96 MPC_LOGGING_FUNC_TYPE (funcname, c_ccc); \
97 MPC_LOGGING_OUT_PREC (rop); \
98 MPC_LOGGING_OUT_C (op1); \
99 MPC_LOGGING_OUT_C (op2); \
100 MPC_LOGGING_OUT_C (op3); \
101 fprintf (stderr, "\n"); \
102 return func (rop, op1, op2, op3, rnd); \
105 #define MPC_LOGGING_CC_C(funcname) \
106 __MPC_DECLSPEC int mpc_log_##funcname (mpc_ptr rop1, mpc_ptr rop2, mpc_srcptr op, mpc_rnd_t rnd1, mpc_rnd_t rnd2) \
108 static cc_c_func_ptr func = NULL; \
110 func = (cc_c_func_ptr) (intptr_t) dlsym (NULL, "mpc_"#funcname); \
111 MPC_LOGGING_FUNC_TYPE (funcname, cc_c); \
112 MPC_LOGGING_OUT_PREC (rop1); \
113 MPC_LOGGING_OUT_PREC (rop2); \
114 MPC_LOGGING_OUT_C (op); \
115 fprintf (stderr, "\n"); \
116 return func (rop1, rop2, op, rnd1, rnd2); \
119 MPC_LOGGING_C_C (sqr
)
120 MPC_LOGGING_C_C (conj
)
121 MPC_LOGGING_C_C (neg
)
122 MPC_LOGGING_C_C (sqrt
)
123 MPC_LOGGING_C_C (proj
)
124 MPC_LOGGING_C_C (exp
)
125 MPC_LOGGING_C_C (log
)
126 MPC_LOGGING_C_C (sin
)
127 MPC_LOGGING_C_C (cos
)
128 MPC_LOGGING_C_C (tan
)
129 MPC_LOGGING_C_C (sinh
)
130 MPC_LOGGING_C_C (cosh
)
131 MPC_LOGGING_C_C (tanh
)
132 MPC_LOGGING_C_C (asin
)
133 MPC_LOGGING_C_C (acos
)
134 MPC_LOGGING_C_C (atan
)
135 MPC_LOGGING_C_C (asinh
)
136 MPC_LOGGING_C_C (acosh
)
137 MPC_LOGGING_C_C (atanh
)
139 MPC_LOGGING_C_CC (add
)
140 MPC_LOGGING_C_CC (sub
)
141 MPC_LOGGING_C_CC (mul
)
142 MPC_LOGGING_C_CC (div
)
143 MPC_LOGGING_C_CC (pow
)
145 MPC_LOGGING_C_CCC (fma
)
147 MPC_LOGGING_CC_C (sin_cos
)