add 'make swap' cmd

main
Dominik Madarász 2023-11-30 16:07:20 +01:00
parent ab06ce0192
commit 32d4aa8d02
5 changed files with 20 additions and 6 deletions

View File

@ -350134,6 +350134,10 @@ void (set_free)(set* m) {
#line 1 "v4k_string.c"
#include <stdarg.h>
#ifndef STACK_ALLOC_SIZE
#define STACK_ALLOC_SIZE (512*1024)
#endif
char* tempvl(const char *fmt, va_list vl) {
va_list copy;
va_copy(copy, vl);
@ -350147,7 +350151,7 @@ char* tempvl(const char *fmt, va_list vl) {
static __thread char buf[STACK_ALLOC];
#else
int heap = 1;
static __thread int STACK_ALLOC = 512*1024;
static __thread int STACK_ALLOC = STACK_ALLOC_SIZE;
static __thread char *buf = 0; if(!buf) buf = REALLOC(0, STACK_ALLOC); // @leak
#endif
static __thread int cur = 0; //printf("string stack %d/%d\n", cur, STACK_ALLOC);

View File

@ -1,5 +1,9 @@
#include <stdarg.h>
#ifndef STACK_ALLOC_SIZE
#define STACK_ALLOC_SIZE (512*1024)
#endif
char* tempvl(const char *fmt, va_list vl) {
va_list copy;
va_copy(copy, vl);
@ -13,7 +17,7 @@ char* tempvl(const char *fmt, va_list vl) {
static __thread char buf[STACK_ALLOC];
#else
int heap = 1;
static __thread int STACK_ALLOC = 512*1024;
static __thread int STACK_ALLOC = STACK_ALLOC_SIZE;
static __thread char *buf = 0; if(!buf) buf = REALLOC(0, STACK_ALLOC); // @leak
#endif
static __thread int cur = 0; //printf("string stack %d/%d\n", cur, STACK_ALLOC);

View File

@ -503,6 +503,10 @@ void (set_free)(set* m) {
#line 1 "v4k_string.c"
#include <stdarg.h>
#ifndef STACK_ALLOC_SIZE
#define STACK_ALLOC_SIZE (512*1024)
#endif
char* tempvl(const char *fmt, va_list vl) {
va_list copy;
va_copy(copy, vl);
@ -516,7 +520,7 @@ char* tempvl(const char *fmt, va_list vl) {
static __thread char buf[STACK_ALLOC];
#else
int heap = 1;
static __thread int STACK_ALLOC = 512*1024;
static __thread int STACK_ALLOC = STACK_ALLOC_SIZE;
static __thread char *buf = 0; if(!buf) buf = REALLOC(0, STACK_ALLOC); // @leak
#endif
static __thread int cur = 0; //printf("string stack %d/%d\n", cur, STACK_ALLOC);

View File

@ -1,3 +1,4 @@
#define STACK_ALLOC_SIZE (128*1024*1024)
#include "v4k.c"
int main(int argc, char **argv) {
@ -18,16 +19,17 @@ int main(int argc, char **argv) {
char mode = strstri(buf, "//@#line 1 \"") == NULL;
char **lines = strsplit(buf, "\n");
printf("Switching #line %s\n", mode?"ON":"OFF");
for (int i = 0; i < array_count(lines); i++) {
char *line = STRDUP(lines[i]);
char *line = STRDUP(lines[i]); //@leak
if (!mode) {
strrepl(&line, "//@#line 1 \"", "#line 1 \"");
} else {
strrepl(&line, "#line 1 \"", "//@#line 1 \"");
}
// printf("%s\n", line);
file_append(argv[1], line, strlen(line));
file_append(argv[1], va("%s\n", line), strlen(line)+1);
}
return 0;

Binary file not shown.