Skip to content

Commit

Permalink
formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jan 16, 2014
1 parent 00c04c7 commit 5555f4f
Show file tree
Hide file tree
Showing 31 changed files with 200 additions and 200 deletions.
28 changes: 14 additions & 14 deletions src/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ jl_sym_t *jl_symbol_lookup(const char *str)

DLLEXPORT jl_sym_t *jl_symbol_n(const char *str, int32_t len)
{
char* name = (char*) alloca(len+1);
char *name = (char*)alloca(len+1);
memcpy(name, str, len);
name[len] = '\0';
return jl_symbol(name);
Expand All @@ -497,7 +497,7 @@ DLLEXPORT jl_sym_t *jl_gensym(void)
DLLEXPORT jl_sym_t *jl_tagged_gensym(const char* str, int32_t len)
{
static char gs_name[14];
char *name = (char*) alloca(sizeof(gs_name)+len+3);
char *name = (char*)alloca(sizeof(gs_name)+len+3);
char *n;
name[0] = '#'; name[1] = '#'; name[2+len] = '#';
memcpy(name+2, str, len);
Expand Down Expand Up @@ -709,15 +709,15 @@ jl_typector_t *jl_new_type_ctor(jl_tuple_t *params, jl_value_t *body)

// bits constructors ----------------------------------------------------------

#define BOXN_FUNC(nb,nw) \
jl_value_t *jl_box##nb(jl_datatype_t *t, int##nb##_t x) \
{ \
assert(jl_is_bitstype(t)); \
assert(jl_datatype_size(t) == sizeof(x)); \
jl_value_t *v = (jl_value_t*) alloc_##nw##w(); \
v->type = (jl_value_t*)t; \
*(int##nb##_t*)jl_data_ptr(v) = x; \
return v; \
#define BOXN_FUNC(nb,nw) \
jl_value_t *jl_box##nb(jl_datatype_t *t, int##nb##_t x) \
{ \
assert(jl_is_bitstype(t)); \
assert(jl_datatype_size(t) == sizeof(x)); \
jl_value_t *v = (jl_value_t*)alloc_##nw##w(); \
v->type = (jl_value_t*)t; \
*(int##nb##_t*)jl_data_ptr(v) = x; \
return v; \
}
BOXN_FUNC(8, 2)
BOXN_FUNC(16, 2)
Expand Down Expand Up @@ -751,7 +751,7 @@ UNBOX_FUNC(voidpointer, void*)
#define BOX_FUNC(typ,c_type,pfx,nw) \
jl_value_t *pfx##_##typ(c_type x) \
{ \
jl_value_t *v = (jl_value_t*) alloc_##nw##w();\
jl_value_t *v = (jl_value_t*)alloc_##nw##w(); \
v->type = (jl_value_t*)jl_##typ##_type; \
*(c_type*)jl_data_ptr(v) = x; \
return v; \
Expand All @@ -773,7 +773,7 @@ jl_value_t *jl_box_##typ(c_type x) \
c_type idx = x+NBOX_C/2; \
if ((u##c_type)idx < (u##c_type)NBOX_C) \
return boxed_##typ##_cache[idx]; \
jl_value_t *v = (jl_value_t*) alloc_##nw##w(); \
jl_value_t *v = (jl_value_t*)alloc_##nw##w(); \
v->type = (jl_value_t*)jl_##typ##_type; \
*(c_type*)jl_data_ptr(v) = x; \
return v; \
Expand All @@ -784,7 +784,7 @@ jl_value_t *jl_box_##typ(c_type x) \
{ \
if (x < NBOX_C) \
return boxed_##typ##_cache[x]; \
jl_value_t *v = (jl_value_t*) alloc_##nw##w(); \
jl_value_t *v = (jl_value_t*)alloc_##nw##w(); \
v->type = (jl_value_t*)jl_##typ##_type; \
*(c_type*)jl_data_ptr(v) = x; \
return v; \
Expand Down
24 changes: 12 additions & 12 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims,
size_t doffs = tsz;
tsz += tot;
tsz = (tsz+15)&-16; // align whole object 16
a = (jl_array_t*) allocobj(tsz);
a = (jl_array_t*)allocobj(tsz);
a->type = atype;
a->how = 0;
data = (char*)a + doffs;
Expand All @@ -83,7 +83,7 @@ static jl_array_t *_new_array_(jl_value_t *atype, uint32_t ndims, size_t *dims,
}
else {
tsz = (tsz+15)&-16; // align whole object size 16
a = (jl_array_t*) allocobj(tsz);
a = (jl_array_t*)allocobj(tsz);
JL_GC_PUSH1(&a);
a->type = atype;
// temporarily initialize to make gc-safe
Expand Down Expand Up @@ -143,7 +143,7 @@ jl_array_t *jl_reshape_array(jl_value_t *atype, jl_array_t *data, jl_tuple_t *di
size_t ndims = jl_tuple_len(dims);

int ndimwords = jl_array_ndimwords(ndims);
a = (jl_array_t*) allocobj((sizeof(jl_array_t) + sizeof(void*) + ndimwords*sizeof(size_t) + 15)&-16);
a = (jl_array_t*)allocobj((sizeof(jl_array_t) + sizeof(void*) + ndimwords*sizeof(size_t) + 15)&-16);
a->type = atype;
a->ndims = ndims;
a->offset = 0;
Expand Down Expand Up @@ -208,7 +208,7 @@ jl_array_t *jl_ptr_to_array_1d(jl_value_t *atype, void *data, size_t nel,
else
elsz = sizeof(void*);

a = (jl_array_t*) allocobj((sizeof(jl_array_t)+jl_array_ndimwords(1)*sizeof(size_t)+15)&-16);
a = (jl_array_t*)allocobj((sizeof(jl_array_t)+jl_array_ndimwords(1)*sizeof(size_t)+15)&-16);
a->type = atype;
a->data = data;
#ifdef STORE_ARRAY_LEN
Expand Down Expand Up @@ -256,7 +256,7 @@ jl_array_t *jl_ptr_to_array(jl_value_t *atype, void *data, jl_tuple_t *dims,
elsz = sizeof(void*);

int ndimwords = jl_array_ndimwords(ndims);
a = (jl_array_t*) allocobj((sizeof(jl_array_t) + ndimwords*sizeof(size_t)+15)&-16);
a = (jl_array_t*)allocobj((sizeof(jl_array_t) + ndimwords*sizeof(size_t)+15)&-16);
a->type = atype;
a->data = data;
#ifdef STORE_ARRAY_LEN
Expand Down Expand Up @@ -292,7 +292,7 @@ jl_array_t *jl_ptr_to_array(jl_value_t *atype, void *data, jl_tuple_t *dims,
jl_array_t *jl_new_array(jl_value_t *atype, jl_tuple_t *dims)
{
size_t ndims = jl_tuple_len(dims);
size_t *adims = (size_t*) alloca(ndims*sizeof(size_t));
size_t *adims = (size_t*)alloca(ndims*sizeof(size_t));
size_t i;
for(i=0; i < ndims; i++)
adims[i] = jl_unbox_long(jl_tupleref(dims,i));
Expand Down Expand Up @@ -326,9 +326,9 @@ jl_array_t *jl_pchar_to_array(const char *str, size_t len)
jl_value_t *jl_array_to_string(jl_array_t *a)
{
// TODO: check type of array?
jl_datatype_t* string_type = u8_isvalid( (char*) a->data, jl_array_len(a)) == 1 ? // ASCII
jl_datatype_t* string_type = u8_isvalid((char*)a->data, jl_array_len(a)) == 1 ? // ASCII
jl_ascii_string_type : jl_utf8_string_type;
jl_value_t *s = (jl_value_t*) alloc_2w();
jl_value_t *s = (jl_value_t*)alloc_2w();
s->type = (jl_value_t*)string_type;
jl_set_nth_field(s, 0, (jl_value_t*)a);
return s;
Expand Down Expand Up @@ -523,21 +523,21 @@ static void array_resize_buffer(jl_array_t *a, size_t newlen, size_t oldlen, siz
char *newdata;
if (a->how == 2) {
// already malloc'd - use realloc
newdata = (char*) jl_gc_managed_realloc((char*)a->data - oldoffsnb, nbytes,
oldnbytes+oldoffsnb, a->isaligned);
newdata = (char*)jl_gc_managed_realloc((char*)a->data - oldoffsnb, nbytes,
oldnbytes+oldoffsnb, a->isaligned);
if (offs != a->offset) {
memmove(&newdata[offsnb], &newdata[oldoffsnb], oldnbytes);
}
}
else {
if (nbytes >= MALLOC_THRESH) {
newdata = (char*) jl_gc_managed_malloc(nbytes);
newdata = (char*)jl_gc_managed_malloc(nbytes);
jl_gc_track_malloced_array(a);
a->how = 2;
a->isaligned = 1;
}
else {
newdata = (char*) allocb(nbytes);
newdata = (char*)allocb(nbytes);
a->how = 1;
}
memcpy(newdata + offsnb, (char*)a->data, oldnbytes);
Expand Down
4 changes: 2 additions & 2 deletions src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ DLLEXPORT void jl_init_frontend(void)
fl_init(2*512*1024);
value_t img = cvalue(iostreamtype, sizeof(ios_t));
ios_t *pi = value2c(ios_t*, img);
ios_static_buffer(pi, (char*) flisp_system_image, sizeof(flisp_system_image));
ios_static_buffer(pi, (char*)flisp_system_image, sizeof(flisp_system_image));

if (fl_load_system_image(img)) {
JL_PRINTF(JL_STDERR, "fatal error loading system image\n");
Expand Down Expand Up @@ -240,7 +240,7 @@ static jl_value_t *scm_to_julia_(value_t e, int eo)
return (jl_value_t*)scmsym_to_julia(e);
}
if (fl_isstring(e)) {
return jl_pchar_to_string( (char*) cvalue_data(e), cvalue_len(e));
return jl_pchar_to_string((char*)cvalue_data(e), cvalue_len(e));
}
if (e == FL_F) {
return jl_false;
Expand Down
2 changes: 1 addition & 1 deletion src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ JL_CALLABLE(jl_f_apply)
goto fancy_apply;
}
}
newargs = (jl_value_t**) alloca(n * sizeof(jl_value_t*));
newargs = (jl_value_t**)alloca(n * sizeof(jl_value_t*));
n = 0;
for(i=1; i < nargs; i++) {
if (jl_is_tuple(args[i])) {
Expand Down
2 changes: 1 addition & 1 deletion src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static Type *julia_type_to_llvm(jl_value_t *jt)
return ret;
}
else {
Type **types = (Type**) alloca(ntypes*sizeof(Type*));
Type **types = (Type**)alloca(ntypes*sizeof(Type*));
size_t j = 0;
for (size_t i = 0; i < ntypes; ++i) {
Type *ty = julia_struct_to_llvm(jl_tupleref(jt,i));
Expand Down
4 changes: 2 additions & 2 deletions src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ static uv_lib_t *jl_load_dynamic_library_(char *modname, unsigned flags, int thr
char *ext;
char path[PATHBUF];
int i;
uv_lib_t *handle = (uv_lib_t*) malloc(sizeof(uv_lib_t));
handle->errmsg=NULL;
uv_lib_t *handle = (uv_lib_t*)malloc(sizeof(uv_lib_t));
handle->errmsg = NULL;

if (modname == NULL) {
#ifdef _OS_WINDOWS_
Expand Down
77 changes: 38 additions & 39 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static void jl_serialize_globalvals(ios_t *s)
for(i=0; i < len; i+=2) {
void *offs = p[i+1];
if (offs != HT_NOTFOUND) {
int32_t gv = jl_get_llvm_gv((jl_value_t*) p[i]);
int32_t gv = jl_get_llvm_gv((jl_value_t*)p[i]);
if (gv != 0) {
write_int32(s, (int)(intptr_t)offs);
write_int32(s, gv);
Expand All @@ -147,7 +147,7 @@ static void jl_deserialize_globalvals(ios_t *s)
while (1) {
intptr_t key = read_int32(s);
if (key == 0) break;
jl_deserialize_gv(s, (jl_value_t*) ptrhash_get(&backref_table, (void*) key));
jl_deserialize_gv(s, (jl_value_t*)ptrhash_get(&backref_table, (void*)key));
}
}

Expand Down Expand Up @@ -197,7 +197,7 @@ static void jl_delayed_fptrs(jl_lambda_info_t *li, int32_t func, int32_t cfunc)
delayed_fptrs_max = 2048;
else
delayed_fptrs_max *= 2;
delayed_fptrs = (struct delayed_fptrs_t*) realloc(delayed_fptrs, delayed_fptrs_max*sizeof(delayed_fptrs[0])); //assumes sizeof==alignof
delayed_fptrs = (struct delayed_fptrs_t*)realloc(delayed_fptrs, delayed_fptrs_max*sizeof(delayed_fptrs[0])); //assumes sizeof==alignof
}
delayed_fptrs[delayed_fptrs_n].li = li;
delayed_fptrs[delayed_fptrs_n].func = func;
Expand Down Expand Up @@ -468,10 +468,10 @@ static void jl_serialize_value_(ios_t *s, jl_value_t *v)
jl_serialize_value(s, (jl_value_t*)f->linfo);
jl_serialize_value(s, f->env);
if (f->linfo && f->linfo->ast && f->fptr != &jl_trampoline) {
jl_serialize_fptr(s, (void*) &jl_trampoline);
jl_serialize_fptr(s, (void*)&jl_trampoline);
}
else {
jl_serialize_fptr(s, (void*) f->fptr);
jl_serialize_fptr(s, (void*)f->fptr);
}
}
else if (jl_is_lambda_info(v)) {
Expand Down Expand Up @@ -532,7 +532,7 @@ static void jl_serialize_value_(ios_t *s, jl_value_t *v)
#endif
}
else {
ios_write(s, (char*) data, jl_datatype_size(t));
ios_write(s, (char*)data, jl_datatype_size(t));
}
}
else {
Expand Down Expand Up @@ -651,7 +651,7 @@ static jl_value_t *jl_deserialize_value_internal(ios_t *s)
return NULL;
if (tag == 0) {
tag = read_uint8(s);
jl_value_t *v = (jl_value_t*) ptrhash_get(&deser_tag, (void*)(ptrint_t)tag);
jl_value_t *v = (jl_value_t*)ptrhash_get(&deser_tag, (void*)(ptrint_t)tag);
assert(v != HT_NOTFOUND);
return v;
}
Expand Down Expand Up @@ -695,7 +695,7 @@ static jl_value_t *jl_deserialize_value_internal(ios_t *s)
len = read_uint8(s);
else
len = read_int32(s);
char *name = (char*) alloca(len+1);
char *name = (char*)alloca(len+1);
ios_read(s, name, len);
name[len] = '\0';
jl_value_t *sym = (jl_value_t*)jl_symbol(name);
Expand All @@ -720,15 +720,15 @@ static jl_value_t *jl_deserialize_value_internal(ios_t *s)
elsize = elsize&0x7fff;
}
jl_value_t *aty = jl_deserialize_value(s);
size_t *dims = (size_t*) alloca(ndims*sizeof(size_t));
size_t *dims = (size_t*)alloca(ndims*sizeof(size_t));
for(i=0; i < ndims; i++)
dims[i] = jl_unbox_long(jl_deserialize_value(s));
jl_array_t *a = jl_new_array_for_deserialization((jl_value_t*)aty, ndims, dims, isunboxed, elsize);
if (usetable)
ptrhash_put(&backref_table, (void*)(ptrint_t)pos, (jl_value_t*)a);
if (!a->ptrarray) {
size_t tot = jl_array_len(a) * a->elsize;
ios_read(s, (char*) jl_array_data(a), tot);
ios_read(s, (char*)jl_array_data(a), tot);
}
else {
for(i=0; i < jl_array_len(a); i++) {
Expand Down Expand Up @@ -861,7 +861,7 @@ static jl_value_t *jl_deserialize_value_internal(ios_t *s)
jl_value_t *v;
if (nf == 0 && jl_datatype_size(dt)>0) {
int nby = jl_datatype_size(dt);
char *data = (char*) alloca(nby);
char *data = (char*)alloca(nby);
ios_read(s, data, nby);
v = NULL;
if (dt == jl_int32_type)
Expand All @@ -872,7 +872,7 @@ static jl_value_t *jl_deserialize_value_internal(ios_t *s)
v = jl_box_bool(*(int8_t*)data);
else {
switch (nby) {
case 1: v = jl_box8 (dt, *(int8_t*) data); break;
case 1: v = jl_box8 (dt, *(int8_t *)data); break;
case 2: v = jl_box16(dt, *(int16_t*)data); break;
case 4: v = jl_box32(dt, *(int32_t*)data); break;
case 8: v = jl_box64(dt, *(int64_t*)data); break;
Expand Down Expand Up @@ -949,8 +949,8 @@ void jl_save_system_image(char *fname)
jl_array_t *spec = mt->defs->func->linfo->specializations;
if (spec != NULL && jl_array_len(spec) > 0 &&
((jl_lambda_info_t*)jl_cellref(spec,0))->inferred == 0) {
mt->cache = (jl_methlist_t*) JL_NULL;
mt->cache_arg1 = (jl_array_t*) JL_NULL;
mt->cache = (jl_methlist_t*)JL_NULL;
mt->cache_arg1 = (jl_array_t*)JL_NULL;
mt->defs->func->linfo->tfunc = (jl_value_t*)jl_null;
mt->defs->func->linfo->specializations = NULL;
}
Expand Down Expand Up @@ -1003,7 +1003,7 @@ void jl_restore_system_image(char *fname, int build_mode)
if (jl_is_debugbuild()) build_mode = 1;
#endif
if (!build_mode) {
char *fname_shlib = (char*) alloca(strlen(fname));
char *fname_shlib = (char*)alloca(strlen(fname));
strcpy(fname_shlib, fname);
char *fname_shlib_dot = strrchr(fname_shlib, '.');
if (fname_shlib_dot != NULL) *fname_shlib_dot = 0;
Expand Down Expand Up @@ -1078,7 +1078,7 @@ jl_value_t *jl_ast_rettype(jl_lambda_info_t *li, jl_value_t *ast)
ios_t src;
jl_array_t *bytes = (jl_array_t*)ast;
ios_mem(&src, 0);
ios_setbuf(&src, (char*) bytes->data, jl_array_len(bytes), 0);
ios_setbuf(&src, (char*)bytes->data, jl_array_len(bytes), 0);
src.size = jl_array_len(bytes);
int en = jl_gc_is_enabled();
jl_gc_disable();
Expand Down Expand Up @@ -1126,7 +1126,7 @@ jl_value_t *jl_uncompress_ast(jl_lambda_info_t *li, jl_value_t *data)
tree_literal_values = li->module->constant_table;
ios_t src;
ios_mem(&src, 0);
ios_setbuf(&src, (char*) bytes->data, jl_array_len(bytes), 0);
ios_setbuf(&src, (char*)bytes->data, jl_array_len(bytes), 0);
src.size = jl_array_len(bytes);
int en = jl_gc_is_enabled();
jl_gc_disable();
Expand Down Expand Up @@ -1273,28 +1273,27 @@ void jl_init_serializer(void)
assert(i <= Null_tag);
VALUE_TAGS = (ptrint_t)ptrhash_get(&ser_tag, jl_null);

jl_fptr_t fptrs[] = {
jl_f_new_expr, jl_f_new_box,
jl_f_throw, jl_f_is,
jl_f_no_function, jl_f_typeof,
jl_f_subtype, jl_f_isa,
jl_f_typeassert, jl_f_apply,
jl_f_top_eval, jl_f_isdefined,
jl_f_tuple, jl_f_tupleref,
jl_f_tuplelen, jl_f_get_field,
jl_f_set_field, jl_f_field_type,
jl_f_arraylen, jl_f_arrayref,
jl_f_arrayset, jl_f_arraysize,
jl_f_instantiate_type, jl_f_kwcall,
jl_f_convert_default, jl_f_convert_tuple,
jl_trampoline, jl_f_new_type_constructor,
jl_f_typevar, jl_f_union,
jl_f_methodexists, jl_f_applicable,
jl_f_invoke, jl_apply_generic,
jl_unprotect_stack, jl_f_task,
jl_f_yieldto, jl_f_ctor_trampoline,
jl_f_new_module,
NULL };
jl_fptr_t fptrs[] = { jl_f_new_expr, jl_f_new_box,
jl_f_throw, jl_f_is,
jl_f_no_function, jl_f_typeof,
jl_f_subtype, jl_f_isa,
jl_f_typeassert, jl_f_apply,
jl_f_top_eval, jl_f_isdefined,
jl_f_tuple, jl_f_tupleref,
jl_f_tuplelen, jl_f_get_field,
jl_f_set_field, jl_f_field_type,
jl_f_arraylen, jl_f_arrayref,
jl_f_arrayset, jl_f_arraysize,
jl_f_instantiate_type, jl_f_kwcall,
jl_f_convert_default, jl_f_convert_tuple,
jl_trampoline, jl_f_new_type_constructor,
jl_f_typevar, jl_f_union,
jl_f_methodexists, jl_f_applicable,
jl_f_invoke, jl_apply_generic,
jl_unprotect_stack, jl_f_task,
jl_f_yieldto, jl_f_ctor_trampoline,
jl_f_new_module,
NULL };
i=2;
while (fptrs[i-2] != NULL) {
ptrhash_put(&fptr_to_id, (void*)fptrs[i-2], (void*)i);
Expand Down
Loading

0 comments on commit 5555f4f

Please sign in to comment.