emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 26eeca71fb: Silence macOS vfork deprecation warnings


From: Mattias Engdegård
Subject: master 26eeca71fb: Silence macOS vfork deprecation warnings
Date: Thu, 10 Feb 2022 17:14:12 -0500 (EST)

branch: master
commit 26eeca71fbb3ee76ad51d3b83b79992f165e5f06
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Silence macOS vfork deprecation warnings
    
    The vfork system call exists and works in macOS 11.6 but the compiler
    gives a deprecation message; silence it, because the performance is
    still better than that of plain fork.  See discussion at
    https://lists.gnu.org/archive/html/emacs-devel/2022-02/msg00260.html
    
    * src/conf_post.h (VFORK): New #define.
    * src/callproc.c (emacs_spawn):
    * src/sysdep.c (sys_subshell): Use it.
---
 src/callproc.c  |  2 +-
 src/conf_post.h | 13 +++++++++++++
 src/sysdep.c    |  2 +-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/callproc.c b/src/callproc.c
index 4d3b0bb8e0..dcee740043 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1500,7 +1500,7 @@ emacs_spawn (pid_t *newpid, int std_in, int std_out, int 
std_err,
   if (pty != NULL)
     pid = fork ();
   else
-    pid = vfork ();
+    pid = VFORK ();
 #else
   pid = vfork ();
 #endif
diff --git a/src/conf_post.h b/src/conf_post.h
index 6db76a2dfa..0b6260b287 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -353,6 +353,19 @@ extern int emacs_setenv_TZ (char const *);
 # define vfork fork
 #endif
 
+/* vfork is deprecated on at least macOS 11.6 and later, but it still works
+   and is faster than fork, so silence the warning as if we knew what we
+   are doing.  */
+#ifdef DARWIN_OS
+#define VFORK()                                                                
\
+  (_Pragma("clang diagnostic push")                                    \
+   _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")   \
+   vfork ()                                                            \
+   _Pragma("clang diagnostic pop"))
+#else
+#define VFORK() vfork ()
+#endif
+
 #if ! (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__)
 # undef PROFILING
 #endif
diff --git a/src/sysdep.c b/src/sysdep.c
index d682e87cc7..c772aff6a0 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -664,7 +664,7 @@ sys_subshell (void)
 #else
   {
     char *volatile str_volatile = str;
-    pid = vfork ();
+    pid = VFORK ();
     str = str_volatile;
   }
 #endif



reply via email to

[Prev in Thread] Current Thread [Next in Thread]