spacing and formatting

This commit is contained in:
TomAwezome 2020-05-23 21:52:50 -04:00
parent 0293e0d373
commit f4d859dce0
4 changed files with 199 additions and 161 deletions

View file

@ -23,6 +23,8 @@ StartOS.CC
ZHash.CC
ZMath.CC
ZMathODE.CC
ZMemory.CC
ZRegistry.CC
ZMouse.CC
ZBlkDev/

View file

@ -2,26 +2,32 @@
public I64 TaskMemAlloced(CTask *task=NULL, Bool override_validate=FALSE)
{//Count of bytes alloced to a task, used+unused.
I64 res;
if (!task) task=Fs;
if (override_validate || TaskValidate(task)) {
if (!task)
task = Fs;
if (override_validate || TaskValidate(task))
{
res = task->code_heap->alloced_u8s;
if (task->code_heap != task->data_heap)
res += task->data_heap->alloced_u8s;
return res;
} else
}
else
return 0;
}
public I64 TaskMemUsed(CTask *task=NULL, Bool override_validate=FALSE)
{//Count of bytes alloced to a task and in use.
I64 res;
if (!task) task=Fs;
if (override_validate || TaskValidate(task)) {
if (!task)
task = Fs;
if (override_validate || TaskValidate(task))
{
res = task->code_heap->used_u8s;
if (task->data_heap != task->code_heap)
res += task->data_heap->used_u8s;
return res;
} else
}
else
return 0;
}
@ -31,11 +37,13 @@ public Bool HeapRep(CTask *task)
I64 i, count;
CMemUnused *uum;
if (!task || task==Fs) {
if (!task || task == Fs)
{
"Task can't HeapRep on self.\n";
return FALSE;
}
if (!TaskValidate(task)) return FALSE;
if (!TaskValidate(task))
return FALSE;
PUSHFD
CLI
@ -45,16 +53,20 @@ public Bool HeapRep(CTask *task)
while (LBts(&task->data_heap->locked_flags, HClf_LOCKED))
PAUSE
for (i=0;i<MEM_HEAP_HASH_SIZE>>3;i++) {
for (i = 0; i < MEM_HEAP_HASH_SIZE >> 3; i++)
{
count = 0;
uum = task->code_heap->heap_hash[i];
while (uum) {
while (uum)
{
count += uum->size;
uum = uum->next;
}
if (task->data_heap!=task->code_heap) {
if (task->data_heap != task->code_heap)
{
uum = task->data_heap->heap_hash[i];
while (uum) {
while (uum)
{
count += uum->size;
uum = uum->next;
}
@ -65,13 +77,16 @@ public Bool HeapRep(CTask *task)
'\n';
uum = task->code_heap->malloc_free_list;
while (uum) {
while (uum)
{
"%X, ", uum->size;
uum = uum->next;
}
if (task->data_heap!=task->code_heap) {
if (task->data_heap != task->code_heap)
{
uum = task->data_heap->malloc_free_list;
while (uum) {
while (uum)
{
"%X, ", uum->size;
uum = uum->next;
}
@ -95,8 +110,10 @@ public Bool IsInHeapCtrl(U8 *a,CHeapCtrl *hc,Bool lock=TRUE)
while (LBts(&hc->locked_flags, HClf_LOCKED))
PAUSE
m=hc->next_mem_blk;
while (m!=&hc->next_mem_blk) {
if (a>=m && a<m(U8 *)+m->pags<<MEM_PAG_BITS) {
while (m != &hc->next_mem_blk)
{
if (a >= m && a < m(U8 *) + m->pags << MEM_PAG_BITS)
{
if (lock)
LBtr(&hc->locked_flags, HClf_LOCKED);
POPFD
@ -120,16 +137,19 @@ public Bool HeapCtrlWalk(CHeapCtrl *hc)
while (LBts(&hc->locked_flags, HClf_LOCKED))
PAUSE
for (i=0;i<MEM_HEAP_HASH_SIZE>>3;i++) {
for (i = 0; i < MEM_HEAP_HASH_SIZE >> 3; i++)
{
uum = hc->heap_hash[i];
while (uum) {
while (uum)
{
if (!IsInHeapCtrl(uum, hc, FALSE))
goto hc_false;
uum = uum->next;
}
}
uum = hc->malloc_free_list;
while (uum) {
while (uum)
{
if (!IsInHeapCtrl(uum, hc, FALSE))
goto hc_false;
uum = uum->next;
@ -139,7 +159,8 @@ public Bool HeapCtrlWalk(CHeapCtrl *hc)
CMemUsed *um, *um1;
um1 = (&hc->next_um)(U8 *) - offset(CMemUsed.next);
um = um1->next;
while (um!=um1) {
while (um != um1)
{
if (!IsInHeapCtrl(um, hc, FALSE))
goto hc_false;
um = um->next;
@ -159,7 +180,8 @@ public Bool HeapCtrlWalk(CHeapCtrl *hc)
#help_index "Memory/Task;Debugging/Heap;Memory/Debugging"
public Bool IsInHeap(U8 *a, CTask *task=NULL, Bool lock=TRUE)
{//Check addr if in task's heaps.
if (!task) task=Fs;
if (!task)
task = Fs;
if (TaskValidate(task) && (IsInHeapCtrl(a, task->code_heap, lock) ||
task->data_heap != task->code_heap &&
IsInHeapCtrl(a, task->data_heap, lock)))
@ -170,9 +192,9 @@ public Bool IsInHeap(U8 *a,CTask *task=NULL,Bool lock=TRUE)
public Bool HeapWalk(CTask *task=NULL)
{//Check integrity of task's heaps.
if (!task) task=Fs;
if (!TaskValidate(task) || !HeapCtrlWalk(task->code_heap) ||
task->data_heap!=task->code_heap && !HeapCtrlWalk(task->data_heap))
if (!task)
task = Fs;
if (!TaskValidate(task) || !HeapCtrlWalk(task->code_heap) || task->data_heap != task->code_heap && !HeapCtrlWalk(task->data_heap))
return FALSE;
else
return TRUE;

View file

@ -1,5 +1,6 @@
#help_index "Registry"
#define REGISTRY_FILENAME "~/Registry.CC"
CDoc *sys_registry_doc = NULL;
I64 sys_message_flags[1] = {0};
F64 registry_version;
@ -7,12 +8,14 @@ F64 registry_version;
Bool RegCache()
{
Bool old_silent;
if (!sys_registry_doc) {
if (!sys_registry_doc)
{
old_silent = Silent;
sys_registry_doc = DocRead(REGISTRY_FILENAME);
Silent(old_silent);
return FALSE;
} else
}
else
return TRUE;
}
@ -21,10 +24,12 @@ public Bool RegDefault(U8 *path,U8 *val,Bool is_zenith_entry=FALSE)
Bool res, unlock_doc;
RegCache;
unlock_doc = DocLock(sys_registry_doc);
if (!DocTreeFind(sys_registry_doc,path)) {
if (!DocTreeFind(sys_registry_doc, path))
{
DocTreeMake(sys_registry_doc, path);
DocPrint(sys_registry_doc, "%s", val);
if (is_zenith_entry) {
if (is_zenith_entry)
{
if (Fs == zenith_task)
ExePrint("%s", val);
else
@ -33,7 +38,8 @@ public Bool RegDefault(U8 *path,U8 *val,Bool is_zenith_entry=FALSE)
if (DriveIsWritable(*sys_registry_doc->filename.name))
DocWrite(sys_registry_doc);
res = FALSE;
} else
}
else
res = TRUE;
if (unlock_doc)
DocUnlock(sys_registry_doc);
@ -59,10 +65,11 @@ public I64 RegCount(U8 *path)
I64 res = 0;
CDocEntry *tree_branch, *start_indent, *end_indent;
Bool unlock_doc = DocLock(sys_registry_doc);
if (DocTreeFind(sys_registry_doc,path,
&tree_branch,&start_indent,&end_indent)) {
if (DocTreeFind(sys_registry_doc, path, &tree_branch, &start_indent, &end_indent))
{
end_indent = end_indent->next;
while (start_indent!=end_indent) {
while (start_indent != end_indent)
{
res++;
start_indent = start_indent->next;
}
@ -85,11 +92,14 @@ public Bool OneTimePopUp(U8 *_flags,I64 flag_num,U8 *message)
Bool res = FALSE;
CDoc *doc = DocNew;
CDocEntry *doc_e;
if (!Bt(_flags,flag_num)) {
if (message) DocPrint(doc,"%s",message);
if (!Bt(_flags, flag_num))
{
if (message)
DocPrint(doc, "%s", message);
doc_e = DocPrint(doc, "\n$$CB,\"Do not show this message again.\",LE=1$$");
DocPrint(doc, "$$CM+CX,0,4$$$$BT,\"OKAY\",LE=1$$\n");
if (PopUpMenu(doc)==1 && doc_e->de_flags&DOCEF_CHECKED_COLLAPSED) {
if (PopUpMenu(doc) == 1 && doc_e->de_flags & DOCEF_CHECKED_COLLAPSED)
{
LBts(_flags, flag_num);
res = TRUE;
}
@ -101,8 +111,7 @@ public Bool OneTimePopUp(U8 *_flags,I64 flag_num,U8 *message)
U0 RegOneTimePopUp(I64 flag_num, U8 *message)
{//You're not supposed to make system pop-up flags, only me.
if (OneTimePopUp(sys_message_flags, flag_num,message))
RegWrite("Zenith/SysMessageFlags","sys_message_flags[0]=0x%X;\n",
sys_message_flags[0]);
RegWrite("Zenith/SysMessageFlags", "sys_message_flags[0]=0x%X;\n", sys_message_flags[0]);
}
U0 RegInit()
@ -113,7 +122,8 @@ U0 RegInit()
StrPrint(buf, "registry_version=%4.3f;\n", sys_os_version);
version_present = RegDefault("Zenith/SysRegVer", buf, TRUE);
RegExe("Zenith");
if (registry_version!=sys_os_version) {
if (registry_version != sys_os_version)
{
RegWrite("Zenith/SysRegVer", buf);
RegExe("Zenith");
}
@ -181,20 +191,24 @@ public U0 OnceExe()
try {
RegDefault("Once/Zenith", "");
if (RegCount("Once/Zenith")>2) {
if (RegCount("Once/Zenith") > 2)
{
Zenith("RegExe(\"Once/Zenith\");");
ZOnceFlush;
}
LBts(&sys_run_level, RLf_ONCE_ZENITH);
RegDefault("Once/User", "");
if (RegCount("Once/User")>2) {
if (RegCount("Once/User") > 2)
{
RegExe("Once/User");
OnceFlush;
}
LBts(&sys_run_level, RLf_ONCE_USER);
} catch {
}
catch
{
ZOnceFlush;
LBts(&sys_run_level, RLf_ONCE_ZENITH);
OnceFlush;