Skip to content

Commit

Permalink
Fix free.c as inex-usage. Add Intel 64 Architecture x2APIC Specificat…
Browse files Browse the repository at this point in the history
…ion detection
  • Loading branch information
eloaders committed Jan 21, 2014
1 parent 32c53e8 commit 44e51b4
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 29 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PKG_INSTALL = apt-get install
AS_ROOT = sudo
CFLAGS = -g -Wall
CC_OPTS_LIBCPUID = $(shell pkg-config libcpuid --cflags --libs)
CC_OPTS_LIBGTOP = $(shell pkg-config libgtop-2.0 --cflags --libs)
CC_OPTS_LIBPROCPS = $(shell pkg-config libprocps --cflags --libs)
GBC = /usr/bin/gbc3
GBCOPTS = -eagtpmv
GBA = gba3
Expand Down Expand Up @@ -53,13 +53,14 @@ dependency_build ?= git \
mesa-utils \
hostname \
libcpuid11 \
libgtop2-dev
libprocps0-dev

make:
@printf "\033[1;31mCompile edid-decode as inex-decode \033[0m$1\n"
$(CC) -o inex-edid edid-decode.c $(CFLAGS) $(additional_confflags)
$(CC) -o inex-usage getusage.c $(CC_OPTS_LIBGTOP) $(additional_confflags)
$(CC) -o inex-cpuid cpu.c -static $(CC_OPTS_LIBCPUID) $(additional_confflags)
$(CC) -o inex-usage free.c -static $(CC_OPTS_LIBPROCPS) $(additional_confflags)

@printf "\033[1;31mCompile src/i-nex stage 1 \033[0m$1\n"
$(GBC) $(GBCOPTS) src/i-nex
@printf "\033[1;31mCompile src/i-nex stage 2 \033[0m$1\n"
Expand Down
8 changes: 8 additions & 0 deletions cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,14 @@ int main(void)
printf(" \"WEBSITE\": \"http://en.wikipedia.org/wiki/X87\",\n");
printf(" \"HAVEWEBSITE\": 1 ,\n");
printf(" \"DESC\": \"Floating point unit\"\n");
printf(" },\n");
printf(" \"95\": {\n");
printf(" \"VALUE\": %s \n", data.flags[CPU_FEATURE_X2APIC] ? "1 ," : "0 ,");
printf(" \"NAME\": \"CPU_FEATURE_X2APIC\",\n");
printf(" \"FEATURE\": \"x2apic\",\n");
printf(" \"WEBSITE\": \"http://en.wikipedia.org/wiki/X2APIC\",\n");
printf(" \"HAVEWEBSITE\": 1 ,\n");
printf(" \"DESC\": \"Intel 64 Architecture x2APIC Specification\"\n");
printf(" }\n");
printf(" },\n");
printf(" \"L1_DATA_CACHE\": \"%d\",\n", data.l1_data_cache);
Expand Down
3 changes: 1 addition & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Build-Depends: debhelper (>= 7),
pkg-config, dpkg-dev (>= 1.14.17),
debhelper (>= 5.0.0),
libcpuid11,
libgtop2-dev (>= 2.22.3),
libprocps0-dev,
gambas3-dev (>= 3.0.90),
gambas3-dev (<< 3.99.0),
gambas3-gb-image (>= 3.0.90),
Expand Down Expand Up @@ -49,7 +49,6 @@ Depends: ${shlibs:Depends},
gambas3-gb-desktop (>= 3.0.90),
gambas3-gb-desktop (<< 3.99.0),
gambas3-gb-form-stock (>= 3.4.0),
libgtop2-7 (>= 2.22.3),
grep (>= 2.5),
mount (>= 2.17),
x11-xserver-utils (>= 7.5),
Expand Down
117 changes: 117 additions & 0 deletions free.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* free.c - free(1)
* procps-ng utility to display free memory information
*
* Copyright (C) 1992-2012
*
* Mostly new, Sami Kerola <kerolasa@iki.fi> 15 Apr 2011
* All new, Robert Love <rml@tech9.net> 18 Nov 2002
* Original by Brian Edmonds and Rafal Maszkowski 14 Dec 1992
*
* Copyright 2003 Robert Love
* Copyright 2004 Albert Cahalan
*
* 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
* of the License, 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 <proc/sysinfo.h>
#include <unistd.h>
#include <malloc.h>
#include <sys/sysinfo.h>
#include <stdio.h>

