Skip to content

Instantly share code, notes, and snippets.

@tshort
Created April 16, 2018 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tshort/8d556559a21bf38da44c0c01d0cf9ea3 to your computer and use it in GitHub Desktop.
Save tshort/8d556559a21bf38da44c0c01d0cf9ea3 to your computer and use it in GitHub Desktop.
`ccall`'s from libjulia

Julia's runtime provides a lot of functionality used by base Julia code. A subset of this is needed to support basic data structures like arrays, dicts, and strings. Here is a list of the ccall's used by base Julia code. The most important ones for basic wasm support are:

# most important
abstractdict.jl
        :jl_eqtable_get
        :jl_eqtable_nextind
        :jl_eqtable_pop
        :jl_eqtable_put
        :jl_idtable_rehash
        :memset
array.jl
        :jl_array_copy
        :jl_array_del_at
        :jl_array_del_beg
        :jl_array_del_end
        :jl_array_grow_at
        :jl_array_grow_beg
        :jl_array_grow_end
        :jl_array_isassigned
        :jl_array_ptr_copy
        :jl_array_sizehint
        :jl_array_store_unboxed
        :jl_islayout_inline
        :jl_reshape_array
        :memcmp
        :memcpy
        :memmove
        :memset
boot.jl
        :jl_alloc_array_1d
        :jl_alloc_array_2d
        :jl_alloc_array_3d
        :jl_array_ptr
        :jl_f_new_module
        :jl_gc_new_weakref_th
        :jl_get_keyword_sorter
        :jl_get_kwsorter
        :jl_get_ptls_states
        :jl_load_
        :jl_new_array
        :jl_new_structv
        :jl_new_task
        :jl_new_typevar
        :jl_set_istopmod
        :jl_static_show
        :jl_string_ptr
        :jl_symbol_n
        :jl_toplevel_eval_in
        :jl_type_unionall
        :jl_typemax_uint
        :jl_uv_putb
        :jl_uv_putc
        :jl_uv_puts
dict.jl
        :jl_arrayunset
error.jl
        :jl_get_backtrace
        :jl_throw
        :jl_rethrow
        :jl_rethrow_other
pointer.jl
        :jl_array_ptr
        :jl_ptr_to_array
        :jl_ptr_to_array_1d
        :jl_symbol_name
        :jl_value_ptr
strings/basic.jl
        :strcmp
strings/search.jl
        :memchr
        :memrchr
strings/string.jl
        :jl_alloc_string
        :jl_array_to_string
        :jl_cstr_to_string
        :jl_pchar_to_string
        :jl_string_to_array
        :memcmp
        :memset
        :u8_isvalid
strings/substring.jl
        :memcmp
strings/unicode.jl
        :utf8proc_category
        :utf8proc_category_string
        :utf8proc_charwidth
        :utf8proc_decompose
        :utf8proc_errmsg
        :utf8proc_grapheme_break
        :utf8proc_grapheme_break_stateful
        :utf8proc_reencode
        :utf8proc_tolower
        :utf8proc_totitle
        :utf8proc_toupper
strings/util.jl
        :memcmp

There are lots more, though:

atomics.jl
        :jl_alignment
        :jl_gc_safepoint
bitarray.jl
        :jl_array_sizehint
c.jl
        :jl_extern_c
        :jl_get_UNAME
        :jl_is_char_signed
        :jl_sigatomic_begin
        :jl_sigatomic_end
        :jl_sizeof_mode_t
        :memchr
checked.jl
        :jl_get_LLVM_VERSION
client.jl
        :jl_exit_on_sigint
        :jl_parse_input_line
clipboard.jl
        :CloseClipboard
        :EmptyClipboard
        :GetClipboardData
        :GlobalAlloc
        :GlobalLock
        :GlobalUnlock
        :OpenClipboard
        :SetClipboardData
        :memcpy
