Add all the assignment code.
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
58c6b1f81c
commit
cfe502c598
1277 changed files with 48709 additions and 1 deletions
38
hw5/ll/llruntime.c
Normal file
38
hw5/ll/llruntime.c
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* TODO: if we enforce that all char literals are null-terminated,
|
||||
and all allocated memory is zero-initialized, are these safe
|
||||
when llvmlite program does not exhibit UB? */
|
||||
|
||||
void *ll_malloc(int64_t n, int64_t size) {
|
||||
return calloc(n, size);
|
||||
}
|
||||
|
||||
int64_t ll_strlen(int8_t *s) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t *ll_strncopy(int8_t *dst, int8_t *src, int64_t i) {
|
||||
int64_t src_size = ll_strlen(src);
|
||||
int64_t dst_size = ll_strlen(dst);
|
||||
if (i >= dst_size)
|
||||
return dst;
|
||||
else
|
||||
return (int8_t*)strncpy((char *)dst + i, (char *)src, dst_size - i);
|
||||
}
|
||||
|
||||
void ll_puts(int8_t *s) {
|
||||
puts((char *)s);
|
||||
}
|
||||
|
||||
int64_t ll_atol(int8_t *s) {
|
||||
return atol((char *)s);
|
||||
}
|
||||
|
||||
int64_t ll_ltoa(int64_t i, int8_t *dst) {
|
||||
int64_t size = ll_strlen(dst);
|
||||
return snprintf((char *)dst, size, "%ld", (long)i);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue