deserialize() fixed and tested on windows
This commit is contained in:
@@ -5,15 +5,13 @@
|
||||
#include "errors.h"
|
||||
#include "mystr.h"
|
||||
|
||||
// sleep function based on std nanosleep()
|
||||
void fsleep(float sec);
|
||||
|
||||
// executes codeblock and prints execution time
|
||||
#define optime(opname,repeats,codeblock) ({\
|
||||
clock_t start=clock();\
|
||||
struct timespec start, stop;\
|
||||
clock_gettime(CLOCK_REALTIME, &start);\
|
||||
for(uint64 ___OPREP=0;___OPREP<repeats;___OPREP++)\
|
||||
(codeblock);\
|
||||
clock_t stop=clock();\
|
||||
double t=(double)(stop-start)/CLOCKS_PER_SEC/repeats;\
|
||||
clock_gettime(CLOCK_REALTIME, &stop);\
|
||||
double t=(double)(stop.tv_sec-start.tv_sec+(double)(stop.tv_nsec-start.tv_nsec)/1000000000)/repeats;\
|
||||
printf("\e[93moperation \e[94m%s\e[93m lasted \e[94m%lf \e[93mseconds\n",opname,t);\
|
||||
})
|
||||
|
||||
@@ -16,12 +16,12 @@ const char* errname(err_t err){
|
||||
|
||||
void _throwint(int err, const char* srcfile, int line, const char* funcname){
|
||||
if(err){ // SUCCESS=0 is not an error
|
||||
printf("\e[91m[%s:%d/%s] throwed error: %s\e[0m\n",srcfile,line,funcname,errname(err));
|
||||
printf("\e[91m[%s:%d %s] throwed error: %s\e[0m\n",srcfile,line,funcname,errname(err));
|
||||
exit(err);
|
||||
}
|
||||
else printf("\e[93m[%s:%d/%s] throwed SUCCESS as an error",srcfile,line,funcname);
|
||||
else printf("\e[93m[%s:%d %s] throwed SUCCESS as an error",srcfile,line,funcname);
|
||||
}
|
||||
void _throwstr(const char* errmesg, const char* srcfile, int line, const char* funcname){
|
||||
printf("\e[91m[%s:%d/%s] throwed error: %s\e[0m\n",srcfile,line,funcname,errmesg);
|
||||
printf("\e[91m[%s:%d %s] throwed error: %s\e[0m\n",srcfile,line,funcname,errmesg);
|
||||
exit(255);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#include "base.h"
|
||||
|
||||
void fsleep(float sec){
|
||||
struct timespec t;
|
||||
t.tv_sec=sec+0.0001f;
|
||||
t.tv_nsec=(sec-t.tv_sec)*1000000000;
|
||||
nanosleep(&t, NULL);
|
||||
}
|
||||
@@ -4,8 +4,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <locale.h>
|
||||
#include <uchar.h>
|
||||
#include <wchar.h>
|
||||
#include <time.h>
|
||||
|
||||
#define CHOOSE(B, Y, N) __builtin_choose_expr(B, Y, N)
|
||||
|
||||
@@ -119,11 +119,12 @@ void Unitype_free(Unitype u){
|
||||
void printuni(Unitype v){
|
||||
switch (v.type) {
|
||||
case Null: printf("{Null}");break;
|
||||
case Double: printf("{%s:%lf}",typename(v.type),v.Double);break;
|
||||
case Char: printf("{%s:%c}",typename(v.type),v.Char);break;
|
||||
case Double: printf("{%s : %lf}",typename(v.type),v.Double);break;
|
||||
case Char: printf("{%s : '%c'}",typename(v.type),v.Char);break;
|
||||
case Bool:
|
||||
case UInt64: printf("{%s:%lu}",typename(v.type),v.UInt64);break;
|
||||
case Int64: printf("{%s:%ld}",typename(v.type),v.Int64);break;
|
||||
default: printf("{%s:%p}",typename(v.type),v.VoidPtr);break;
|
||||
case UInt64: printf("{%s : %lu}",typename(v.type),v.UInt64);break;
|
||||
case Int64: printf("{%s : %ld}",typename(v.type),v.Int64);break;
|
||||
case CharPtr: printf("{%s : \"%s\"}",typename(v.type),(char*)v.VoidPtr);break;
|
||||
default: printf("{%s : %p}",typename(v.type),v.VoidPtr);break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user