aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pu2/pu2.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/pu2/pu2.c b/pu2/pu2.c
index 61886c0..7fdad50 100644
--- a/pu2/pu2.c
+++ b/pu2/pu2.c
@@ -11,10 +11,10 @@
typedef char *string;
-string read_file(string path, size_t *out_size) {
+string read_file(string path, int *out_size) {
FILE *f = fopen(path, "rb");
string buf;
- size_t size;
+ int size;
if (!f) return NULL;
fseek(f, 0, SEEK_END);
size = ftell(f);
@@ -182,7 +182,7 @@ const bool false = 0;
// use this instead of strdup'ing and allocating extra storage!
typedef struct {
- size_t len;
+ int len;
string ref;
} slice_t;
@@ -193,7 +193,7 @@ typedef struct {
typedef struct {
slice_t name;
- size_t location;
+ int location;
} label_t;
typedef struct {
@@ -247,7 +247,7 @@ clean_slice_ref(slice_t *val) { free(val->ref); }
} else if (*I == '"') { \
string str_start = ++I; \
bool T = false; \
- size_t str_len = 0; \
+ int str_len = 0; \
while (*I != '"' || T) { \
if (*I == '\\') { \
T = !T; \
@@ -891,7 +891,7 @@ string _ir2(string I, macro_t macros[ 1 << 9 ], label_t labels[ 1 << 10 ], label
space;
slice_t arguments[ 1 << 7 ];
- size_t arg_count = 0;
+ int arg_count = 0;
string fail_I = I;
@@ -939,7 +939,7 @@ string _ir2(string I, macro_t macros[ 1 << 9 ], label_t labels[ 1 << 10 ], label
// done reading blob! check it and parse macro :)
// find index
- size_t i;
+ int i;
for (i = 0; i < (1 << 9); i++) {
macro_t cur = macros[ i ];
if (cur.data.key.len != name.len) continue;
@@ -952,7 +952,7 @@ string _ir2(string I, macro_t macros[ 1 << 9 ], label_t labels[ 1 << 10 ], label
if (arg_count != macros[ i ].arg_count) {
run_err(
fail_I,
- "macro argument count mismatch (expected %i, got %li)",
+ "macro argument count mismatch (expected %i, got %i)",
macros[ i ].arg_count,
arg_count);
}
@@ -960,7 +960,7 @@ string _ir2(string I, macro_t macros[ 1 << 9 ], label_t labels[ 1 << 10 ], label
string N = target.ref;
string oldN = N;
memslice_t new = { target.len, malloc(target.len) };
- size_t used = 0;
+ int used = 0;
bool needs_scan = true;
while (needs_scan) {
@@ -972,7 +972,7 @@ string _ir2(string I, macro_t macros[ 1 << 9 ], label_t labels[ 1 << 10 ], label
if (*N == '/' && isdigit(N[ 1 ])) {
N++;
string old = N - 1;
- size_t index = strtol(N, &N, 10);
+ int index = strtol(N, &N, 10);
if (index > arg_count) {
N--;
@@ -1200,9 +1200,9 @@ double bench_cycle(int instr) {
c = 0;
clock_t start = ntime();
- size_t wstart = rdtsc();
+ int wstart = rdtsc();
pu2();
- size_t wend = rdtsc();
+ int wend = rdtsc();
clock_t end = ntime();
double nanoseconds = (end - start);
@@ -1291,9 +1291,9 @@ benchmark(double (*target)(int), const char *mode_label) {
printf("---------------------------------------------\n");
- size_t start = rdtsc();
+ int start = rdtsc();
sleep_milli(100);
- size_t end = rdtsc();
+ int end = rdtsc();
double clock_speed_mhz = ((end - start) / 1e6) * 10;
@@ -1354,14 +1354,14 @@ main(int argc, char **argv) {
}
char *filename = argv[ 1 ];
- size_t file_size;
+ int file_size;
string contents = read_file(filename, &file_size);
if (contents == NULL) {
perror("unable to open file");
exit(1);
}
- size_t o_size;
+ int o_size;
long before = ntime();
long cycles_bef = rdtsc();
ir2(contents);
@@ -1379,7 +1379,7 @@ main(int argc, char **argv) {
free(contents);
- size_t res_size = Code - &m[ 4000 ];
+ int res_size = Code - &m[ 4000 ];
emu();
}