Skip to content

Instantly share code, notes, and snippets.

@zhuomingliang
Last active December 20, 2015 05:19
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 zhuomingliang/6077134 to your computer and use it in GitHub Desktop.
Save zhuomingliang/6077134 to your computer and use it in GitHub Desktop.
What we need when do apr => libuv in MoarVM

apr => libuv

What we need when do apr => libuv in MoarVM

NOTE: the no means it may be not found (by me) or not existed at all, but we can added it to libuv by ourself.

Threads

NOTE: libuv has a thread pool.

[ ] apr_thread_mutex_create            uv_mutex_init
[ ] apr_thread_mutex_unlock            uv_mutex_lock
[ ] apr_thread_mutex_unlock            uv_mutex_unlock
[ ] apr_thread_mutex_destroy           uv_mutex_destroy
[ ] apr_thread_create                  uv_thread_create
[ ] apr_thread_yield                   # no, I(JimmyZ) added uv_thread_yield
[ ] apr_thread_join                    uv_thread_join
[ ] apr_thread_exit                    # no, I(JimmyZ) added uv_thread_exit

File

[ ] apr_file_open                      uv_fs_open
[ ] apr_file_seek                      # no, I(JimmyZ) added untested uv_fs_seek
[ ] apr_file_getc                      uv_fs_read
[ ] apr_file_read                      uv_fs_read
[ ] apr_file_write                     uv_fs_write
[ ] apr_file_lock                      # no, I(JimmyZ) added untested uv_fs_lock
[ ] apr_file_unlock                    # no, I(JimmyZ) added untested uv_fs_unlock
[ ] apr_file_flush                     # no, I(JimmyZ) added untested uv_fs_flush
[ ] apr_file_sync                      uv_fs_fsync
[ ] apr_file_pipe_create               uv_pipe_init
[ ] apr_file_trunc                     uv_fs_ftruncate
[ ] apr_file_open_stdin                # libuv has uv_tty_init and uv_write
                                       # you should do if (uv_guess_handle(0) == UV_TTY) {
                                       # uv_tty_init(); } else { uv_fs_open(); }, and also for UV_UDP, UV_TCP, UV_NAMED_PIPE, UV_UNKNOWN_HANDLE etc.
[ ] apr_file_open_stdout               # libuv has uv_tty_init and uv_write
                                       # you should do if (uv_guess_handle(1) == UV_TTY) {
                                       # uv_tty_init(); } else { uv_fs_open(); }, and also for UV_UDP, UV_TCP, UV_NAMED_PIPE, UV_UNKNOWN_HANDLE etc.
[ ] apr_file_open_stderr               # libuv has uv_tty_init and uv_write
                                       # you should do if (uv_guess_handle(2) == UV_TTY) {
                                       # uv_tty_init(); } else { uv_fs_open(); }, and also for UV_UDP, UV_TCP, UV_NAMED_PIPE, UV_UNKNOWN_HANDLE etc.
[ ] apr_file_eof                       # no, but we don't need it, just add a flag
                                       # to _MVMOSHandleBody when uv_fs_read returns 0
[ ] apr_file_copy                      # uv_fs_sendfile
[ ] apr_file_append                    # no, seems that we don't need it. We can use uv_fs_open,
                                       # uv_fs_read, uv_fs_write, or we don't need it
[ ] apr_file_rename                    uv_fs_rename
[ ] apr_file_remove                    uv_fs_unlink
[ ] apr_file_perms_set                 uv_fs_fchmod
[ ] apr_file_info_get                  uv_fs_stat
[ ] apr_filepath_root                  # no, but we don't need it
[ ] apr_filepath_get                   # uv_cwd
[ ] apr_file_close                     uv_fs_close       uv_fs_req_cleanup

[ ] apr_dir_open                       # uv_fs_open
[ ] apr_dir_make_recursive             # no, I(JimmyZ) added untested uv_fs_mkdir_p
[ ] apr_dir_remove                     uv_fs_rmdir
[ ] apr_dir_read                       uv_fs_readdir
[ ] apr_dir_close                      uv_fs_close       uv_fs_req_cleanup

[ ] apr_stat                           uv_fs_stat

Socket

[ ] apr_socket_create                  uv_tcp_init uv_udp_init    # no sctp, unix doesn't support it either
[ ] apr_sockaddr_info_get              uv_getaddrinfo uv_tcp_getpeername uv_tcp_getsockname uv_udp_getsockname
[ ] apr_socket_connect                 uv_tcp_connect
[ ] apr_socket_bind                    uv_tcp_bind uv_udp_bind
[ ] apr_socket_listen                  uv_listen
[ ] apr_socket_accept                  uv_accept
[ ] apr_socket_send                    uv_udp_send
[ ] apr_socket_timeout_set             uv_timer_*   # see tests/test-tcp-connect-timeout.c
[ ] apr_socket_recv                    uv_read_start uv_read_stop
[ ] apr_socket_close                   uv_close

Error

[ ] apr_strerror                       uv_strerror, uv_err_name

Atomic

There are no similar functions in libuv, we can use libatomic

[ ] apr_atomic_inc32                   AO_fetch_and_add1
[ ] apr_atomic_dec32                   AO_fetch_and_sub1
[ ] apr_atomic_casptr                  AO_fetch_compare_and_swap
[ ] apr_atomic_cas32                   AO_fetch_compare_and_swap

Process

[ ] apr_env_get                        # no, we don't need it
[ ] apr_env_set                        # no, we don't need it
[ ] apr_env_delete                     # no, we don't need it
[ ] apr_gid_get                        # no, we don't need it
[ ] apr_gid_name_get                   # no, we don't need it
[ ] apr_uid_get                        # no, we don't need it
[ ] apr_uid_name_get                   # no, we don't need it
[ ] apr_uid_current                    # no, we don't need it
[ ] apr_uid_homepath_get               # no, we don't need it
[ ] apr_os_locale_encoding             # no, we don't need it
[ ] apr_gethostname                    # no, we don't need it
[ ] apr_generate_random_bytes          # no
[ ] apr_time_now                       # no

Others

These most are not necessary actually.

[ ] apr_pool_create
[ ] apr_pool_destroy
[ ] apr_sleep                          # no
[ ] apr_pstrcat
[ ] apr_getopt_init
[ ] apr_getopt_long
[ ] apr_initialize
[ ] apr_terminate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment