From owner-freebsd-ppc@freebsd.org Thu Jun 9 13:09:21 2016 Return-Path: Delivered-To: freebsd-ppc@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 DA989B6F157 for ; Thu, 9 Jun 2016 13:09:21 +0000 (UTC) (envelope-from bacon4000@gmail.com) Received: from mail-it0-x22a.google.com (mail-it0-x22a.google.com [IPv6:2607:f8b0:4001:c0b::22a]) (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 A606E1FB0 for ; Thu, 9 Jun 2016 13:09:21 +0000 (UTC) (envelope-from bacon4000@gmail.com) Received: by mail-it0-x22a.google.com with SMTP id z189so153483064itg.0 for ; Thu, 09 Jun 2016 06:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=VyvDS8VvQudSIHEPJnAQc5PMBrPBQpIY6MHpuANxl2c=; b=EvKjj94brnwxbHrQXys39JUWEXcxik95WHSd/RwAlqLf5MMaDEkoY9MpIsdKy+aCh3 IpQil8e/pnhLIMnkyUBLfmRiK3xXf6OkORba8fG+0Jua5hKM1o5C087nd5Mdvw36XxpX FCa6PbIPpPdB6E8DmSa1i7rkIAhMHUBukKMvWC454r409rExIUTr/rxbNSKAl2dn1j7x nl2hPHqJaaJAqvv2PH7blgDL9VTE5udyCAQm1IhYIvaSg1RhRRONRw+dNFo+EJ90s8EX 6wu/tpfV3sCEaLpvvZRynzu1ymAicHF3PHS/kXWhf6zzJ7p13D/cRiILqp7mtKm2YRsu PsAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=VyvDS8VvQudSIHEPJnAQc5PMBrPBQpIY6MHpuANxl2c=; b=Qlkzx4sNK0KbR9I3uJGlckgcWFyZLEFksDxgDnTEhN2TgJIxewGKcEQ006EPyemM92 f4BLUPCTDIcdE84i7ma2BLyvp8C+2MMjUt5bdnUQrPep9ABp4Na2SoElj5A2BheBZz3S cev5iR3DjatraUV0pVtkHF162dlUWqIIPmFYiu7THw9GSxf42K1w1J1ACGRDC6lFH3Uh I1+nHi3hlKBiyTlbj7A+n/HaASZlXNiw0jskiyjZcjjvu8XrKXJ3Rr+e722qLhtQTVK6 RQ7x5zLy50nzJUZ67uvwmif2OmR7z1rN81tzpAsxTWlBx0ptlVYu9xU7neN2ohOg+jPH nMmA== X-Gm-Message-State: ALyK8tKjaMTU0L6GDxFGN4/11f8d/Byzp+I4K8yC7FXPvLTIv3KuPUBMGGv0Vm7nE4ObLA== X-Received: by 10.36.16.67 with SMTP id 64mr17389107ity.88.1465477760909; Thu, 09 Jun 2016 06:09:20 -0700 (PDT) Received: from imacbsd.acadix.biz (cpe-174-102-163-140.wi.res.rr.com. [174.102.163.140]) by smtp.gmail.com with ESMTPSA id 127sm3153493iov.34.2016.06.09.06.09.20 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Jun 2016 06:09:20 -0700 (PDT) To: "freebsd-ppc@freebsd.org" From: Jason Bacon Subject: Detecting Power7 in C Message-ID: <765d3292-78ae-8b02-8a5b-43bafc68d9e8@gmail.com> Date: Thu, 9 Jun 2016 08:09:19 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jun 2016 13:09:21 -0000 I'm porting the SLURM task/affinity plugin to FreeBSD and wondering what's the best way to detect whether we're running on a power7 processor. The Linux code is below. I could do something similar with dmesg.boot on FreeBSD, but hoping there's a more elegant way within a C program. If I have to use dmesg.boot, what string would I be looking for? I don't have a power7 installation at the moment. Thanks, Jason FILE *cpu_info_file; char buffer[128]; char* _cpuinfo_path = "/proc/cpuinfo"; cpu_info_file = fopen(_cpuinfo_path, "r"); if (cpu_info_file == NULL) { error("_get_is_power: error %d opening %s", errno, _cpuinfo_path); return false; /* assume not power processor */ } is_power = 0; while (fgets(buffer, sizeof(buffer), cpu_info_file) != NULL) { if (strstr(buffer, "POWER7")) { is_power = 1; break; } } fclose(cpu_info_file); -- All wars are civil wars, because all men are brothers ... Each one owes infinitely more to the human race than to the particular country in which he was born. -- Francois Fenelon