diff mbox series

xf86drm: only include <sys/sysctl.h> for FreeBSD build case

Message ID 1578562330-25594-1-git-send-email-sw0312.kim@samsung.com (mailing list archive)
State New, archived
Headers show
Series xf86drm: only include <sys/sysctl.h> for FreeBSD build case | expand

Commit Message

Seung-Woo Kim Jan. 9, 2020, 9:32 a.m. UTC
The <sys/sysctl.h> header is only required FreeBSD and GNU libc
2.30 starts to warn about Linux specific <sys/sysctl.h> header
deprecation. Only include <sys/sysctl.h> for FreeBSD.

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
---
 xf86drmMode.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Jani Nikula Jan. 9, 2020, 3:18 p.m. UTC | #1
On Thu, 09 Jan 2020, Seung-Woo Kim <sw0312.kim@samsung.com> wrote:
> The <sys/sysctl.h> header is only required FreeBSD and GNU libc
> 2.30 starts to warn about Linux specific <sys/sysctl.h> header
> deprecation. Only include <sys/sysctl.h> for FreeBSD.
>
> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
> ---
>  xf86drmMode.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/xf86drmMode.c b/xf86drmMode.c
> index 207d7be..ff1d31d 100644
> --- a/xf86drmMode.c
> +++ b/xf86drmMode.c
> @@ -42,9 +42,11 @@
>  #include <stdint.h>
>  #include <stdlib.h>
>  #include <sys/ioctl.h>
> +#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
>  #ifdef HAVE_SYS_SYSCTL_H

Not that I know anything about this, but shouldn't you instead fix
HAVE_SYS_SYSCTL_H definition in configure stage to only be enabled on
FreeBSD?

BR,
Jani.

>  #include <sys/sysctl.h>
>  #endif
> +#endif /* defined (__FreeBSD__) || defined (__FreeBSD_kernel__) */
>  #include <stdio.h>
>  #include <stdbool.h>
Niclas Zeising Jan. 9, 2020, 3:28 p.m. UTC | #2
On 2020-01-09 16:18, Jani Nikula wrote:
> On Thu, 09 Jan 2020, Seung-Woo Kim <sw0312.kim@samsung.com> wrote:
>> The <sys/sysctl.h> header is only required FreeBSD and GNU libc
>> 2.30 starts to warn about Linux specific <sys/sysctl.h> header
>> deprecation. Only include <sys/sysctl.h> for FreeBSD.
>>
>> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
>> ---
>>   xf86drmMode.c |    2 ++
>>   1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/xf86drmMode.c b/xf86drmMode.c
>> index 207d7be..ff1d31d 100644
>> --- a/xf86drmMode.c
>> +++ b/xf86drmMode.c
>> @@ -42,9 +42,11 @@
>>   #include <stdint.h>
>>   #include <stdlib.h>
>>   #include <sys/ioctl.h>
>> +#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
>>   #ifdef HAVE_SYS_SYSCTL_H
> 
> Not that I know anything about this, but shouldn't you instead fix
> HAVE_SYS_SYSCTL_H definition in configure stage to only be enabled on
> FreeBSD?
> 
> BR,
> Jani.
> 
>>   #include <sys/sysctl.h>
>>   #endif
>> +#endif /* defined (__FreeBSD__) || defined (__FreeBSD_kernel__) */
>>   #include <stdio.h>
>>   #include <stdbool.h>
> 

Hi!
This fix looks OK on FreeBSD (I haven't had time to test), however, as 
has been pointed out, perhaps the change should go into the meson build 
script or configure instead.
I don't know if other OSes (other BSDs primarily) need this as well. 
I'm pretty sure it's needed on DragonflyBSD at least.
Perhaps keep the include for everything except Linux for the time being?
Regards
Seung-Woo Kim Jan. 10, 2020, 12:47 a.m. UTC | #3
Hi,

On 2020년 01월 10일 00:18, Jani Nikula wrote:
> On Thu, 09 Jan 2020, Seung-Woo Kim <sw0312.kim@samsung.com> wrote:
>> The <sys/sysctl.h> header is only required FreeBSD and GNU libc
>> 2.30 starts to warn about Linux specific <sys/sysctl.h> header
>> deprecation. Only include <sys/sysctl.h> for FreeBSD.
>>
>> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
>> ---
>>  xf86drmMode.c |    2 ++
>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/xf86drmMode.c b/xf86drmMode.c
>> index 207d7be..ff1d31d 100644
>> --- a/xf86drmMode.c
>> +++ b/xf86drmMode.c
>> @@ -42,9 +42,11 @@
>>  #include <stdint.h>
>>  #include <stdlib.h>
>>  #include <sys/ioctl.h>
>> +#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
>>  #ifdef HAVE_SYS_SYSCTL_H
> 
> Not that I know anything about this, but shouldn't you instead fix
> HAVE_SYS_SYSCTL_H definition in configure stage to only be enabled on
> FreeBSD?

That seems better even in the xf86drmMode.c, <sys/sysctl.h> is required
for sysctlbyname() called from drmCheckModesettingSupported() with
FeeBSD build macro.

Unfortunately, I am not the meson build expert so if there is someone to
fix, then I am okay. Anyway, I will try to fix with HAVE_SYS_SYSCTL_H.

Best Regards,
- Seung-Woo Kim

> 
> BR,
> Jani.
> 
>>  #include <sys/sysctl.h>
>>  #endif
>> +#endif /* defined (__FreeBSD__) || defined (__FreeBSD_kernel__) */
>>  #include <stdio.h>
>>  #include <stdbool.h>
>
Seung-Woo Kim Jan. 10, 2020, 12:52 a.m. UTC | #4
Hi

On 2020년 01월 10일 00:28, Niclas Zeising wrote:
> On 2020-01-09 16:18, Jani Nikula wrote:
>> On Thu, 09 Jan 2020, Seung-Woo Kim <sw0312.kim@samsung.com> wrote:
>>> The <sys/sysctl.h> header is only required FreeBSD and GNU libc
>>> 2.30 starts to warn about Linux specific <sys/sysctl.h> header
>>> deprecation. Only include <sys/sysctl.h> for FreeBSD.
>>>
>>> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
>>> ---
>>>   xf86drmMode.c |    2 ++
>>>   1 files changed, 2 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/xf86drmMode.c b/xf86drmMode.c
>>> index 207d7be..ff1d31d 100644
>>> --- a/xf86drmMode.c
>>> +++ b/xf86drmMode.c
>>> @@ -42,9 +42,11 @@
>>>   #include <stdint.h>
>>>   #include <stdlib.h>
>>>   #include <sys/ioctl.h>
>>> +#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
>>>   #ifdef HAVE_SYS_SYSCTL_H
>>
>> Not that I know anything about this, but shouldn't you instead fix
>> HAVE_SYS_SYSCTL_H definition in configure stage to only be enabled on
>> FreeBSD?
>>
>> BR,
>> Jani.
>>
>>>   #include <sys/sysctl.h>
>>>   #endif
>>> +#endif /* defined (__FreeBSD__) || defined (__FreeBSD_kernel__) */
>>>   #include <stdio.h>
>>>   #include <stdbool.h>
>>
> 
> Hi!
> This fix looks OK on FreeBSD (I haven't had time to test), however, as
> has been pointed out, perhaps the change should go into the meson build
> script or configure instead.

Ok, I will try to fix in build side instead of include itself.

> I don't know if other OSes (other BSDs primarily) need this as well. I'm
> pretty sure it's needed on DragonflyBSD at least.
> Perhaps keep the include for everything except Linux for the time being?

As far as I checked, sysctlbyname() called only with FreeBSD build flag
is only function defined in <sys/sysctl.h> at least for xf86drmMode.c,
but I missed something. The header deprecation is done from Linux, so it
seems fine removing the header include only for Linux.

Best Regards,
- Seung-Woo Kim

> Regards
diff mbox series

Patch

diff --git a/xf86drmMode.c b/xf86drmMode.c
index 207d7be..ff1d31d 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -42,9 +42,11 @@ 
 #include <stdint.h>
 #include <stdlib.h>
 #include <sys/ioctl.h>
+#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
 #ifdef HAVE_SYS_SYSCTL_H
 #include <sys/sysctl.h>
 #endif
+#endif /* defined (__FreeBSD__) || defined (__FreeBSD_kernel__) */
 #include <stdio.h>
 #include <stdbool.h>