All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] run-command: make async_exit usage consistent
@ 2023-01-03 17:59 Rose via GitGitGadget
  2023-01-08 14:33 ` [PATCH v2] " Rose via GitGitGadget
  0 siblings, 1 reply; 3+ messages in thread
From: Rose via GitGitGadget @ 2023-01-03 17:59 UTC (permalink / raw)
  To: git; +Cc: Rose, Seija Kijin

From: Seija Kijin <doremylover123@gmail.com>

Use async_exit instead of pthread_exit,
and make async_exit inline.

Functions were reordered
so that this would compile.

Luckily, the order remains consistent.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    run-command: make async_exit usage consistent
    
    Use async_exit instead of pthread_exit, and make async_exit inline.
    
    Finally, make the parameter an unsigned int, because the Win32 API uses
    unsigned int, and for other platforms, we cast to void anyway.
    
    Signed-off-by: Seija Kijin doremylover123@gmail.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1423%2FAtariDreams%2Fconsistency-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1423/AtariDreams/consistency-v1
Pull-Request: https://github.com/git/git/pull/1423

 run-command.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/run-command.c b/run-command.c
index 756f1839aab..e1eab4cb69b 100644
--- a/run-command.c
+++ b/run-command.c
@@ -1030,6 +1030,18 @@ static void *run_thread(void *data)
 	return (void *)ret;
 }
 
+int in_async(void)
+{
+	if (!main_thread_set)
+		return 0; /* no asyncs started yet */
+	return !pthread_equal(main_thread, pthread_self());
+}
+
+static inline void NORETURN async_exit(int code)
+{
+	pthread_exit((void *)(intptr_t)code);
+}
+
 static NORETURN void die_async(const char *err, va_list params)
 {
 	report_fn die_message_fn = get_die_message_routine();
@@ -1042,7 +1054,7 @@ static NORETURN void die_async(const char *err, va_list params)
 			close(async->proc_in);
 		if (async->proc_out >= 0)
 			close(async->proc_out);
-		pthread_exit((void *)128);
+		async_exit(128);
 	}
 
 	exit(128);
@@ -1055,18 +1067,6 @@ static int async_die_is_recursing(void)
 	return ret != NULL;
 }
 
-int in_async(void)
-{
-	if (!main_thread_set)
-		return 0; /* no asyncs started yet */
-	return !pthread_equal(main_thread, pthread_self());
-}
-
-static void NORETURN async_exit(int code)
-{
-	pthread_exit((void *)(intptr_t)code);
-}
-
 #else
 
 static struct {
@@ -1112,7 +1112,7 @@ int in_async(void)
 	return process_is_async;
 }
 
-static void NORETURN async_exit(int code)
+static inline void NORETURN async_exit(int code)
 {
 	exit(code);
 }

base-commit: 2b4f5a4e4bb102ac8d967cea653ed753b608193c
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2] run-command: make async_exit usage consistent
  2023-01-03 17:59 [PATCH] run-command: make async_exit usage consistent Rose via GitGitGadget
@ 2023-01-08 14:33 ` Rose via GitGitGadget
  2023-01-08 15:13   ` [PATCH v3] run-command: remove async_exit Rose via GitGitGadget
  0 siblings, 1 reply; 3+ messages in thread
From: Rose via GitGitGadget @ 2023-01-08 14:33 UTC (permalink / raw)
  To: git; +Cc: Rose, Seija Kijin

From: Seija Kijin <doremylover123@gmail.com>

Use async_exit instead of pthread_exit,
and make async_exit inline.

Functions were reordered
so that this would compile.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    run-command: make async_exit usage consistent
    
    Use async_exit instead of pthread_exit, and make async_exit inline.
    
    Finally, make the parameter an unsigned int, because the Win32 API uses
    unsigned int, and for other platforms, we cast to void anyway.
    
    Signed-off-by: Seija Kijin doremylover123@gmail.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1423%2FAtariDreams%2Fconsistency-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1423/AtariDreams/consistency-v2
Pull-Request: https://github.com/git/git/pull/1423

Range-diff vs v1:

 1:  b5f29059d79 ! 1:  d4cf19107ed run-command: make async_exit usage consistent
     @@ Commit message
          Functions were reordered
          so that this would compile.
      
     -    Luckily, the order remains consistent.
     -
          Signed-off-by: Seija Kijin <doremylover123@gmail.com>
      
       ## run-command.c ##


 run-command.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/run-command.c b/run-command.c
index 756f1839aab..e1eab4cb69b 100644
--- a/run-command.c
+++ b/run-command.c
@@ -1030,6 +1030,18 @@ static void *run_thread(void *data)
 	return (void *)ret;
 }
 
+int in_async(void)
+{
+	if (!main_thread_set)
+		return 0; /* no asyncs started yet */
+	return !pthread_equal(main_thread, pthread_self());
+}
+
+static inline void NORETURN async_exit(int code)
+{
+	pthread_exit((void *)(intptr_t)code);
+}
+
 static NORETURN void die_async(const char *err, va_list params)
 {
 	report_fn die_message_fn = get_die_message_routine();
@@ -1042,7 +1054,7 @@ static NORETURN void die_async(const char *err, va_list params)
 			close(async->proc_in);
 		if (async->proc_out >= 0)
 			close(async->proc_out);
-		pthread_exit((void *)128);
+		async_exit(128);
 	}
 
 	exit(128);
@@ -1055,18 +1067,6 @@ static int async_die_is_recursing(void)
 	return ret != NULL;
 }
 
-int in_async(void)
-{
-	if (!main_thread_set)
-		return 0; /* no asyncs started yet */
-	return !pthread_equal(main_thread, pthread_self());
-}
-
-static void NORETURN async_exit(int code)
-{
-	pthread_exit((void *)(intptr_t)code);
-}
-
 #else
 
 static struct {
@@ -1112,7 +1112,7 @@ int in_async(void)
 	return process_is_async;
 }
 
-static void NORETURN async_exit(int code)
+static inline void NORETURN async_exit(int code)
 {
 	exit(code);
 }

base-commit: a38d39a4c50d1275833aba54c4dbdfce9e2e9ca1
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v3] run-command: remove async_exit
  2023-01-08 14:33 ` [PATCH v2] " Rose via GitGitGadget
