Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Patches for AIX #1767

Open
wants to merge 3 commits into
base: bugfix/aix-issues-jq1.6
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/builtin.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#define _BSD_SOURCE
#define _GNU_SOURCE
#ifndef _AIX
#ifndef __sun__
# define _XOPEN_SOURCE
# define _XOPEN_SOURCE_EXTENDED 1
#elif defined _AIX
# define _XOPEN_SOURCE 700
#else
# define _XPG6
# define __EXTENSIONS__
#endif
#endif /* _AIX */
#include <sys/time.h>
#include <stdlib.h>
#include <stddef.h>
3 changes: 2 additions & 1 deletion src/bytecode.c
Original file line number Diff line number Diff line change
@@ -56,7 +56,8 @@ static void dump_code(int indent, struct bytecode* bc) {
}

static void symbol_table_free(struct symbol_table* syms) {
jv_mem_free(syms->cfunctions);
if (syms->cfunctions)
jv_mem_free(syms->cfunctions);
jv_free(syms->cfunc_names);
jv_mem_free(syms);
}
1 change: 1 addition & 0 deletions src/bytecode.h
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ struct cfunction {
struct symbol_table {
struct cfunction* cfunctions;
int ncfunctions;
int lencfunctions;
jv cfunc_names;
};

8 changes: 7 additions & 1 deletion src/compile.c
Original file line number Diff line number Diff line change
@@ -1257,6 +1257,7 @@ static int compile(struct bytecode* bc, block b, struct locfile* lf, jv args, jv
int idx = bc->globals->ncfunctions++;
bc->globals->cfunc_names = jv_array_append(bc->globals->cfunc_names,
jv_string(curr->symbol));
assert(idx <= bc->globals->lencfunctions);
bc->globals->cfunctions[idx] = *curr->imm.cfunc;
curr->imm.intval = idx;
}
@@ -1359,8 +1360,13 @@ int block_compile(block b, struct bytecode** out, struct locfile* lf, jv args) {
bc->nclosures = 0;
bc->globals = jv_mem_alloc(sizeof(struct symbol_table));
int ncfunc = count_cfunctions(b);
bc->globals->lencfunctions = ncfunc;
bc->globals->ncfunctions = 0;
bc->globals->cfunctions = jv_mem_calloc(sizeof(struct cfunction), ncfunc);
if (ncfunc > 0) {
bc->globals->cfunctions = jv_mem_calloc(sizeof(struct cfunction), ncfunc);
} else {
bc->globals->cfunctions = NULL;
}
bc->globals->cfunc_names = jv_array();
bc->debuginfo = jv_object_set(jv_object(), jv_string("name"), jv_null());
jv env = jv_invalid();