1.1 --- a/templates/native.c Sat Dec 03 17:16:15 2016 +0100
1.2 +++ b/templates/native.c Sat Dec 03 17:34:44 2016 +0100
1.3 @@ -103,6 +103,20 @@
1.4 return x->value != y->value ? __builtins___boolean_True : __builtins___boolean_False;
1.5 }
1.6
1.7 +__attr __fn_native__get_maxint(__attr __args[])
1.8 +{
1.9 + __attr * const status = &__args[1];
1.10 +
1.11 + return __new_int(INT_MAX);
1.12 +}
1.13 +
1.14 +__attr __fn_native__get_minint(__attr __args[])
1.15 +{
1.16 + __attr * const status = &__args[1];
1.17 +
1.18 + return __new_int(INT_MIN);
1.19 +}
1.20 +
1.21 __attr __fn_native__int_add(__attr __args[])
1.22 {
1.23 __attr * const _data = &__args[1];
1.24 @@ -332,10 +346,11 @@
1.25 __attr * const _data = &__args[1];
1.26 /* _data interpreted as int */
1.27 int i = _data->intvalue;
1.28 - int n = i != 0 ? (int) ceil(log10(abs(i)+1)) + 1 : 2;
1.29 + /* Employ a buffer big enough to fit the largest integer plus an extra
1.30 + character, a minus sign, and the null terminator. */
1.31 + unsigned int n = (int) log10(INT_MAX) + 3;
1.32 char *s = (char *) __ALLOCATE(n, sizeof(char));
1.33
1.34 - if (i < 0) n++;
1.35 snprintf(s, n, "%d", i);
1.36
1.37 /* Return a new string. */