@ 2023-01-08 15:13   ` Rose via GitGitGadget
  0 siblings, 0 replies; 3+ messages in thread
From: Rose via GitGitGadget @ 2023-01-08 15:13 UTC (permalink / raw)
  To: git; +Cc: Rose, Seija Kijin

From: Seija Kijin <doremylover123@gmail.com>

Use pthread_exit instead of async_exit.

This means we do not have
to deal with Windows's implementation
requiring an unsigned exit coded
despite the POSIX exit code requiring
a signed exit code.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    run-command: remove async_exit
    
    Use pthread_exit instead of async_exit.
    
    This means we do not have to deal with Windows's implementation
    requiring an unsigned exit coded despite the POSIX exit code requiring a
    signed exit code.
    
    Signed-off-by: Seija Kijin doremylover123@gmail.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1423%2FAtariDreams%2Fconsistency-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1423/AtariDreams/consistency-v3
Pull-Request: https://github.com/git/git/pull/1423

Range-diff vs v2:

 1:  d4cf19107ed ! 1:  21833375dca run-command: make async_exit usage consistent
     @@ Metadata
      Author: Seija Kijin <doremylover123@gmail.com>
      
       ## Commit message ##
     -    run-command: make async_exit usage consistent
     +    run-command: remove async_exit
      
     -    Use async_exit instead of pthread_exit,
     -    and make async_exit inline.
     +    Use pthread_exit instead of async_exit.
      
     -    Functions were reordered
     -    so that this would compile.
     +    This means we do not have
     +    to deal with Windows's implementation
     +    requiring an unsigned exit coded
     +    despite the POSIX exit code requiring
     +    a signed exit code.
      
          Signed-off-by: Seija Kijin <doremylover123@gmail.com>
      
     @@ run-command.c: static void *run_thread(void *data)
      +		return 0; /* no asyncs started yet */
      +	return !pthread_equal(main_thread, pthread_self());
      +}
     -+
     -+static inline void NORETURN async_exit(int code)
     -+{
     -+	pthread_exit((void *)(intptr_t)code);
     -+}
      +
       static NORETURN void die_async(const char *err, va_list params)
       {
       	report_fn die_message_fn = get_die_message_routine();
     -@@ run-command.c: static NORETURN void die_async(const char *err, va_list params)
     - 			close(async->proc_in);
     - 		if (async->proc_out >= 0)
     - 			close(async->proc_out);
     --		pthread_exit((void *)128);
     -+		async_exit(128);
     - 	}
     - 
     - 	exit(128);
      @@ run-command.c: static int async_die_is_recursing(void)
       	return ret != NULL;
       }
     @@ run-command.c: int in_async(void)
       }
       
      -static void NORETURN async_exit(int code)
     -+static inline void NORETURN async_exit(int code)
     +-{
     +-	exit(code);
     +-}
     +-
     + #endif
     + 
     + void check_pipe(int err)
       {
     - 	exit(code);
     - }
     + 	if (err == EPIPE) {
     +-		if (in_async())
     +-			async_exit(141);
     ++		if (in_async()) {
     ++#ifdef NO_PTHREADS
     ++			exit(141);
     ++#else
     ++			pthread_exit((void *)141);
     ++#endif
     ++		}
     + 
     + 		signal(SIGPIPE, SIG_DFL);
     + 		raise(SIGPIPE);


 run-command.c | 33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/run-command.c b/run-command.c
index 756f1839aab..4a9bcd6c841 100644
--- a/run-command.c
+++ b/run-command.c
@@ -1030,6 +1030,13 @@ static void *run_thread(void *data)
 	return (void *)ret;
 }
 
+int in_async(void)
+{
+	if (!main_thread_set)
+		return 0; /* no asyncs started yet */
+	return !pthread_equal(main_thread, pthread_self());
+}
+
 static NORETURN void die_async(const char *err, va_list params)
 {
 	report_fn die_message_fn = get_die_message_routine();
@@ -1055,18 +1062,6 @@ static int async_die_is_recursing(void)
 	return ret != NULL;
 }
 
-int in_async(void)
-{
-	if (!main_thread_set)
-		return 0; /* no asyncs started yet */
-	return !pthread_equal(main_thread, pthread_self());
-}
-
-static void NORETURN async_exit(int code)
-{
-	pthread_exit((void *)(intptr_t)code);
-}
-
 #else
 
 static struct {
@@ -1112,18 +1107,18 @@ int in_async(void)
 	return process_is_async;
 }
 
-static void NORETURN async_exit(int code)
-{
-	exit(code);
-}
-
 #endif
 
 void check_pipe(int err)
 {
 	if (err == EPIPE) {
-		if (in_async())
-			async_exit(141);
+		if (in_async()) {
+#ifdef NO_PTHREADS
+			exit(141);
+#else
+			pthread_exit((void *)141);
+#endif
+		}
 
 		signal(SIGPIPE, SIG_DFL);
 		raise(SIGPIPE);

base-commit: a38d39a4c50d1275833aba54c4dbdfce9e2e9ca1
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-08 15:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-03 17:59 [PATCH] run-command: make async_exit usage consistent Rose via GitGitGadget
2023-01-08 14:33 ` [PATCH v2] " Rose via GitGitGadget
2023-01-08 15:13   ` [PATCH v3] run-command: remove async_exit Rose via GitGitGadget

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.