rewrite comments into one, unified style
This commit is contained in:
1 parent
6260de0085
commit
467a58c9c6
163 files changed
+3560
-2556
No files matched your search
@@ -1,4 +1,5 @@
|
||||
// posix_proc.c - posix_spawn, waitpid, getpid
|
||||
// POSIX compatibility support for posix proc.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <ntlite/syscall.h>
|
||||
@@ -8,18 +9,20 @@
|
||||
|
||||
static SYS_PEB* gProcessPeb = NULL;
|
||||
|
||||
// Implements the peb operation.
|
||||
static SYS_PEB* PosixPeb(void) {
|
||||
if (!gProcessPeb) gProcessPeb = SysGetPeb();
|
||||
return gProcessPeb;
|
||||
}
|
||||
|
||||
// Implements the posix get command line operation.
|
||||
__declspec(dllexport) const char* posix_get_command_line(void) {
|
||||
SYS_PEB* peb = PosixPeb();
|
||||
if (!peb || peb->Magic != SYS_PEB_MAGIC || !peb->CommandLine.Data) return "";
|
||||
return peb->CommandLine.Data;
|
||||
}
|
||||
|
||||
// pid -> proc handle table (user-mode side, for waitpid)
|
||||
// pid -> proc handle table (user-mode side, for waitpid).
|
||||
#define PROC_TABLE_SIZE 32
|
||||
typedef struct {
|
||||
pid_t pid;
|
||||
@@ -29,6 +32,7 @@ typedef struct {
|
||||
|
||||
static ProcEntry gProcTable[PROC_TABLE_SIZE];
|
||||
|
||||
// Implements the proc Table Insert operation.
|
||||
static void ProcTableInsert(pid_t pid, uint32_t handle) {
|
||||
for (int i = 0; i < PROC_TABLE_SIZE; i++) {
|
||||
if (!gProcTable[i].used) {
|
||||
@@ -39,6 +43,7 @@ static void ProcTableInsert(pid_t pid, uint32_t handle) {
|
||||
SysCloseHandle(handle);
|
||||
}
|
||||
|
||||
// Implements the proc Table Find operation.
|
||||
static uint32_t ProcTableFind(pid_t pid) {
|
||||
for (int i = 0; i < PROC_TABLE_SIZE; i++)
|
||||
if (gProcTable[i].used && gProcTable[i].pid == pid)
|
||||
@@ -46,6 +51,7 @@ static uint32_t ProcTableFind(pid_t pid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Implements the proc Table Remove operation.
|
||||
static void ProcTableRemove(pid_t pid) {
|
||||
for (int i = 0; i < PROC_TABLE_SIZE; i++)
|
||||
if (gProcTable[i].used && gProcTable[i].pid == pid)
|
||||
@@ -72,9 +78,7 @@ static void BuildCmdline(char* const argv[], char* out, size_t outSize) {
|
||||
if (pos < outSize) out[pos] = '\0';
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// POSIX API
|
||||
// ---------------------------------------------------------------------------
|
||||
// POSIX API.
|
||||
|
||||
__declspec(dllexport) pid_t getpid(void) {
|
||||
return (pid_t)SysGetCurrentPid();
|
||||
@@ -133,6 +137,7 @@ __declspec(dllexport) pid_t waitpid(pid_t pid, int* status, int options) {
|
||||
return pid;
|
||||
}
|
||||
|
||||
// Implements the exit operation.
|
||||
__declspec(dllexport) void exit(int status) {
|
||||
SysExitProcess(status);
|
||||
}
|
||||
Reference in new issue
Block a user