/* Debugging extensions for Guile
- * Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2006, 2008, 2009, 2010, 2011, 2012 Free Software Foundation
+ * Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2006, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
#include <sys/resource.h>
#endif
+#ifdef __MINGW32__
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#endif
+
#include "libguile/_scm.h"
#include "libguile/async.h"
#include "libguile/eval.h"
}
#undef FUNC_NAME
-\f
-SCM_SYMBOL (scm_sym_source, "source");
-
-SCM_DEFINE (scm_procedure_name, "procedure-name", 1, 0, 0,
- (SCM proc),
- "Return the name of the procedure @var{proc}")
-#define FUNC_NAME s_scm_procedure_name
-{
- SCM_VALIDATE_PROC (1, proc);
- while (SCM_STRUCTP (proc) && SCM_STRUCT_APPLICABLE_P (proc))
- proc = SCM_STRUCT_PROCEDURE (proc);
- return scm_procedure_property (proc, scm_sym_name);
-}
-#undef FUNC_NAME
-
-SCM_DEFINE (scm_procedure_source, "procedure-source", 1, 0, 0,
- (SCM proc),
- "Return the source of the procedure @var{proc}.")
-#define FUNC_NAME s_scm_procedure_source
-{
- SCM src;
- SCM_VALIDATE_PROC (1, proc);
-
- do
- {
- src = scm_procedure_property (proc, scm_sym_source);
- if (scm_is_true (src))
- return src;
-
- if (SCM_STRUCTP (proc) && SCM_STRUCT_APPLICABLE_P (proc)
- && SCM_HEAP_OBJECT_P ((proc = SCM_STRUCT_PROCEDURE (proc))))
- continue;
- }
- while (0);
-
- return SCM_BOOL_F;
-}
-#undef FUNC_NAME
-
\f
#undef FUNC_NAME
#endif
+static SCM local_eval_var;
+
+static void
+init_local_eval_var (void)
+{
+ local_eval_var = scm_c_public_variable ("ice-9 local-eval", "local-eval");
+}
+
SCM
scm_local_eval (SCM exp, SCM env)
{
- static SCM local_eval_var = SCM_BOOL_F;
+ static scm_i_pthread_once_t once = SCM_I_PTHREAD_ONCE_INIT;
+ scm_i_pthread_once (&once, init_local_eval_var);
- if (scm_is_false (local_eval_var))
- local_eval_var = scm_c_public_variable ("ice-9 local-eval", "local-eval");
-
- return scm_call_2 (SCM_VARIABLE_REF (local_eval_var), exp, env);
+ return scm_call_2 (scm_variable_ref (local_eval_var), exp, env);
}
static void
init_stack_limit (void)
{
-#ifdef HAVE_GETRLIMIT
+#if defined HAVE_GETRLIMIT
struct rlimit lim;
if (getrlimit (RLIMIT_STACK, &lim) == 0)
{
SCM_STACK_LIMIT = bytes * 8 / 10 / sizeof (scm_t_bits);
}
errno = 0;
+#elif defined __MINGW32__
+ MEMORY_BASIC_INFORMATION m;
+ uintptr_t bytes;
+
+ if (VirtualQuery ((LPCVOID) &m, &m, sizeof m))
+ {
+ bytes = (DWORD_PTR) m.BaseAddress + m.RegionSize
+ - (DWORD_PTR) m.AllocationBase;
+ SCM_STACK_LIMIT = bytes * 8 / 10 / sizeof (scm_t_bits);
+ }
#endif
}