From adb32f3f8f376d26381d78b8421bf860939ad426 Mon Sep 17 00:00:00 2001
From: Jan Beich <jbeich@FreeBSD.org>
Date: Wed, 16 Jun 2021 23:28:38 +0000
Subject: [PATCH] Reorder headers on FreeBSD per cpuset_setaffinity(2) manpage

In file included from tools/cpu/os_specific.cc:51:
/usr/include/sys/cpuset.h:153:12: error: unknown type name 'cpusetid_t'
int     cpuset(cpusetid_t *);
               ^
/usr/include/sys/cpuset.h:154:18: error: unknown type name 'cpuwhich_t'; did you mean '__cpuwhich_t'?
int     cpuset_setid(cpuwhich_t, id_t, cpusetid_t);
                     ^
/usr/include/sys/_types.h:146:14: note: '__cpuwhich_t' declared here
typedef int             __cpuwhich_t;   /* which parameter for cpuset. */
                        ^
In file included from tools/cpu/os_specific.cc:51:
/usr/include/sys/cpuset.h:154:30: error: unknown type name 'id_t'; did you mean 'pid_t'?
int     cpuset_setid(cpuwhich_t, id_t, cpusetid_t);
                                 ^
/usr/include/time.h:102:18: note: 'pid_t' declared here
typedef __pid_t         pid_t;
                        ^
In file included from tools/cpu/os_specific.cc:51:
/usr/include/sys/cpuset.h:154:36: error: unknown type name 'cpusetid_t'
int     cpuset_setid(cpuwhich_t, id_t, cpusetid_t);
                                       ^
/usr/include/sys/cpuset.h:155:18: error: unknown type name 'cpulevel_t'; did you mean '__cpulevel_t'?
int     cpuset_getid(cpulevel_t, cpuwhich_t, id_t, cpusetid_t *);
                     ^
/usr/include/sys/_types.h:147:14: note: '__cpulevel_t' declared here
typedef int             __cpulevel_t;   /* level parameter for cpuset. */
                        ^
In file included from tools/cpu/os_specific.cc:51:
/usr/include/sys/cpuset.h:155:30: error: unknown type name 'cpuwhich_t'; did you mean '__cpuwhich_t'?
int     cpuset_getid(cpulevel_t, cpuwhich_t, id_t, cpusetid_t *);
                                 ^
/usr/include/sys/_types.h:146:14: note: '__cpuwhich_t' declared here
typedef int             __cpuwhich_t;   /* which parameter for cpuset. */
                        ^
In file included from tools/cpu/os_specific.cc:51:
/usr/include/sys/cpuset.h:155:42: error: unknown type name 'id_t'; did you mean 'pid_t'?
int     cpuset_getid(cpulevel_t, cpuwhich_t, id_t, cpusetid_t *);
                                             ^
/usr/include/time.h:102:18: note: 'pid_t' declared here
typedef __pid_t         pid_t;
                        ^
In file included from tools/cpu/os_specific.cc:51:
/usr/include/sys/cpuset.h:155:48: error: unknown type name 'cpusetid_t'
int     cpuset_getid(cpulevel_t, cpuwhich_t, id_t, cpusetid_t *);
                                                   ^
/usr/include/sys/cpuset.h:156:24: error: unknown type name 'cpulevel_t'; did you mean '__cpulevel_t'?
int     cpuset_getaffinity(cpulevel_t, cpuwhich_t, id_t, size_t, cpuset_t *);
                           ^
/usr/include/sys/_types.h:147:14: note: '__cpulevel_t' declared here
typedef int             __cpulevel_t;   /* level parameter for cpuset. */
                        ^
In file included from tools/cpu/os_specific.cc:51:
/usr/include/sys/cpuset.h:156:36: error: unknown type name 'cpuwhich_t'; did you mean '__cpuwhich_t'?
int     cpuset_getaffinity(cpulevel_t, cpuwhich_t, id_t, size_t, cpuset_t *);
                                       ^
/usr/include/sys/_types.h:146:14: note: '__cpuwhich_t' declared here
typedef int             __cpuwhich_t;   /* which parameter for cpuset. */
                        ^
In file included from tools/cpu/os_specific.cc:51:
/usr/include/sys/cpuset.h:156:48: error: unknown type name 'id_t'; did you mean 'pid_t'?
int     cpuset_getaffinity(cpulevel_t, cpuwhich_t, id_t, size_t, cpuset_t *);
                                                   ^
/usr/include/time.h:102:18: note: 'pid_t' declared here
typedef __pid_t         pid_t;
                        ^
In file included from tools/cpu/os_specific.cc:51:
/usr/include/sys/cpuset.h:157:24: error: unknown type name 'cpulevel_t'; did you mean '__cpulevel_t'?
int     cpuset_setaffinity(cpulevel_t, cpuwhich_t, id_t, size_t, const cpuset_t *);
                           ^
/usr/include/sys/_types.h:147:14: note: '__cpulevel_t' declared here
typedef int             __cpulevel_t;   /* level parameter for cpuset. */
                        ^
In file included from tools/cpu/os_specific.cc:51:
/usr/include/sys/cpuset.h:157:36: error: unknown type name 'cpuwhich_t'; did you mean '__cpuwhich_t'?
int     cpuset_setaffinity(cpulevel_t, cpuwhich_t, id_t, size_t, const cpuset_t *);
                                       ^
/usr/include/sys/_types.h:146:14: note: '__cpuwhich_t' declared here
typedef int             __cpuwhich_t;   /* which parameter for cpuset. */
                        ^
In file included from tools/cpu/os_specific.cc:51:
/usr/include/sys/cpuset.h:157:48: error: unknown type name 'id_t'; did you mean 'pid_t'?
int     cpuset_setaffinity(cpulevel_t, cpuwhich_t, id_t, size_t, const cpuset_t *);
                                                   ^
/usr/include/time.h:102:18: note: 'pid_t' declared here
typedef __pid_t         pid_t;
                        ^
14 errors generated.
---
 tools/cpu/os_specific.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/cpu/os_specific.cc b/tools/cpu/os_specific.cc
index d87e3d72f..02145643e 100644
--- a/tools/cpu/os_specific.cc
+++ b/tools/cpu/os_specific.cc
@@ -48,9 +48,8 @@
 #endif  // JXL_OS_MAC
 
 #if JXL_OS_FREEBSD
-#include <sys/cpuset.h>
 #include <sys/param.h>
-#include <sys/types.h>
+#include <sys/cpuset.h>
 #include <sys/wait.h>
 #include <unistd.h>
 #endif  // JXL_OS_FREEBSD
