+2021-12-11 Bruno Haible <bruno@clisp.org>
+
+ get_ppid_of, get_progname_of: Fix compilation error on Mac OS X < 10.5.
+ Reported by Ryan Schmidt <gnulib@ryandesign.com> in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2021-12/msg00011.html>.
+ * lib/get_ppid_of.c: Include AvailabilityMacros.h
+ (get_ppid_of): Use MAC_OS_X_VERSION_MAX_ALLOWED and
+ MAC_OS_X_VERSION_MIN_REQUIRED.
+ * lib/get_progname_of: Include AvailabilityMacros.h
+ (get_progname_of): Use MAC_OS_X_VERSION_MAX_ALLOWED and
+ MAC_OS_X_VERSION_MIN_REQUIRED.
+
2021-12-10 Paul Eggert <eggert@cs.ucla.edu>
backupfile: assume C99 decls
#endif
#if defined __APPLE__ && defined __MACH__ /* Mac OS X */
-# include <libproc.h>
+/* Get MAC_OS_X_VERSION_MIN_REQUIRED, MAC_OS_X_VERSION_MAX_ALLOWED.
+ The version at runtime satisfies
+ MAC_OS_X_VERSION_MIN_REQUIRED <= version <= MAC_OS_X_VERSION_MAX_ALLOWED. */
+# include <AvailabilityMacros.h>
+# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
+# include <libproc.h>
+# endif
#endif
#if defined _AIX /* AIX */
#endif
#if defined __APPLE__ && defined __MACH__ /* Mac OS X */
+# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
-# if defined PROC_PIDT_SHORTBSDINFO
+ /* Mac OS X >= 10.7 has PROC_PIDT_SHORTBSDINFO. */
+# if defined PROC_PIDT_SHORTBSDINFO
struct proc_bsdshortinfo info;
if (proc_pidinfo (pid, PROC_PIDT_SHORTBSDINFO, 0, &info, sizeof (info))
== sizeof (info))
return info.pbsi_ppid;
-# else
+# endif
+
+# if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+ /* For older versions, use PROC_PIDTBSDINFO instead. */
/* Note: The second part of 'struct proc_bsdinfo' differs in size between
32-bit and 64-bit environments, and the kernel of Mac OS X 10.5 knows
only about the 32-bit 'struct proc_bsdinfo'. Fortunately all the info
if (proc_pidinfo (pid, PROC_PIDTBSDINFO, 0, &info, 128) == 128)
return info.pbi_ppid;
-# endif
+# endif
+# endif
#endif
#if defined _AIX /* AIX */
#endif
#if defined __APPLE__ && defined __MACH__ /* Mac OS X */
-# include <libproc.h>
+/* Get MAC_OS_X_VERSION_MIN_REQUIRED, MAC_OS_X_VERSION_MAX_ALLOWED.
+ The version at runtime satisfies
+ MAC_OS_X_VERSION_MIN_REQUIRED <= version <= MAC_OS_X_VERSION_MAX_ALLOWED. */
+# include <AvailabilityMacros.h>
+# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
+# include <libproc.h>
+# endif
#endif
#if defined _AIX /* AIX */
#endif
#if defined __APPLE__ && defined __MACH__ /* Mac OS X */
+# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
-# if defined PROC_PIDT_SHORTBSDINFO
+ /* Mac OS X >= 10.7 has PROC_PIDT_SHORTBSDINFO. */
+# if defined PROC_PIDT_SHORTBSDINFO
struct proc_bsdshortinfo info;
if (proc_pidinfo (pid, PROC_PIDT_SHORTBSDINFO, 0, &info, sizeof (info))
== sizeof (info))
return strdup (info.pbsi_comm);
-# else
+# endif
+
+# if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+ /* For older versions, use PROC_PIDTBSDINFO instead. */
/* Note: The second part of 'struct proc_bsdinfo' differs in size between
32-bit and 64-bit environments, and the kernel of Mac OS X 10.5 knows
only about the 32-bit 'struct proc_bsdinfo'. Fortunately all the info
if (proc_pidinfo (pid, PROC_PIDTBSDINFO, 0, &info, 128) == 128)
return strdup (info.pbi_comm);
-# endif
+# endif
+# endif
#endif
#if defined _AIX /* AIX */