summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2021-09-09 11:20:39 +0200
committerjonsykkel <jonrevold@gmail.com>2021-09-09 11:21:29 +0200
commit6e5d88cb8bdc85183c206a8c128b4a5c8577904c (patch)
tree16285046610b0940431ada409ad7b3dab1c87686
parentdfb1fe4dac4b146dc24f197984febd8ef390111e (diff)
downloadokeffa-6e5d88cb8bdc85183c206a8c128b4a5c8577904c.tar.gz
vla
-rw-r--r--calc/main.c1
-rw-r--r--inc/okeffa/fz.h6
-rw-r--r--makefile2
-rw-r--r--src/fz_div.c13
-rw-r--r--src/fz_mul.c8
-rw-r--r--src/fz_pred.c8
6 files changed, 10 insertions, 28 deletions
diff --git a/calc/main.c b/calc/main.c
index 0a27f58..6f5533e 100644
--- a/calc/main.c
+++ b/calc/main.c
@@ -1,6 +1,5 @@
#include "os.h"
#include <okeffa/word.h>
-#include <okeffa/fz.h>
#include <okeffa/fz_lim.h>
#include <okeffa/fz_basic.h>
#include <okeffa/fz_arith.h>
diff --git a/inc/okeffa/fz.h b/inc/okeffa/fz.h
deleted file mode 100644
index 65788f7..0000000
--- a/inc/okeffa/fz.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef OKEFFA_FZ_H
-#define OKEFFA_FZ_H
-
-#define FZ_MAXLEN 64
-
-#endif
diff --git a/makefile b/makefile
index 88013af..27cf191 100644
--- a/makefile
+++ b/makefile
@@ -8,7 +8,7 @@ bin_dir := bin
src_dir := src
CFLAGS := -pthread -std=c11 -fdata-sections -ffunction-sections -I$(inc_dir)
-CFLAGS += -pedantic -Wall -Wextra -Wcast-qual -Wstrict-aliasing -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wvla -Wno-parentheses
+CFLAGS += -pedantic -Wall -Wextra -Wcast-qual -Wstrict-aliasing -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-parentheses
LDFLAGS :=
LDLIBS := -lm
ARFLAGS := -rcs
diff --git a/src/fz_div.c b/src/fz_div.c
index 24390d4..861040c 100644
--- a/src/fz_div.c
+++ b/src/fz_div.c
@@ -2,17 +2,14 @@
#include <okeffa/fz_basic.h>
#include <okeffa/fz_shift.h>
#include <okeffa/fz_bitop.h>
-#include <okeffa/fz.h>
#include <okeffa/w_op.h>
-#include <assert.h>
void fz_idiv(word_t *a,word_t *b,word_t *q_out,word_t *r_out,size_t len){
- assert(len <= FZ_MAXLEN);
- word_t qr[FZ_MAXLEN*2];
size_t qr_len = len*2;
+ size_t bitness = fz_bitness(len);
+ word_t qr[qr_len];
word_t *q = qr;
word_t *r = qr+len;
- size_t bitness = fz_bitness(len);
fz_copy(a,q,len);
fz_clear(r,len);
@@ -28,14 +25,12 @@ void fz_idiv(word_t *a,word_t *b,word_t *q_out,word_t *r_out,size_t len){
}
void fz_div(word_t *a,word_t *b,word_t *q,size_t len){
- assert(len <= FZ_MAXLEN);
- word_t r[FZ_MAXLEN];
+ word_t r[len];
fz_idiv(a,b,q,r,len);
}
void fz_mod(word_t *a,word_t *b,word_t *r,size_t len){
- assert(len <= FZ_MAXLEN);
- word_t q[FZ_MAXLEN];
+ word_t q[len];
fz_idiv(a,b,q,r,len);
}
diff --git a/src/fz_mul.c b/src/fz_mul.c
index 70d4c9c..deaa645 100644
--- a/src/fz_mul.c
+++ b/src/fz_mul.c
@@ -3,16 +3,14 @@
#include <okeffa/fz_shift.h>
#include <okeffa/fz_bitop.h>
#include <okeffa/fz_pred.h>
-#include <okeffa/fz.h>
#include <okeffa/w_op.h>
void fz_mul_egypt(word_t *a,word_t *b,word_t *o_lo,word_t *o_hi,size_t len){
- assert(len <= FZ_MAXLEN);
- word_t xy[FZ_MAXLEN*2];
- word_t xs[FZ_MAXLEN*2];
- word_t ys[FZ_MAXLEN];
size_t len2 = len*2;
size_t bitness = fz_bitness(len);
+ word_t xy[len2];
+ word_t xs[len2];
+ word_t ys[len];
fz_clear(xy,len2);
fz_copy(a,xs,len);
diff --git a/src/fz_pred.c b/src/fz_pred.c
index d6780a7..f3e1ee7 100644
--- a/src/fz_pred.c
+++ b/src/fz_pred.c
@@ -1,7 +1,5 @@
#include <okeffa/fz_pred.h>
#include <okeffa/fz_arith.h>
-#include <okeffa/fz.h>
-#include <assert.h>
extern wbool_t fz_odd (word_t *a);
@@ -26,13 +24,11 @@ wbool_t fz_eq(word_t *a,word_t *b,size_t len){
}
wbool_t fz_lt(word_t *a,word_t *b,size_t len){
- assert(len <= FZ_MAXLEN);
- word_t scratch[FZ_MAXLEN];
+ word_t scratch[len];
return fz_sub(a,b,scratch,len);
}
wbool_t fz_gt(word_t *a,word_t *b,size_t len){
- assert(len <= FZ_MAXLEN);
- word_t scratch[FZ_MAXLEN];
+ word_t scratch[len];
return fz_sub(b,a,scratch,len);
}