aboutsummaryrefslogtreecommitdiff
path: root/src/benchmarks/cfrac/picmp.c
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-08-24 17:57:51 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-08-24 17:57:51 +0200
commit77ac9ce0a5c55d4f79f8fb8f7daa59ddb53cb507 (patch)
tree93d4e30a207265af03394d347bfff76ba677f3ce /src/benchmarks/cfrac/picmp.c
parent971adefadb94e8780b1a73f08ed11d76c2ead8a2 (diff)
downloadallocbench-77ac9ce0a5c55d4f79f8fb8f7daa59ddb53cb507.tar.gz
allocbench-77ac9ce0a5c55d4f79f8fb8f7daa59ddb53cb507.zip
add cfrac benchmark
Diffstat (limited to 'src/benchmarks/cfrac/picmp.c')
-rw-r--r--src/benchmarks/cfrac/picmp.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/benchmarks/cfrac/picmp.c b/src/benchmarks/cfrac/picmp.c
new file mode 100644
index 0000000..b942268
--- /dev/null
+++ b/src/benchmarks/cfrac/picmp.c
@@ -0,0 +1,41 @@
+#include "pdefs.h"
+#include "precision.h"
+
+static char cmpError[] = "Second arg not single digit";
+
+/*
+ * Single-digit compare
+ */
+int picmp(u, v)
+ register precision u;
+ register int v;
+{
+ register int i;
+
+ (void) pparm(u);
+
+ if (u->sign) {
+ i = -1;
+ if (v < 0) {
+ if (-v >= BASE) {
+ errorp(PDOMAIN, "picmp", cmpError);
+ }
+ if (u->size == 1) {
+ i = - (int) *(u->value) - v;
+ }
+ }
+ } else {
+ i = 1;
+ if (v >= 0) {
+ if (v >= BASE) {
+ errorp(PDOMAIN, "picmp", cmpError);
+ }
+ if (u->size == 1) {
+ i = (int) *(u->value) - v;
+ }
+ }
+ }
+
+ pdestroy(u);
+ return i;
+}