mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
8a91518633
Cosmopolitan's QuickJS is now equally conformant and performant, with the exception of Atomics, which have been disabled since Cosmopolitan currently doesn't support pthreads. QuickJS memory usage -- BigNum 2021-03-27 version, 64-bit, malloc limit: -1 NAME COUNT SIZE memory allocated 937 131764 (140.6 per block) memory used 938 116103 (8 overhead, 16.7 average slack) atoms 513 21408 (41.7 per atom) objects 170 12279 (72.2 per object) properties 864 15531 (5.1 per object) shapes 58 12995 (224.1 per shape) bytecode functions 13 1512 bytecode 13 867 (66.7 per function) C functions 99 arrays 1 fast arrays 1 elements 1 16 (1.0 per fast array) Result: 35/74740 errors, 1279 excluded, 485 skipped, 19 new, 2 fixed real 2m40.828s user 2m29.764s sys 0m10.939s
52 lines
2.3 KiB
C
52 lines
2.3 KiB
C
#if 0
|
|
/*─────────────────────────────────────────────────────────────────╗
|
|
│ To the extent possible under law, Justine Tunney has waived │
|
|
│ all copyright and related or neighboring rights to this file, │
|
|
│ as it is written in the following disclaimers: │
|
|
│ • http://unlicense.org/ │
|
|
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
|
╚─────────────────────────────────────────────────────────────────*/
|
|
#endif
|
|
#include "libc/calls/calls.h"
|
|
#include "libc/calls/struct/stat.h"
|
|
#include "libc/log/log.h"
|
|
#include "libc/runtime/runtime.h"
|
|
#include "libc/sysv/consts/exit.h"
|
|
#include "third_party/musl/ftw.h"
|
|
|
|
/**
|
|
* @fileoverview Directory walker example.
|
|
* Copied from IEEE Std 1003.1-2017
|
|
*/
|
|
|
|
static int display_info(const char *fpath, const struct stat *sb, int tflag,
|
|
struct FTW *ftwbuf) {
|
|
printf("%-3s %2d %7jd %-40s %d %s\n",
|
|
(tflag == FTW_D) ? "d"
|
|
: (tflag == FTW_DNR) ? "dnr"
|
|
: (tflag == FTW_DP) ? "dp"
|
|
: (tflag == FTW_F) ? (S_ISBLK(sb->st_mode) ? "f b"
|
|
: S_ISCHR(sb->st_mode) ? "f c"
|
|
: S_ISFIFO(sb->st_mode) ? "f p"
|
|
: S_ISREG(sb->st_mode) ? "f r"
|
|
: S_ISSOCK(sb->st_mode) ? "f s"
|
|
: "f ?")
|
|
: (tflag == FTW_NS) ? "ns"
|
|
: (tflag == FTW_SL) ? "sl"
|
|
: (tflag == FTW_SLN) ? "sln"
|
|
: "?",
|
|
ftwbuf->level, (intmax_t)sb->st_size, fpath, ftwbuf->base,
|
|
fpath + ftwbuf->base);
|
|
return 0; /* To tell nftw() to continue */
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
int flags = 0;
|
|
if (argc > 2 && strchr(argv[2], 'd') != NULL) flags |= FTW_DEPTH;
|
|
if (argc > 2 && strchr(argv[2], 'p') != NULL) flags |= FTW_PHYS;
|
|
if (nftw((argc < 2) ? "." : argv[1], display_info, 20, flags) == -1) {
|
|
perror("nftw");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
exit(EXIT_SUCCESS);
|
|
}
|