compiler/abstractinterpretation.jl
        :jl_ast_flag_inferred
        :jl_ast_flag_inlineable
        :jl_instantiate_type_in_env
        :jl_type_intersection_with_env
compiler/bootstrap.jl
        :jl_get_world_counter
compiler/compiler.jl
        :jl_set_istopmod
        :jl_set_typeinf_func
compiler/optimize.jl
        :abort
        :jl_arrayunset
        :jl_ast_flag_inferred
        :jl_ast_flag_inlineable
        :jl_compress_ast
        :jl_get_invoke_lambda
        :jl_get_spec_lambda
        :jl_get_tls_world_age
        :jl_gf_invoke_lookup
        :jl_instantiate_type_in_env
        :jl_is_cacheable_sig
        :jl_set_method_inferred
        :jl_type_error_new_expr
        :jl_type_intersection_with_env
        :jl_uncompress_ast
compiler/tfuncs.jl
        :jl_argument_datatype
        :jl_gf_invoke_lookup
        :jl_type_intersection_with_env
compiler/typeinfer.jl
        :jl_method_instance_add_backedge
        :jl_method_table_add_backedge
        :jl_new_code_info_uninit
        :jl_typeinf_begin
        :jl_typeinf_end
compiler/typeutils.jl
        :jl_has_free_typevars
compiler/utilities.jl
        :jl_base_relative_to
        :jl_code_for_staged
        :jl_copy_code_info
        :jl_invoke_api
        :jl_specializations_get_linfo
        :jl_specializations_lookup
        :jl_uncompress_ast
        :strcmp
deepcopy.jl
        :jl_array_isassigned
        :jl_arrayref
        :jl_arrayset
        :jl_new_struct_uninit
        :jl_set_nth_field
deprecated.jl
        :jl_deprecate_binding
        :jl_first_argument_datatype
        :jl_function_ptr
        :jl_get_current_module
        :memchr
dict.jl
        :jl_arrayunset
docs/basedocs.jl
        function_name
        function_pointer
env.jl
        :FreeEnvironmentStringsW
        :GetEnvironmentStringsW
        :GetEnvironmentVariableW
        :SetEnvironmentVariableW
        :getenv
        :jl_environ
        :setenv
        :unsetenv
        :wcslen
error.jl
        :jl_get_backtrace
        :jl_rethrow
        :jl_rethrow_other
errorshow.jl
        :jl_get_world_counter
        :jl_printf
        :jl_static_show
        :jl_stderr_stream
essentials.jl
        :jl_compile_hint
event.jl
        :Sleep
        :jl_close_uv
        :jl_safe_printf
        :jl_switchto
        :pause
        :uv_async_init
        :uv_stop
        :uv_timer_get_repeat
        :uv_timer_init
        :uv_timer_start
        :uv_timer_stop
        :uv_update_time
expr.jl
        :jl_gensym
        :jl_macroexpand
        :jl_macroexpand1
        :jl_tagged_gensym
        :strlen