int main() {

meminfo();
struct sysinfo sys_info;

long long physMemUsed = sys_info.totalram - sys_info.freeram;
long long totalVirtualMem = sys_info.totalram;
unsigned long total_bytes;
unsigned int sleepfor = 5000;
int days, hours, mins;

if(sysinfo(&sys_info) != 0)
perror("sysinfo");

physMemUsed *= sys_info.mem_unit;
totalVirtualMem += sys_info.totalswap;
totalVirtualMem *= sys_info.mem_unit;
total_bytes = sys_info.mem_unit * sys_info.totalram;

days = sys_info.uptime / 86400;
hours = (sys_info.uptime / 3600) - (days * 24);
mins = (sys_info.uptime / 60) - (days * 1440) - (hours * 60);
/* Translation Hint: You can use 9 character words in
* the header, and the words need to be right align to
* beginning of a number. */
//printf("%s\n", _(" total used free shared buffers cached"));
//printf("%-7s", _("Mem:"));
unsigned KLONG buffers_plus_cached = kb_main_buffers + kb_main_cached;
printf("{\n");
printf(" \"MEMORY_TOTAL\": %ld ,\n", kb_main_total/1024);
printf(" \"MEMORY_USED\": %ld ,\n", kb_main_used/1024);
printf(" \"MEMORY_FREE\": %ld ,\n", kb_main_free/1024);
printf(" \"MEMORY_SHARED\": %ld ,\n", kb_main_shared/1024);
printf(" \"MEMORY_BUFFERS\": %ld ,\n", kb_main_buffers/1024);
printf(" \"MEMORY_CACHED\": %ld ,\n", kb_main_cached/1024);
printf(" \"OTH\": {\n");
printf(" \"LOW\": {\n");
printf(" \"TOTAL\": %ld ,\n", kb_low_total/1024);
printf(" \"USED\": %ld ,\n", (kb_low_total - kb_low_free)/1024);
printf(" \"FREE\": %ld \n", kb_low_free/1024);
printf(" },\n");
printf(" \"HIGH\": {\n");
printf(" \"TOTAL\": %ld ,\n", kb_high_total/1024);
printf(" \"USED\": %ld ,\n", (kb_high_total - kb_high_free)/1024);
printf(" \"FREE\": %ld \n", kb_high_free/1024);
printf(" }\n");
printf(" },\n");
printf(" \"USED_PLUS_CACHED\": %ld ,\n", (kb_main_used - buffers_plus_cached)/1024);
printf(" \"FREE_PLUS_CACHED\": %ld ,\n", (kb_main_free + buffers_plus_cached)/1024);
printf(" \"TOTAL\": {\n");
printf(" \"TOTAL\": {\n");
printf(" \"TOTAL\": %ld ,\n", (kb_main_total + kb_swap_total)/1024);
printf(" \"USED\": %ld ,\n", (kb_main_used + kb_swap_used)/1024);
printf(" \"FREE\": %ld \n", (kb_main_free + kb_swap_free)/1024);
printf(" }\n");
printf(" },\n");
printf(" \"SWAP_TOTAL\": %ld ,\n", kb_swap_total/1024);
printf(" \"SWAP_USED\": %ld ,\n", kb_swap_used/1024);
printf(" \"SWAP_FREE\": %ld ,\n", kb_swap_free/1024);
printf(" \"UPTIME_DAYS\": %d ,\n", days);
printf(" \"UPTIME_HOURS\": %d ,\n", hours);
printf(" \"UPTIME_MINUTES\": %d ,\n", mins);
printf(" \"UPTIME_SECONDS\": %ld ,\n", sys_info.uptime % 60);
printf(" \"LOAD_AVG_1MIN\": %ld ,\n", sys_info.loads[0]/1000);
printf(" \"LOAD_AVG_5MIN\": %ld ,\n", sys_info.loads[1]/1000);
printf(" \"LOAD_AVG_15MIN\": %ld ,\n", sys_info.loads[2]/1000);
printf(" \"TOTAL_RAM\": %ld ,\n", sys_info.totalram /1024/1024);
printf(" \"FREE_RAM\": %ld ,\n", sys_info.freeram /1024/1024);
printf(" \"SHARED_RAM\": %ld ,\n", sys_info.sharedram /1024/1024);
printf(" \"BUFFERED_RAM\": %ld ,\n", sys_info.bufferram /1024/1024);
printf(" \"TOTAL_RAM_UNIT\": %llu ,\n", sys_info.totalram *(unsigned long long)sys_info.mem_unit/1024/1024);
printf(" \"FREE_RAM_UNIT\": %llu ,\n", sys_info.freeram *(unsigned long long)sys_info.mem_unit/1024/1024);
printf(" \"TOTAL_SWAP\": %ld ,\n", sys_info.totalswap /1024/1024);
printf(" \"FREE_SWAP\": %ld ,\n", sys_info.freeswap /1024/1024);
printf(" \"TOTAL_HIGH\": %ld ,\n", sys_info.totalhigh /1024/1024);
printf(" \"FREE_HIGH\": %ld ,\n", sys_info.freehigh /1024/1024);
printf(" \"PHYS_MEM_USED\": %llu ,\n", physMemUsed /1024/1024);
printf(" \"TOTAL_VIRTUAL_MEM\": %llu ,\n", totalVirtualMem /1024/1024);
printf(" \"NUMBER_OF_PROCESSES\": %d \n", sys_info.procs);
printf("}\n");

return 0;
}
9 changes: 4 additions & 5 deletions src/i-nex/.settings
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[Bookmarks]
CFlags=[9]
Finfosys=[]

