diff --git a/subprojects/cextras.wrap b/subprojects/cextras.wrap index 89da79d5..3466c916 100644 --- a/subprojects/cextras.wrap +++ b/subprojects/cextras.wrap @@ -1,6 +1,6 @@ [wrap-git] directory = cextras -revision = f3478d1e00d38846af03bd776d92336fbcf6e1f7 +revision = d063e11e5e3dd6fb1f9486f2ffa29c6b4e4a00be url = https://github.com/Gottox/cextras.git depth = 1 diff --git a/tools/meson.build b/tools/meson.build index cb1fa7f9..c2c6a0f3 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -10,6 +10,11 @@ tool_sources = [ 'src/unpack.c', ] +tool_dependencies = [ + libsqsh_dep, + cextras_dep, +] + c_args = ['-DVERSION="@0@"'.format(meson.project_version())] tools = {} @@ -21,7 +26,7 @@ foreach src : tool_sources c_args: c_args, include_directories: tools_private_include, install: not meson.is_subproject(), - dependencies: libsqsh_dep, + dependencies: tool_dependencies, ) tools += {tool_name: tool} endforeach @@ -33,7 +38,7 @@ if fuse3_dep.found() c_args: c_args, include_directories: tools_private_include, install: not meson.is_subproject(), - dependencies: [libsqsh_dep, fuse3_dep], + dependencies: tool_dependencies + [fuse3_dep], ) tools += {'sqshfs': tool} endif @@ -50,7 +55,7 @@ if fuse2_dep.found() c_args: c_args, include_directories: tools_private_include, install: not meson.is_subproject() and not fuse3_dep.found(), - dependencies: [libsqsh_dep, fuse2_dep], + dependencies: tool_dependencies + [fuse2_dep], ) tools += {'sqshfs2': tool} endif diff --git a/tools/src/unpack.c b/tools/src/unpack.c index c7885eb8..613f8739 100644 --- a/tools/src/unpack.c +++ b/tools/src/unpack.c @@ -33,10 +33,10 @@ #include +#include #include #include #include -#include #include #include #include @@ -48,7 +48,7 @@ typedef int (*extract_fn)( const char *, enum SqshFileType, const struct SqshFile *); -sem_t file_descriptor_sem; +struct CxSemaphore file_descriptor_sem; size_t extracted_files = 0; bool do_chown = false; bool verbose = false; @@ -189,7 +189,7 @@ extract_file_after( fclose(stream); rv = update_metadata(data->path, file); out: - sem_post(&file_descriptor_sem); + cx_semaphore_post(&file_descriptor_sem); if (rv < 0) { sqsh_perror(rv, data->path); } @@ -214,7 +214,7 @@ extract_file(const char *path, const struct SqshFile *file) { } strcpy(data->tmp_filename, ".sqsh-unpack-XXXXXX"); - rv = sem_wait(&file_descriptor_sem); + rv = cx_semaphore_wait(&file_descriptor_sem); if (rv < 0) { rv = -errno; perror(path); @@ -508,9 +508,9 @@ main(int argc, char *argv[]) { goto out; } // Leave some file descriptors for the rest of the system - rv = sem_init(&file_descriptor_sem, 0, limits.rlim_cur - 32); + rv = cx_semaphore_init(&file_descriptor_sem, limits.rlim_cur - 32); if (rv < 0) { - perror("sem_init"); + perror("cx_semaphore_init"); rv = EXIT_FAILURE; goto out; } @@ -552,7 +552,7 @@ main(int argc, char *argv[]) { rv = extract_all(target_path, src_root, extract_second_pass); } out: - sem_destroy(&file_descriptor_sem); + cx_semaphore_destroy(&file_descriptor_sem); sqsh_threadpool_free(threadpool); sqsh_close(src_root); sqsh_archive_close(sqsh);