Date: Thu, 24 Sep 2015 11:11:27 -0700 From: Jason Schulz <schulz.j@gmail.com> To: freebsd-threads@freebsd.org Subject: pthread_getaffinity_np issue Message-ID: <20150924181127.GC3104@gmail.com>
next in thread | raw e-mail | index | archive | help
I'm having an issue using the non-posix thread affinity methods. Specifically, I'm having trouble using CPU_COUNT. I'm trying to use the following code to get the current number of processors in a processes affinity... long cs = 0; #if defined(HAVE_LINUX) || defined(HAVE_FREEBSD) pthread_t this = pthread_self(); cpu_set_t cpus; CPU_ZERO(&cpus); int err = pthread_getaffinity_np(this, sizeof(cpus), &cpus); if (err) return err; cs = (long) CPU_COUNT(&cpus); However, I get the compiler error... clang -DHAVE_CONFIG_H -I. -g -O2 -D_THREAD_SAFE -pthread -pipe -std=c99 -D_XOPEN_SOURCE=700 -pedantic -Wall -Wextra -Wsign-conversion -Wconversion -Werror -MT thread.o -MD -MP -MF .deps/thread.Tpo -c -o thread.o thread.c thread.c:85:15: error: implicit declaration of function '__bitcountl' is invalid in C99 [-Werror,-Wimplicit-function-declaration] cs = (long) CPU_COUNT(&cpus); ^ /usr/include/sys/cpuset.h:63:24: note: expanded from macro 'CPU_COUNT' #define CPU_COUNT(p) BIT_COUNT(CPU_SETSIZE, p) ^ /usr/include/sys/bitset.h:185:14: note: expanded from macro 'BIT_COUNT' __count += __bitcountl((p)->__bits[__i]); \ ^ 1 error generated. I'm able to use CPU_ISSET to the same effect, but obviously I'd rather use CPU_COUNT. Suggestions? -Jason
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150924181127.GC3104>