[Breakpoints]
Count=0
Expand All @@ -25,7 +24,6 @@ SearchComment=False
SearchString=True

[OpenFile]
Active=1
File[1]=".src/Finfosys.form"
File[2]=".src/Global.class:199.7"
File[3]=".src/About.form"
Expand All @@ -50,7 +48,8 @@ File[21]=".src/net.module:2.19"
File[22]="Data/report-ng.sh:5.3"
File[23]=".src/Distribution_Detect.module:13.1"
File[24]=".src/FFlags.module:2.19"
File[25]=".src/Finfosys.class:608.3"
Active=25
File[25]=".src/Finfosys.class:623.2"
File[26]=".src/FDF.form"
File[27]=".src/FDF.class:26.6"
File[28]=".src/FNET_R_T.form"
Expand All @@ -61,7 +60,7 @@ File[32]=".src/FCPU.module:2.19"
File[33]=".src/FUdisks.form"
File[34]=".src/FUdisks.class:26.6"
File[35]=".src/FCpudb.module:19.29"
File[36]=".src/JSON.module:106.32"
File[36]=".src/JSON.module:121.31"
File[37]=".src/Settings.class:2.19"
File[38]=".src/Main.module:2.19"
File[39]=".src/_Settings_Keys.class:15.20"
Expand All @@ -88,7 +87,7 @@ File[59]=".src/FDirDialog.class:2.19"
File[60]=".src/FFileDialog.class:2.19"
File[61]=".src/FInputDate.class:2.19"
File[62]=".src/FDIMM.form"
File[63]=".src/FDIMM.class:64.23"
File[63]=".src/FDIMM.class:72.16"
Count=63

[Watches]
Expand Down
1 change: 0 additions & 1 deletion src/i-nex/.src/FDIMM.class
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
Private Label[200] As Label
Private ToolButton[200] As ToolButton
Public Logs As New Logger
Public Sub Form_Open()
Dim data As Stream
Expand Down
36 changes: 18 additions & 18 deletions src/i-nex/.src/Finfosys.class
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
Private ToolButton[95] As ToolButton
Private Label[95] As Label ' Dim the array of controls
Private Button[95] As Button
Private TextLabel[95] As TextLabel
Private ToolButton[96] As ToolButton
Private Label[96] As Label ' Dim the array of controls
Private Button[96] As Button
Private TextLabel[96] As TextLabel
Private YESNO As Picture
Public AllowLog As Boolean
Public sLine As String
Expand Down Expand Up @@ -84,7 +84,7 @@ Public Sub Form_Open()

