Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit 25be69f

Browse files
committedJan 15, 2014
work towards making libjulia combilable with a c++ compiler (required for MSVC)
1 parent c6d359b commit 25be69f

37 files changed

+269
-224
lines changed
 

‎Windows.inc

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,20 @@ WINVER = 0x0600
3030

3131
###############################################################################
3232

33+
!ifdef INTEL
3334
CC = icl /nologo /Qstd=c99
3435
LINK = xilink /nologo
3536
AR = xilib /nologo
37+
!else
38+
CC = cl /nologo /TP
39+
LINK = link /nologo
40+
AR = lib /nologo
41+
!endif
3642

3743
###############################################################################
3844

3945
CFLAGS = /c /DCRTAPI1=_cdecl /DCRTAPI2=_cdecl /GS /D_WINNT /D_WIN32_WINNT=$(WINVER) /DNTDDI_VERSION=$(WINVER)0000 /DWINVER=$(WINVER) /DWIN32 /D_WIN32
40-
LFLAGS = /INCREMENTAL:NO
46+
LFLAGS = /INCREMENTAL:NO /NODEFAULTLIB:MSVCRT
4147

4248
!if "$(CPU)" == "i386"
4349
CFLAGS = $(CFLAGS) /D_X86_=1

‎src/Windows.mk

+7-3
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@ LIBSUPPORT = support\libsupport.lib
3838
LIBUV = ..\deps\libuv\libuv.lib
3939
FLISP = flisp\flisp.exe
4040

41-
INCLUDE = $(INCLUDE);$(MAKEDIR)\..\deps\libuv\include;$(MAKEDIR)\flisp;$(MAKEDIR)\support;C:\Program Files\LLVM\include;
42-
LIB = $(LIB);C:\Program Files\LLVM\lib;
41+
INCLUDE = $(INCLUDE);$(MAKEDIR)\..\deps\libuv\include;$(MAKEDIR)\flisp;$(MAKEDIR)\support;C:\Program Files\llvm\include
42+
!ifdef DEBUG
43+
LIB = $(LIB);C:\Program Files\llvm\lib\Debug
44+
!else
45+
LIB = $(LIB);C:\Program Files\llvm\lib\Release
46+
!endif
4347

4448
CFLAGS = $(CFLAGS) -DCOPY_STACKS -D_CRT_SECURE_NO_WARNINGS
45-
CFLAGS = $(CFLAGS) -DJL_SYSTEM_IMAGE_PATH=\"../lib/julia/sys.ji\"
49+
CFLAGS = $(CFLAGS) -DJL_SYSTEM_IMAGE_PATH=\"../lib/julia/sys.ji\" -DLIBRARY_EXPORTS
4650

4751
LIBWINDOWS = \
4852
kernel32.lib \

‎src/alloc.c

+21-21
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ jl_sym_t *jl_symbol_lookup(const char *str)
472472

