mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 00:08:30 +00:00
Add fixes performance and static web server
This commit is contained in:
parent
b6793d42d5
commit
c45e46f871
108 changed files with 2927 additions and 819 deletions
|
@ -17,10 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ int clock_gettime(int clockid, struct timespec *out_ts) {
|
|||
} else {
|
||||
struct NtFileTime ft;
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
*out_ts = filetimetotimespec(ft);
|
||||
*out_ts = FileTimeToTimeSpec(ft);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,9 +49,9 @@ textwindows int fstat$nt(int64_t handle, struct stat *st) {
|
|||
: (((filetype == kNtFileTypeDisk) ? S_IFBLK : 0) |
|
||||
((filetype == kNtFileTypeChar) ? S_IFCHR : 0) |
|
||||
((filetype == kNtFileTypePipe) ? S_IFIFO : 0))));
|
||||
st->st_atim = filetimetotimespec(wst.ftLastAccessFileTime);
|
||||
st->st_mtim = filetimetotimespec(wst.ftLastWriteFileTime);
|
||||
st->st_ctim = filetimetotimespec(wst.ftCreationFileTime);
|
||||
st->st_atim = FileTimeToTimeSpec(wst.ftLastAccessFileTime);
|
||||
st->st_mtim = FileTimeToTimeSpec(wst.ftLastWriteFileTime);
|
||||
st->st_ctim = FileTimeToTimeSpec(wst.ftCreationFileTime);
|
||||
st->st_size = (uint64_t)wst.nFileSizeHigh << 32 | wst.nFileSizeLow;
|
||||
st->st_blksize = PAGESIZE;
|
||||
st->st_dev = wst.dwVolumeSerialNumber;
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
static int g_pid;
|
||||
|
||||
static void __updatepid(void) {
|
||||
atfork(__updatepid, NULL);
|
||||
g_pid = __getpid();
|
||||
}
|
||||
|
||||
|
@ -47,8 +46,9 @@ int __getpid(void) {
|
|||
int getpid(void) {
|
||||
static bool once;
|
||||
if (!once) {
|
||||
once = true;
|
||||
__updatepid();
|
||||
atfork(__updatepid, NULL);
|
||||
once = true;
|
||||
}
|
||||
return g_pid;
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ textwindows int getrusage$nt(int who, struct rusage *usage) {
|
|||
if ((who == RUSAGE_SELF ? GetProcessTimes : GetThreadTimes)(
|
||||
(who == RUSAGE_SELF ? GetCurrentProcess : GetCurrentThread)(),
|
||||
&CreationFileTime, &ExitFileTime, &KernelFileTime, &UserFileTime)) {
|
||||
filetimetotimeval(&usage->ru_utime, UserFileTime);
|
||||
filetimetotimeval(&usage->ru_stime, KernelFileTime);
|
||||
FileTimeToTimeVal(&usage->ru_utime, UserFileTime);
|
||||
FileTimeToTimeVal(&usage->ru_stime, KernelFileTime);
|
||||
return 0;
|
||||
} else {
|
||||
return winerr();
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
int gettimeofday$nt(struct timeval *tv, struct timezone *tz) {
|
||||
struct NtFileTime ft;
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
filetimetotimeval(tv, ft);
|
||||
FileTimeToTimeVal(tv, ft);
|
||||
if (tz) memset(tz, 0, sizeof(*tz));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
* @param mode is an octal user/group/other permission signifier, that's
|
||||
* ignored if O_CREAT or O_TMPFILE weren't passed
|
||||
* @return number needing close(), or -1 w/ errno
|
||||
* @asyncsignalsafe
|
||||
* @note don't call open() from signal handlers
|
||||
*/
|
||||
nodiscard int open(const char *file, int flags, ...) {
|
||||
va_list va;
|
||||
|
|
|
@ -155,7 +155,7 @@ int(sigaction)(int sig, const struct sigaction *act, struct sigaction *oldact) {
|
|||
ap->sa_restorer = &__restore_rt;
|
||||
}
|
||||
}
|
||||
if (rva >= 0) {
|
||||
if (rva >= kSigactionMinRva) {
|
||||
ap->sa_sigaction = (sigaction_f)__sigenter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ textwindows int utimensat$nt(int dirfd, const char *path,
|
|||
} else if (ts[i].tv_nsec == UTIME_OMIT) {
|
||||
ftp[i] = NULL;
|
||||
} else {
|
||||
ft[i] = timespectofiletime(ts[i]);
|
||||
ft[i] = TimeSpecToFileTime(ts[i]);
|
||||
ftp[i] = &ft[i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ textwindows int wait4$nt(int pid, int *opt_out_wstatus, int options,
|
|||
memset(opt_out_rusage, 0, sizeof(*opt_out_rusage));
|
||||
GetProcessTimes(GetCurrentProcess(), &createfiletime, &exitfiletime,
|
||||
&kernelfiletime, &userfiletime);
|
||||
filetimetotimeval(&opt_out_rusage->ru_utime, userfiletime);
|
||||
filetimetotimeval(&opt_out_rusage->ru_stime, kernelfiletime);
|
||||
FileTimeToTimeVal(&opt_out_rusage->ru_utime, userfiletime);
|
||||
FileTimeToTimeVal(&opt_out_rusage->ru_stime, kernelfiletime);
|
||||
}
|
||||
return pid;
|
||||
} else if (options & WNOHANG) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue