{"thread":{"id":"59031","subject":"[PATCH] run-command: make async_exit usage consistent","startedAt":"2023-01-03T17:59:43Z","lastAt":"2023-01-08T15:13:38Z","messageCount":3,"participants":["Rose via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"469773","messageId":"pull.1423.git.git.1672768772484.gitgitgadget@gmail.com","threadId":"59031","inReplyTo":null,"subject":"[PATCH] run-command: make async_exit usage consistent","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-03T17:59:32Z","receivedAt":"2023-01-03T17:59:43Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nUse async_exit instead of pthread_exit,\nand make async_exit inline.\n\nFunctions were reordered\nso that this would compile.\n\nLuckily, the order remains consistent.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    run-command: make async_exit usage consistent\n    \n    Use async_exit instead of pthread_exit, and make async_exit inline.\n    \n    Finally, make the parameter an unsigned int, because the Win32 API uses\n    unsigned int, and for other platforms, we cast to void anyway.\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1423%2FAtariDreams%2Fconsistency-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1423/AtariDreams/consistency-v1\nPull-Request: https://github.com/git/git/pull/1423\n\n run-command.c | 28 ++++++++++++++--------------\n 1 file changed, 14 insertions(+), 14 deletions(-)\n\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..e1eab4cb69b 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1030,6 +1030,18 @@ static void *run_thread(void *data)\n \treturn (void *)ret;\n }\n \n+int in_async(void)\n+{\n+\tif (!main_thread_set)\n+\t\treturn 0; /* no asyncs started yet */\n+\treturn !pthread_equal(main_thread, pthread_self());\n+}\n+\n+static inline void NORETURN async_exit(int code)\n+{\n+\tpthread_exit((void *)(intptr_t)code);\n+}\n+\n static NORETURN void die_async(const char *err, va_list params)\n {\n \treport_fn die_message_fn = get_die_message_routine();\n@@ -1042,7 +1054,7 @@ static NORETURN void die_async(const char *err, va_list params)\n \t\t\tclose(async->proc_in);\n \t\tif (async->proc_out >= 0)\n \t\t\tclose(async->proc_out);\n-\t\tpthread_exit((void *)128);\n+\t\tasync_exit(128);\n \t}\n \n \texit(128);\n@@ -1055,18 +1067,6 @@ static int async_die_is_recursing(void)\n \treturn ret != NULL;\n }\n \n-int in_async(void)\n-{\n-\tif (!main_thread_set)\n-\t\treturn 0; /* no asyncs started yet */\n-\treturn !pthread_equal(main_thread, pthread_self());\n-}\n-\n-static void NORETURN async_exit(int code)\n-{\n-\tpthread_exit((void *)(intptr_t)code);\n-}\n-\n #else\n \n static struct {\n@@ -1112,7 +1112,7 @@ int in_async(void)\n \treturn process_is_async;\n }\n \n-static void NORETURN async_exit(int code)\n+static inline void NORETURN async_exit(int code)\n {\n \texit(code);\n }\n\nbase-commit: 2b4f5a4e4bb102ac8d967cea653ed753b608193c\n-- \ngitgitgadget\n"},{"id":"469915","messageId":"pull.1423.v2.git.git.1673188382186.gitgitgadget@gmail.com","threadId":"59031","inReplyTo":"pull.1423.git.git.1672768772484.gitgitgadget@gmail.com","subject":"[PATCH v2] run-command: make async_exit usage consistent","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-08T14:33:02Z","receivedAt":"2023-01-08T14:33:09Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nUse async_exit instead of pthread_exit,\nand make async_exit inline.\n\nFunctions were reordered\nso that this would compile.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    run-command: make async_exit usage consistent\n    \n    Use async_exit instead of pthread_exit, and make async_exit inline.\n    \n    Finally, make the parameter an unsigned int, because the Win32 API uses\n    unsigned int, and for other platforms, we cast to void anyway.\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1423%2FAtariDreams%2Fconsistency-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1423/AtariDreams/consistency-v2\nPull-Request: https://github.com/git/git/pull/1423\n\nRange-diff vs v1:\n\n 1:  b5f29059d79 ! 1:  d4cf19107ed run-command: make async_exit usage consistent\n     @@ Commit message\n          Functions were reordered\n          so that this would compile.\n      \n     -    Luckily, the order remains consistent.\n     -\n          Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n      \n       ## run-command.c ##\n\n\n run-command.c | 28 ++++++++++++++--------------\n 1 file changed, 14 insertions(+), 14 deletions(-)\n\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..e1eab4cb69b 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1030,6 +1030,18 @@ static void *run_thread(void *data)\n \treturn (void *)ret;\n }\n \n+int in_async(void)\n+{\n+\tif (!main_thread_set)\n+\t\treturn 0; /* no asyncs started yet */\n+\treturn !pthread_equal(main_thread, pthread_self());\n+}\n+\n+static inline void NORETURN async_exit(int code)\n+{\n+\tpthread_exit((void *)(intptr_t)code);\n+}\n+\n static NORETURN void die_async(const char *err, va_list params)\n {\n \treport_fn die_message_fn = get_die_message_routine();\n@@ -1042,7 +1054,7 @@ static NORETURN void die_async(const char *err, va_list params)\n \t\t\tclose(async->proc_in);\n \t\tif (async->proc_out >= 0)\n \t\t\tclose(async->proc_out);\n-\t\tpthread_exit((void *)128);\n+\t\tasync_exit(128);\n \t}\n \n \texit(128);\n@@ -1055,18 +1067,6 @@ static int async_die_is_recursing(void)\n \treturn ret != NULL;\n }\n \n-int in_async(void)\n-{\n-\tif (!main_thread_set)\n-\t\treturn 0; /* no asyncs started yet */\n-\treturn !pthread_equal(main_thread, pthread_self());\n-}\n-\n-static void NORETURN async_exit(int code)\n-{\n-\tpthread_exit((void *)(intptr_t)code);\n-}\n-\n #else\n \n static struct {\n@@ -1112,7 +1112,7 @@ int in_async(void)\n \treturn process_is_async;\n }\n \n-static void NORETURN async_exit(int code)\n+static inline void NORETURN async_exit(int code)\n {\n \texit(code);\n }\n\nbase-commit: a38d39a4c50d1275833aba54c4dbdfce9e2e9ca1\n-- \ngitgitgadget\n"},{"id":"469920","messageId":"pull.1423.v3.git.git.1673190790670.gitgitgadget@gmail.com","threadId":"59031","inReplyTo":"pull.1423.v2.git.git.1673188382186.gitgitgadget@gmail.com","subject":"[PATCH v3] run-command: remove async_exit","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-08T15:13:10Z","receivedAt":"2023-01-08T15:13:38Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nUse pthread_exit instead of async_exit.\n\nThis means we do not have\nto deal with Windows's implementation\nrequiring an unsigned exit coded\ndespite the POSIX exit code requiring\na signed exit code.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    run-command: remove async_exit\n    \n    Use pthread_exit instead of async_exit.\n    \n    This means we do not have to deal with Windows's implementation\n    requiring an unsigned exit coded despite the POSIX exit code requiring a\n    signed exit code.\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1423%2FAtariDreams%2Fconsistency-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1423/AtariDreams/consistency-v3\nPull-Request: https://github.com/git/git/pull/1423\n\nRange-diff vs v2:\n\n 1:  d4cf19107ed ! 1:  21833375dca run-command: make async_exit usage consistent\n     @@ Metadata\n      Author: Seija Kijin <doremylover123@gmail.com>\n      \n       ## Commit message ##\n     -    run-command: make async_exit usage consistent\n     +    run-command: remove async_exit\n      \n     -    Use async_exit instead of pthread_exit,\n     -    and make async_exit inline.\n     +    Use pthread_exit instead of async_exit.\n      \n     -    Functions were reordered\n     -    so that this would compile.\n     +    This means we do not have\n     +    to deal with Windows's implementation\n     +    requiring an unsigned exit coded\n     +    despite the POSIX exit code requiring\n     +    a signed exit code.\n      \n          Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n      \n     @@ run-command.c: static void *run_thread(void *data)\n      +\t\treturn 0; /* no asyncs started yet */\n      +\treturn !pthread_equal(main_thread, pthread_self());\n      +}\n     -+\n     -+static inline void NORETURN async_exit(int code)\n     -+{\n     -+\tpthread_exit((void *)(intptr_t)code);\n     -+}\n      +\n       static NORETURN void die_async(const char *err, va_list params)\n       {\n       \treport_fn die_message_fn = get_die_message_routine();\n     -@@ run-command.c: static NORETURN void die_async(const char *err, va_list params)\n     - \t\t\tclose(async->proc_in);\n     - \t\tif (async->proc_out >= 0)\n     - \t\t\tclose(async->proc_out);\n     --\t\tpthread_exit((void *)128);\n     -+\t\tasync_exit(128);\n     - \t}\n     - \n     - \texit(128);\n      @@ run-command.c: static int async_die_is_recursing(void)\n       \treturn ret != NULL;\n       }\n     @@ run-command.c: int in_async(void)\n       }\n       \n      -static void NORETURN async_exit(int code)\n     -+static inline void NORETURN async_exit(int code)\n     +-{\n     +-\texit(code);\n     +-}\n     +-\n     + #endif\n     + \n     + void check_pipe(int err)\n       {\n     - \texit(code);\n     - }\n     + \tif (err == EPIPE) {\n     +-\t\tif (in_async())\n     +-\t\t\tasync_exit(141);\n     ++\t\tif (in_async()) {\n     ++#ifdef NO_PTHREADS\n     ++\t\t\texit(141);\n     ++#else\n     ++\t\t\tpthread_exit((void *)141);\n     ++#endif\n     ++\t\t}\n     + \n     + \t\tsignal(SIGPIPE, SIG_DFL);\n     + \t\traise(SIGPIPE);\n\n\n run-command.c | 33 ++++++++++++++-------------------\n 1 file changed, 14 insertions(+), 19 deletions(-)\n\ndiff --git a/run-command.c b/run-command.c\nindex 756f1839aab..4a9bcd6c841 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -1030,6 +1030,13 @@ static void *run_thread(void *data)\n \treturn (void *)ret;\n }\n \n+int in_async(void)\n+{\n+\tif (!main_thread_set)\n+\t\treturn 0; /* no asyncs started yet */\n+\treturn !pthread_equal(main_thread, pthread_self());\n+}\n+\n static NORETURN void die_async(const char *err, va_list params)\n {\n \treport_fn die_message_fn = get_die_message_routine();\n@@ -1055,18 +1062,6 @@ static int async_die_is_recursing(void)\n \treturn ret != NULL;\n }\n \n-int in_async(void)\n-{\n-\tif (!main_thread_set)\n-\t\treturn 0; /* no asyncs started yet */\n-\treturn !pthread_equal(main_thread, pthread_self());\n-}\n-\n-static void NORETURN async_exit(int code)\n-{\n-\tpthread_exit((void *)(intptr_t)code);\n-}\n-\n #else\n \n static struct {\n@@ -1112,18 +1107,18 @@ int in_async(void)\n \treturn process_is_async;\n }\n \n-static void NORETURN async_exit(int code)\n-{\n-\texit(code);\n-}\n-\n #endif\n \n void check_pipe(int err)\n {\n \tif (err == EPIPE) {\n-\t\tif (in_async())\n-\t\t\tasync_exit(141);\n+\t\tif (in_async()) {\n+#ifdef NO_PTHREADS\n+\t\t\texit(141);\n+#else\n+\t\t\tpthread_exit((void *)141);\n+#endif\n+\t\t}\n \n \t\tsignal(SIGPIPE, SIG_DFL);\n \t\traise(SIGPIPE);\n\nbase-commit: a38d39a4c50d1275833aba54c4dbdfce9e2e9ca1\n-- \ngitgitgadget\n"}]}