473473
DLLEXPORT jl_sym_t *jl_symbol_n(const char *str, int32_t len)
474474
{
475-
char name[len+1];
475+
char* name = (char*) alloca(len+1);
476476
memcpy(name, str, len);
477477
name[len] = '\0';
478478
return jl_symbol(name);
@@ -497,7 +497,7 @@ DLLEXPORT jl_sym_t *jl_gensym(void)
497497
DLLEXPORT jl_sym_t *jl_tagged_gensym(const char* str, int32_t len)
498498
{
499499
static char gs_name[14];
500-
char name[sizeof(gs_name)+len+3];
500+
char *name = (char*) alloca(sizeof(gs_name)+len+3);
501501
char *n;
502502
name[0] = '#'; name[1] = '#'; name[2+len] = '#';
503503
memcpy(name+2, str, len);
@@ -714,7 +714,7 @@ jl_value_t *jl_box##nb(jl_datatype_t *t, int##nb##_t x) \
714714
{ \
715715
assert(jl_is_bitstype(t)); \
716716
assert(jl_datatype_size(t) == sizeof(x)); \
717-
jl_value_t *v = alloc_##nw##w(); \
717+
jl_value_t *v = (jl_value_t*) alloc_##nw##w(); \
718718
v->type = (jl_value_t*)t; \
719719
*(int##nb##_t*)jl_data_ptr(v) = x; \
720720
return v; \
@@ -748,13 +748,13 @@ UNBOX_FUNC(float32, float)
748748
UNBOX_FUNC(float64, double)
749749
UNBOX_FUNC(voidpointer, void*)
750750

751-
#define BOX_FUNC(typ,c_type,pfx,nw) \
752-
jl_value_t *pfx##_##typ(c_type x) \
753-
{ \
754-
jl_value_t *v = alloc_##nw##w(); \
755-
v->type = (jl_value_t*)jl_##typ##_type; \
756-
*(c_type*)jl_data_ptr(v) = x; \
757-
return v; \
751+
#define BOX_FUNC(typ,c_type,pfx,nw) \
752+
jl_value_t *pfx##_##typ(c_type x) \
753+
{ \
754+
jl_value_t *v = (jl_value_t*) alloc_##nw##w();\
755+
v->type = (jl_value_t*)jl_##typ##_type; \
756+
*(c_type*)jl_data_ptr(v) = x; \
757+
return v; \
758758
}
759759
BOX_FUNC(float32, float, jl_box, 2)
760760
BOX_FUNC(voidpointer, void*, jl_box, 2) //2 pointers == two words on all platforms
@@ -773,21 +773,21 @@ jl_value_t *jl_box_##typ(c_type x) \
773773
c_type idx = x+NBOX_C/2; \
774774
if ((u##c_type)idx < (u##c_type)NBOX_C) \
775775
return boxed_##typ##_cache[idx]; \
776-
jl_value_t *v = alloc_##nw##w(); \
776+
jl_value_t *v = (jl_value_t*) alloc_##nw##w(); \
777777
v->type = (jl_value_t*)jl_##typ##_type; \
778778
*(c_type*)jl_data_ptr(v) = x; \
779779
return v; \
780780
}
781-
#define UIBOX_FUNC(typ,c_type,nw) \
782-
static jl_value_t *boxed_##typ##_cache[NBOX_C]; \
783-
jl_value_t *jl_box_##typ(c_type x) \
784-
{ \
785-
if (x < NBOX_C) \
786-
return boxed_##typ##_cache[x]; \
787-
jl_value_t *v = alloc_##nw##w(); \
788-
v->type = (jl_value_t*)jl_##typ##_type; \
789-
*(c_type*)jl_data_ptr(v) = x; \
790-
return v; \
781+
#define UIBOX_FUNC(typ,c_type,nw) \
782+
static jl_value_t *boxed_##typ##_cache[NBOX_C]; \
783+
jl_value_t *jl_box_##typ(c_type x) \
784+
{ \
785+
if (x < NBOX_C) \
786+
return boxed_##typ##_cache[x]; \
787+
jl_value_t *v = (jl_value_t*) alloc_##nw##w(); \
788+
v->type = (jl_value_t*)jl_##typ##_type; \
789+
*(c_type*)jl_data_ptr(v) = x; \
790+
return v; \
791791
}
792792
SIBOX_FUNC(int16, int16_t, 2)
793793
SIBOX_FUNC(int32, int32_t, 2)

‎src/array.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims,
7373
size_t doffs = tsz;
7474
tsz += tot;
7575
tsz = (tsz+15)&-16; // align whole object 16
76-
a = allocobj(tsz);
76+
a = (jl_array_t*) allocobj(tsz);
7777
a->type = atype;
7878
a->how = 0;
7979
data = (char*)a + doffs;
@@ -83,7 +83,7 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims,
8383
}
8484
else {
8585
tsz = (tsz+15)&-16; // align whole object size 16
86-
a = allocobj(tsz);
86+
a = (jl_array_t*) allocobj(tsz);
8787
JL_GC_PUSH1(&a);
8888
a->type = atype;
8989
// temporarily initialize to make gc-safe
@@ -143,7 +143,7 @@ jl_array_t *jl_reshape_array(jl_value_t *atype, jl_array_t *data, jl_tuple_t *di
143143
size_t ndims = jl_tuple_len(dims);
144144

145145
int ndimwords = jl_array_ndimwords(ndims);
146-
a = allocobj((sizeof(jl_array_t) + sizeof(void*) + ndimwords*sizeof(size_t) + 15)&-16);
146+
a = (jl_array_t*) allocobj((sizeof(jl_array_t) + sizeof(void*) + ndimwords*sizeof(size_t) + 15)&-16);
147147
a->type = atype;
148148
a->ndims = ndims;
149149
a->offset = 0;
@@ -208,7 +208,7 @@ jl_array_t *jl_ptr_to_array_1d(jl_value_t *atype, void *data, size_t nel,
208208
else
209209
elsz = sizeof(void*);
210210

211-
a = allocobj((sizeof(jl_array_t)+jl_array_ndimwords(1)*sizeof(size_t)+15)&-16);
211+
a = (jl_array_t*) allocobj((sizeof(jl_array_t)+jl_array_ndimwords(1)*sizeof(size_t)+15)&-16);
212212
a->type = atype;
213213
a->data = data;
214214
#ifdef STORE_ARRAY_LEN
@@ -256,7 +256,7 @@ jl_array_t *jl_ptr_to_array(jl_value_t *atype, void *data, jl_tuple_t *dims,
256256
elsz = sizeof(void*);
257257

258258
int ndimwords = jl_array_ndimwords(ndims);
259-
a = allocobj((sizeof(jl_array_t) + ndimwords*sizeof(size_t)+15)&-16);
259+
a = (jl_array_t*) allocobj((sizeof(jl_array_t) + ndimwords*sizeof(size_t)+15)&-16);
260260
a->type = atype;
261261
a->data = data;
262262
#ifdef STORE_ARRAY_LEN
@@ -292,7 +292,7 @@ jl_array_t *jl_ptr_to_array(jl_value_t *atype, void *data, jl_tuple_t *dims,
292292
jl_array_t *jl_new_array(jl_value_t *atype, jl_tuple_t *dims)
293293
{
294294
size_t ndims = jl_tuple_len(dims);
295-
size_t *adims = alloca(ndims*sizeof(size_t));
295+
size_t *adims = (size_t*) alloca(ndims*sizeof(size_t));
296296
size_t i;
297297
for(i=0; i < ndims; i++)
298298
adims[i] = jl_unbox_long(jl_tupleref(dims,i));
@@ -326,9 +326,9 @@ jl_array_t *jl_pchar_to_array(const char *str, size_t len)
326326
jl_value_t *jl_array_to_string(jl_array_t *a)
327327
{
328328
// TODO: check type of array?
329-
jl_datatype_t* string_type = u8_isvalid(a->data, jl_array_len(a)) == 1 ? // ASCII
329+
jl_datatype_t* string_type = u8_isvalid( (char*) a->data, jl_array_len(a)) == 1 ? // ASCII
330330
jl_ascii_string_type : jl_utf8_string_type;
331-
jl_value_t *s = alloc_2w();
331+
jl_value_t *s = (jl_value_t*) alloc_2w();
332332
s->type = (jl_value_t*)string_type;
333333
jl_set_nth_field(s, 0, (jl_value_t*)a);
334334
return s;
@@ -523,21 +523,21 @@ static void array_resize_buffer(jl_array_t *a, size_t newlen, size_t oldlen, siz
523523
char *newdata;
524524
if (a->how == 2) {
525525
// already malloc'd - use realloc
526-
newdata = jl_gc_managed_realloc((char*)a->data - oldoffsnb, nbytes,
526+
newdata = (char*) jl_gc_managed_realloc((char*)a->data - oldoffsnb, nbytes,
527527
oldnbytes+oldoffsnb, a->isaligned);
528528
if (offs != a->offset) {
529529
memmove(&newdata[offsnb], &newdata[oldoffsnb], oldnbytes);
530530
}
531531
}
532532
else {
533533
if (nbytes >= MALLOC_THRESH) {
534-
newdata = jl_gc_managed_malloc(nbytes);
534+
newdata = (char*) jl_gc_managed_malloc(nbytes);
535535
jl_gc_track_malloced_array(a);
536536
a->how = 2;
537537
a->isaligned = 1;
538538
}
539539
else {
540-
newdata = allocb(nbytes);
540+
newdata = (char*) allocb(nbytes);
541541
a->how = 1;
542542
}
543543
memcpy(newdata + offsnb, (char*)a->data, oldnbytes);

‎src/ast.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "julia.h"
1313
#include "flisp.h"
1414

15-
static char flisp_system_image[] = {
15+
static uint8_t flisp_system_image[] = {
1616
#include "julia_flisp.boot.inc"
1717
};
1818

@@ -111,7 +111,7 @@ DLLEXPORT void jl_init_frontend(void)
111111
fl_init(2*512*1024);
112112
value_t img = cvalue(iostreamtype, sizeof(ios_t));
113113
ios_t *pi = value2c(ios_t*, img);
114-
ios_static_buffer(pi, flisp_system_image, sizeof(flisp_system_image));
114+
ios_static_buffer(pi, (char*) flisp_system_image, sizeof(flisp_system_image));
115115

116116
if (fl_load_system_image(img)) {
117117
JL_PRINTF(JL_STDERR, "fatal error loading system image\n");
@@ -240,7 +240,7 @@ static jl_value_t *scm_to_julia_(value_t e, int eo)
240240
return (jl_value_t*)scmsym_to_julia(e);
241241
}
242242
if (fl_isstring(e)) {
243-
return jl_pchar_to_string(cvalue_data(e), cvalue_len(e));
243+
return jl_pchar_to_string( (char*) cvalue_data(e), cvalue_len(e));
244244
}
245245
if (e == FL_F) {
246246
return jl_false;

‎src/builtins.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ JL_CALLABLE(jl_f_apply)
254254
jl_tuple_len(args[1]));
255255
}
256256
}
257+
jl_value_t **newargs;
257258
size_t n=0, i, j;
258259
for(i=1; i < nargs; i++) {
259260
if (jl_is_tuple(args[i])) {
@@ -275,7 +276,7 @@ JL_CALLABLE(jl_f_apply)
275276
goto fancy_apply;
276277
}
277278
}
278-
jl_value_t **newargs = alloca(n * sizeof(jl_value_t*));
279+
newargs = (jl_value_t**) alloca(n * sizeof(jl_value_t*));
279280
n = 0;
280281
for(i=1; i < nargs; i++) {
281282
if (jl_is_tuple(args[i])) {

‎src/cgutils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ static Type *julia_type_to_llvm(jl_value_t *jt)
233233
return ret;
234234
}
235235
else {
236-
Type *types[ntypes];
236+
Type **types = (Type**) alloca(ntypes*sizeof(Type*));
237237
size_t j = 0;
238238
for (size_t i = 0; i < ntypes; ++i) {
239239
Type *ty = julia_struct_to_llvm(jl_tupleref(jt,i));

‎src/dlload.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static uv_lib_t *jl_load_dynamic_library_(char *modname, unsigned flags, int thr
8080
char *ext;
8181
char path[PATHBUF];
8282
int i;
83-
uv_lib_t *handle=malloc(sizeof(uv_lib_t));
83+
uv_lib_t *handle = (uv_lib_t*) malloc(sizeof(uv_lib_t));
8484
handle->errmsg=NULL;
8585

8686
if (modname == NULL) {

0 commit comments

Comments
 (0)
This repository has been archived.