Skip to content

Commit

Permalink
Work so far, compiles and includes benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
jsadusk committed Nov 29, 2024
1 parent 3a7f425 commit 8db74f7
Show file tree
Hide file tree
Showing 5 changed files with 309 additions and 48 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ project(TrampLibSSH VERSION 0.1
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_library(emacs-libssh SHARED src/emacs-libssh.c hashtable/hashtable.c emacs-modules/emacs-module-helpers.c)
add_executable(test_stat src/test_stat.c)

find_program(emacs_executable emacs)
get_filename_component(emacs_bin_dir ${emacs_executable} DIRECTORY)
Expand All @@ -24,6 +25,8 @@ find_package(LIBSSH)
if (LIBSSH_FOUND)
target_include_directories(emacs-libssh SYSTEM AFTER PUBLIC ${LIBSSH_INCLUDE_DIR})
target_link_libraries(emacs-libssh PRIVATE ssh)
target_include_directories(test_stat SYSTEM AFTER PUBLIC ${LIBSSH_INCLUDE_DIR})
target_link_libraries(test_stat PRIVATE ssh)
else ()
message(FATAL_ERROR "Unable to find libssh")
endif ()
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ libc = "0.2.153"
libssh-rs = { git = "https://github.com/jsadusk/libssh-rs" }
thread_local = "1.1.7"
thiserror = "1.0"
pipe = "0.4"
crossbeam = "0.8"
crossbeam-channel = "0.5.13"

[dev-dependencies]
emacs-rs-module = {version = "0.18.0"}
Expand Down
20 changes: 18 additions & 2 deletions src/emacs-libssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,15 +606,31 @@ static emacs_value emacs_libssh_marker (emacs_env *env, ptrdiff_t nargs, emacs_v
return 0;
}

static emacs_value test_bare (emacs_env *env, ptrdiff_t nargs, emacs_value args[], void *data) {
emacs_value get_t = env->intern(env, "get-t");
for (int i = 0; i < 10000; ++i) {
ptrdiff_t size;
env->copy_string_contents(env, args[0], NULL, &size);
char* message = calloc(sizeof(char), size);
env->copy_string_contents(env, args[0], message, &size);

emacs_value message_str = env->make_string (env, message, strlen(message));
env->funcall(env, get_t, 1, &message_str);
free(message);
}
return nilval(env);
}

int emacs_module_init(struct emacs_runtime *ert)
{

emacs_env *env = ert->get_environment(ert);

DEFUN("emacs-libssh-sftp-write-region", emacs_libssh_sftp_write_region, 6, 6, "Write a region from the current buffer into an sftp file", NULL);
/*DEFUN("emacs-libssh-sftp-write-region", emacs_libssh_sftp_write_region, 6, 6, "Write a region from the current buffer into an sftp file", NULL);
DEFUN("emacs-libssh-get-ssh-session", emacs_libssh_get_ssh_session, 2, 2, "Get an ssh session", NULL);
DEFUN("emacs-libssh-get-sftp-session", emacs_libssh_get_sftp_session, 1, 1, "Get an sftp session", NULL);
DEFUN("emacs-libssh-sftp-insert", emacs_libssh_sftp_insert, 5, 5, "Insert a file from sftp into the current buffer", NULL);
DEFUN("emacs-libssh-sftp-insert", emacs_libssh_sftp_insert, 5, 5, "Insert a file from sftp into the current buffer", NULL);*/
DEFUN("emacs-libssh-test-bare", test_bare, 1, 1, "Bare test", NULL);
provide(env, "emacs-libssh");

return 0;
Expand Down
Loading

0 comments on commit 8db74f7

Please sign in to comment.