forked from john-sharratt/wasix-libc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request WebAssembly#1 from waynr/cpython-compatibility-fixes
CPython compatibility updates
- Loading branch information
Showing
41 changed files
with
5,705 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.ccls* | ||
sysroot | ||
sysroot32 | ||
sysroot64 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <stdio.h> | ||
#include <sys/random.h> | ||
#include <unistd.h> | ||
|
||
int print_random_int_array() { | ||
ssize_t retval; | ||
int buf[100]; | ||
retval = getrandom(buf, sizeof(int) * 100, 0); | ||
if (retval == -1) { | ||
return retval; | ||
} | ||
for (int i = 0; i < 100; ++i) { | ||
printf("%d ", buf[i]); | ||
} | ||
printf("\n"); | ||
return 0; | ||
} | ||
|
||
int main() { | ||
int i = 0, retval = 0; | ||
while (i < 5) { | ||
printf("trial %d:\n ", i); | ||
retval = print_random_int_array(); | ||
printf("\n"); | ||
if (retval == -1) { | ||
printf("failed!\n"); | ||
return retval; | ||
} | ||
i++; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include <stdarg.h> | ||
#include <stdio.h> | ||
#include <sys/random.h> | ||
#include <unistd.h> | ||
#include <string.h> | ||
|
||
#include <dirent.h> | ||
|
||
void print(int lvl, const char *format, ...) { | ||
for (int i = 0; i < lvl; i++) { | ||
printf(" "); | ||
} | ||
va_list args; | ||
va_start(args, format); | ||
vprintf(format, args); | ||
va_end(args); | ||
fflush(stdout); | ||
} | ||
|
||
int handle_dir(int lvl, DIR *d) { | ||
DIR *new; | ||
int ret = 0; | ||
for (;;) { | ||
struct dirent *ent = readdir(d); | ||
if (ent == NULL) { | ||
return 0; | ||
} | ||
|
||
if (strcmp(ent->d_name, "..") == 0 || strcmp(ent->d_name, ".") == 0) { | ||
continue; | ||
} | ||
|
||
switch (ent->d_type) { | ||
case DT_DIR: | ||
print(lvl, "%s:\n", ent->d_name); | ||
new = opendir(ent->d_name); | ||
ret = handle_dir(lvl + 1, new); | ||
if (ret < 0) { | ||
return ret; | ||
} | ||
continue; | ||
default: | ||
print(lvl, "%s\n", ent->d_name); | ||
} | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
if (argc < 1) { | ||
fprintf(stderr, "not enough args!"); | ||
} | ||
for (int i = 1; i < argc; i++) { | ||
print(0, "%s\n", argv[i]); | ||
|
||
DIR *d = opendir(argv[i]); | ||
int ret = handle_dir(1, d); | ||
if (ret < 0) { | ||
return ret; | ||
} | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.