/* General utility routines for GDB/Scheme code.
- Copyright (C) 2014 Free Software Foundation, Inc.
+ Copyright (C) 2014-2016 Free Software Foundation, Inc.
This file is part of GDB.
conventions, et.al. */
#include "defs.h"
-#include <stdarg.h>
-#include <stdint.h>
-#include "gdb_assert.h"
#include "guile-internal.h"
/* Define VARIABLES in the gdb module. */
void
-gdbscm_define_variables (const scheme_variable *variables, int public)
+gdbscm_define_variables (const scheme_variable *variables, int is_public)
{
const scheme_variable *sv;
for (sv = variables; sv->name != NULL; ++sv)
{
scm_c_define (sv->name, sv->value);
- if (public)
+ if (is_public)
scm_c_export (sv->name, NULL);
}
}
/* Define FUNCTIONS in the gdb module. */
void
-gdbscm_define_functions (const scheme_function *functions, int public)
+gdbscm_define_functions (const scheme_function *functions, int is_public)
{
const scheme_function *sf;
scm_set_procedure_property_x (proc, gdbscm_documentation_symbol,
gdbscm_scm_from_c_string (sf->doc_string));
- if (public)
+ if (is_public)
scm_c_export (sf->name, NULL);
}
}
void
gdbscm_define_integer_constants (const scheme_integer_constant *constants,
- int public)
+ int is_public)
{
const scheme_integer_constant *sc;
for (sc = constants; sc->name != NULL; ++sc)
{
scm_c_define (sc->name, scm_from_int (sc->value));
- if (public)
+ if (is_public)
scm_c_export (sc->name, NULL);
}
}
{
case 's':
{
- char **arg_ptr = argp;
+ char **arg_ptr = (char **) argp;
CHECK_TYPE (gdbscm_is_true (scm_string_p (arg)), arg, position,
func_name, _("string"));
}
case 't':
{
- int *arg_ptr = argp;
+ int *arg_ptr = (int *) argp;
/* While in Scheme, anything non-#f is "true", we're strict. */
CHECK_TYPE (gdbscm_is_bool (arg), arg, position, func_name,
}
case 'i':
{
- int *arg_ptr = argp;
+ int *arg_ptr = (int *) argp;
CHECK_TYPE (scm_is_signed_integer (arg, INT_MIN, INT_MAX),
arg, position, func_name, _("int"));
}
case 'u':
{
- int *arg_ptr = argp;
+ int *arg_ptr = (int *) argp;
CHECK_TYPE (scm_is_unsigned_integer (arg, 0, UINT_MAX),
arg, position, func_name, _("unsigned int"));
}
case 'l':
{
- long *arg_ptr = argp;
+ long *arg_ptr = (long *) argp;
CHECK_TYPE (scm_is_signed_integer (arg, LONG_MIN, LONG_MAX),
arg, position, func_name, _("long"));
}
case 'n':
{
- unsigned long *arg_ptr = argp;
+ unsigned long *arg_ptr = (unsigned long *) argp;
CHECK_TYPE (scm_is_unsigned_integer (arg, 0, ULONG_MAX),
arg, position, func_name, _("unsigned long"));
}
case 'L':
{
- LONGEST *arg_ptr = argp;
+ LONGEST *arg_ptr = (LONGEST *) argp;
CHECK_TYPE (scm_is_signed_integer (arg, INT64_MIN, INT64_MAX),
arg, position, func_name, _("LONGEST"));
}
case 'U':
{
- ULONGEST *arg_ptr = argp;
+ ULONGEST *arg_ptr = (ULONGEST *) argp;
CHECK_TYPE (scm_is_unsigned_integer (arg, 0, UINT64_MAX),
arg, position, func_name, _("ULONGEST"));
}
case 'O':
{
- SCM *arg_ptr = argp;
+ SCM *arg_ptr = (SCM *) argp;
*arg_ptr = arg;
break;
if (num_keywords > 0)
{
- SCM *keyword_args = (SCM *) alloca (num_keywords * sizeof (SCM));
- int *keyword_positions = (int *) alloca (num_keywords * sizeof (int));
+ SCM *keyword_args = XALLOCAVEC (SCM, num_keywords);
+ int *keyword_positions = XALLOCAVEC (int, num_keywords);
gdb_assert (*p == '#');
++p;
gdbscm_gc_xstrdup (const char *str)
{
size_t len = strlen (str);
- char *result = scm_gc_malloc_pointerless (len + 1, "gdbscm_gc_xstrdup");
+ char *result
+ = (char *) scm_gc_malloc_pointerless (len + 1, "gdbscm_gc_xstrdup");
strcpy (result, str);
return result;
/* Allocating "pointerless" works because the pointers are all
self-contained within the object. */
- result = scm_gc_malloc_pointerless (((len + 1) * sizeof (char *))
- + string_space, "parameter enum list");
+ result = (char **) scm_gc_malloc_pointerless (((len + 1) * sizeof (char *))
+ + string_space,
+ "parameter enum list");
p = (char *) &result[len + 1];
for (i = 0; i < len; ++i)
return (const char * const *) result;
}
+
+/* Return non-zero if the version of Guile being used it at least
+ MAJOR.MINOR.MICRO. */
+
+int
+gdbscm_guile_version_is_at_least (int major, int minor, int micro)
+{
+ if (major > gdbscm_guile_major_version)
+ return 0;
+ if (major < gdbscm_guile_major_version)
+ return 1;
+ if (minor > gdbscm_guile_minor_version)
+ return 0;
+ if (minor < gdbscm_guile_minor_version)
+ return 1;
+ if (micro > gdbscm_guile_micro_version)
+ return 0;
+ return 1;
+}