From: Bruno Haible Date: Tue, 3 Apr 2007 00:10:00 +0000 (+0000) Subject: It was a joke. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ab80ecab4d3ac4fbf703c731b33f37169327881;p=pspp It was a joke. --- diff --git a/ChangeLog b/ChangeLog index a2ed43f324..6012027761 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,3 @@ -2007-04-01 Bruno Haible - - * modules/phystemp: New file. - * lib/phystemp.h: New file. - * lib/phystemp.c: New file. - 2007-04-01 Simon Josefsson * modules/crypto/arcfour: Moved from ../. diff --git a/lib/phystemp.c b/lib/phystemp.c deleted file mode 100644 index 127b46193e..0000000000 --- a/lib/phystemp.c +++ /dev/null @@ -1,139 +0,0 @@ -/* Return physical temperatures. - Copyright (C) 2007 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#include - -/* Specification. */ -#include "phystemp.h" - -#if defined __linux__ - -# include -# include - -# include "pipe.h" -# include "wait-process.h" -# include "getline.h" - -/* On Linux, temperature values are available through the 'sensors' program, - part of the 'sensors' or 'lm_sensors' package - - - To configure it, run 'sensors-detect' as root and follow the - recommendations. More explanations in this article: - */ - -double -phystemp_cpu (void) -{ - /* APRIL FOOL! */ - /* The output of the 'sensors' program consists of lines of the form - CPU Temp: +25°C (low = +0°C, high = +50°C) - or - temp1: +34°C (limit = +60°C) sensor = thermistor - So take the first line of this form. */ - char *argv[2]; - pid_t child; - int fd[1]; - FILE *fp; - char *line; - size_t linesize; - size_t linelen; - int exitstatus; - double temp_cpu; - double temp_mb; - - /* Call the sensors program. */ - argv[0] = "/usr/bin/sensors"; - argv[1] = NULL; - child = create_pipe_in ("sensors", argv[0], argv, DEV_NULL, true, true, - false, fd); - if (child == -1) - return -273 - 1; - - /* Retrieve its result. */ - fp = fdopen (fd[0], "r"); - if (fp == NULL) - return -273 - 1; - - temp_cpu = -273 - 1; - temp_mb = -273 - 1; - line = NULL; linesize = 0; - for (;;) - { - linelen = getline (&line, &linesize, fp); - if (linelen == (size_t)(-1)) - break; - if (linelen > 0 && line[linelen - 1] == '\n') - line[linelen - 1] = '\0'; - if (linelen >= 9 && memcmp (line, "CPU Temp:", 9) == 0) - temp_cpu = strtod (line + 9, NULL); - else if (linelen >= 5 && memcmp (line, "temp:", 5) == 0) - { - if (temp_cpu < -273) - temp_cpu = strtod (line + 5, NULL); - } - else if (linelen >= 6 && memcmp (line, "temp1:", 6) == 0) - { - if (temp_cpu < -273) - temp_cpu = strtod (line + 6, NULL); - } - else if (linelen >= 9 && memcmp (line, "M/B Temp:", 9) == 0) - temp_mb = strtod (line + 9, NULL); - } - - fclose (fp); - - /* Remove zombie process from process list, and retrieve exit status. */ - exitstatus = wait_subprocess (child, "sensors", true, true, true, false); - if (exitstatus != 0) - return -273 - 1; - - /* The temperature of the motherboard is a good approximation of the - temperature of the CPU. */ - if (temp_cpu < -273) - temp_cpu = temp_mb; - - return temp_cpu; -} - -#elif defined __BEOS__ - -# include - -double -phystemp_cpu (void) -{ - /* Yes, it's a function called 'is_...' that returns a 'double'! - It is specified as - "Returns the temperature of the motherboard if the computer is - currently on fire." - The temperature of the motherboard is a good approximation of the - temperature of the CPU. */ - double temp = is_computer_on_fire (); - return (temp > 0 ? temp : -273 - 1); -} - -#else - -double -phystemp_cpu (void) -{ - return -273 - 1; -} - -#endif diff --git a/lib/phystemp.h b/lib/phystemp.h deleted file mode 100644 index ba12c8cbf3..0000000000 --- a/lib/phystemp.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Return physical temperatures. - Copyright (C) 2007 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef _PHYSTEMP_H -#define _PHYSTEMP_H - -/* Return the physical temperature of the CPU, measured in degrees Celsius. - If it cannot be obtained, return a value < -273. */ -/* APRIL FOOL! */ -extern double phystemp_cpu (void); - -#endif /* _PHYSTEMP_H */ diff --git a/modules/phystemp b/modules/phystemp deleted file mode 100644 index 8538d267f2..0000000000 --- a/modules/phystemp +++ /dev/null @@ -1,26 +0,0 @@ -Description: -Return physical temperature. - -Files: -lib/phystemp.h -lib/phystemp.c - -Depends-on: -pipe -wait-process -getline -strtod - -configure.ac: - -Makefile.am: - -Include: -"phystemp.h" - -License: -GPL - -Maintainer: -Bruno Haible -