1 /* GDB/Scheme support for math operations on values.
3 Copyright (C) 2008-2020 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. */
24 #include "arch-utils.h"
27 #include "target-float.h"
28 #include "symtab.h" /* Needed by language.h. */
32 #include "guile-internal.h"
34 /* Note: Use target types here to remain consistent with the values system in
35 GDB (which uses target arithmetic). */
37 enum valscm_unary_opcode
43 /* Note: This is Scheme's "logical not", not GDB's.
44 GDB calls this UNOP_COMPLEMENT. */
48 enum valscm_binary_opcode
66 /* If TYPE is a reference, return the target; otherwise return TYPE. */
67 #define STRIP_REFERENCE(TYPE) \
68 ((TYPE_CODE (TYPE) == TYPE_CODE_REF) ? (TYPE_TARGET_TYPE (TYPE)) : (TYPE))
70 /* Helper for vlscm_unop. Contains all the code that may throw a GDB
74 vlscm_unop_gdbthrow (enum valscm_unary_opcode opcode
, SCM x
,
75 const char *func_name
)
77 struct gdbarch
*gdbarch
= get_current_arch ();
78 const struct language_defn
*language
= current_language
;
80 scoped_value_mark free_values
;
83 value
*arg1
= vlscm_convert_value_from_scheme (func_name
, SCM_ARG1
, x
,
89 struct value
*res_val
= NULL
;
94 /* Alas gdb and guile use the opposite meaning for "logical
97 struct type
*type
= language_bool_type (language
, gdbarch
);
99 = value_from_longest (type
,
100 (LONGEST
) value_logical_not (arg1
));
104 res_val
= value_neg (arg1
);
107 /* Seemingly a no-op, but if X was a Scheme value it is now a
108 <gdb:value> object. */
112 if (value_less (arg1
, value_zero (value_type (arg1
), not_lval
)))
113 res_val
= value_neg (arg1
);
118 res_val
= value_complement (arg1
);
121 gdb_assert_not_reached ("unsupported operation");
124 gdb_assert (res_val
!= NULL
);
125 return vlscm_scm_from_value (res_val
);
129 vlscm_unop (enum valscm_unary_opcode opcode
, SCM x
, const char *func_name
)
131 return gdbscm_wrap (vlscm_unop_gdbthrow
, opcode
, x
, func_name
);
134 /* Helper for vlscm_binop. Contains all the code that may throw a GDB
138 vlscm_binop_gdbthrow (enum valscm_binary_opcode opcode
, SCM x
, SCM y
,
139 const char *func_name
)
141 struct gdbarch
*gdbarch
= get_current_arch ();
142 const struct language_defn
*language
= current_language
;
143 struct value
*arg1
, *arg2
;
144 struct value
*res_val
= NULL
;
147 scoped_value_mark free_values
;
149 arg1
= vlscm_convert_value_from_scheme (func_name
, SCM_ARG1
, x
,
150 &except_scm
, gdbarch
, language
);
154 arg2
= vlscm_convert_value_from_scheme (func_name
, SCM_ARG2
, y
,
155 &except_scm
, gdbarch
, language
);
163 struct type
*ltype
= value_type (arg1
);
164 struct type
*rtype
= value_type (arg2
);
166 ltype
= check_typedef (ltype
);
167 ltype
= STRIP_REFERENCE (ltype
);
168 rtype
= check_typedef (rtype
);
169 rtype
= STRIP_REFERENCE (rtype
);
171 if (TYPE_CODE (ltype
) == TYPE_CODE_PTR
172 && is_integral_type (rtype
))
173 res_val
= value_ptradd (arg1
, value_as_long (arg2
));
174 else if (TYPE_CODE (rtype
) == TYPE_CODE_PTR
175 && is_integral_type (ltype
))
176 res_val
= value_ptradd (arg2
, value_as_long (arg1
));
178 res_val
= value_binop (arg1
, arg2
, BINOP_ADD
);
183 struct type
*ltype
= value_type (arg1
);
184 struct type
*rtype
= value_type (arg2
);
186 ltype
= check_typedef (ltype
);
187 ltype
= STRIP_REFERENCE (ltype
);
188 rtype
= check_typedef (rtype
);
189 rtype
= STRIP_REFERENCE (rtype
);
191 if (TYPE_CODE (ltype
) == TYPE_CODE_PTR
192 && TYPE_CODE (rtype
) == TYPE_CODE_PTR
)
194 /* A ptrdiff_t for the target would be preferable here. */
196 = value_from_longest (builtin_type (gdbarch
)->builtin_long
,
197 value_ptrdiff (arg1
, arg2
));
199 else if (TYPE_CODE (ltype
) == TYPE_CODE_PTR
200 && is_integral_type (rtype
))
201 res_val
= value_ptradd (arg1
, - value_as_long (arg2
));
203 res_val
= value_binop (arg1
, arg2
, BINOP_SUB
);
207 res_val
= value_binop (arg1
, arg2
, BINOP_MUL
);
210 res_val
= value_binop (arg1
, arg2
, BINOP_DIV
);
213 res_val
= value_binop (arg1
, arg2
, BINOP_REM
);
216 res_val
= value_binop (arg1
, arg2
, BINOP_MOD
);
219 res_val
= value_binop (arg1
, arg2
, BINOP_EXP
);
222 res_val
= value_binop (arg1
, arg2
, BINOP_LSH
);
225 res_val
= value_binop (arg1
, arg2
, BINOP_RSH
);
228 res_val
= value_binop (arg1
, arg2
, BINOP_MIN
);
231 res_val
= value_binop (arg1
, arg2
, BINOP_MAX
);
234 res_val
= value_binop (arg1
, arg2
, BINOP_BITWISE_AND
);
237 res_val
= value_binop (arg1
, arg2
, BINOP_BITWISE_IOR
);
240 res_val
= value_binop (arg1
, arg2
, BINOP_BITWISE_XOR
);
243 gdb_assert_not_reached ("unsupported operation");
246 gdb_assert (res_val
!= NULL
);
247 return vlscm_scm_from_value (res_val
);
250 /* Returns a value object which is the result of applying the operation
251 specified by OPCODE to the given arguments.
252 If there's an error a Scheme exception is thrown. */
255 vlscm_binop (enum valscm_binary_opcode opcode
, SCM x
, SCM y
,
256 const char *func_name
)
258 return gdbscm_wrap (vlscm_binop_gdbthrow
, opcode
, x
, y
, func_name
);
261 /* (value-add x y) -> <gdb:value> */
264 gdbscm_value_add (SCM x
, SCM y
)
266 return vlscm_binop (VALSCM_ADD
, x
, y
, FUNC_NAME
);
269 /* (value-sub x y) -> <gdb:value> */
272 gdbscm_value_sub (SCM x
, SCM y
)
274 return vlscm_binop (VALSCM_SUB
, x
, y
, FUNC_NAME
);
277 /* (value-mul x y) -> <gdb:value> */
280 gdbscm_value_mul (SCM x
, SCM y
)
282 return vlscm_binop (VALSCM_MUL
, x
, y
, FUNC_NAME
);
285 /* (value-div x y) -> <gdb:value> */
288 gdbscm_value_div (SCM x
, SCM y
)
290 return vlscm_binop (VALSCM_DIV
, x
, y
, FUNC_NAME
);
293 /* (value-rem x y) -> <gdb:value> */
296 gdbscm_value_rem (SCM x
, SCM y
)
298 return vlscm_binop (VALSCM_REM
, x
, y
, FUNC_NAME
);
301 /* (value-mod x y) -> <gdb:value> */
304 gdbscm_value_mod (SCM x
, SCM y
)
306 return vlscm_binop (VALSCM_MOD
, x
, y
, FUNC_NAME
);
309 /* (value-pow x y) -> <gdb:value> */
312 gdbscm_value_pow (SCM x
, SCM y
)
314 return vlscm_binop (VALSCM_POW
, x
, y
, FUNC_NAME
);
317 /* (value-neg x) -> <gdb:value> */
320 gdbscm_value_neg (SCM x
)
322 return vlscm_unop (VALSCM_NEG
, x
, FUNC_NAME
);
325 /* (value-pos x) -> <gdb:value> */
328 gdbscm_value_pos (SCM x
)
330 return vlscm_unop (VALSCM_NOP
, x
, FUNC_NAME
);
333 /* (value-abs x) -> <gdb:value> */
336 gdbscm_value_abs (SCM x
)
338 return vlscm_unop (VALSCM_ABS
, x
, FUNC_NAME
);
341 /* (value-lsh x y) -> <gdb:value> */
344 gdbscm_value_lsh (SCM x
, SCM y
)
346 return vlscm_binop (VALSCM_LSH
, x
, y
, FUNC_NAME
);
349 /* (value-rsh x y) -> <gdb:value> */
352 gdbscm_value_rsh (SCM x
, SCM y
)
354 return vlscm_binop (VALSCM_RSH
, x
, y
, FUNC_NAME
);
357 /* (value-min x y) -> <gdb:value> */
360 gdbscm_value_min (SCM x
, SCM y
)
362 return vlscm_binop (VALSCM_MIN
, x
, y
, FUNC_NAME
);
365 /* (value-max x y) -> <gdb:value> */
368 gdbscm_value_max (SCM x
, SCM y
)
370 return vlscm_binop (VALSCM_MAX
, x
, y
, FUNC_NAME
);
373 /* (value-not x) -> <gdb:value> */
376 gdbscm_value_not (SCM x
)
378 return vlscm_unop (VALSCM_NOT
, x
, FUNC_NAME
);
381 /* (value-lognot x) -> <gdb:value> */
384 gdbscm_value_lognot (SCM x
)
386 return vlscm_unop (VALSCM_LOGNOT
, x
, FUNC_NAME
);
389 /* (value-logand x y) -> <gdb:value> */
392 gdbscm_value_logand (SCM x
, SCM y
)
394 return vlscm_binop (VALSCM_BITAND
, x
, y
, FUNC_NAME
);
397 /* (value-logior x y) -> <gdb:value> */
400 gdbscm_value_logior (SCM x
, SCM y
)
402 return vlscm_binop (VALSCM_BITOR
, x
, y
, FUNC_NAME
);
405 /* (value-logxor x y) -> <gdb:value> */
408 gdbscm_value_logxor (SCM x
, SCM y
)
410 return vlscm_binop (VALSCM_BITXOR
, x
, y
, FUNC_NAME
);
413 /* Utility to perform all value comparisons.
414 If there's an error a Scheme exception is thrown. */
417 vlscm_rich_compare (int op
, SCM x
, SCM y
, const char *func_name
)
419 return gdbscm_wrap ([=]
421 struct gdbarch
*gdbarch
= get_current_arch ();
422 const struct language_defn
*language
= current_language
;
425 scoped_value_mark free_values
;
428 = vlscm_convert_value_from_scheme (func_name
, SCM_ARG1
, x
,
429 &except_scm
, gdbarch
, language
);
434 = vlscm_convert_value_from_scheme (func_name
, SCM_ARG2
, y
,
435 &except_scm
, gdbarch
, language
);
443 result
= value_less (v1
, v2
);
446 result
= (value_less (v1
, v2
)
447 || value_equal (v1
, v2
));
450 result
= value_equal (v1
, v2
);
453 gdb_assert_not_reached ("not-equal not implemented");
455 result
= value_less (v2
, v1
);
458 result
= (value_less (v2
, v1
)
459 || value_equal (v1
, v2
));
462 gdb_assert_not_reached ("invalid <gdb:value> comparison");
464 return scm_from_bool (result
);
468 /* (value=? x y) -> boolean
469 There is no "not-equal?" function (value!= ?) on purpose.
470 We're following string=?, etc. as our Guide here. */
473 gdbscm_value_eq_p (SCM x
, SCM y
)
475 return vlscm_rich_compare (BINOP_EQUAL
, x
, y
, FUNC_NAME
);
478 /* (value<? x y) -> boolean */
481 gdbscm_value_lt_p (SCM x
, SCM y
)
483 return vlscm_rich_compare (BINOP_LESS
, x
, y
, FUNC_NAME
);
486 /* (value<=? x y) -> boolean */
489 gdbscm_value_le_p (SCM x
, SCM y
)
491 return vlscm_rich_compare (BINOP_LEQ
, x
, y
, FUNC_NAME
);
494 /* (value>? x y) -> boolean */
497 gdbscm_value_gt_p (SCM x
, SCM y
)
499 return vlscm_rich_compare (BINOP_GTR
, x
, y
, FUNC_NAME
);
502 /* (value>=? x y) -> boolean */
505 gdbscm_value_ge_p (SCM x
, SCM y
)
507 return vlscm_rich_compare (BINOP_GEQ
, x
, y
, FUNC_NAME
);
510 /* Subroutine of vlscm_convert_typed_value_from_scheme to simplify it.
511 Convert OBJ, a Scheme number, to a <gdb:value> object.
512 OBJ_ARG_POS is its position in the argument list, used in exception text.
514 TYPE is the result type. TYPE_ARG_POS is its position in
515 the argument list, used in exception text.
516 TYPE_SCM is Scheme object wrapping TYPE, used in exception text.
518 If the number isn't representable, e.g. it's too big, a <gdb:exception>
519 object is stored in *EXCEPT_SCMP and NULL is returned.
520 The conversion may throw a gdb error, e.g., if TYPE is invalid. */
522 static struct value
*
523 vlscm_convert_typed_number (const char *func_name
, int obj_arg_pos
, SCM obj
,
524 int type_arg_pos
, SCM type_scm
, struct type
*type
,
525 struct gdbarch
*gdbarch
, SCM
*except_scmp
)
527 if (is_integral_type (type
)
528 || TYPE_CODE (type
) == TYPE_CODE_PTR
)
530 if (TYPE_UNSIGNED (type
))
534 get_unsigned_type_max (type
, &max
);
535 if (!scm_is_unsigned_integer (obj
, 0, max
))
538 = gdbscm_make_out_of_range_error (func_name
,
540 _("value out of range for type"));
543 return value_from_longest (type
, gdbscm_scm_to_ulongest (obj
));
549 get_signed_type_minmax (type
, &min
, &max
);
550 if (!scm_is_signed_integer (obj
, min
, max
))
553 = gdbscm_make_out_of_range_error (func_name
,
555 _("value out of range for type"));
558 return value_from_longest (type
, gdbscm_scm_to_longest (obj
));
561 else if (TYPE_CODE (type
) == TYPE_CODE_FLT
)
562 return value_from_host_double (type
, scm_to_double (obj
));
565 *except_scmp
= gdbscm_make_type_error (func_name
, obj_arg_pos
, obj
,
571 /* Return non-zero if OBJ, an integer, fits in TYPE. */
574 vlscm_integer_fits_p (SCM obj
, struct type
*type
)
576 if (TYPE_UNSIGNED (type
))
580 /* If scm_is_unsigned_integer can't work with this type, just punt. */
581 if (TYPE_LENGTH (type
) > sizeof (scm_t_uintmax
))
583 get_unsigned_type_max (type
, &max
);
584 return scm_is_unsigned_integer (obj
, 0, max
);
590 /* If scm_is_signed_integer can't work with this type, just punt. */
591 if (TYPE_LENGTH (type
) > sizeof (scm_t_intmax
))
593 get_signed_type_minmax (type
, &min
, &max
);
594 return scm_is_signed_integer (obj
, min
, max
);
598 /* Subroutine of vlscm_convert_typed_value_from_scheme to simplify it.
599 Convert OBJ, a Scheme number, to a <gdb:value> object.
600 OBJ_ARG_POS is its position in the argument list, used in exception text.
602 If OBJ is an integer, then the smallest int that will hold the value in
603 the following progression is chosen:
604 int, unsigned int, long, unsigned long, long long, unsigned long long.
605 Otherwise, if OBJ is a real number, then it is converted to a double.
606 Otherwise an exception is thrown.
608 If the number isn't representable, e.g. it's too big, a <gdb:exception>
609 object is stored in *EXCEPT_SCMP and NULL is returned. */
611 static struct value
*
612 vlscm_convert_number (const char *func_name
, int obj_arg_pos
, SCM obj
,
613 struct gdbarch
*gdbarch
, SCM
*except_scmp
)
615 const struct builtin_type
*bt
= builtin_type (gdbarch
);
617 /* One thing to keep in mind here is that we are interested in the
618 target's representation of OBJ, not the host's. */
620 if (scm_is_exact (obj
) && scm_is_integer (obj
))
622 if (vlscm_integer_fits_p (obj
, bt
->builtin_int
))
623 return value_from_longest (bt
->builtin_int
,
624 gdbscm_scm_to_longest (obj
));
625 if (vlscm_integer_fits_p (obj
, bt
->builtin_unsigned_int
))
626 return value_from_longest (bt
->builtin_unsigned_int
,
627 gdbscm_scm_to_ulongest (obj
));
628 if (vlscm_integer_fits_p (obj
, bt
->builtin_long
))
629 return value_from_longest (bt
->builtin_long
,
630 gdbscm_scm_to_longest (obj
));
631 if (vlscm_integer_fits_p (obj
, bt
->builtin_unsigned_long
))
632 return value_from_longest (bt
->builtin_unsigned_long
,
633 gdbscm_scm_to_ulongest (obj
));
634 if (vlscm_integer_fits_p (obj
, bt
->builtin_long_long
))
635 return value_from_longest (bt
->builtin_long_long
,
636 gdbscm_scm_to_longest (obj
));
637 if (vlscm_integer_fits_p (obj
, bt
->builtin_unsigned_long_long
))
638 return value_from_longest (bt
->builtin_unsigned_long_long
,
639 gdbscm_scm_to_ulongest (obj
));
641 else if (scm_is_real (obj
))
642 return value_from_host_double (bt
->builtin_double
, scm_to_double (obj
));
644 *except_scmp
= gdbscm_make_out_of_range_error (func_name
, obj_arg_pos
, obj
,
645 _("value not a number representable on the target"));
649 /* Subroutine of vlscm_convert_typed_value_from_scheme to simplify it.
650 Convert BV, a Scheme bytevector, to a <gdb:value> object.
652 TYPE, if non-NULL, is the result type. Otherwise, a vector of type
654 TYPE_SCM is Scheme object wrapping TYPE, used in exception text,
655 or #f if TYPE is NULL.
657 If the bytevector isn't the same size as the type, then a <gdb:exception>
658 object is stored in *EXCEPT_SCMP, and NULL is returned. */
660 static struct value
*
661 vlscm_convert_bytevector (SCM bv
, struct type
*type
, SCM type_scm
,
662 int arg_pos
, const char *func_name
,
663 SCM
*except_scmp
, struct gdbarch
*gdbarch
)
665 LONGEST length
= SCM_BYTEVECTOR_LENGTH (bv
);
670 type
= builtin_type (gdbarch
)->builtin_uint8
;
671 type
= lookup_array_range_type (type
, 0, length
);
672 make_vector_type (type
);
674 type
= check_typedef (type
);
675 if (TYPE_LENGTH (type
) != length
)
677 *except_scmp
= gdbscm_make_out_of_range_error (func_name
, arg_pos
,
679 _("size of type does not match size of bytevector"));
683 value
= value_from_contents (type
,
684 (gdb_byte
*) SCM_BYTEVECTOR_CONTENTS (bv
));
688 /* Convert OBJ, a Scheme value, to a <gdb:value> object.
689 OBJ_ARG_POS is its position in the argument list, used in exception text.
691 TYPE, if non-NULL, is the result type which must be compatible with
692 the value being converted.
693 If TYPE is NULL then a suitable default type is chosen.
694 TYPE_SCM is Scheme object wrapping TYPE, used in exception text,
695 or SCM_UNDEFINED if TYPE is NULL.
696 TYPE_ARG_POS is its position in the argument list, used in exception text,
697 or -1 if TYPE is NULL.
699 OBJ may also be a <gdb:value> object, in which case a copy is returned
700 and TYPE must be NULL.
702 If the value cannot be converted, NULL is returned and a gdb:exception
703 object is stored in *EXCEPT_SCMP.
704 Otherwise the new value is returned, added to the all_values chain. */
707 vlscm_convert_typed_value_from_scheme (const char *func_name
,
708 int obj_arg_pos
, SCM obj
,
709 int type_arg_pos
, SCM type_scm
,
712 struct gdbarch
*gdbarch
,
713 const struct language_defn
*language
)
715 struct value
*value
= NULL
;
716 SCM except_scm
= SCM_BOOL_F
;
720 gdb_assert (type_arg_pos
== -1);
721 gdb_assert (SCM_UNBNDP (type_scm
));
724 *except_scmp
= SCM_BOOL_F
;
728 if (vlscm_is_value (obj
))
732 except_scm
= gdbscm_make_misc_error (func_name
, type_arg_pos
,
734 _("No type allowed"));
738 value
= value_copy (vlscm_scm_to_value (obj
));
740 else if (gdbscm_is_true (scm_bytevector_p (obj
)))
742 value
= vlscm_convert_bytevector (obj
, type
, type_scm
,
743 obj_arg_pos
, func_name
,
744 &except_scm
, gdbarch
);
746 else if (gdbscm_is_bool (obj
))
749 && !is_integral_type (type
))
751 except_scm
= gdbscm_make_type_error (func_name
, type_arg_pos
,
756 value
= value_from_longest (type
758 : language_bool_type (language
,
760 gdbscm_is_true (obj
));
763 else if (scm_is_number (obj
))
767 value
= vlscm_convert_typed_number (func_name
, obj_arg_pos
, obj
,
768 type_arg_pos
, type_scm
, type
,
769 gdbarch
, &except_scm
);
773 value
= vlscm_convert_number (func_name
, obj_arg_pos
, obj
,
774 gdbarch
, &except_scm
);
777 else if (scm_is_string (obj
))
783 except_scm
= gdbscm_make_misc_error (func_name
, type_arg_pos
,
785 _("No type allowed"));
790 /* TODO: Provide option to specify conversion strategy. */
791 gdb::unique_xmalloc_ptr
<char> s
792 = gdbscm_scm_to_string (obj
, &len
,
793 target_charset (gdbarch
),
797 value
= value_cstring (s
.get (), len
,
798 language_string_char_type (language
,
804 else if (lsscm_is_lazy_string (obj
))
808 except_scm
= gdbscm_make_misc_error (func_name
, type_arg_pos
,
810 _("No type allowed"));
815 value
= lsscm_safe_lazy_string_to_value (obj
, obj_arg_pos
,
820 else /* OBJ isn't anything we support. */
822 except_scm
= gdbscm_make_type_error (func_name
, obj_arg_pos
, obj
,
827 catch (const gdb_exception
&except
)
829 except_scm
= gdbscm_scm_from_gdb_exception (unpack (except
));
832 if (gdbscm_is_true (except_scm
))
834 gdb_assert (value
== NULL
);
835 *except_scmp
= except_scm
;
841 /* Wrapper around vlscm_convert_typed_value_from_scheme for cases where there
842 is no supplied type. See vlscm_convert_typed_value_from_scheme for
846 vlscm_convert_value_from_scheme (const char *func_name
,
847 int obj_arg_pos
, SCM obj
,
848 SCM
*except_scmp
, struct gdbarch
*gdbarch
,
849 const struct language_defn
*language
)
851 return vlscm_convert_typed_value_from_scheme (func_name
, obj_arg_pos
, obj
,
852 -1, SCM_UNDEFINED
, NULL
,
857 /* Initialize value math support. */
859 static const scheme_function math_functions
[] =
861 { "value-add", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_add
),
865 { "value-sub", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_sub
),
869 { "value-mul", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_mul
),
873 { "value-div", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_div
),
877 { "value-rem", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_rem
),
881 { "value-mod", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_mod
),
883 Return a mod b. See Knuth 1.2.4." },
885 { "value-pow", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_pow
),
887 Return pow (x, y)." },
889 { "value-not", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_not
),
893 { "value-neg", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_neg
),
897 { "value-pos", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_pos
),
901 { "value-abs", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_abs
),
905 { "value-lsh", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_lsh
),
909 { "value-rsh", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_rsh
),
913 { "value-min", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_min
),
915 Return min (a, b)." },
917 { "value-max", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_max
),
919 Return max (a, b)." },
921 { "value-lognot", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_lognot
),
925 { "value-logand", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_logand
),
929 { "value-logior", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_logior
),
933 { "value-logxor", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_logxor
),
937 { "value=?", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_eq_p
),
941 { "value<?", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_lt_p
),
945 { "value<=?", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_le_p
),
949 { "value>?", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_gt_p
),
953 { "value>=?", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_ge_p
),
961 gdbscm_initialize_math (void)
963 gdbscm_define_functions (math_functions
, 1);