From owner-freebsd-threads@freebsd.org Thu Sep 24 18:11:39 2015 Return-Path: Delivered-To: freebsd-threads@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 58B5FA079AC for ; Thu, 24 Sep 2015 18:11:39 +0000 (UTC) (envelope-from schulz.j@gmail.com) Received: from mail-pa0-x231.google.com (mail-pa0-x231.google.com [IPv6:2607:f8b0:400e:c03::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2D9B41EC1 for ; Thu, 24 Sep 2015 18:11:39 +0000 (UTC) (envelope-from schulz.j@gmail.com) Received: by pacgz1 with SMTP id gz1so13024855pac.3 for ; Thu, 24 Sep 2015 11:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=6nX2tqxaDg7s44mFFLDx6QKkEiS8C2Rby3MGgIue3Fo=; b=QXAOyv2Iqy7HxP0RQpsJql60w6A9Wo60Et54C9BNFPQn1fz7KwgEWkhF+sWWxv6BRU 1axbVTRdw5iqYmDq02tl6CgpxZqxjks5/Jp4E/bPOFMHkzM/iqqFkDY4J6Q+REYiPZj2 BCtXl4N2MAml97YHmB19azJcUlFflZ2i7ntOOh8sa8dpjFSjPbRDuyI9zD/XxycI3yUL XVt19Jwopmszp4AEAjTxDSJ0yeN6c2CHnz3o9M5GBAlcNOL4ZN+QYy6WMYPGgKkk8uF6 0yfUojeViCYkaip+glb2uwQjyoKN7Y8E3aJ28jXYY7jdKY3B7fbuVZDGV6c8KUtwz8Nr kMag== X-Received: by 10.66.165.106 with SMTP id yx10mr1286690pab.102.1443118298868; Thu, 24 Sep 2015 11:11:38 -0700 (PDT) Received: from gmail.com (c-73-140-192-75.hsd1.wa.comcast.net. [73.140.192.75]) by smtp.gmail.com with ESMTPSA id yk5sm14867124pab.31.2015.09.24.11.11.36 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Sep 2015 11:11:37 -0700 (PDT) Sender: Jason Schulz Date: Thu, 24 Sep 2015 11:11:27 -0700 From: Jason Schulz To: freebsd-threads@freebsd.org Subject: pthread_getaffinity_np issue Message-ID: <20150924181127.GC3104@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Sep 2015 18:11:39 -0000 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