Skip to content

Commit

Permalink
fix #3842 -- macro function definitions are annoying
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Jul 28, 2013
1 parent 63cc141 commit a78e48c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion base/c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ typealias Cdouble Float64
#typealias Ccomplex_float Complex64
#typealias Ccomplex_double Complex128

const sizeof_off_t = ccall(:jl_sizeof_off_t, Int, ())
const sizeof_off_t = ccall(:jl_sizeof_off_t, Cint, ())

if sizeof_off_t === 4
typealias FileOffset Int32
Expand Down
10 changes: 5 additions & 5 deletions base/mmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function mmap(len::Integer, prot::Integer, flags::Integer, fd::Integer, offset::
offset_page::FileOffset = ifloor(offset/pagesize)*pagesize
len_page::Int = (offset-offset_page) + len
# Mmap the file
p = ccall(:mmap, Ptr{Void}, (Ptr{Void}, Csize_t, Cint, Cint, Cint, FileOffset), C_NULL, len_page, prot, flags, fd, offset_page)
p = ccall(:jl_mmap, Ptr{Void}, (Ptr{Void}, Csize_t, Cint, Cint, Cint, FileOffset), C_NULL, len_page, prot, flags, fd, offset_page)
if int(p) == -1
error("Memory mapping failed", strerror())
end
Expand All @@ -46,21 +46,21 @@ function mmap_grow(len::Integer, prot::Integer, flags::Integer, fd::Integer, off
const SEEK_CUR::Cint = 1
const SEEK_END::Cint = 2
# Save current file position so we can restore it later
cpos = ccall(:lseek, FileOffset, (Cint, FileOffset, Cint), fd, 0, SEEK_CUR)
cpos = ccall(:jl_lseek, FileOffset, (Cint, FileOffset, Cint), fd, 0, SEEK_CUR)
if cpos < 0
error(strerror())
end
filelen = ccall(:lseek, FileOffset, (Cint, FileOffset, Cint), fd, 0, SEEK_END)
filelen = ccall(:jl_lseek, FileOffset, (Cint, FileOffset, Cint), fd, 0, SEEK_END)
if filelen < 0
error(strerror())
end
if (filelen < offset + len)
n = ccall(:pwrite, Cssize_t, (Cint, Ptr{Void}, Uint, FileOffset), fd, int8([0]), 1, offset + len - 1)
n = ccall(:jl_pwrite, Cssize_t, (Cint, Ptr{Void}, Uint, FileOffset), fd, int8([0]), 1, offset + len - 1)
if (n < 1)
error(strerror())
end
end
cpos = ccall(:lseek, FileOffset, (Cint, FileOffset, Cint), fd, cpos, SEEK_SET)
cpos = ccall(:jl_lseek, FileOffset, (Cint, FileOffset, Cint), fd, cpos, SEEK_SET)
return mmap(len, prot, flags, fd, offset)
end

Expand Down
5 changes: 4 additions & 1 deletion src/julia.expmap
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
jl_arrayset;
jl_arrayunset;
jl_array_to_string;
jl_ast_rettype;
jl_atexit_hook;
jl_backtrace_type;
jl_base_module;
Expand Down Expand Up @@ -182,6 +183,7 @@
jl_loaderror_type;
jl_load_file_string;
jl_locate_sysimg;
jl_lseek;
jl_lstat;
jl_macroexpand;
jl_main_module;
Expand All @@ -190,6 +192,7 @@
jl_make_tcp;
jl_matching_methods;
jl_match_method;
jl_mmap;
jl_module_export;
jl_module_names;
jl_module_name;
Expand Down Expand Up @@ -218,7 +221,6 @@
jl_pchar_to_string;
jl_pgcstack;
jl_prepare_ast;
jl_ast_rettype;
jl_print_int64;
jl_print_symbol;
jl_printf;
Expand All @@ -237,6 +239,7 @@
jl_puts;
jl_pututf8;
jl_pututf8_copy;
jl_pwrite;
jl_readBuffer;
jl_readdir;
jl_readuntil;
Expand Down
24 changes: 11 additions & 13 deletions src/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,21 @@ DLLEXPORT uint32_t jl_getutf8(ios_t *s)
return wc;
}

DLLEXPORT size_t jl_ios_size(ios_t *s)
{
return s->size;
}
DLLEXPORT size_t jl_ios_size(ios_t *s) { return s->size; }

#ifdef _P64
DLLEXPORT int64_t jl_sizeof_off_t(void) { return sizeof(off_t); }
#else
DLLEXPORT int32_t jl_sizeof_off_t(void) { return sizeof(off_t); }
#endif
DLLEXPORT int jl_sizeof_off_t(void) { return sizeof(off_t); }
DLLEXPORT off_t jl_lseek(int fd, off_t offset, int whence) { return lseek(fd, offset, whence); }
DLLEXPORT ssize_t jl_pwrite(int fd, const void *buf, size_t count, off_t offset) {
return pwrite(fd, buf, count, offset);
}
DLLEXPORT void *jl_mmap(void *addr, size_t length, int prot, int flags,
int fd, off_t offset) {
return mmap(addr, length, prot, flags, fd, offset);
}

DLLEXPORT int jl_sizeof_ios_t(void) { return sizeof(ios_t); }

DLLEXPORT long jl_ios_fd(ios_t *s)
{
return s->fd;
}
DLLEXPORT long jl_ios_fd(ios_t *s) { return s->fd; }

DLLEXPORT int32_t jl_nb_available(ios_t *s)
{
Expand Down

3 comments on commit a78e48c

@StefanKarpinski
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent fix, somewhat inscrutable commit message. I was trying to figure out what this had to do with Julia macros.

@staticfloat
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm this fixes all my issues! Linux 32-bit passes all tests again!

@vtjnash
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good. It still sometimes crashes on my machine while running numbers.jl

Please sign in to comment.