aboutsummaryrefslogtreecommitdiff
path: root/gcc/m2/pge-boot/Glibc.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/m2/pge-boot/Glibc.c')
-rw-r--r--gcc/m2/pge-boot/Glibc.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/gcc/m2/pge-boot/Glibc.c b/gcc/m2/pge-boot/Glibc.c
index 3e9b486..e939565 100644
--- a/gcc/m2/pge-boot/Glibc.c
+++ b/gcc/m2/pge-boot/Glibc.c
@@ -116,6 +116,43 @@ libc_printf (char *_format, unsigned int _format_high, ...)
}
EXTERN
+int
+libc_snprintf (char *dest, size_t length, char *_format, unsigned int _format_high, ...)
+{
+ va_list arg;
+ int done;
+ char format[_format_high + 1];
+ unsigned int i = 0;
+ unsigned int j = 0;
+ char *c;
+
+ do
+ {
+ c = index (&_format[i], '\\');
+ if (c == NULL)
+ strcpy (&format[j], &_format[i]);
+ else
+ {
+ memcpy (&format[j], &_format[i], (c - _format) - i);
+ i = c - _format;
+ j += c - _format;
+ if (_format[i + 1] == 'n')
+ format[j] = '\n';
+ else
+ format[j] = _format[i + 1];
+ j++;
+ i += 2;
+ }
+ }
+ while (c != NULL);
+
+ va_start (arg, _format_high);
+ done = vsnprintf (dest, length, format, arg);
+ va_end (arg);
+ return done;
+}
+
+EXTERN
void *
libc_malloc (unsigned int size)
{