From e5fe2b82b7cf8842a5a202da69c003d2a2c6af3f Mon Sep 17 00:00:00 2001 From: Brandon Potter Date: Wed, 1 Mar 2017 13:18:49 -0600 Subject: [PATCH] style: Correct some style issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changeset fixes line alignment issues, spacing, spelling, etc. for files that are used during SE Mode. Change-Id: Ie61b8d0eb4ebb5af554d72f1297808027833616e Reviewed-on: https://gem5-review.googlesource.com/2264 Maintainer: Jason Lowe-Power Reviewed-by: Tony Gutierrez Reviewed-by: Michael LeBeane Reviewed-by: Andreas Sandberg Reviewed-by: Pierre-Yves PĂ©neau --- src/arch/x86/linux/process.cc | 4 +- src/arch/x86/process.cc | 80 +++++++++++++++++----------------- src/base/loader/elf_object.hh | 7 ++- src/base/loader/object_file.hh | 6 +-- src/sim/process.cc | 2 +- src/sim/syscall_emul.cc | 32 +++++++------- src/sim/syscall_emul.hh | 47 ++++++++++---------- 7 files changed, 87 insertions(+), 91 deletions(-) diff --git a/src/arch/x86/linux/process.cc b/src/arch/x86/linux/process.cc index c2d67eb81..806d8605b 100644 --- a/src/arch/x86/linux/process.cc +++ b/src/arch/x86/linux/process.cc @@ -83,7 +83,7 @@ archPrctlFunc(SyscallDesc *desc, int callnum, Process *process, GetGS = 0x1004 }; - //First argument is the code, second is the address + // First argument is the code, second is the address int index = 0; int code = process->getSyscallArg(tc, index); uint64_t addr = process->getSyscallArg(tc, index); @@ -91,7 +91,7 @@ archPrctlFunc(SyscallDesc *desc, int callnum, Process *process, SETranslatingPortProxy &p = tc->getMemProxy(); switch(code) { - //Each of these valid options should actually check addr. + // Each of these valid options should actually check addr. case SetFS: tc->setMiscRegNoEffect(MISCREG_FS_BASE, addr); tc->setMiscRegNoEffect(MISCREG_FS_EFF_BASE, addr); diff --git a/src/arch/x86/process.cc b/src/arch/x86/process.cc index 1e6401b10..d7a057151 100644 --- a/src/arch/x86/process.cc +++ b/src/arch/x86/process.cc @@ -73,9 +73,9 @@ static const int ArgumentReg[] = { INTREG_RDI, INTREG_RSI, INTREG_RDX, - //This argument register is r10 for syscalls and rcx for C. + // This argument register is r10 for syscalls and rcx for C. INTREG_R10W, - //INTREG_RCX, + // INTREG_RCX, INTREG_R8W, INTREG_R9W }; @@ -183,7 +183,7 @@ X86_64Process::initState() argsInit(PageBytes); - // Set up the vsyscall page for this process. + // Set up the vsyscall page for this process. allocateMem(vsyscallPage.base, vsyscallPage.size); uint8_t vtimeBlob[] = { 0x48,0xc7,0xc0,0xc9,0x00,0x00,0x00, // mov $0xc9,%rax @@ -566,7 +566,7 @@ X86_64Process::initState() dataAttr.expandDown = 0; dataAttr.system = 1; - //Initialize the segment registers. + // Initialize the segment registers. for (int seg = 0; seg < NUM_SEGMENTREGS; seg++) { tc->setMiscRegNoEffect(MISCREG_SEG_BASE(seg), 0); tc->setMiscRegNoEffect(MISCREG_SEG_EFF_BASE(seg), 0); @@ -598,7 +598,7 @@ X86_64Process::initState() efer.ffxsr = 1; // Turn on fast fxsave and fxrstor. tc->setMiscReg(MISCREG_EFER, efer); - //Set up the registers that describe the operating mode. + // Set up the registers that describe the operating mode. CR0 cr0 = 0; cr0.pg = 1; // Turn on paging. cr0.cd = 0; // Don't disable caching. @@ -677,7 +677,7 @@ I386Process::initState() dataAttr.expandDown = 0; dataAttr.system = 1; - //Initialize the segment registers. + // Initialize the segment registers. for (int seg = 0; seg < NUM_SEGMENTREGS; seg++) { tc->setMiscRegNoEffect(MISCREG_SEG_BASE(seg), 0); tc->setMiscRegNoEffect(MISCREG_SEG_EFF_BASE(seg), 0); @@ -718,7 +718,7 @@ I386Process::initState() efer.ffxsr = 1; // Turn on fast fxsave and fxrstor. tc->setMiscReg(MISCREG_EFER, efer); - //Set up the registers that describe the operating mode. + // Set up the registers that describe the operating mode. CR0 cr0 = 0; cr0.pg = 1; // Turn on paging. cr0.cd = 0; // Don't disable caching. @@ -755,7 +755,7 @@ X86Process::argsInit(int pageSize, else filename = argv[0]; - //We want 16 byte alignment + // We want 16 byte alignment uint64_t align = 16; // Patch the ld_bias for dynamic executables. @@ -841,13 +841,13 @@ X86Process::argsInit(int pageSize, // X86_IA64Processor | 0; - //Bits which describe the system hardware capabilities - //XXX Figure out what these should be + // Bits which describe the system hardware capabilities + // XXX Figure out what these should be auxv.push_back(auxv_t(M5_AT_HWCAP, features)); - //The system page size + // The system page size auxv.push_back(auxv_t(M5_AT_PAGESZ, X86ISA::PageBytes)); - //Frequency at which times() increments - //Defined to be 100 in the kernel source. + // Frequency at which times() increments + // Defined to be 100 in the kernel source. auxv.push_back(auxv_t(M5_AT_CLKTCK, 100)); // This is the virtual address of the program header tables if they // appear in the executable image. @@ -860,32 +860,32 @@ X86Process::argsInit(int pageSize, // zero for static executables or contain the base address for // dynamic executables. auxv.push_back(auxv_t(M5_AT_BASE, getBias())); - //XXX Figure out what this should be. + // XXX Figure out what this should be. auxv.push_back(auxv_t(M5_AT_FLAGS, 0)); - //The entry point to the program + // The entry point to the program auxv.push_back(auxv_t(M5_AT_ENTRY, objFile->entryPoint())); - //Different user and group IDs + // Different user and group IDs auxv.push_back(auxv_t(M5_AT_UID, uid())); auxv.push_back(auxv_t(M5_AT_EUID, euid())); auxv.push_back(auxv_t(M5_AT_GID, gid())); auxv.push_back(auxv_t(M5_AT_EGID, egid())); - //Whether to enable "secure mode" in the executable + // Whether to enable "secure mode" in the executable auxv.push_back(auxv_t(M5_AT_SECURE, 0)); - //The address of 16 "random" bytes. + // The address of 16 "random" bytes. auxv.push_back(auxv_t(M5_AT_RANDOM, 0)); - //The name of the program + // The name of the program auxv.push_back(auxv_t(M5_AT_EXECFN, 0)); - //The platform string + // The platform string auxv.push_back(auxv_t(M5_AT_PLATFORM, 0)); } - //Figure out how big the initial stack needs to be + // Figure out how big the initial stack needs to be // A sentry NULL void pointer at the top of the stack. int sentry_size = intSize; - //This is the name of the file which is present on the initial stack - //It's purpose is to let the user space linker examine the original file. + // This is the name of the file which is present on the initial stack + // It's purpose is to let the user space linker examine the original file. int file_name_size = filename.size() + 1; const int numRandomBytes = 16; @@ -901,10 +901,10 @@ X86Process::argsInit(int pageSize, for (int i = 0; i < argv.size(); ++i) arg_data_size += argv[i].size() + 1; - //The info_block needs to be padded so it's size is a multiple of the - //alignment mask. Also, it appears that there needs to be at least some - //padding, so if the size is already a multiple, we need to increase it - //anyway. + // The info_block needs to be padded so its size is a multiple of the + // alignment mask. Also, it appears that there needs to be at least some + // padding, so if the size is already a multiple, we need to increase it + // anyway. int base_info_block_size = sentry_size + file_name_size + env_data_size + arg_data_size; @@ -912,7 +912,7 @@ X86Process::argsInit(int pageSize, int info_block_padding = info_block_size - base_info_block_size; - //Each auxilliary vector is two 8 byte words + // Each auxiliary vector is two 8 byte words int aux_array_size = intSize * 2 * (auxv.size() + 1); int envp_array_size = intSize * (envp.size() + 1); @@ -920,15 +920,15 @@ X86Process::argsInit(int pageSize, int argc_size = intSize; - //Figure out the size of the contents of the actual initial frame + // Figure out the size of the contents of the actual initial frame int frame_size = aux_array_size + envp_array_size + argv_array_size + argc_size; - //There needs to be padding after the auxiliary vector data so that the - //very bottom of the stack is aligned properly. + // There needs to be padding after the auxiliary vector data so that the + // very bottom of the stack is aligned properly. int partial_size = frame_size + aux_data_size; int aligned_partial_size = roundUp(partial_size, align); int aux_padding = aligned_partial_size - partial_size; @@ -982,15 +982,14 @@ X86Process::argsInit(int pageSize, IntType argc = argv.size(); IntType guestArgc = X86ISA::htog(argc); - //Write out the sentry void * + // Write out the sentry void * IntType sentry_NULL = 0; - initVirtMem.writeBlob(sentry_base, - (uint8_t*)&sentry_NULL, sentry_size); + initVirtMem.writeBlob(sentry_base, (uint8_t*)&sentry_NULL, sentry_size); - //Write the file name + // Write the file name initVirtMem.writeString(file_name_base, filename.c_str()); - //Fix up the aux vectors which point to data + // Fix up the aux vectors which point to data assert(auxv[auxv.size() - 3].a_type == M5_AT_RANDOM); auxv[auxv.size() - 3].a_val = aux_data_base; assert(auxv[auxv.size() - 2].a_type == M5_AT_EXECFN); @@ -998,14 +997,15 @@ X86Process::argsInit(int pageSize, assert(auxv[auxv.size() - 1].a_type == M5_AT_PLATFORM); auxv[auxv.size() - 1].a_val = aux_data_base + numRandomBytes; - //Copy the aux stuff + + // Copy the aux stuff for (int x = 0; x < auxv.size(); x++) { initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize, (uint8_t*)&(auxv[x].a_type), intSize); initVirtMem.writeBlob(auxv_array_base + (x * 2 + 1) * intSize, (uint8_t*)&(auxv[x].a_val), intSize); } - //Write out the terminating zeroed auxilliary vector + // Write out the terminating zeroed auxiliary vector const uint64_t zero = 0; initVirtMem.writeBlob(auxv_array_base + auxv.size() * 2 * intSize, (uint8_t*)&zero, intSize); @@ -1020,14 +1020,14 @@ X86Process::argsInit(int pageSize, initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize); ThreadContext *tc = system->getThreadContext(contextIds[0]); - //Set the stack pointer register + // Set the stack pointer register tc->setIntReg(StackPointerReg, stack_min); // There doesn't need to be any segment base added in since we're dealing // with the flat segmentation model. tc->pcState(getStartPC()); - //Align the "stack_min" to a page boundary. + // Align the "stack_min" to a page boundary. memState->setStackMin(roundDown(stack_min, pageSize)); } diff --git a/src/base/loader/elf_object.hh b/src/base/loader/elf_object.hh index aa28cd62a..d74ee8914 100644 --- a/src/base/loader/elf_object.hh +++ b/src/base/loader/elf_object.hh @@ -51,12 +51,11 @@ class ElfObject : public ObjectFile { protected: - - //The global definition of a "Section" is closest to elf's segments. + // The global definition of a gem5 "Section" is closest to ELF's segments. typedef ObjectFile::Section Segment; - //These values are provided to a linux process by the kernel, so we - //need to keep them around. + // These values are provided to a linux process by the kernel, so we + // need to keep them around. Addr _programHeaderTable; uint16_t _programHeaderSize; uint16_t _programHeaderCount; diff --git a/src/base/loader/object_file.hh b/src/base/loader/object_file.hh index 98e1fc538..80ffa91f6 100644 --- a/src/base/loader/object_file.hh +++ b/src/base/loader/object_file.hh @@ -74,7 +74,7 @@ class ObjectFile uint8_t *fileData; size_t len; - Arch arch; + Arch arch; OpSys opSys; ObjectFile(const std::string &_filename, size_t _len, uint8_t *_data, @@ -114,9 +114,9 @@ class ObjectFile protected: struct Section { - Addr baseAddr; + Addr baseAddr; uint8_t *fileImage; - size_t size; + size_t size; }; Addr entry; diff --git a/src/sim/process.cc b/src/sim/process.cc index e516e2a05..71f398893 100644 --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -340,7 +340,7 @@ Process::fixupStackFault(Addr vaddr) fatal("Maximum stack size exceeded\n"); allocateMem(stack_min, TheISA::PageBytes); inform("Increasing stack size by one page."); - }; + } memState->setStackMin(stack_min); return true; } diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc index f61de229c..2459c801f 100644 --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -177,8 +177,7 @@ brkFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) tp.memsetBlob(gen.addr(), zero, size_needed); if (gen.addr() + PageBytes > next_page && next_page < new_brk && - p->pTable->translate(next_page)) - { + p->pTable->translate(next_page)) { size_needed = PageBytes - size_needed; tp.memsetBlob(next_page, zero, size_needed); } @@ -218,7 +217,7 @@ readFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) { int index = 0; int tgt_fd = p->getSyscallArg(tc, index); - Addr bufPtr = p->getSyscallArg(tc, index); + Addr buf_ptr = p->getSyscallArg(tc, index); int nbytes = p->getSyscallArg(tc, index); auto hbfdp = std::dynamic_pointer_cast((*p->fds)[tgt_fd]); @@ -226,7 +225,7 @@ readFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) return -EBADF; int sim_fd = hbfdp->getSimFD(); - BufferArg bufArg(bufPtr, nbytes); + BufferArg bufArg(buf_ptr, nbytes); int bytes_read = read(sim_fd, bufArg.bufferPtr(), nbytes); if (bytes_read > 0) @@ -240,7 +239,7 @@ writeFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) { int index = 0; int tgt_fd = p->getSyscallArg(tc, index); - Addr bufPtr = p->getSyscallArg(tc, index); + Addr buf_ptr = p->getSyscallArg(tc, index); int nbytes = p->getSyscallArg(tc, index); auto hbfdp = std::dynamic_pointer_cast((*p->fds)[tgt_fd]); @@ -248,7 +247,7 @@ writeFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) return -EBADF; int sim_fd = hbfdp->getSimFD(); - BufferArg bufArg(bufPtr, nbytes); + BufferArg bufArg(buf_ptr, nbytes); bufArg.copyIn(tc->getMemProxy()); int bytes_written = write(sim_fd, bufArg.bufferPtr(), nbytes); @@ -324,9 +323,9 @@ SyscallReturn gethostnameFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) { int index = 0; - Addr bufPtr = p->getSyscallArg(tc, index); + Addr buf_ptr = p->getSyscallArg(tc, index); int name_len = p->getSyscallArg(tc, index); - BufferArg name(bufPtr, name_len); + BufferArg name(buf_ptr, name_len); strncpy((char *)name.bufferPtr(), hostname, name_len); @@ -340,9 +339,9 @@ getcwdFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) { int result = 0; int index = 0; - Addr bufPtr = p->getSyscallArg(tc, index); + Addr buf_ptr = p->getSyscallArg(tc, index); unsigned long size = p->getSyscallArg(tc, index); - BufferArg buf(bufPtr, size); + BufferArg buf(buf_ptr, size); // Is current working directory defined? string cwd = p->getcwd(); @@ -386,10 +385,10 @@ readlinkFunc(SyscallDesc *desc, int num, Process *p, ThreadContext *tc, // Adjust path for current working directory path = p->fullPath(path); - Addr bufPtr = p->getSyscallArg(tc, index); + Addr buf_ptr = p->getSyscallArg(tc, index); size_t bufsiz = p->getSyscallArg(tc, index); - BufferArg buf(bufPtr, bufsiz); + BufferArg buf(buf_ptr, bufsiz); int result = -1; if (path != "/proc/self/exe") { @@ -539,7 +538,7 @@ truncate64Func(SyscallDesc *desc, int num, string path; if (!tc->getMemProxy().tryReadString(path, process->getSyscallArg(tc, index))) - return -EFAULT; + return -EFAULT; int64_t length = process->getSyscallArg(tc, index, 64); @@ -729,7 +728,6 @@ fcntl64Func(SyscallDesc *desc, int num, Process *p, ThreadContext *tc) // to the underlying OS warn("fcntl64(%d, %d) passed through to host\n", tgt_fd, cmd); return fcntl(sim_fd, cmd); - // return 0; } } @@ -823,8 +821,8 @@ getuidPseudoFunc(SyscallDesc *desc, int callnum, Process *process, // simulation to be deterministic. // EUID goes in r20. - tc->setIntReg(SyscallPseudoReturnReg, process->euid()); //EUID - return process->uid(); // UID + tc->setIntReg(SyscallPseudoReturnReg, process->euid()); // EUID + return process->uid(); // UID } @@ -833,7 +831,7 @@ getgidPseudoFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc) { // Get current group ID. EGID goes in r20. - tc->setIntReg(SyscallPseudoReturnReg, process->egid()); //EGID + tc->setIntReg(SyscallPseudoReturnReg, process->egid()); // EGID return process->gid(); } diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 8cca6ebcb..099ff58d9 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -285,8 +285,8 @@ SyscallReturn accessFunc(SyscallDesc *desc, int num, int index); /// Futex system call -/// Implemented by Daniel Sanchez -/// Used by printf's in multi-threaded apps +/// Implemented by Daniel Sanchez +/// Used by printf's in multi-threaded apps template SyscallReturn futexFunc(SyscallDesc *desc, int callnum, Process *process, @@ -477,7 +477,7 @@ convertStatBuf(target_stat &tgt, host_stat *host, bool fakeTTY = false) tgt->st_mtimeX = TheISA::htog(tgt->st_mtimeX); tgt->st_ctimeX = host->st_ctime; tgt->st_ctimeX = TheISA::htog(tgt->st_ctimeX); - // Force the block size to be 8k. This helps to ensure buffered io works + // Force the block size to be 8KB. This helps to ensure buffered io works // consistently across different hosts. tgt->st_blksize = 0x2000; tgt->st_blksize = TheISA::htog(tgt->st_blksize); @@ -508,11 +508,11 @@ convertStat64Buf(target_stat &tgt, host_stat64 *host, bool fakeTTY = false) #endif } -//Here are a couple convenience functions +// Here are a couple of convenience functions template static void copyOutStatBuf(SETranslatingPortProxy &mem, Addr addr, - hst_stat *host, bool fakeTTY = false) + hst_stat *host, bool fakeTTY = false) { typedef TypedBufferArg tgt_stat_buf; tgt_stat_buf tgt(addr); @@ -523,7 +523,7 @@ copyOutStatBuf(SETranslatingPortProxy &mem, Addr addr, template static void copyOutStat64Buf(SETranslatingPortProxy &mem, Addr addr, - hst_stat64 *host, bool fakeTTY = false) + hst_stat64 *host, bool fakeTTY = false) { typedef TypedBufferArg tgt_stat_buf; tgt_stat_buf tgt(addr); @@ -1604,24 +1604,24 @@ getrlimitFunc(SyscallDesc *desc, int callnum, Process *process, TypedBufferArg rlp(process->getSyscallArg(tc, index)); switch (resource) { - case OS::TGT_RLIMIT_STACK: - // max stack size in bytes: make up a number (8MB for now) - rlp->rlim_cur = rlp->rlim_max = 8 * 1024 * 1024; - rlp->rlim_cur = TheISA::htog(rlp->rlim_cur); - rlp->rlim_max = TheISA::htog(rlp->rlim_max); - break; + case OS::TGT_RLIMIT_STACK: + // max stack size in bytes: make up a number (8MB for now) + rlp->rlim_cur = rlp->rlim_max = 8 * 1024 * 1024; + rlp->rlim_cur = TheISA::htog(rlp->rlim_cur); + rlp->rlim_max = TheISA::htog(rlp->rlim_max); + break; - case OS::TGT_RLIMIT_DATA: - // max data segment size in bytes: make up a number - rlp->rlim_cur = rlp->rlim_max = 256 * 1024 * 1024; - rlp->rlim_cur = TheISA::htog(rlp->rlim_cur); - rlp->rlim_max = TheISA::htog(rlp->rlim_max); - break; + case OS::TGT_RLIMIT_DATA: + // max data segment size in bytes: make up a number + rlp->rlim_cur = rlp->rlim_max = 256 * 1024 * 1024; + rlp->rlim_cur = TheISA::htog(rlp->rlim_cur); + rlp->rlim_max = TheISA::htog(rlp->rlim_max); + break; - default: - warn("getrlimit: unimplemented resource %d", resource); - return -EINVAL; - break; + default: + warn("getrlimit: unimplemented resource %d", resource); + return -EINVAL; + break; } rlp.copyOut(tc->getMemProxy()); @@ -1703,8 +1703,7 @@ utimesFunc(SyscallDesc *desc, int callnum, Process *process, tp.copyIn(tc->getMemProxy()); struct timeval hostTimeval[2]; - for (int i = 0; i < 2; ++i) - { + for (int i = 0; i < 2; ++i) { hostTimeval[i].tv_sec = TheISA::gtoh((*tp)[i].tv_sec); hostTimeval[i].tv_usec = TheISA::gtoh((*tp)[i].tv_usec); }