refactor(kernel): remove 'foreach' macro

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
EnderIce2 2025-03-29 22:43:07 +00:00
parent 93d897e95c
commit 8d71ed0ad5
Signed by: enderice2
GPG Key ID: FEB6B8A8507BA62E
42 changed files with 112 additions and 119 deletions

View File

@ -571,7 +571,7 @@ namespace v0
__PCIArray *head = nullptr;
__PCIArray *array = nullptr;
foreach (auto &dev in Devices)
for (auto &dev : Devices)
{
/* TODO: optimize memory allocation */
PCI::PCIDevice *dptr = (PCI::PCIDevice *)vma->RequestPages(TO_PAGES(sizeof(PCI::PCIDevice)));

View File

@ -110,7 +110,7 @@ namespace Driver
return;
}
foreach (const auto &drvNode in drvDirNode->Children)
for (const auto &drvNode : drvDirNode->Children)
{
debug("Checking driver %s", drvNode->Path.c_str());
if (!drvNode->IsRegularFile())
@ -169,7 +169,7 @@ namespace Driver
return;
}
foreach (auto &var in Drivers)
for (auto &var : Drivers)
{
DriverObject &Drv = var.second;
@ -224,7 +224,7 @@ namespace Driver
void Manager::UnloadAllDrivers()
{
foreach (auto &var in Drivers)
for (auto &var : Drivers)
{
DriverObject *Drv = &var.second;
if (!Drv->Initialized)
@ -240,7 +240,7 @@ namespace Driver
if (!Drv->InterruptHandlers->empty())
{
foreach (auto &rInt in * Drv->InterruptHandlers)
for (auto &rInt : *Drv->InterruptHandlers)
{
Interrupts::RemoveHandler((void (*)(CPU::TrapFrame *))rInt.second);
}
@ -256,7 +256,7 @@ namespace Driver
if (Drivers.size() == 0)
return;
foreach (auto Driver in Drivers)
for (auto Driver : Drivers)
{
if (!Driver.second.Initialized)
continue;

View File

@ -191,7 +191,7 @@ namespace Interrupts
void *ctx, bool Critical)
{
/* Just log a warning if the interrupt is already registered. */
foreach (auto ev in RegisteredEvents)
for (auto ev : RegisteredEvents)
{
if (ev.IRQ == InterruptNumber &&
ev.Callback == Callback)
@ -279,7 +279,7 @@ namespace Interrupts
{ return a.Priority < b.Priority; });
#ifdef DEBUG
foreach (auto ev in RegisteredEvents)
for (auto ev : RegisteredEvents)
{
void *fct = ev.IsHandler
? ev.Data
@ -421,7 +421,7 @@ namespace Interrupts
Handler::Handler(int InterruptNumber, bool Critical)
{
foreach (auto ev in RegisteredEvents)
for (auto ev : RegisteredEvents)
{
if (ev.IRQ == InterruptNumber)
{

View File

@ -79,7 +79,7 @@ namespace Memory
this->Expanded = Parent->Expanded;
std::list<AllocatedPages> ParentAllocatedPages = Parent->GetAllocatedPages();
foreach (auto Page in ParentAllocatedPages)
for (auto Page : ParentAllocatedPages)
{
void *NewPhysical = vma->RequestPages(1);
debug("Forking address %#lx to %#lx", Page.PhysicalAddress, NewPhysical);

View File

@ -82,7 +82,7 @@ namespace Memory
func("%#lx, %lld", Address, Count);
SmartLock(MgrLock);
foreach (auto &apl in AllocatedPagesList)
for (auto &apl : AllocatedPagesList)
{
if (apl.VirtualAddress != Address)
continue;
@ -128,7 +128,7 @@ namespace Memory
/* No need to remap pages, the page table will be destroyed */
Virtual vmm(this->Table);
foreach (auto ap in AllocatedPagesList)
for (auto ap : AllocatedPagesList)
{
KernelAllocator.FreePages(ap.PhysicalAddress, ap.PageCount);

View File

@ -29,7 +29,7 @@ namespace Memory
{
SmartLock(MgrLock);
uint64_t Size = 0;
foreach (auto ap in AllocatedPagesList)
for (auto ap : AllocatedPagesList)
Size += ap.PageCount;
return FROM_PAGES(Size);
}
@ -214,7 +214,7 @@ namespace Memory
return false;
}
foreach (auto sr in SharedRegions)
for (auto sr : SharedRegions)
{
uintptr_t Start = (uintptr_t)sr.Address;
uintptr_t End = (uintptr_t)sr.Address + sr.Length;
@ -263,7 +263,7 @@ namespace Memory
void VirtualMemoryArea::FreeAllPages()
{
SmartLock(MgrLock);
foreach (auto ap in AllocatedPagesList)
for (auto ap : AllocatedPagesList)
{
KernelAllocator.FreePages(ap.Address, ap.PageCount);
Virtual vmm(this->Table);
@ -287,7 +287,7 @@ namespace Memory
Virtual vmm(this->Table);
SmartLock(MgrLock);
foreach (auto &ap in Parent->AllocatedPagesList)
for (auto &ap : Parent->AllocatedPagesList)
{
if (ap.Protected)
{
@ -339,7 +339,7 @@ namespace Memory
(uintptr_t)ap.Address + (ap.PageCount * PAGE_SIZE));
}
foreach (auto &sr in Parent->SharedRegions)
for (auto &sr : Parent->SharedRegions)
{
MgrLock.Unlock();
void *Address = this->CreateCoWRegion(sr.Address, sr.Length,
@ -496,7 +496,7 @@ namespace Memory
/* No need to remap pages, the page table will be destroyed */
SmartLock(MgrLock);
foreach (auto ap in AllocatedPagesList)
for (auto ap : AllocatedPagesList)
KernelAllocator.FreePages(ap.Address, ap.PageCount);
}
}

View File

@ -489,12 +489,12 @@ nsa void DisplayProcessScreen(CPU::ExceptionFrame *Frame, bool IgnoreReady = tru
bool pRdy = false;
bool showNote = false;
/* FIXME: This is slow */
foreach (auto Process in Plist)
for (auto Process : Plist)
{
bool ignore = true;
if (Process->State == Tasking::Ready && IgnoreReady)
{
foreach (auto Thread in Process->Threads)
for (auto Thread : Process->Threads)
{
if (Thread->State == Tasking::Ready)
continue;
@ -522,7 +522,7 @@ nsa void DisplayProcessScreen(CPU::ExceptionFrame *Frame, bool IgnoreReady = tru
: "none");
bool tRdy = false;
foreach (auto Thread in Process->Threads)
for (auto Thread : Process->Threads)
{
if (Thread->State == Tasking::Ready && IgnoreReady)
{

View File

@ -1079,7 +1079,7 @@ namespace PCI
std::list<PCIDevice> Manager::FindPCIDevice(uint8_t Class, uint8_t Subclass, uint8_t ProgIF)
{
std::list<PCIDevice> DeviceFound;
foreach (auto dev in Devices)
for (auto dev : Devices)
{
if (dev.Header->Class == Class &&
dev.Header->Subclass == Subclass &&
@ -1094,7 +1094,7 @@ namespace PCI
std::list<PCIDevice> Manager::FindPCIDevice(uint16_t VendorID, uint16_t DeviceID)
{
std::list<PCIDevice> DeviceFound;
foreach (auto dev in Devices)
for (auto dev : Devices)
{
if (dev.Header->VendorID == VendorID &&
dev.Header->DeviceID == DeviceID)
@ -1109,11 +1109,11 @@ namespace PCI
std::list<uint16_t> DeviceIDs)
{
std::list<PCIDevice> DeviceFound;
foreach (auto dev in Devices)
for (auto dev : Devices)
{
foreach (auto VendorID in VendorIDs)
for (auto VendorID : VendorIDs)
{
foreach (auto DeviceID in DeviceIDs)
for (auto DeviceID : DeviceIDs)
{
if (dev.Header->VendorID == VendorID &&
dev.Header->DeviceID == DeviceID)

View File

@ -25,14 +25,14 @@ namespace Random
__constructor void InitRandomSeed()
{
if (std::strcmp(CPU::Hypervisor(), x86_CPUID_VENDOR_TCG) != 0)
if (strcmp(CPU::Hypervisor(), x86_CPUID_VENDOR_TCG) != 0)
{
if (std::strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
{
CPU::x86::AMD::CPUID0x00000007_ECX_0 cpuid;
RDSEEDFlag = cpuid.EBX.RDSEED;
}
else if (std::strcmp(CPU::Vendor(), x86_CPUID_VENDOR_INTEL) == 0)
else if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_INTEL) == 0)
{
CPU::x86::Intel::CPUID0x00000007_0 cpuid;
RDSEEDFlag = cpuid.EBX.RDSEED;
@ -41,14 +41,14 @@ namespace Random
else
RDSEEDFlag = false;
if (std::strcmp(CPU::Hypervisor(), x86_CPUID_VENDOR_TCG) != 0)
if (strcmp(CPU::Hypervisor(), x86_CPUID_VENDOR_TCG) != 0)
{
if (std::strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
{
CPU::x86::AMD::CPUID0x00000001 cpuid;
RDRANDFlag = cpuid.ECX.RDRAND;
}
else if (std::strcmp(CPU::Vendor(), x86_CPUID_VENDOR_INTEL) == 0)
else if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_INTEL) == 0)
{
CPU::x86::Intel::CPUID0x00000001 cpuid;
RDRANDFlag = cpuid.ECX.RDRAND;

View File

@ -324,7 +324,7 @@ namespace SymbolResolver
debug("- %#lx", this);
debug("Freeing %d symbols",
this->SymTable.size());
foreach (auto tbl in this->SymTable)
for (auto tbl : this->SymTable)
delete[] tbl.FunctionName;
}
}

View File

@ -966,7 +966,7 @@ namespace Driver::AHCI
// ctx->Device->Header->Command |= PCI::PCI_COMMAND_INTX_DISABLE;
// std::list<PCI::PCIDevice> Devices = PCIManager->FindPCIDevice(VendorIDs, DeviceIDs);
// foreach (auto dev in Devices)
// for (auto dev : Devices)
// Interrupts::RemoveHandler(OnInterruptReceived, iLine(dev));
return 0;
}

View File

@ -84,7 +84,7 @@ namespace Execute
// AT_MINSIGSTKSZ 51
#ifdef DEBUG
foreach (auto var in Elfauxv)
for (auto var : Elfauxv)
{
debug("auxv: %ld %#lx",
var.archaux.a_type,
@ -103,7 +103,7 @@ namespace Execute
{
#if defined(__amd64__)
std::vector<Elf64_Phdr> PhdrINTERP = ELFGetSymbolType_x86_64(fd, PT_INTERP);
foreach (auto Interp in PhdrINTERP)
for (auto Interp : PhdrINTERP)
{
std::string interpreterPath;
interpreterPath.resize(256);
@ -350,7 +350,7 @@ namespace Execute
{
#if defined(__amd64__)
std::vector<Elf64_Phdr> PhdrINTERP = ELFGetSymbolType_x86_64(fd, PT_INTERP);
foreach (auto Interp in PhdrINTERP)
for (auto Interp : PhdrINTERP)
{
std::string interpreterPath;
interpreterPath.resize(256);

View File

@ -38,7 +38,7 @@ namespace Execute
return Ret;
}
foreach (auto Phdr in DYNAMICPhdrs)
for (auto Phdr : DYNAMICPhdrs)
{
Elf64_Dyn Dynamic{};
for (size_t i = 0; i < Phdr.p_filesz / sizeof(Elf64_Dyn); i++)

View File

@ -112,7 +112,7 @@ namespace Execute
CriticalSection cs;
Process = Parent;
foreach (auto tcb in Process->Threads)
for (auto tcb : Process->Threads)
{
debug("Deleting thread %d", tcb->ID);
// delete tcb;
@ -153,7 +153,7 @@ namespace Execute
if (unlikely(SearchNode == nullptr))
return false;
foreach (const auto &ffd in pfdt->FileMap)
for (const auto &ffd : pfdt->FileMap)
{
if (ffd.second.Flags & O_CLOEXEC)
continue;

View File

@ -54,9 +54,6 @@
#define ilp inf_loop; /* Used for debugging */
#ifdef __cplusplus
#define foreach for
#define in :
#define forItr(itr, container) \
for (auto itr = container.begin(); \
itr != container.end(); ++itr)

View File

@ -17,12 +17,8 @@
#pragma once
#include <convert.h>
namespace std
{
int strcmp(const char *lhs, const char *rhs)
{
for (; *lhs == *rhs && *lhs; lhs++, rhs++)
;
return *(unsigned char *)lhs - *(unsigned char *)rhs;
}
}

View File

@ -216,7 +216,7 @@ namespace std
list(std::initializer_list<T> init, const Allocator &alloc = Allocator())
{
foreach (const_reference value in init)
for (const_reference value : init)
push_back(value);
}
@ -250,7 +250,7 @@ namespace std
list &operator=(std::initializer_list<T> ilist)
{
clear();
foreach (const_reference value in ilist)
for (const_reference value : ilist)
push_back(value);
return *this;
}
@ -273,7 +273,7 @@ namespace std
void assign(std::initializer_list<T> ilist)
{
clear();
foreach (const_reference value in ilist)
for (const_reference value : ilist)
push_back(value);
}
@ -443,7 +443,7 @@ namespace std
iterator insert(const_iterator pos, std::initializer_list<T> ilist)
{
iterator ret;
foreach (const_reference value in ilist)
for (const_reference value : ilist)
ret = insert(pos, value);
return ret;
}

View File

@ -477,7 +477,7 @@ namespace std
void clear() noexcept
{
foreach (auto &bucket in buckets)
for (auto &bucket : buckets)
bucket.clear();
elementsCount = 0;
}
@ -589,7 +589,7 @@ namespace std
void insert(std::initializer_list<value_type> ilist)
{
foreach (const auto &value in ilist)
for (const auto &value : ilist)
insert(value);
}

View File

@ -27,7 +27,7 @@ using namespace Tasking;
void cmd_killall(const char *args)
{
foreach (auto Proc in TaskManager->GetProcessList())
for (auto Proc : TaskManager->GetProcessList())
{
if (strcmp(Proc->Name, args) == 0)
{

View File

@ -27,7 +27,7 @@ using namespace vfs;
void cmd_lsacpi(const char *)
{
ACPI::ACPI *acpi = (ACPI::ACPI *)PowerManager->GetACPI();
foreach (auto Table in acpi->Tables)
for (auto Table : acpi->Tables)
{
printf("%#lx: %.4s [%.6s:%.8s] %d bytes\n",
(uintptr_t)Table.second,

View File

@ -26,7 +26,7 @@ void cmd_lsmod(const char *)
printf("DRIVER | ID | INIT | MEMORY\n");
foreach (auto &drv in drivers)
for (auto &drv : drivers)
{
printf("%-15s | %5ld | %s | %ld KiB\n",
drv.second.Name,

View File

@ -29,7 +29,7 @@ void cmd_lspci(const char *args)
{
if (IF_ARG("-i") || IF_ARG("--info"))
{
foreach (auto Device in PCIManager->GetDevices())
for (auto Device : PCIManager->GetDevices())
{
const char *HdrType;
switch (Device.Header->HeaderType)
@ -65,7 +65,7 @@ void cmd_lspci(const char *args)
}
}
foreach (auto Device in PCIManager->GetDevices())
for (auto Device : PCIManager->GetDevices())
{
printf("%02x:%02x.%d: %s: %s %s\n",
Device.Bus,

View File

@ -35,7 +35,7 @@ void cmd_modinfo(const char *args)
if (drivers.find(id) == drivers.end())
{
bool found = false;
foreach (auto var in drivers)
for (auto var : drivers)
{
if (strcmp(var.second.Name, args) == 0)
{
@ -70,7 +70,7 @@ void cmd_modinfo(const char *args)
printf(" Path: %s\n", drv.Path.c_str());
printf(" Used Memory: %ld KiB\n", TO_KiB(drv.vma->GetAllocatedMemorySize()));
printf(" Used IRQs:%s\n", drv.InterruptHandlers->empty() ? " none" : "");
foreach (auto var in *drv.InterruptHandlers)
for (auto var : *drv.InterruptHandlers)
{
printf(" IRQ%-2d: %#lx\n",
var.first, (uintptr_t)var.second);

View File

@ -28,6 +28,6 @@ using namespace Tasking;
void cmd_ps(const char *)
{
printf("PID Name\n");
foreach (auto p in TaskManager->GetProcessList())
for (auto p : TaskManager->GetProcessList())
printf("%d %s\n", p->ID, p->Name);
}

View File

@ -43,7 +43,7 @@ const char *TaskStateStrings[] = {
void cmd_top(const char *)
{
printf("PID Name State Priority Memory Usage CPU Usage\n");
foreach (auto Proc in TaskManager->GetProcessList())
for (auto Proc : TaskManager->GetProcessList())
{
#if defined(__amd64__)
printf("%-4d %-20s %s %d %ld KiB %ld\n",
@ -57,7 +57,7 @@ void cmd_top(const char *)
Proc->Info.UserTime + Proc->Info.KernelTime);
#endif
foreach (auto Thrd in Proc->Threads)
for (auto Thrd : Proc->Threads)
{
#if defined(__amd64__)
printf(" %-4d %-20s %s %d %ld KiB %ld\n",

View File

@ -23,7 +23,7 @@
void tree_loop(FileNode *rootNode, int depth = 0)
{
// foreach (auto Child in rootNode->GetChildren(true))
// for (auto Child : rootNode->GetChildren(true))
// {
// Display->UpdateBuffer();
// if (Child->Stat.IsType(DIRECTORY) || Child->Stat.IsType(MOUNTPOINT))

View File

@ -88,22 +88,22 @@ namespace NetworkEthernet
switch (b16(Packet->Header.Type))
{
case TYPE_IPV4:
foreach (auto e in RegisteredEvents)
for (auto e : RegisteredEvents)
if (e.Type == TYPE_IPV4)
Reply = e.Ptr->OnEthernetPacketReceived((uint8_t *)Packet->Data, Length);
break;
case TYPE_ARP:
foreach (auto e in RegisteredEvents)
for (auto e : RegisteredEvents)
if (e.Type == TYPE_ARP)
Reply = e.Ptr->OnEthernetPacketReceived((uint8_t *)Packet->Data, Length);
break;
case TYPE_RARP:
foreach (auto e in RegisteredEvents)
for (auto e : RegisteredEvents)
if (e.Type == TYPE_RARP)
Reply = e.Ptr->OnEthernetPacketReceived((uint8_t *)Packet->Data, Length);
break;
case TYPE_IPV6:
foreach (auto e in RegisteredEvents)
for (auto e : RegisteredEvents)
if (e.Type == TYPE_IPV6)
Reply = e.Ptr->OnEthernetPacketReceived((uint8_t *)Packet->Data, Length);
break;

View File

@ -86,7 +86,7 @@ namespace NetworkIPv4
if (TotalLength > Length)
TotalLength = Length;
foreach (auto Event in RegisteredEvents)
for (auto Event : RegisteredEvents)
if (Packet->Header.Protocol == Event->GetProtocol())
{
InternetProtocol SourceIP;

View File

@ -40,7 +40,7 @@ namespace NetworkInterfaceManager
/* KernelCallback */
// if (DriverManager->GetModules().size() > 0)
// {
// foreach (auto Driver in DriverManager->GetModules())
// for (auto Driver : DriverManager->GetModules())
// if (((FexExtended *)Driver.ExtendedHeaderAddress)->Driver.Type == FexDriverType::FexDriverType_Network)
// this->FetchNetworkCards(Driver.modUniqueID);
// }
@ -81,7 +81,7 @@ namespace NetworkInterfaceManager
Iface->DriverID = modUniqueID;
Interfaces.push_back(Iface);
foreach (auto var in RegisteredEvents)
for (auto var : RegisteredEvents)
var->OnInterfaceAdded(Iface);
debug("Network Card: %s; MAC: %#lx", Iface->Name, Iface->MAC.ToHex());
@ -97,7 +97,7 @@ namespace NetworkInterfaceManager
{
thisThread->SetPriority(Tasking::TaskPriority::Critical);
DeviceInterface *DefaultDevice = nullptr;
foreach (auto inf in Interfaces)
for (auto inf : Interfaces)
{
if (inf)
{
@ -183,7 +183,7 @@ namespace NetworkInterfaceManager
void NetworkInterface::DrvSend(unsigned int DriverID, unsigned char *Data, unsigned short Size)
{
// foreach (auto inf in this->Interfaces)
// for (auto inf : this->Interfaces)
// if (inf->DriverID == DriverID)
// NIManager->Send(inf, Data, Size);
assert(!"Function not implemented");
@ -191,7 +191,7 @@ namespace NetworkInterfaceManager
void NetworkInterface::DrvReceive(unsigned int DriverID, unsigned char *Data, unsigned short Size)
{
// foreach (auto inf in this->Interfaces)
// for (auto inf : this->Interfaces)
// if (inf->DriverID == DriverID)
// NIManager->Receive(inf, Data, Size);
assert(!"Function not implemented");
@ -210,13 +210,13 @@ namespace NetworkInterfaceManager
// DriverManager->IOCB(Interface->DriverID, &cb);
vma->FreePages(DataToBeSent, TO_PAGES(Length + 1));
foreach (auto ev in RegisteredEvents)
for (auto ev : RegisteredEvents)
ev->OnInterfaceSent(Interface, Data, Length);
}
void NetworkInterface::Receive(DeviceInterface *Interface, uint8_t *Data, size_t Length)
{
foreach (auto re in RegisteredEvents)
for (auto re : RegisteredEvents)
re->OnInterfaceReceived(Interface, Data, Length);
}

View File

@ -109,7 +109,7 @@ namespace NetworkUDP
Socket *GoodSocket = nullptr;
foreach (auto &var in RegisteredEvents)
for (auto &var : RegisteredEvents)
{
netdbg("UDP->SKT[]: LP:%d | LIP:%s | RP:%d | RIP:%s | LST:%d",
b16(var.UDPSocket->LocalPort),

View File

@ -86,7 +86,7 @@ namespace vfs
struct kdirent *ent = nullptr;
vfsInode *Node = (vfsInode *)_Node;
off_t entries = 0;
foreach (const auto &Root in Node->Children)
for (const auto &Root : Node->Children)
{
if (entries >= Entries)
break;

View File

@ -540,7 +540,7 @@ int ConvertSignalToLinux(signal_t sig)
if (sig >= SIGRTMIN && sig <= SIGRTMAX)
return sig; /* We ignore for now */
foreach (auto &mapping in signalMapping)
for (auto &mapping : signalMapping)
{
if (mapping.nativeSignal == sig)
{
@ -560,7 +560,7 @@ signal_t ConvertSignalToNative(int sig)
if (sig >= linux_SIGRTMIN && sig <= linux_SIGRTMAX)
return (signal_t)sig; /* We ignore for now */
foreach (auto &mapping in signalMapping)
for (auto &mapping : signalMapping)
{
if (mapping.linuxSignal == sig)
{
@ -2035,7 +2035,7 @@ static pid_t linux_wait4(SysFrm *, pid_t pid, int *wstatus,
}
#ifdef DEBUG
foreach (auto child in pcb->Children)
for (auto child : pcb->Children)
debug("Child: %s(%d)", child->Name, child->ID);
#endif
@ -2122,7 +2122,7 @@ static int linux_kill(SysFrm *, pid_t pid, int sig)
bool found = false;
signal_t nSig = ConvertSignalToNative(sig);
assert(nSig != SIGNULL);
foreach (auto proc in pcb->GetContext()->GetProcessList())
for (auto proc : pcb->GetContext()->GetProcessList())
{
if (proc->Security.ProcessGroupID == thisProcess->Security.ProcessGroupID)
{
@ -2507,7 +2507,7 @@ static int linux_getrusage(SysFrm *, int who, struct rusage *usage)
size_t uTime = 0;
size_t _maxrss = 0;
foreach (auto child in pcb->Children)
for (auto child : pcb->Children)
{
kTime += child->Info.KernelTime;
uTime += child->Info.UserTime;
@ -3181,7 +3181,7 @@ static int linux_tgkill(SysFrm *sf, pid_t tgid, pid_t tid, int sig)
debug("Invalid tgid %d tid %d", tgid, tid);
tcb = nullptr;
foreach (auto t in thisProcess->Threads)
for (auto t : thisProcess->Threads)
{
if (t->Linux.tgid == tgid)
{

View File

@ -178,7 +178,7 @@ int sys_kill(SysFrm *Frame, pid_t pid, int sig)
if (pid == 0)
{
bool found = false;
foreach (auto proc in pcb->GetContext()->GetProcessList())
for (auto proc : pcb->GetContext()->GetProcessList())
{
if (proc->Security.ProcessGroupID == thisProcess->Security.ProcessGroupID)
{

View File

@ -295,7 +295,7 @@ namespace Tasking
}
/* Exit all children processes */
foreach (auto pcb in this->Children)
for (auto pcb : this->Children)
{
if (pcb == nullptr)
{
@ -309,7 +309,7 @@ namespace Tasking
}
/* Exit all threads */
foreach (auto tcb in this->Threads)
for (auto tcb : this->Threads)
{
if (tcb == nullptr)
{

View File

@ -140,7 +140,7 @@ namespace Tasking::Scheduler
return true;
}
foreach (TCB *Thread in Process->Threads)
for (TCB *Thread : Process->Threads)
{
if (Thread->State == Terminated)
RemoveThread(Thread);
@ -151,7 +151,7 @@ namespace Tasking::Scheduler
PCB *Custom::GetProcessByID(TID ID)
{
foreach (auto p in ProcessList)
for (auto p : ProcessList)
{
if (p->ID == ID)
return p;
@ -164,7 +164,7 @@ namespace Tasking::Scheduler
if (unlikely(Parent == nullptr))
return nullptr;
foreach (auto t in Parent->Threads)
for (auto t : Parent->Threads)
{
if (t->ID == ID)
return t;
@ -305,11 +305,11 @@ namespace Tasking::Scheduler
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
fnp_schedbg("%d processes", ProcessList.size());
#ifdef DEBUG_FIND_NEW_PROCESS
foreach (auto process in ProcessList)
for (auto process : ProcessList)
fnp_schedbg("Process %d %s", process->ID,
process->Name);
#endif
foreach (auto process in ProcessList)
for (auto process : ProcessList)
{
switch (process->State.load())
{
@ -330,7 +330,7 @@ namespace Tasking::Scheduler
continue;
}
foreach (auto thread in process->Threads)
for (auto thread : process->Threads)
{
if (thread->State.load() != TaskState::Ready)
continue;
@ -401,7 +401,7 @@ namespace Tasking::Scheduler
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
bool Skip = true;
foreach (auto process in ProcessList)
for (auto process : ProcessList)
{
if (process == CurrentCPU->CurrentProcess.load())
{
@ -422,7 +422,7 @@ namespace Tasking::Scheduler
continue;
}
foreach (auto thread in process->Threads)
for (auto thread : process->Threads)
{
if (thread->State.load() != TaskState::Ready)
{
@ -448,7 +448,7 @@ namespace Tasking::Scheduler
{
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
foreach (auto process in ProcessList)
for (auto process : ProcessList)
{
if (process->State.load() != TaskState::Ready)
{
@ -456,7 +456,7 @@ namespace Tasking::Scheduler
continue;
}
foreach (auto thread in process->Threads)
for (auto thread : process->Threads)
{
if (thread->State.load() != TaskState::Ready)
{
@ -479,7 +479,7 @@ namespace Tasking::Scheduler
nsa NIF void Custom::UpdateProcessState()
{
foreach (auto process in ProcessList)
for (auto process : ProcessList)
{
if (process->State.load() == TaskState::Terminated)
continue;
@ -491,7 +491,7 @@ namespace Tasking::Scheduler
}
bool AllThreadsSleeping = true;
foreach (auto thread in process->Threads)
for (auto thread : process->Threads)
{
if (thread->State.load() == TaskState::Terminated)
continue;
@ -512,7 +512,7 @@ namespace Tasking::Scheduler
nsa NIF void Custom::WakeUpThreads()
{
foreach (auto process in ProcessList)
for (auto process : ProcessList)
{
Tasking::TaskState pState = process->State.load();
if (pState != TaskState::Ready &&
@ -520,7 +520,7 @@ namespace Tasking::Scheduler
pState != TaskState::Blocked)
continue;
foreach (auto thread in process->Threads)
for (auto thread : process->Threads)
{
if (likely(thread->State.load() != TaskState::Sleeping))
continue;
@ -546,7 +546,7 @@ namespace Tasking::Scheduler
nsa NIF void Custom::CleanupTerminated()
{
foreach (auto pcb in ProcessList)
for (auto pcb : ProcessList)
{
if (pcb->State.load() == TaskState::Terminated)
{
@ -555,7 +555,7 @@ namespace Tasking::Scheduler
continue;
}
foreach (TCB *tcb in pcb->Threads)
for (TCB *tcb : pcb->Threads)
{
if (tcb->State == Terminated)
delete tcb;
@ -736,9 +736,9 @@ namespace Tasking::Scheduler
Custom::~Custom()
{
foreach (PCB *Process in ProcessList)
for (PCB *Process : ProcessList)
{
foreach (TCB *Thread in Process->Threads)
for (TCB *Thread : Process->Threads)
{
if (Thread == GetCurrentCPU()->CurrentThread.load())
continue;
@ -756,7 +756,7 @@ namespace Tasking::Scheduler
{
trace("Waiting for %d processes to terminate", this->GetProcessList().size());
int NotTerminated = 0;
foreach (PCB *Process in this->GetProcessList())
for (PCB *Process : this->GetProcessList())
{
trace("Process %s(%d) is still running (or waiting to be removed state %#lx)",
Process->Name, Process->ID, Process->State);

View File

@ -176,7 +176,7 @@ static const struct
signal_disposition_t GetDefaultSignalDisposition(signal_t sig)
{
foreach (auto var in SignalDisposition)
for (auto var : SignalDisposition)
{
if (var.Signal == sig)
return var.Disposition;
@ -519,7 +519,7 @@ namespace Tasking
debug("Signal %s(%d) completed", sigStr[sig], sig);
if (Disposition[sig] != SIG_IGN)
{
foreach (auto info in Watchers)
for (auto info : Watchers)
{
Signal *who = (Signal *)info.val.sival_ptr;
assert(who != nullptr);

View File

@ -201,7 +201,7 @@ namespace Tasking
GetCurrentProcess()->Name, GetCurrentProcess()->ID,
GetCurrentThread()->Name, GetCurrentThread()->ID);
foreach (auto pcb in((Scheduler::Base *)Scheduler)->GetProcessList())
for (auto pcb : ((Scheduler::Base *)Scheduler)->GetProcessList())
{
if (pcb->State == TaskState::Terminated ||
pcb->State == TaskState::Zombie)

View File

@ -268,7 +268,7 @@ namespace Tasking
auxv_array.push_back({.archaux = {.a_type = AT_NULL, .a_un = {.a_val = 0}}});
/* Store auxillary vector */
foreach (AuxiliaryVector av in auxv_array)
for (AuxiliaryVector av : auxv_array)
{
/* Subtract the size of the auxillary vector */
Stack64 -= sizeof(Elf_auxv_t) / sizeof(uintptr_t);

View File

@ -25,18 +25,18 @@ __constructor void TestRandom()
{
#if defined(__amd64__) || defined(__i386__)
int RDRANDFlag = 0;
if (std::strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_AMD) == 0)
{
CPU::x86::AMD::CPUID0x00000001 cpuid;
RDRANDFlag = cpuid.ECX.RDRAND;
}
else if (std::strcmp(CPU::Vendor(), x86_CPUID_VENDOR_INTEL) == 0)
else if (strcmp(CPU::Vendor(), x86_CPUID_VENDOR_INTEL) == 0)
{
CPU::x86::Intel::CPUID0x00000001 cpuid;
RDRANDFlag = cpuid.ECX.RDRAND;
}
if (std::strcmp(CPU::Hypervisor(), x86_CPUID_VENDOR_TCG) == 0)
if (strcmp(CPU::Hypervisor(), x86_CPUID_VENDOR_TCG) == 0)
RDRANDFlag = 0;
if (RDRANDFlag)

View File

@ -31,7 +31,7 @@ void killChildren(Tasking::PCB *pcb)
std::vector<Tasking::PCB *> children = pcb->Children;
foreach (auto child in children)
for (auto child : children)
{
if (child->State.load() == Tasking::Terminated)
{

View File

@ -131,7 +131,7 @@ void TaskMgr()
// Display->SetBufferCursor(0, 0);
printf("\eF02C21Task Manager\n");
static uint64_t OldSystemTime = 0;
foreach (auto Proc in TaskManager->GetProcessList())
for (auto Proc : TaskManager->GetProcessList())
{
if (!Proc)
continue;
@ -150,7 +150,7 @@ void TaskMgr()
#warning "aarch64 not implemented"
#endif
foreach (auto Thd in Proc->Threads)
for (auto Thd : Proc->Threads)
{
if (!Thd)
continue;

View File

@ -24,7 +24,7 @@
void TreeFS(FileNode *node, int Depth)
{
return;
// foreach (auto Chld in node->GetChildren(true))
// for (auto Chld : node->GetChildren(true))
// {
// printf("%*c %s\eFFFFFF\n", Depth, ' ', Chld->FileName);