Dramatically reduced energy impact by improving code efficiency

Cached various information to reduce calls to get information from
hardware. Avoided dynamic memory allocation. Added brief comments and
TODOs.
This commit is contained in:
Michael Wilber
2013-12-21 09:26:27 -05:00
parent 3212d78eac
commit c537db9fdd
6 changed files with 413 additions and 382 deletions

24
smc-command/smc.h Normal file → Executable file
View File

@ -1,6 +1,7 @@
/*
* Apple System Management Control (SMC) Tool
* Copyright (C) 2006 devnull
* Portions Copyright (C) 2013 Michael Wilber
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -89,13 +90,20 @@ typedef struct {
} SMCVal_t;
UInt32 _strtoul(char *str, int size, int base);
kern_return_t SMCOpen(io_connect_t *conn);
kern_return_t SMCReadKey(UInt32Char_t key, SMCVal_t *val);
kern_return_t SMCReadKey2(UInt32Char_t key, SMCVal_t *val,io_connect_t conn);
kern_return_t SMCWriteSimple(UInt32Char_t key,char *wvalue,io_connect_t conn);
kern_return_t SMCClose(io_connect_t conn);
void smc_init();
void smc_close();
float _strtof(char *str, int size, int e);
// Exclude command-line only code from smcFanControl UI
#ifdef CMD_TOOL
void smc_init();
void smc_close();
kern_return_t SMCReadKey(UInt32Char_t key, SMCVal_t *val);
kern_return_t SMCWriteSimple(UInt32Char_t key,char *wvalue,io_connect_t conn);
#endif //#ifdef CMD_TOOL
kern_return_t SMCOpen(io_connect_t *conn);
kern_return_t SMCClose(io_connect_t conn);
kern_return_t SMCReadKey2(UInt32Char_t key, SMCVal_t *val,io_connect_t conn);