sched: Add cpu_set_t as expected by linux programs

The affinity-related functions defined in GNU's non-portable pthread extension
need access to the cpu_set_t type, found in glibc's sched.h. Given that we
intend to implement those functions to further improve Linux application
support, we need this type. This type is usually manipulated through a set of
macros, which are also included in this patch.

Notice that not all macros or functions are implemented, but only those
strictly necessary for our purposes: those that are going to be used by our
pthread implementation.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Renato L. F. Cunha <renato@renatocunha.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
pthread: Add cpu_set_t support to pthread

Adds a cpu_set_t instance to pthread's thread_attr implementation. That way,
new threads can be created already pinned to a specific CPU, if that member is
set.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Renato L. F. Cunha <renato@renatocunha.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
pthread: Add pthread_attr_setaffinity_np and pthread_attr_getaffinity_np

Adds support to setting a thread's affinity by actually pinning it to a CPU.
This uses the cpuset member present in the internal thread_attr type.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Renato L. F. Cunha <renato@renatocunha.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
pthread: Add stubbed versions of pthread_setaffinity_np and its get counterpart

Some binaries, especially those that make use of GCC's OpenMP implementation,
expect pthread_setaffinity_np and pthread_getaffinity_np to be available. Since
we still don't know how this functionality would be best implemented, adding
a stubbed version of said functions will at least make those programs runnable.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Renato L. F. Cunha <renato@renatocunha.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: Add testing for pthread_attr_setaffinity_np and get counterpart

Added basic sanity checking test code for the new pthread affinity
functionality.

The test tries to pin one thread to each CPU in two variants:

 * A sequential one, in which each thread is created and destroyed and assigned
   to one CPU at a time;
 * A parallel one, in which all threads are created simultaneously, but still
   with one thread per CPU.

Signed-off-by: Renato L. F. Cunha <renato@renatocunha.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>