Deleted Added
full compact
powerd.c (185050) powerd.c (185053)
1/*-
2 * Copyright (c) 2004 Colin Percival
3 * Copyright (c) 2005 Nate Lawson
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted providing that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2004 Colin Percival
3 * Copyright (c) 2005 Nate Lawson
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted providing that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/usr.sbin/powerd/powerd.c 185050 2008-11-18 13:24:38Z mav $");
29__FBSDID("$FreeBSD: head/usr.sbin/powerd/powerd.c 185053 2008-11-18 15:48:23Z mav $");
30
31#include <sys/param.h>
32#include <sys/ioctl.h>
33#include <sys/sysctl.h>
34#include <sys/resource.h>
35#include <sys/socket.h>
36#include <sys/time.h>
37#include <sys/un.h>

--- 379 unchanged lines hidden (view full) ---

417int
418main(int argc, char * argv[])
419{
420 struct timeval timeout;
421 fd_set fdset;
422 int nfds;
423 struct pidfh *pfh = NULL;
424 const char *pidfile = NULL;
30
31#include <sys/param.h>
32#include <sys/ioctl.h>
33#include <sys/sysctl.h>
34#include <sys/resource.h>
35#include <sys/socket.h>
36#include <sys/time.h>
37#include <sys/un.h>

--- 379 unchanged lines hidden (view full) ---

417int
418main(int argc, char * argv[])
419{
420 struct timeval timeout;
421 fd_set fdset;
422 int nfds;
423 struct pidfh *pfh = NULL;
424 const char *pidfile = NULL;
425 int freq, curfreq, *freqs, i, j, *mwatts, numfreqs, load;
425 int freq, curfreq, initfreq, *freqs, i, j, *mwatts, numfreqs, load;
426 int ch, mode, mode_ac, mode_battery, mode_none;
427 uint64_t mjoules_used;
428 size_t len;
429
430 /* Default mode for all AC states is adaptive. */
431 mode_ac = mode_none = MODE_HIADAPTIVE;
432 mode_battery = MODE_ADAPTIVE;
433 cpu_running_mark = DEFAULT_ACTIVE_PERCENT;

--- 97 unchanged lines hidden (view full) ---

531 acline_init();
532
533 /*
534 * Exit cleanly on signals.
535 */
536 signal(SIGINT, handle_sigs);
537 signal(SIGTERM, handle_sigs);
538
426 int ch, mode, mode_ac, mode_battery, mode_none;
427 uint64_t mjoules_used;
428 size_t len;
429
430 /* Default mode for all AC states is adaptive. */
431 mode_ac = mode_none = MODE_HIADAPTIVE;
432 mode_battery = MODE_ADAPTIVE;
433 cpu_running_mark = DEFAULT_ACTIVE_PERCENT;

--- 97 unchanged lines hidden (view full) ---

531 acline_init();
532
533 /*
534 * Exit cleanly on signals.
535 */
536 signal(SIGINT, handle_sigs);
537 signal(SIGTERM, handle_sigs);
538
539 freq = get_freq();
539 freq = initfreq = get_freq();
540 if (freq < 1)
541 freq = 1;
542 /* Main loop. */
543 for (;;) {
544 FD_ZERO(&fdset);
545 if (devd_pipe >= 0) {
546 FD_SET(devd_pipe, &fdset);
547 nfds = devd_pipe + 1;

--- 129 unchanged lines hidden (view full) ---

677 " speed from %d MHz to %d MHz\n",
678 freqs[i], freqs[j]);
679 }
680 if (set_freq(freqs[j]))
681 warn("error setting CPU frequency %d",
682 freqs[j]);
683 }
684 }
540 if (freq < 1)
541 freq = 1;
542 /* Main loop. */
543 for (;;) {
544 FD_ZERO(&fdset);
545 if (devd_pipe >= 0) {
546 FD_SET(devd_pipe, &fdset);
547 nfds = devd_pipe + 1;

--- 129 unchanged lines hidden (view full) ---

677 " speed from %d MHz to %d MHz\n",
678 freqs[i], freqs[j]);
679 }
680 if (set_freq(freqs[j]))
681 warn("error setting CPU frequency %d",
682 freqs[j]);
683 }
684 }
685 if (set_freq(initfreq))
686 warn("error setting CPU frequency %d", initfreq);
685 free(freqs);
686 free(mwatts);
687 devd_close();
688 if (!vflag)
689 pidfile_remove(pfh);
690
691 exit(0);
692}
687 free(freqs);
688 free(mwatts);
689 devd_close();
690 if (!vflag)
691 pidfile_remove(pfh);
692
693 exit(0);
694}