1 /* GDB/Scheme support for math operations on values.
3 Copyright (C) 2008-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* See README file in this directory for implementation notes, coding
21 conventions, et.al. */
23 #include "arch-utils.h"
26 #include "target-float.h"
31 #include "guile-internal.h"
33 /* Note: Use target types here to remain consistent with the values system in
34 GDB (which uses target arithmetic). */
36 enum valscm_unary_opcode
42 /* Note: This is Scheme's "logical not", not GDB's.
43 GDB calls this UNOP_COMPLEMENT. */
47 enum valscm_binary_opcode
65 /* If TYPE is a reference, return the target; otherwise return TYPE. */
66 #define STRIP_REFERENCE(TYPE) \
67 ((TYPE->code () == TYPE_CODE_REF) ? ((TYPE)->target_type ()) : (TYPE))
69 /* Helper for vlscm_unop. Contains all the code that may throw a GDB
73 vlscm_unop_gdbthrow (enum valscm_unary_opcode opcode
, SCM x
,
74 const char *func_name
)
76 struct gdbarch
*gdbarch
= get_current_arch ();
77 const struct language_defn
*language
= current_language
;
79 scoped_value_mark free_values
;
82 value
*arg1
= vlscm_convert_value_from_scheme (func_name
, SCM_ARG1
, x
,
88 struct value
*res_val
= NULL
;
93 /* Alas gdb and guile use the opposite meaning for "logical
96 struct type
*type
= language_bool_type (language
, gdbarch
);
98 = value_from_longest (type
,
99 (LONGEST
) value_logical_not (arg1
));
103 res_val
= value_neg (arg1
);
106 /* Seemingly a no-op, but if X was a Scheme value it is now a
107 <gdb:value> object. */
111 if (value_less (arg1
, value::zero (arg1
->type (), not_lval
)))
112 res_val
= value_neg (arg1
);
117 res_val
= value_complement (arg1
);
120 gdb_assert_not_reached ("unsupported operation");
123 gdb_assert (res_val
!= NULL
);
124 return vlscm_scm_from_value (res_val
);
128 vlscm_unop (enum valscm_unary_opcode opcode
, SCM x
, const char *func_name
)
130 return gdbscm_wrap (vlscm_unop_gdbthrow
, opcode
, x
, func_name
);
133 /* Helper for vlscm_binop. Contains all the code that may throw a GDB
137 vlscm_binop_gdbthrow (enum valscm_binary_opcode opcode
, SCM x
, SCM y
,
138 const char *func_name
)
140 struct gdbarch
*gdbarch
= get_current_arch ();
141 const struct language_defn
*language
= current_language
;
142 struct value
*arg1
, *arg2
;
143 struct value
*res_val
= NULL
;
146 scoped_value_mark free_values
;
148 arg1
= vlscm_convert_value_from_scheme (func_name
, SCM_ARG1
, x
,
149 &except_scm
, gdbarch
, language
);
153 arg2
= vlscm_convert_value_from_scheme (func_name
, SCM_ARG2
, y
,
154 &except_scm
, gdbarch
, language
);
162 struct type
*ltype
= arg1
->type ();
163 struct type
*rtype
= arg2
->type ();
165 ltype
= check_typedef (ltype
);
166 ltype
= STRIP_REFERENCE (ltype
);
167 rtype
= check_typedef (rtype
);
168 rtype
= STRIP_REFERENCE (rtype
);
170 if (ltype
->code () == TYPE_CODE_PTR
171 && is_integral_type (rtype
))
172 res_val
= value_ptradd (arg1
, value_as_long (arg2
));
173 else if (rtype
->code () == TYPE_CODE_PTR
174 && is_integral_type (ltype
))
175 res_val
= value_ptradd (arg2
, value_as_long (arg1
));
177 res_val
= value_binop (arg1
, arg2
, BINOP_ADD
);
182 struct type
*ltype
= arg1
->type ();
183 struct type
*rtype
= arg2
->type ();
185 ltype
= check_typedef (ltype
);
186 ltype
= STRIP_REFERENCE (ltype
);
187 rtype
= check_typedef (rtype
);
188 rtype
= STRIP_REFERENCE (rtype
);
190 if (ltype
->code () == TYPE_CODE_PTR
191 && rtype
->code () == TYPE_CODE_PTR
)
193 /* A ptrdiff_t for the target would be preferable here. */
195 = value_from_longest (builtin_type (gdbarch
)->builtin_long
,
196 value_ptrdiff (arg1
, arg2
));
198 else if (ltype
->code () == TYPE_CODE_PTR
199 && is_integral_type (rtype
))
200 res_val
= value_ptradd (arg1
, - value_as_long (arg2
));
202 res_val
= value_binop (arg1
, arg2
, BINOP_SUB
);
206 res_val
= value_binop (arg1
, arg2
, BINOP_MUL
);
209 res_val
= value_binop (arg1
, arg2
, BINOP_DIV
);
212 res_val
= value_binop (arg1
, arg2
, BINOP_REM
);
215 res_val
= value_binop (arg1
, arg2
, BINOP_MOD
);
218 res_val
= value_binop (arg1
, arg2
, BINOP_EXP
);
221 res_val
= value_binop (arg1
, arg2
, BINOP_LSH
);
224 res_val
= value_binop (arg1
, arg2
, BINOP_RSH
);
227 res_val
= value_binop (arg1
, arg2
, BINOP_MIN
);
230 res_val
= value_binop (arg1
, arg2
, BINOP_MAX
);
233 res_val
= value_binop (arg1
, arg2
, BINOP_BITWISE_AND
);
236 res_val
= value_binop (arg1
, arg2
, BINOP_BITWISE_IOR
);
239 res_val
= value_binop (arg1
, arg2
, BINOP_BITWISE_XOR
);
242 gdb_assert_not_reached ("unsupported operation");
245 gdb_assert (res_val
!= NULL
);
246 return vlscm_scm_from_value (res_val
);
249 /* Returns a value object which is the result of applying the operation
250 specified by OPCODE to the given arguments.
251 If there's an error a Scheme exception is thrown. */
254 vlscm_binop (enum valscm_binary_opcode opcode
, SCM x
, SCM y
,
255 const char *func_name
)
257 return gdbscm_wrap (vlscm_binop_gdbthrow
, opcode
, x
, y
, func_name
);
260 /* (value-add x y) -> <gdb:value> */
263 gdbscm_value_add (SCM x
, SCM y
)
265 return vlscm_binop (VALSCM_ADD
, x
, y
, FUNC_NAME
);
268 /* (value-sub x y) -> <gdb:value> */
271 gdbscm_value_sub (SCM x
, SCM y
)
273 return vlscm_binop (VALSCM_SUB
, x
, y
, FUNC_NAME
);
276 /* (value-mul x y) -> <gdb:value> */
279 gdbscm_value_mul (SCM x
, SCM y
)
281 return vlscm_binop (VALSCM_MUL
, x
, y
, FUNC_NAME
);
284 /* (value-div x y) -> <gdb:value> */
287 gdbscm_value_div (SCM x
, SCM y
)
289 return vlscm_binop (VALSCM_DIV
, x
, y
, FUNC_NAME
);
292 /* (value-rem x y) -> <gdb:value> */
295 gdbscm_value_rem (SCM x
, SCM y
)
297 return vlscm_binop (VALSCM_REM
, x
, y
, FUNC_NAME
);
300 /* (value-mod x y) -> <gdb:value> */
303 gdbscm_value_mod (SCM x
, SCM y
)
305 return vlscm_binop (VALSCM_MOD
, x
, y
, FUNC_NAME
);
308 /* (value-pow x y) -> <gdb:value> */
311 gdbscm_value_pow (SCM x
, SCM y
)
313 return vlscm_binop (VALSCM_POW
, x
, y
, FUNC_NAME
);
316 /* (value-neg x) -> <gdb:value> */
319 gdbscm_value_neg (SCM x
)
321 return vlscm_unop (VALSCM_NEG
, x
, FUNC_NAME
);
324 /* (value-pos x) -> <gdb:value> */
327 gdbscm_value_pos (SCM x
)
329 return vlscm_unop (VALSCM_NOP
, x
, FUNC_NAME
);
332 /* (value-abs x) -> <gdb:value> */
335 gdbscm_value_abs (SCM x
)
337 return vlscm_unop (VALSCM_ABS
, x
, FUNC_NAME
);
340 /* (value-lsh x y) -> <gdb:value> */
343 gdbscm_value_lsh (SCM x
, SCM y
)
345 return vlscm_binop (VALSCM_LSH
, x
, y
, FUNC_NAME
);
348 /* (value-rsh x y) -> <gdb:value> */
351 gdbscm_value_rsh (SCM x
, SCM y
)
353 return vlscm_binop (VALSCM_RSH
, x
, y
, FUNC_NAME
);
356 /* (value-min x y) -> <gdb:value> */
359 gdbscm_value_min (SCM x
, SCM y
)
361 return vlscm_binop (VALSCM_MIN
, x
, y
, FUNC_NAME
);
364 /* (value-max x y) -> <gdb:value> */
367 gdbscm_value_max (SCM x
, SCM y
)
369 return vlscm_binop (VALSCM_MAX
, x
, y
, FUNC_NAME
);
372 /* (value-not x) -> <gdb:value> */
375 gdbscm_value_not (SCM x
)
377 return vlscm_unop (VALSCM_NOT
, x
, FUNC_NAME
);
380 /* (value-lognot x) -> <gdb:value> */
383 gdbscm_value_lognot (SCM x
)
385 return vlscm_unop (VALSCM_LOGNOT
, x
, FUNC_NAME
);
388 /* (value-logand x y) -> <gdb:value> */
391 gdbscm_value_logand (SCM x
, SCM y
)
393 return vlscm_binop (VALSCM_BITAND
, x
, y
, FUNC_NAME
);
396 /* (value-logior x y) -> <gdb:value> */
399 gdbscm_value_logior (SCM x
, SCM y
)
401 return vlscm_binop (VALSCM_BITOR
, x
, y
, FUNC_NAME
);
404 /* (value-logxor x y) -> <gdb:value> */
407 gdbscm_value_logxor (SCM x
, SCM y
)
409 return vlscm_binop (VALSCM_BITXOR
, x
, y
, FUNC_NAME
);
412 /* Utility to perform all value comparisons.
413 If there's an error a Scheme exception is thrown. */
416 vlscm_rich_compare (int op
, SCM x
, SCM y
, const char *func_name
)
418 return gdbscm_wrap ([=]
420 struct gdbarch
*gdbarch
= get_current_arch ();
421 const struct language_defn
*language
= current_language
;
424 scoped_value_mark free_values
;
427 = vlscm_convert_value_from_scheme (func_name
, SCM_ARG1
, x
,
428 &except_scm
, gdbarch
, language
);
433 = vlscm_convert_value_from_scheme (func_name
, SCM_ARG2
, y
,
434 &except_scm
, gdbarch
, language
);
442 result
= value_less (v1
, v2
);
445 result
= (value_less (v1
, v2
)
446 || value_equal (v1
, v2
));
449 result
= value_equal (v1
, v2
);
452 gdb_assert_not_reached ("not-equal not implemented");
454 result
= value_less (v2
, v1
);
457 result
= (value_less (v2
, v1
)
458 || value_equal (v1
, v2
));
461 gdb_assert_not_reached ("invalid <gdb:value> comparison");
463 return scm_from_bool (result
);
467 /* (value=? x y) -> boolean
468 There is no "not-equal?" function (value!= ?) on purpose.
469 We're following string=?, etc. as our Guide here. */
472 gdbscm_value_eq_p (SCM x
, SCM y
)
474 return vlscm_rich_compare (BINOP_EQUAL
, x
, y
, FUNC_NAME
);
477 /* (value<? x y) -> boolean */
480 gdbscm_value_lt_p (SCM x
, SCM y
)
482 return vlscm_rich_compare (BINOP_LESS
, x
, y
, FUNC_NAME
);
485 /* (value<=? x y) -> boolean */
488 gdbscm_value_le_p (SCM x
, SCM y
)
490 return vlscm_rich_compare (BINOP_LEQ
, x
, y
, FUNC_NAME
);
493 /* (value>? x y) -> boolean */
496 gdbscm_value_gt_p (SCM x
, SCM y
)
498 return vlscm_rich_compare (BINOP_GTR
, x
, y
, FUNC_NAME
);
501 /* (value>=? x y) -> boolean */
504 gdbscm_value_ge_p (SCM x
, SCM y
)
506 return vlscm_rich_compare (BINOP_GEQ
, x
, y
, FUNC_NAME
);
509 /* Subroutine of vlscm_convert_typed_value_from_scheme to simplify it.
510 Convert OBJ, a Scheme number, to a <gdb:value> object.
511 OBJ_ARG_POS is its position in the argument list, used in exception text.
513 TYPE is the result type. TYPE_ARG_POS is its position in
514 the argument list, used in exception text.
515 TYPE_SCM is Scheme object wrapping TYPE, used in exception text.
517 If the number isn't representable, e.g. it's too big, a <gdb:exception>
518 object is stored in *EXCEPT_SCMP and NULL is returned.
519 The conversion may throw a gdb error, e.g., if TYPE is invalid. */
521 static struct value
*
522 vlscm_convert_typed_number (const char *func_name
, int obj_arg_pos
, SCM obj
,
523 int type_arg_pos
, SCM type_scm
, struct type
*type
,
524 struct gdbarch
*gdbarch
, SCM
*except_scmp
)
526 if (is_integral_type (type
))
528 if (type
->is_unsigned ())
530 ULONGEST max
= get_unsigned_type_max (type
);
531 if (!scm_is_unsigned_integer (obj
, 0, max
))
534 = gdbscm_make_out_of_range_error
535 (func_name
, obj_arg_pos
, obj
,
536 _("value out of range for type"));
539 return value_from_longest (type
, gdbscm_scm_to_ulongest (obj
));
545 get_signed_type_minmax (type
, &min
, &max
);
546 if (!scm_is_signed_integer (obj
, min
, max
))
549 = gdbscm_make_out_of_range_error
550 (func_name
, obj_arg_pos
, obj
,
551 _("value out of range for type"));
554 return value_from_longest (type
, gdbscm_scm_to_longest (obj
));
557 else if (type
->code () == TYPE_CODE_PTR
)
559 CORE_ADDR max
= get_pointer_type_max (type
);
560 if (!scm_is_unsigned_integer (obj
, 0, max
))
563 = gdbscm_make_out_of_range_error
564 (func_name
, obj_arg_pos
, obj
,
565 _("value out of range for type"));
568 return value_from_pointer (type
, gdbscm_scm_to_ulongest (obj
));
570 else if (type
->code () == TYPE_CODE_FLT
)
571 return value_from_host_double (type
, scm_to_double (obj
));
574 *except_scmp
= gdbscm_make_type_error (func_name
, obj_arg_pos
, obj
,
580 /* Return non-zero if OBJ, an integer, fits in TYPE. */
583 vlscm_integer_fits_p (SCM obj
, struct type
*type
)
585 if (type
->is_unsigned ())
587 /* If scm_is_unsigned_integer can't work with this type, just punt. */
588 if (type
->length () > sizeof (uintmax_t))
591 ULONGEST max
= get_unsigned_type_max (type
);
592 return scm_is_unsigned_integer (obj
, 0, max
);
598 /* If scm_is_signed_integer can't work with this type, just punt. */
599 if (type
->length () > sizeof (intmax_t))
601 get_signed_type_minmax (type
, &min
, &max
);
602 return scm_is_signed_integer (obj
, min
, max
);
606 /* Subroutine of vlscm_convert_typed_value_from_scheme to simplify it.
607 Convert OBJ, a Scheme number, to a <gdb:value> object.
608 OBJ_ARG_POS is its position in the argument list, used in exception text.
610 If OBJ is an integer, then the smallest int that will hold the value in
611 the following progression is chosen:
612 int, unsigned int, long, unsigned long, long long, unsigned long long.
613 Otherwise, if OBJ is a real number, then it is converted to a double.
614 Otherwise an exception is thrown.
616 If the number isn't representable, e.g. it's too big, a <gdb:exception>
617 object is stored in *EXCEPT_SCMP and NULL is returned. */
619 static struct value
*
620 vlscm_convert_number (const char *func_name
, int obj_arg_pos
, SCM obj
,
621 struct gdbarch
*gdbarch
, SCM
*except_scmp
)
623 const struct builtin_type
*bt
= builtin_type (gdbarch
);
625 /* One thing to keep in mind here is that we are interested in the
626 target's representation of OBJ, not the host's. */
628 if (scm_is_exact (obj
) && scm_is_integer (obj
))
630 if (vlscm_integer_fits_p (obj
, bt
->builtin_int
))
631 return value_from_longest (bt
->builtin_int
,
632 gdbscm_scm_to_longest (obj
));
633 if (vlscm_integer_fits_p (obj
, bt
->builtin_unsigned_int
))
634 return value_from_longest (bt
->builtin_unsigned_int
,
635 gdbscm_scm_to_ulongest (obj
));
636 if (vlscm_integer_fits_p (obj
, bt
->builtin_long
))
637 return value_from_longest (bt
->builtin_long
,
638 gdbscm_scm_to_longest (obj
));
639 if (vlscm_integer_fits_p (obj
, bt
->builtin_unsigned_long
))
640 return value_from_longest (bt
->builtin_unsigned_long
,
641 gdbscm_scm_to_ulongest (obj
));
642 if (vlscm_integer_fits_p (obj
, bt
->builtin_long_long
))
643 return value_from_longest (bt
->builtin_long_long
,
644 gdbscm_scm_to_longest (obj
));
645 if (vlscm_integer_fits_p (obj
, bt
->builtin_unsigned_long_long
))
646 return value_from_longest (bt
->builtin_unsigned_long_long
,
647 gdbscm_scm_to_ulongest (obj
));
649 else if (scm_is_real (obj
))
650 return value_from_host_double (bt
->builtin_double
, scm_to_double (obj
));
652 *except_scmp
= gdbscm_make_out_of_range_error (func_name
, obj_arg_pos
, obj
,
653 _("value not a number representable on the target"));
657 /* Subroutine of vlscm_convert_typed_value_from_scheme to simplify it.
658 Convert BV, a Scheme bytevector, to a <gdb:value> object.
660 TYPE, if non-NULL, is the result type. Otherwise, a vector of type
662 TYPE_SCM is Scheme object wrapping TYPE, used in exception text,
663 or #f if TYPE is NULL.
665 If the bytevector isn't the same size as the type, then a <gdb:exception>
666 object is stored in *EXCEPT_SCMP, and NULL is returned. */
668 static struct value
*
669 vlscm_convert_bytevector (SCM bv
, struct type
*type
, SCM type_scm
,
670 int arg_pos
, const char *func_name
,
671 SCM
*except_scmp
, struct gdbarch
*gdbarch
)
673 LONGEST length
= SCM_BYTEVECTOR_LENGTH (bv
);
678 type
= builtin_type (gdbarch
)->builtin_uint8
;
679 type
= lookup_array_range_type (type
, 0, length
);
680 make_vector_type (type
);
682 type
= check_typedef (type
);
683 if (type
->length () != length
)
685 *except_scmp
= gdbscm_make_out_of_range_error (func_name
, arg_pos
,
687 _("size of type does not match size of bytevector"));
691 value
= value_from_contents (type
,
692 (gdb_byte
*) SCM_BYTEVECTOR_CONTENTS (bv
));
696 /* Convert OBJ, a Scheme value, to a <gdb:value> object.
697 OBJ_ARG_POS is its position in the argument list, used in exception text.
699 TYPE, if non-NULL, is the result type which must be compatible with
700 the value being converted.
701 If TYPE is NULL then a suitable default type is chosen.
702 TYPE_SCM is Scheme object wrapping TYPE, used in exception text,
703 or SCM_UNDEFINED if TYPE is NULL.
704 TYPE_ARG_POS is its position in the argument list, used in exception text,
705 or -1 if TYPE is NULL.
707 OBJ may also be a <gdb:value> object, in which case a copy is returned
708 and TYPE must be NULL.
710 If the value cannot be converted, NULL is returned and a gdb:exception
711 object is stored in *EXCEPT_SCMP.
712 Otherwise the new value is returned, added to the all_values chain. */
715 vlscm_convert_typed_value_from_scheme (const char *func_name
,
716 int obj_arg_pos
, SCM obj
,
717 int type_arg_pos
, SCM type_scm
,
720 struct gdbarch
*gdbarch
,
721 const struct language_defn
*language
)
723 struct value
*value
= NULL
;
724 SCM except_scm
= SCM_BOOL_F
;
728 gdb_assert (type_arg_pos
== -1);
729 gdb_assert (SCM_UNBNDP (type_scm
));
732 *except_scmp
= SCM_BOOL_F
;
736 if (vlscm_is_value (obj
))
740 except_scm
= gdbscm_make_misc_error (func_name
, type_arg_pos
,
742 _("No type allowed"));
746 value
= vlscm_scm_to_value (obj
)->copy ();
748 else if (gdbscm_is_true (scm_bytevector_p (obj
)))
750 value
= vlscm_convert_bytevector (obj
, type
, type_scm
,
751 obj_arg_pos
, func_name
,
752 &except_scm
, gdbarch
);
754 else if (gdbscm_is_bool (obj
))
757 && !is_integral_type (type
))
759 except_scm
= gdbscm_make_type_error (func_name
, type_arg_pos
,
764 value
= value_from_longest (type
766 : language_bool_type (language
,
768 gdbscm_is_true (obj
));
771 else if (scm_is_number (obj
))
775 value
= vlscm_convert_typed_number (func_name
, obj_arg_pos
, obj
,
776 type_arg_pos
, type_scm
, type
,
777 gdbarch
, &except_scm
);
781 value
= vlscm_convert_number (func_name
, obj_arg_pos
, obj
,
782 gdbarch
, &except_scm
);
785 else if (scm_is_string (obj
))
791 except_scm
= gdbscm_make_misc_error (func_name
, type_arg_pos
,
793 _("No type allowed"));
798 /* TODO: Provide option to specify conversion strategy. */
799 gdb::unique_xmalloc_ptr
<char> s
800 = gdbscm_scm_to_string (obj
, &len
,
801 target_charset (gdbarch
),
805 value
= language
->value_string (gdbarch
, s
.get (), len
);
810 else if (lsscm_is_lazy_string (obj
))
814 except_scm
= gdbscm_make_misc_error (func_name
, type_arg_pos
,
816 _("No type allowed"));
821 value
= lsscm_safe_lazy_string_to_value (obj
, obj_arg_pos
,
826 else /* OBJ isn't anything we support. */
828 except_scm
= gdbscm_make_type_error (func_name
, obj_arg_pos
, obj
,
833 catch (const gdb_exception
&except
)
835 except_scm
= gdbscm_scm_from_gdb_exception (unpack (except
));
838 if (gdbscm_is_true (except_scm
))
840 gdb_assert (value
== NULL
);
841 *except_scmp
= except_scm
;
847 /* Wrapper around vlscm_convert_typed_value_from_scheme for cases where there
848 is no supplied type. See vlscm_convert_typed_value_from_scheme for
852 vlscm_convert_value_from_scheme (const char *func_name
,
853 int obj_arg_pos
, SCM obj
,
854 SCM
*except_scmp
, struct gdbarch
*gdbarch
,
855 const struct language_defn
*language
)
857 return vlscm_convert_typed_value_from_scheme (func_name
, obj_arg_pos
, obj
,
858 -1, SCM_UNDEFINED
, NULL
,
863 /* Initialize value math support. */
865 static const scheme_function math_functions
[] =
867 { "value-add", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_add
),
871 { "value-sub", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_sub
),
875 { "value-mul", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_mul
),
879 { "value-div", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_div
),
883 { "value-rem", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_rem
),
887 { "value-mod", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_mod
),
889 Return a mod b. See Knuth 1.2.4." },
891 { "value-pow", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_pow
),
893 Return pow (x, y)." },
895 { "value-not", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_not
),
899 { "value-neg", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_neg
),
903 { "value-pos", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_pos
),
907 { "value-abs", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_abs
),
911 { "value-lsh", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_lsh
),
915 { "value-rsh", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_rsh
),
919 { "value-min", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_min
),
921 Return min (a, b)." },
923 { "value-max", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_max
),
925 Return max (a, b)." },
927 { "value-lognot", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_lognot
),
931 { "value-logand", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_logand
),
935 { "value-logior", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_logior
),
939 { "value-logxor", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_logxor
),
943 { "value=?", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_eq_p
),
947 { "value<?", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_lt_p
),
951 { "value<=?", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_le_p
),
955 { "value>?", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_gt_p
),
959 { "value>=?", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_ge_p
),
967 gdbscm_initialize_math (void)
969 gdbscm_define_functions (math_functions
, 1);