From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from gnuweeb.org (unknown [51.81.211.47]) by gnuweeb.org (Postfix) with ESMTPSA id D5FD4832D7; Sat, 11 Mar 2023 11:28:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1678534101; bh=EVkRb0qfgf76WFL+APTI03U4xGcoNR8ubkWa601lI20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qfu/pZ4SQVwouqM/1YCMfOFypFjHrcnY5rLC3yWH1HELvThSftJOxbfDECY9pVZBv VEFkshB+H1Yw7gq62KTFwEObxXKbury619QamxGB7yeX43mWK/OYF1Bi71yX7+0qoG 39ztQJXpgZWzuZbfDgU/htrs18m7O8V5pQ2AO5dg68TLthRDFZeOrqLUxfk6Q+EwI5 fdRyaBvs1/0s37kL33R1s7S+1170OeJQY98m4Re6rFJVkiX3aBVv2emZeN3aXwDPl6 PfGeLpM9cfaC2P2yoBsTL1yMMCnQglMlpCf4vzxuJZbfx9k7ANgep4Q1zlLDYv2TRt HjsnydYgRn3yA== From: Alviro Iskandar Setiawan To: Ammar Faizi Cc: Alviro Iskandar Setiawan , Irvan Malik Azantha , GNU/Weeb Mailing List Subject: [RFC PATCH v1 3/3] configure: Introduce `--cpp-thread` option Date: Sat, 11 Mar 2023 11:28:10 +0000 Message-Id: <20230311112810.3670483-4-alviro.iskandar@gnuweeb.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230311112810.3670483-1-alviro.iskandar@gnuweeb.org> References: <20230311112810.3670483-1-alviro.iskandar@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Allow user to force use C++ thread instead of pthread on Linux. It also allows us to debug the C++ implementation on Linux. Signed-off-by: Alviro Iskandar Setiawan --- configure | 8 ++++++++ core/thread.cc | 2 +- include/gw/thread.h | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 887b0b2..2f93056 100755 --- a/configure +++ b/configure @@ -40,6 +40,9 @@ for opt do --sanitize) use_sanitize="yes"; ;; + --cpp-thread) + use_cpp_thread="yes"; + ;; *) echo "ERROR: unknown option $opt"; echo "Try '$0 --help' for more information"; @@ -60,6 +63,7 @@ Options: [defaults in brackets after descriptions] --cxx=CMD Use CMD as the C++ compiler --debug Build with debug enabled --sanitize Build with sanitize enabled + --cpp-thread Force to use C++ thread implementation EOF exit 0; fi @@ -308,6 +312,10 @@ if test "${use_sanitize}" = "yes"; then LDFLAGS="${LDFLAGS} -fsanitize=address -fsanitize=undefined"; fi; +if test "${use_cpp_thread}" = "yes"; then + add_config "CONFIG_CPP_THREAD"; +fi; + add_config "CONFIG_MODULE_PING"; add_make_var "CC" "${cc}"; diff --git a/core/thread.cc b/core/thread.cc index 54e06e7..50cc8ed 100644 --- a/core/thread.cc +++ b/core/thread.cc @@ -15,7 +15,7 @@ extern "C" { #endif -#if defined(__linux__) +#if !defined(CONFIG_CPP_THREAD) int thread_create(thread_t *ts_p, void *(*func)(void *), void *arg) { diff --git a/include/gw/thread.h b/include/gw/thread.h index 68a0ee7..f383bd2 100644 --- a/include/gw/thread.h +++ b/include/gw/thread.h @@ -10,7 +10,7 @@ extern "C" { #endif -#if defined(__linux__) +#if !defined(CONFIG_CPP_THREAD) #include typedef pthread_t thread_t; typedef pthread_mutex_t mutex_t; -- Alviro Iskandar Setiawan