From 06ac5663bbc62ae089d10f36a7f90021420c8e1f Mon Sep 17 00:00:00 2001 From: Ron Olson Date: Wed, 3 Feb 2021 10:59:14 -0600 Subject: [PATCH] Initial version of libdispatch --- .gitignore | 1 + asprintf.patch | 104 +++++++++++++++++++++++++++++++++++++++++++++++ libdispatch.spec | 90 ++++++++++++++++++++++++++++++++++++++++ sources | 1 + 4 files changed, 196 insertions(+) create mode 100644 .gitignore create mode 100644 asprintf.patch create mode 100644 libdispatch.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b171319 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/corelibs-libdispatch.tar.gz diff --git a/asprintf.patch b/asprintf.patch new file mode 100644 index 0000000..6573607 --- /dev/null +++ b/asprintf.patch @@ -0,0 +1,104 @@ +diff -Naur ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE-orig/tests/bsdtests.c ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE/tests/bsdtests.c +--- ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE-orig/tests/bsdtests.c 2020-09-02 02:28:48.000000000 -0500 ++++ ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE/tests/bsdtests.c 2021-01-19 11:17:43.952112327 -0600 +@@ -347,8 +347,8 @@ + { + char* actual_str; + char* expected_str; +- asprintf(&actual_str, "%d\t%s", actual, actual ? strerror(actual) : ""); +- asprintf(&expected_str, "%d\t%s", expected, expected ? strerror(expected) : ""); ++ (void)asprintf(&actual_str, "%d\t%s", actual, actual ? strerror(actual) : ""); ++ (void)asprintf(&expected_str, "%d\t%s", expected, expected ? strerror(expected) : ""); + _test_print(file, line, desc, + (actual == expected), "%s", actual_str, "%s", expected_str); + free(actual_str); +@@ -369,8 +369,8 @@ + { + char* actual_str; + char* expected_str; +- asprintf(&actual_str, "%d %s", actual, actual ? mach_error_string(actual) : ""); +- asprintf(&expected_str, "%d %s", expected, expected ? mach_error_string(expected) : ""); ++ (void)asprintf(&actual_str, "%d %s", actual, actual ? mach_error_string(actual) : ""); ++ (void)asprintf(&expected_str, "%d %s", expected, expected ? mach_error_string(expected) : ""); + _test_print(file, line, desc, + (actual == expected), "%s", actual_str, "%s", expected_str); + free(actual_str); +@@ -416,12 +416,12 @@ + if (code != expectedCode) { + char buffer[BUFSIZ]; + CFStringGetCString(errDesc, buffer, sizeof(buffer), kCFStringEncodingUTF8); +- asprintf(&actual_str, "%ld\t%s", code, buffer); ++ (void)asprintf(&actual_str, "%ld\t%s", code, buffer); + } else { +- asprintf(&actual_str, "%ld", code); ++ (void)asprintf(&actual_str, "%ld", code); + } + +- asprintf(&expected_str, "%ld", expectedCode); ++ (void)asprintf(&expected_str, "%ld", expectedCode); + _test_print("", (long) 0, desc, + (code == expectedCode), "%s", actual_str, "%s", expected_str); + +diff -Naur ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE-orig/tests/dispatch_io.c ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE/tests/dispatch_io.c +--- ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE-orig/tests/dispatch_io.c 2020-09-02 02:28:48.000000000 -0500 ++++ ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE/tests/dispatch_io.c 2021-01-19 11:19:09.286850562 -0600 +@@ -255,7 +255,7 @@ + test_stop(); + } + char *path_out = NULL; +- asprintf(&path_out, "%s\\dispatchtest_io.XXXXXX", temp_dir); ++ (void)asprintf(&path_out, "%s\\dispatchtest_io.XXXXXX", temp_dir); + #else + char path_out[] = "/tmp/dispatchtest_io.XXXXXX"; + #endif +@@ -486,7 +486,7 @@ + #if defined(_WIN32) + for (size_t i = 0; paths[i]; i++) { + char *search_path = NULL; +- asprintf(&search_path, "%s\\*", paths[i]); ++ (void)asprintf(&search_path, "%s\\*", paths[i]); + WIN32_FIND_DATAA node; + HANDLE find = FindFirstFileA(search_path, &node); + free(search_path); +@@ -503,7 +503,7 @@ + continue; + } + char *node_path = NULL; +- asprintf(&node_path, "%s\\%s", paths[i], node.cFileName); ++ (void)asprintf(&node_path, "%s\\%s", paths[i], node.cFileName); + if (node.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + char *subdir_paths[] = {node_path, NULL}; + test_enumerate_dir_trees(subdir_paths, process_file); +@@ -590,7 +590,7 @@ + test_ptr_notnull("SystemRoot", system_root); + test_stop(); + } +- asprintf(&paths[0], "%s\\System32", system_root); ++ (void)asprintf(&paths[0], "%s\\System32", system_root); + #else + char *paths[] = {"/usr/lib", NULL}; + #endif +diff -Naur ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE-orig/tests/dispatch_io_muxed.c ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE/tests/dispatch_io_muxed.c +--- ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE-orig/tests/dispatch_io_muxed.c 2020-09-02 02:28:48.000000000 -0500 ++++ ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE/tests/dispatch_io_muxed.c 2021-01-19 11:18:19.122416587 -0600 +@@ -64,7 +64,7 @@ + const char *path_separator = "/"; + #endif + char *path = NULL; +- asprintf(&path, "%s%sdispatchtest_io.XXXXXX", temp_dir, path_separator); ++ (void)asprintf(&path, "%s%sdispatchtest_io.XXXXXX", temp_dir, path_separator); + dispatch_fd_t fd = mkstemp(path); + if (fd == -1) { + test_errno("mkstemp", errno, 0); +diff -Naur ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE-orig/tests/dispatch_overcommit.c ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE/tests/dispatch_overcommit.c +--- ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE-orig/tests/dispatch_overcommit.c 2020-09-02 02:28:48.000000000 -0500 ++++ ./swift-corelibs-libdispatch-swift-5.3.2-RELEASE/tests/dispatch_overcommit.c 2021-01-19 11:16:37.385536454 -0600 +@@ -48,7 +48,7 @@ + int i; + for (i = 0; i < final; ++i) { + char* name; +- asprintf(&name, "test.overcommit.%d", i); ++ (void)asprintf(&name, "test.overcommit.%d", i); + + dispatch_queue_t queue = dispatch_queue_create(name, NULL); + test_ptr_notnull("dispatch_queue_create", queue); diff --git a/libdispatch.spec b/libdispatch.spec new file mode 100644 index 0000000..b58e823 --- /dev/null +++ b/libdispatch.spec @@ -0,0 +1,90 @@ +%global toolchain clang +%global reltag 5.3.3-RELEASE + + +Name: libdispatch +Version: 5.3.3 +Release: 1%{?dist} +Summary: Apple's Grand Central Dispatch library +License: ASL 2.0 +URL: https://github.com/apple/swift-corelibs-libdispatch + +Source0: https://github.com/apple/swift-corelibs-libdispatch/archive/swift-%{reltag}.tar.gz#/corelibs-libdispatch.tar.gz + +Patch0: asprintf.patch + +BuildRequires: clang +BuildRequires: libbsd-devel +BuildRequires: ninja-build +BuildRequires: cmake +BuildRequires: chrpath + +ExclusiveArch: x86_64 aarch64 + +Provides: libblocksruntime = %{version}-%{release} +Obsoletes: libblocksruntime < 7.0.0-5 + +Epoch: 1 + +%description +Grand Central Dispatch (GCD or libdispatch) provides +comprehensive support for concurrent code execution on +multicore hardware. + +libdispatch is currently available on all Darwin platforms. +This project aims to make a modern version of libdispatch +available on all other Swift platforms. To do this, we will +implement as much of the portable subset of the API as +possible, using the existing open source C implementation. + +libdispatch on Darwin is a combination of logic in the xnu +kernel alongside the user-space Library. The kernel has the +most information available to balance workload across the +entire system. As a first step, however, we believe it is +useful to bring up the basic functionality of the library +using user-space pthread primitives on Linux. Eventually, a +Linux kernel module could be developed to support more +informed thread scheduling. + + +%package devel +Summary: Development files for libdispatch +Requires: %{name}%{?_isa} = %{version}-%{release} + + +%description devel +Development files for libdispatch + + +%prep +%setup -q -n swift-corelibs-libdispatch-swift-%{reltag} + +%patch0 -p2 + + +%build +%cmake -G Ninja . +%cmake_build + + +%install +%cmake_install +chrpath --delete %{buildroot}%{_libdir}/libdispatch.so + + +%files +%license LICENSE +%{_libdir}/libBlocksRuntime.so +%{_libdir}/libdispatch.so +%{_mandir}/man3/* + + +%files devel +%{_includedir}/Block.h +%{_includedir}/dispatch/* +%{_includedir}/os/* + + +%changelog +* Wed Feb 03 2021 Ron Olson 5.3.3-1 +- Initial version based on version 5.3.3-RELEASE diff --git a/sources b/sources new file mode 100644 index 0000000..f362882 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (corelibs-libdispatch.tar.gz) = b76071e8fac19ef5aed8cb3998b903a17a4f2b9e6b992d22d394212f4d48c4a547fb7a8cf16e4ce2ef17d6b58e253c2d52c6b176c3a874132410215b73332909