fastmath.jl
        "atan2"
        "atan2f"
        "llvm.powi.f32"
        "llvm.powi.f64"
        "pow"
        "powf"
        $(string(f
        :sincos
        :sincosf
file.jl
        :GetTempFileNameW
        :GetTempPathW
        :_wmkdir
        :_wrmdir
        :close
        :fchdir
        :jl_fs_chmod
        :jl_fs_chown
        :jl_fs_rename
        :jl_fs_symlink
        :jl_fs_unlink
        :jl_sizeof_uv_fs_t
        :jl_uv_fs_req_cleanup
        :jl_uv_fs_t_ptr
        :mkdir
        :mkdtemp
        :mkstemp
        :open
        :rmdir
        :tempnam
        :uv_chdir
        :uv_cwd
        :uv_fs_readlink
        :uv_fs_req_cleanup
        :uv_fs_scandir
        :uv_fs_scandir_next
filesystem.jl
        :jl_fs_close
        :jl_fs_read
        :jl_fs_read_byte
        :jl_fs_sendfile
        :jl_fs_write
        :jl_lseek
        :jl_uv_fs_result
        :uv_fs_ftruncate
        :uv_fs_futime
        :uv_fs_open
        :uv_fs_req_cleanup
floatfuncs.jl
        "fma"
        "fmaf"
gcutils.jl
        :jl_finalize_th
        :jl_gc_add_finalizer_th
        :jl_gc_add_ptr_finalizer
        :jl_gc_collect
        :jl_gc_enable
gmp.jl
        $(gmpz(op
        :__gmp_set_memory_functions
        :__gmpn_cmp
        :__gmpn_popcount
        :__gmpz_cmp
        :__gmpz_cmp_d
        :__gmpz_cmp_si
        :__gmpz_cmp_ui
        :__gmpz_gcdext
        :__gmpz_get_d
        :__gmpz_get_str
        :__gmpz_import
        :__gmpz_init
        :__gmpz_init2
        :__gmpz_invert
        :__gmpz_limbs_finish
        :__gmpz_limbs_write
        :__gmpz_mul_si
        :__gmpz_popcount
        :__gmpz_powm
        :__gmpz_realloc2
        :__gmpz_set_str
        :__gmpz_setbit
        :__gmpz_sizeinbase
        :__gmpz_tdiv_qr
        :__gmpz_tstbit
        :__gmpz_ui_sub
hashing2.jl
        :__gmpz_realloc2
        :memcpy
        memhash
initdefs.jl
        :jl_exit
io.jl
        :strlen
iobuffer.jl
        :memchr
iostream.jl
        :ios_close
        :ios_eof_blocking
        :ios_fd
        :ios_file
        :ios_flush
        :ios_get_readable
        :ios_get_writable
        :ios_getc
        :ios_isopen
        :ios_peekc
        :ios_peekutf8
        :ios_pos
        :ios_putc
        :ios_read
        :ios_readall
        :ios_seek
        :ios_seek_end
        :ios_skip
        :ios_trunc
        :ios_write
        :jl_ios_fd
        :jl_ios_get_nbyte_int
        :jl_nb_available
        :jl_readuntil
        :jl_sizeof_ios_t
        :jl_take_buffer
irrationals.jl
        $(string("mpfr_const_"
libc.jl
        :DuplicateHandle
        :FormatMessageW
        :GetCurrentProcess
        :GetLastError
        :LocalFree
        :Sleep
        :_close
        :_get_osfhandle
        :_open_osfhandle
        :calloc
        :fclose
        :free
        :fseek
        :ftell
        :gethostname
        :jl_clock_now
        :jl_errno
        :jl_flush_cstdio
        :jl_getpid
        :jl_gettimeofday
        :jl_set_errno
        :localtime_r
        :malloc
        :mktime
        :rand
        :realloc
        :srand
        :strerror
        :strftime
        :strptime
        :usleep
        @static
libuv.jl
        :jl_global_event_loop
        :jl_new_event_loop
        :jl_process_events
        :jl_run_event_loop
        :jl_run_once
        :jl_stderr_stream
        :jl_stdin_stream
        :jl_stdout_stream
        :jl_uv_associate_julia_struct
        :jl_uv_disassociate_julia_struct
        :jl_uv_handle_data
        :jl_uv_req_data
        :jl_uv_req_set_data
        :uv_err_name
        :uv_handle_size
        :uv_req_size
        :uv_strerror
loading.jl
        :getattrlist
        :jl_generating_output
        :jl_load_file_string
        :jl_module_build_id
        :jl_module_uuid
        :jl_read_verify_header
        :jl_restore_incremental
        :jl_set_module_uuid
locks.jl
        :jl_cpu_pause
        :jl_cpu_wake
        :jl_gc_safe_enter
        :jl_gc_safe_leave
        :jl_gc_safepoint
        :jl_sizeof_uv_mutex
        :uv_mutex_destroy
        :uv_mutex_init
        :uv_mutex_lock
        :uv_mutex_trylock
        :uv_mutex_unlock
math.jl
        "llvm.pow.f32"
        "llvm.pow.f64"
        $(string(f
        :modf
        :modff
        :remainder
        :remainderf
meta.jl
        :jl_expand
        :jl_parse_string
methodshow.jl
        :jl_fill_argnames
        :jl_methtable_lookup
mpfr.jl
        "mpfr_fma"
        $(string(:mpfr_
        $(string(:mpfr_set_
        :__gmpfr_mpfr_get_sj
        :__gmpfr_mpfr_get_uj
        :mpfr_add
        :mpfr_atan2
        :mpfr_beta
        :mpfr_cmp_d
        :mpfr_cmp_si
        :mpfr_cmp_ui
        :mpfr_cmp_z
        :mpfr_const_log2
        :mpfr_copysign
        :mpfr_d_div
        :mpfr_div
        :mpfr_div_d
        :mpfr_div_si
        :mpfr_div_ui
        :mpfr_div_z
        :mpfr_equal_p
        :mpfr_fac_ui
        :mpfr_fmod
        :mpfr_frexp
        :mpfr_get_d
        :mpfr_get_emax
        :mpfr_get_emax_max
        :mpfr_get_emax_min
        :mpfr_get_emin
        :mpfr_get_emin_max
        :mpfr_get_emin_min
        :mpfr_get_exp
        :mpfr_get_flt
        :mpfr_get_patches
        :mpfr_get_prec
        :mpfr_get_version
        :mpfr_get_z
        :mpfr_greater_p
        :mpfr_greaterequal_p
        :mpfr_hypot
        :mpfr_inf_p
        :mpfr_init2
        :mpfr_integer_p
        :mpfr_less_p
        :mpfr_lessequal_p
        :mpfr_lgamma
        :mpfr_log1p
        :mpfr_max
        :mpfr_min
        :mpfr_modf
        :mpfr_mul_2si
        :mpfr_mul_2ui
        :mpfr_mul_si
        :mpfr_nan_p
        :mpfr_neg
        :mpfr_nextabove
        :mpfr_nextbelow
        :mpfr_pow
        :mpfr_pow_si
        :mpfr_pow_ui
        :mpfr_pow_z
        :mpfr_remainder
        :mpfr_set
        :mpfr_set_d
        :mpfr_set_emax
        :mpfr_set_emin
        :mpfr_set_str
        :mpfr_set_z
        :mpfr_si_div
        :mpfr_signbit
        :mpfr_sin_cos
        :mpfr_snprintf
        :mpfr_sprintf
        :mpfr_sqrt
        :mpfr_trunc
        :mpfr_ui_div
        :mpfr_z_sub
namedtuple.jl
        :jl_new_structv
options.jl
        :jl_sizeof_jl_options
        :jl_throw
parse.jl
        :jl_try_substrtod
        :jl_try_substrtof
        :memcmp
path.jl
        :GetFullPathNameW
        :GetLongPathNameW
        :realpath
        :uv_os_homedir
pcre.jl
        :pcre2_code_free_8
        :pcre2_compile_8
        :pcre2_get_error_message_8
        :pcre2_get_ovector_count_8
        :pcre2_get_ovector_pointer_8
        :pcre2_jit_compile_8
        :pcre2_jit_stack_assign_8
        :pcre2_jit_stack_create_8
        :pcre2_jit_stack_free_8
        :pcre2_match_8
        :pcre2_match_context_create_8
        :pcre2_match_context_free_8
        :pcre2_match_data_create_from_pattern_8
        :pcre2_match_data_free_8
        :pcre2_pattern_info_8
        :pcre2_substring_copy_bynumber_8
        :pcre2_substring_length_bynumber_8
        :pcre2_substring_number_from_name_8
printf.jl
        :memset
        :mpfr_snprintf
process.jl
        :jl_close_uv
        :jl_forceclose_uv
        :jl_spawn
        :jl_uv_process_data
        :memchr
        :uv_process_kill
reflection.jl
        :jl_argument_datatype
        :jl_binding_resolved_p
        :jl_field_index
        :jl_first_argument_datatype
        :jl_get_field_offset
        :jl_get_module_of_binding
        :jl_get_world_counter
        :jl_gf_invoke_lookup
        :jl_is_binding_deprecated
        :jl_is_const
        :jl_is_in_pure_context
        :jl_matching_methods
        :jl_method_exists
        :jl_method_table_disable
        :jl_module_exports_p
        :jl_module_name
        :jl_module_names
        :jl_module_parent
        :jl_object_id
        :jl_type_intersection
        :jl_uncompress_ast
rounding.jl
        :fegetround
        :fesetround
        :jl_get_fenv_consts
        :jl_get_zero_subnormals
        :jl_set_zero_subnormals
show.jl
        :jl_binding_owner
        :jl_has_typevar
        :jl_id_char
        :jl_id_start_char
        :jl_intrinsic_name
        :jl_is_operator
        :jl_is_unary_and_binary_operator
        :jl_is_unary_operator
        :jl_operator_precedence
special/gamma.jl
        :lgamma_r
        :lgammaf_r
        :tgamma
        :tgammaf
special/hyperbolic.jl
        "__ldexp_exp"
        "__ldexp_expf"
stacktraces.jl
        :jl_backtrace_from_here
        :jl_lookup_code_address
stat.jl
        $(Expr(:quote
        :jl_sizeof_stat
        :jl_stat_blksize
        :jl_stat_blocks
        :jl_stat_ctime
        :jl_stat_dev
        :jl_stat_gid
        :jl_stat_ino
        :jl_stat_mode
        :jl_stat_mtime
        :jl_stat_nlink
        :jl_stat_rdev
        :jl_stat_size
        :jl_stat_uid
stream.jl
        :CloseHandle
        :SetStdHandle
        :_open_osfhandle
        :close
        :jl_close_uv
        :jl_forceclose_uv
        :jl_ispty
        :jl_pipe_open
        :jl_uv_buf_len
        :jl_uv_buf_set_base
        :jl_uv_buf_set_len
        :jl_uv_file_handle
        :jl_uv_handle_type
        :jl_uv_write
        :uv_fileno
        :uv_is_readable
        :uv_is_writable
        :uv_pipe
        :uv_pipe_init
        :uv_read_start
        :uv_read_stop
        :uv_tty_get_winsize
        :uv_tty_init
summarysize.jl
        :jl_array_isassigned
        :jl_value_ptr
sysimg.jl
        :jl_hrtime
        :jl_module_parent
        :jl_prepend_cwd
        :jl_set_istopmod
sysinfo.jl
        :GetVersion
        :jl_SC_CLK_TCK
        :jl_cpu_cores
        :jl_get_ARCH
        :jl_get_JIT
        :jl_get_UNAME
        :jl_get_cpu_name
        :jl_get_julia_bindir
        :jl_maxrss
        :uv_cpu_info
        :uv_free_cpu_info
        :uv_get_free_memory
        :uv_get_process_title
        :uv_get_total_memory
        :uv_loadavg
        :uv_set_process_title
        :uv_uptime
task.jl
        :jl_get_current_task
        :jl_is_task_started
threadcall.jl
        $f
        :jl_queue_work
threadingconstructs.jl
        :jl_threadid
        :jl_threading_run
util.jl
        :CoTaskMemFree
        :CredPackAuthenticationBufferW
        :CredUIPromptForWindowsCredentialsW
        :CredUnPackAuthenticationBufferW
        :SecureZeroMemory
        :_getch
        :getpass
        :jl_crc32c
        :jl_gc_num
        :jl_gc_total_bytes
        :jl_gc_total_hrtime
        :jl_is_debugbuild
        :memset
version.jl
        :jl_clock_now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment