summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2020-04-05 02:38:23 +0200
committerjonsykkel <jonrevold@gmail.com>2020-04-05 02:38:23 +0200
commit61d1ffd0230358d3abc2bd2bd58a36d298967e99 (patch)
treecae390c7adaf99a9cd7905abaf4be05e5d4da4b9
parentde4bb42d54d733c9740e05a3eea48bfd0a31b06a (diff)
downloadct_sequence-61d1ffd0230358d3abc2bd2bd58a36d298967e99.tar.gz
vorkk
-rw-r--r--makefile2
-rw-r--r--src/def.h5
-rw-r--r--src/main.c38
3 files changed, 33 insertions, 12 deletions
diff --git a/makefile b/makefile
index b2f6bcd..1b69bd8 100644
--- a/makefile
+++ b/makefile
@@ -1,6 +1,6 @@
#version 5
-out_name := numper3
+out_name := numper
build := release
tmp_dir := tmp
bin_dir := bin
diff --git a/src/def.h b/src/def.h
index bd43d01..82f3fd7 100644
--- a/src/def.h
+++ b/src/def.h
@@ -5,7 +5,10 @@
extern uint64_t t;
-void fuk (char const *str);
+void fuk (char const *fmt,...);
+
+void n1_init (uint64_t n);
+void n1_loop (uint64_t x0,uint64_t x1);
void n3_init (uint64_t n);
void n3_loop (uint64_t x0,uint64_t x1);
diff --git a/src/main.c b/src/main.c
index 51674c2..dc0ffa9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -13,9 +13,13 @@ static void (*init)(uint64_t n);
static void (*nump)(void);
static void (*loop)(uint64_t,uint64_t);
-void fuk(char const *str){
- printf("error!( %s\n",str);
+void fuk(char const *fmt,...){
+ va_list args;
+ va_start(args,fmt);
+ vfprintf(stdout,fmt,args);
+ putc('\n',stdout);
fflush(stdout);
+ va_end(args),
exit(1);
}
@@ -34,7 +38,6 @@ static void perse(int p){
static void numper(void){
loop(1,n);
- perse(100);
}
static void numper_p(void){
@@ -56,20 +59,35 @@ static void numper_p(void){
}
int main(int argc,char **argv){
+ int err;
+
if(argc < 2){
- printf("usake: numper <n>\n"); fflush(stdout);
+ printf("usake: numper [-p] <n>\n");
+ printf(" -p display progress percentage\n");
+ fflush(stdout);
return 1;
}
- init = n3_init;
- loop = n3_loop;
- nump = numper_p;
+ init = n1_init;
+ loop = n1_loop;
+ nump = numper;
+ err = 0;
+
+ for(int x = 1;x < argc-1;x++){
+ if(strcmp(argv[x],"-p") == 0){
+ nump = numper_p;
+ continue;
+ }
+
+ printf("unrecognized option: %s\n",argv[x]);
+ err++;
+ }
- n = strtoull(argv[1],0,10);
- n = 100000000;
+ if(err) exit(1);
+
+ n = strtoull(argv[argc-1],0,10);
printf("n = %llu\n",n); fflush(stdout);
init(n);
-
ftimer_init(&ft);
nump();
printf("t = %llu\n",t); fflush(stdout);