pthread_t mono_gc_get_mach_exception_thread (void) MONO_INTERNAL;
#endif
+gboolean mono_gc_parse_environment_string_extract_number (const char *str, glong *out) MONO_INTERNAL;
+
#endif /* __MONO_METADATA_GC_INTERNAL_H__ */
#include <config.h>
#include <glib.h>
#include <string.h>
+#include <errno.h>
#include <mono/metadata/gc-internal.h>
#include <mono/metadata/mono-gc.h>
return mach_exception_thread;
}
#endif
+
+/**
+ * mono_gc_parse_environment_string_extract_number:
+ *
+ * @str: points to the first digit of the number
+ * @out: pointer to the variable that will receive the value
+ *
+ * Tries to extract a number from the passed string, taking in to account m, k
+ * and g suffixes
+ *
+ * Returns true if passing was successful
+ */
+gboolean
+mono_gc_parse_environment_string_extract_number (const char *str, glong *out)
+{
+ char *endptr;
+ int len = strlen (str), shift = 0;
+ glong val;
+ gboolean is_suffix = FALSE;
+ char suffix;
+
+ switch (str [len - 1]) {
+ case 'g':
+ case 'G':
+ shift += 10;
+ case 'm':
+ case 'M':
+ shift += 10;
+ case 'k':
+ case 'K':
+ shift += 10;
+ is_suffix = TRUE;
+ suffix = str [len - 1];
+ break;
+ }
+
+ errno = 0;
+ val = strtol (str, &endptr, 10);
+
+ if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN))
+ || (errno != 0 && val == 0) || (endptr == str))
+ return FALSE;
+
+ if (is_suffix) {
+ if (*(endptr + 1)) /* Invalid string. */
+ return FALSE;
+ val <<= shift;
+ }
+
+ *out = val;
+ return TRUE;
+}
return result;
}
-/* Tries to extract a number from the passed string, taking in to account m, k
- * and g suffixes */
-gboolean
-mono_sgen_parse_environment_string_extract_number (const char *str, glong *out)
-{
- char *endptr;
- int len = strlen (str), shift = 0;
- glong val;
- gboolean is_suffix = FALSE;
- char suffix;
-
- switch (str [len - 1]) {
- case 'g':
- case 'G':
- shift += 10;
- case 'm':
- case 'M':
- shift += 10;
- case 'k':
- case 'K':
- shift += 10;
- is_suffix = TRUE;
- suffix = str [len - 1];
- break;
- }
-
- errno = 0;
- val = strtol (str, &endptr, 10);
-
- if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN))
- || (errno != 0 && val == 0) || (endptr == str))
- return FALSE;
-
- if (is_suffix) {
- if (*(endptr + 1)) /* Invalid string. */
- return FALSE;
- val <<= shift;
- }
-
- *out = val;
- return TRUE;
-}
-
void
mono_gc_base_init (void)
{
if (g_str_has_prefix (opt, "nursery-size=")) {
long val;
opt = strchr (opt, '=') + 1;
- if (*opt && mono_sgen_parse_environment_string_extract_number (opt, &val)) {
+ if (*opt && mono_gc_parse_environment_string_extract_number (opt, &val)) {
default_nursery_size = val;
#ifdef SGEN_ALIGN_NURSERY
if ((val & (val - 1))) {
#include "metadata/sgen-gc.h"
#include "metadata/sgen-protocol.h"
#include "metadata/sgen-cardtable.h"
-
+#include "metadata/gc-internal.h"
#define DEBUG(l,x)
if (g_str_has_prefix (opt, "major-heap-size=")) {
const char *arg = strchr (opt, '=') + 1;
glong size;
- if (!mono_sgen_parse_environment_string_extract_number (arg, &size))
+ if (!mono_gc_parse_environment_string_extract_number (arg, &size))
return FALSE;
ms_heap_num_blocks = (size + MS_BLOCK_SIZE - 1) / MS_BLOCK_SIZE;
g_assert (ms_heap_num_blocks > 0);