diff options
| author | Mattias EngdegÄrd | 2022-04-16 11:33:14 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2022-04-16 11:33:14 +0200 |
| commit | 855e15dbf10a6aac42b860fdb28711f979e2bf22 (patch) | |
| tree | e790bd946cfff4abb300d2e475ba63c1581d3ead /src | |
| parent | 9da744e45021648a37f175967b536b151fd18750 (diff) | |
| download | emacs-855e15dbf10a6aac42b860fdb28711f979e2bf22.tar.gz emacs-855e15dbf10a6aac42b860fdb28711f979e2bf22.zip | |
Fix builds on older versions of macOS
This adds back macOS-specific code replaced earlier (bug#48548),
specifically to fix build errors on macOS 10.7.5. See discussion at
https://lists.gnu.org/archive/html/emacs-devel/2022-04/msg00779.html .
* src/sysdep.c (HAVE_RUSAGE_INFO_CURRENT, HAVE_PROC_PIDINFO): New.
(system_process_attributes): Use alternative code or exclude features
when building on older macOS versions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/sysdep.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/sysdep.c b/src/sysdep.c index 1e630835add..f6d7d3920bd 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -4027,6 +4027,9 @@ system_process_attributes (Lisp_Object pid) | |||
| 4027 | 4027 | ||
| 4028 | #elif defined DARWIN_OS | 4028 | #elif defined DARWIN_OS |
| 4029 | 4029 | ||
| 4030 | #define HAVE_RUSAGE_INFO_CURRENT (MAC_OS_X_VERSION_MIN_REQUIRED >= 101000) | ||
| 4031 | #define HAVE_PROC_PIDINFO (MAC_OS_X_VERSION_MIN_REQUIRED >= 1050) | ||
| 4032 | |||
| 4030 | Lisp_Object | 4033 | Lisp_Object |
| 4031 | system_process_attributes (Lisp_Object pid) | 4034 | system_process_attributes (Lisp_Object pid) |
| 4032 | { | 4035 | { |
| @@ -4130,6 +4133,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 4130 | attrs = Fcons (Fcons (Qtpgid, INT_TO_INTEGER (proc.kp_eproc.e_tpgid)), | 4133 | attrs = Fcons (Fcons (Qtpgid, INT_TO_INTEGER (proc.kp_eproc.e_tpgid)), |
| 4131 | attrs); | 4134 | attrs); |
| 4132 | 4135 | ||
| 4136 | #if HAVE_RUSAGE_INFO_CURRENT | ||
| 4133 | rusage_info_current ri; | 4137 | rusage_info_current ri; |
| 4134 | if (proc_pid_rusage(proc_id, RUSAGE_INFO_CURRENT, (rusage_info_t *) &ri) == 0) | 4138 | if (proc_pid_rusage(proc_id, RUSAGE_INFO_CURRENT, (rusage_info_t *) &ri) == 0) |
| 4135 | { | 4139 | { |
| @@ -4143,6 +4147,24 @@ system_process_attributes (Lisp_Object pid) | |||
| 4143 | 4147 | ||
| 4144 | attrs = Fcons (Fcons (Qmajflt, INT_TO_INTEGER (ri.ri_pageins)), attrs); | 4148 | attrs = Fcons (Fcons (Qmajflt, INT_TO_INTEGER (ri.ri_pageins)), attrs); |
| 4145 | } | 4149 | } |
| 4150 | #else /* !HAVE_RUSAGE_INFO_CURRENT */ | ||
| 4151 | struct rusage *rusage = proc.kp_proc.p_ru; | ||
| 4152 | if (rusage) | ||
| 4153 | { | ||
| 4154 | attrs = Fcons (Fcons (Qminflt, INT_TO_INTEGER (rusage->ru_minflt)), | ||
| 4155 | attrs); | ||
| 4156 | attrs = Fcons (Fcons (Qmajflt, INT_TO_INTEGER (rusage->ru_majflt)), | ||
| 4157 | attrs); | ||
| 4158 | |||
| 4159 | attrs = Fcons (Fcons (Qutime, make_lisp_timeval (rusage->ru_utime)), | ||
| 4160 | attrs); | ||
| 4161 | attrs = Fcons (Fcons (Qstime, make_lisp_timeval (rusage->ru_stime)), | ||
| 4162 | attrs); | ||
| 4163 | struct timespec t = timespec_add (timeval_to_timespec (rusage->ru_utime), | ||
| 4164 | timeval_to_timespec (rusage->ru_stime)); | ||
| 4165 | attrs = Fcons (Fcons (Qtime, make_lisp_time (t)), attrs); | ||
| 4166 | } | ||
| 4167 | #endif /* !HAVE_RUSAGE_INFO_CURRENT */ | ||
| 4146 | 4168 | ||
| 4147 | starttime = proc.kp_proc.p_starttime; | 4169 | starttime = proc.kp_proc.p_starttime; |
| 4148 | attrs = Fcons (Fcons (Qnice, make_fixnum (proc.kp_proc.p_nice)), attrs); | 4170 | attrs = Fcons (Fcons (Qnice, make_fixnum (proc.kp_proc.p_nice)), attrs); |
| @@ -4152,6 +4174,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 4152 | t = timespec_sub (now, timeval_to_timespec (starttime)); | 4174 | t = timespec_sub (now, timeval_to_timespec (starttime)); |
| 4153 | attrs = Fcons (Fcons (Qetime, make_lisp_time (t)), attrs); | 4175 | attrs = Fcons (Fcons (Qetime, make_lisp_time (t)), attrs); |
| 4154 | 4176 | ||
| 4177 | #if HAVE_PROC_PIDINFO | ||
| 4155 | struct proc_taskinfo taskinfo; | 4178 | struct proc_taskinfo taskinfo; |
| 4156 | if (proc_pidinfo (proc_id, PROC_PIDTASKINFO, 0, &taskinfo, sizeof (taskinfo)) > 0) | 4179 | if (proc_pidinfo (proc_id, PROC_PIDTASKINFO, 0, &taskinfo, sizeof (taskinfo)) > 0) |
| 4157 | { | 4180 | { |
| @@ -4159,6 +4182,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 4159 | attrs = Fcons (Fcons (Qrss, make_fixnum (taskinfo.pti_resident_size / 1024)), attrs); | 4182 | attrs = Fcons (Fcons (Qrss, make_fixnum (taskinfo.pti_resident_size / 1024)), attrs); |
| 4160 | attrs = Fcons (Fcons (Qthcount, make_fixnum (taskinfo.pti_threadnum)), attrs); | 4183 | attrs = Fcons (Fcons (Qthcount, make_fixnum (taskinfo.pti_threadnum)), attrs); |
| 4161 | } | 4184 | } |
| 4185 | #endif /* HAVE_PROC_PIDINFO */ | ||
| 4162 | 4186 | ||
| 4163 | #ifdef KERN_PROCARGS2 | 4187 | #ifdef KERN_PROCARGS2 |
| 4164 | char args[ARG_MAX]; | 4188 | char args[ARG_MAX]; |