Skip to content

Commit

Permalink
generalize integer literal size compiler option
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Mar 13, 2014
1 parent fdb12bb commit fc1b225
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ static jl_value_t *scm_to_julia_(value_t e, int eo)
}
if (
#ifdef _P64
jl_compileropts.int32_literals
jl_compileropts.int_literals==32
#else
1
jl_compileropts.int_literals!=64
#endif
) {
if (i64 > (int64_t)S32_MAX || i64 < (int64_t)S32_MIN)
Expand Down
2 changes: 1 addition & 1 deletion src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ typedef struct {
char *build_path;
int8_t code_coverage;
int8_t check_bounds;
int8_t int32_literals;
int int_literals;
} jl_compileropts_t;

extern DLLEXPORT jl_compileropts_t jl_compileropts;
Expand Down
16 changes: 12 additions & 4 deletions ui/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ char system_image[256] = JL_SYSTEM_IMAGE_PATH;

static int lisp_prompt = 0;
static int codecov=0;
static int int32lit=0;
static char *program = NULL;
char *image_file = NULL;
int tab_width = 2;
Expand Down Expand Up @@ -45,7 +44,7 @@ static const char *opts =

" --code-coverage Count executions of source lines\n"
" --check-bounds=yes|no Emit bounds checks always or never (ignoring declarations)\n"
" --int32-literals Use Int32 for integer literals on all platforms\n";
" --int-literals=32|64 Select integer literal size independent of platform\n";

void parse_opts(int *argcp, char ***argvp)
{
Expand All @@ -59,7 +58,7 @@ void parse_opts(int *argcp, char ***argvp)
{ "sysimage", required_argument, 0, 'J' },
{ "code-coverage", no_argument, &codecov, 1 },
{ "check-bounds", required_argument, 0, 300 },
{ "int32-literals", no_argument, &int32lit, 1 },
{ "int-literals", required_argument, 0, 301 },
{ 0, 0, 0, 0 }
};
int c;
Expand Down Expand Up @@ -101,14 +100,23 @@ void parse_opts(int *argcp, char ***argvp)
else if (!strcmp(optarg,"no"))
jl_compileropts.check_bounds = JL_COMPILEROPT_CHECK_BOUNDS_OFF;
break;
case 301:
if (!strcmp(optarg,"32"))
jl_compileropts.int_literals = 32;
else if (!strcmp(optarg,"64"))
jl_compileropts.int_literals = 64;
else {
ios_printf(ios_stderr, "julia: invalid integer literal size (%s)\n", optarg);
exit(1);
}
break;
default:
ios_printf(ios_stderr, "julia: unhandled option -- %c\n", c);
ios_printf(ios_stderr, "This is a bug, please report it.\n");
exit(1);
}
}
jl_compileropts.code_coverage = codecov;
jl_compileropts.int32_literals = int32lit;
if (!julia_home) {
julia_home = getenv("JULIA_HOME");
if (julia_home) {
Expand Down

0 comments on commit fc1b225

Please sign in to comment.