Logs("Create Labels in ScrollView1", Logger.Info)

For i = 1 To 94
For i = 1 To 95
Label[i] = New Label(ScrollView1)
With Label[i]
.X = 2
Expand All @@ -98,7 +98,7 @@ Public Sub Form_Open()
End With
Next
Logs("Create ToolButtons in ScrollView1", Logger.Info)
For i = 1 To 94
For i = 1 To 95
ToolButton[i] = New ToolButton(ScrollView1)
If DATAT["Flags"][i]["VALUE"] = 1 Then
YESNO = Picture["Data/check_true.png"]
Expand All @@ -115,7 +115,7 @@ Public Sub Form_Open()
End With
Next
Logs("Create TextLabels in ScrollView1", Logger.Info)
For i = 1 To 94
For i = 1 To 95
Button[i] = New Button(ScrollView1) As "Buttongroup"
With Button[i]
.X = 400
Expand All @@ -131,7 +131,7 @@ Public Sub Form_Open()
.Picture = Picture["AppIcons/applications-internet.png"]
End With
Next
For i = 1 To 94
For i = 1 To 95
TextLabel[i] = New TextLabel(ScrollView1)
With TextLabel[i]
.X = 320
Expand Down Expand Up @@ -596,34 +596,34 @@ Public Sub dospam_uptime()
USAGE = JSON.Decode(USAGE_BUFFER)

Label85.Text = "Total: " &
Int(USAGE["TOTAL_RAM"]) &
Int(USAGE["MEMORY_TOTAL"]) &
" MB"
Label86.Text = "Used: " &
Int(Int(USAGE["TOTAL_RAM"]) - Int(USAGE["FREE_RAM"])) &
Int(USAGE["MEMORY_USED"]) &
" MB"
Label87.Text = "Free: " &
Int(USAGE["MEMORY_FREE"]) &
" MB"
Label88.Text = "Shared: " &
Int(USAGE["SHARED_RAM"]) &
Int(USAGE["MEMORY_SHARED"]) &
" MB"
Label89.Text = "Buffers: " &
Int(USAGE["BUFFERED_RAM"]) &
Int(USAGE["MEMORY_BUFFERS"]) &
" MB"
Label90.Text = "Cached: " &
Int(USAGE["MEMORY_CACHED"]) &
" MB"
Label223.Text = "Ram used: " &
Int(USAGE["MEMORY_USER"]) &
Int(USAGE["USED_PLUS_CACHED"]) &
" MB"
Label91.Text = "SWAP Total: " &
Int(USAGE["TOTAL_SWAP"]) &
Int(USAGE["SWAP_TOTAL"]) &
" MB "
TextLabel15.Text = "Physical Memory Used: " &
Int(USAGE["PHYS_MEM_USED"]) &
" MB "
" MB "
TextLabel24.Text = "SWAP memory used: " &
Int(Int(USAGE["TOTAL_SWAP"]) - Int(USAGE["FREE_SWAP"])) &
Int(USAGE["SWAP_USED"]) &
" MB"

TextBox58.Text = "Days: " & USAGE["UPTIME_DAYS"] &
Expand All @@ -640,8 +640,8 @@ Public Sub dospam_uptime()
", " & Int(USAGE["LOAD_AVG_15MIN"])

Try ProgressBar6.Value = Int(USAGE["PHYS_MEM_USED"]) / Int(USAGE["TOTAL_VIRTUAL_MEM"])
Try ProgressBar1.Value = Int(USAGE["MEMORY_USER"]) / Int(USAGE["MEMORY_TOTAL"])
Try ProgressBar4.Value = Int(Int(USAGE["TOTAL_SWAP"]) - Int(USAGE["FREE_SWAP"])) / Int(USAGE["TOTAL_SWAP"])
Try ProgressBar1.Value = Int(USAGE["USED_PLUS_CACHED"]) / Int(USAGE["MEMORY_TOTAL"])
Try ProgressBar4.Value = Int(USAGE["SWAP_USED"]) / Int(USAGE["SWAP_TOTAL"])

End

Expand Down

0 comments on commit 44e51b4

Please sign in to comment.