summaryrefslogtreecommitdiff
path: root/src/stdlib/ldiv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib/ldiv.c')
-rw-r--r--src/stdlib/ldiv.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/stdlib/ldiv.c b/src/stdlib/ldiv.c
index dc236d10..0b7f0167 100644
--- a/src/stdlib/ldiv.c
+++ b/src/stdlib/ldiv.c
@@ -1,3 +1,4 @@
+#include <limits.h>
#include <stdlib.h>
#include "_stdlib.h"
@@ -8,12 +9,17 @@ ldiv_t ldiv(long int numer, long int denom)
ldiv_t d;
SIGNAL_SAFE(0);
+ if ((denom == 0) || (numer == LONG_MIN && denom == -1)) {
+ UNDEFINED("In call to ldiv(): The result of %ld / %ld is not representable as a long int", numer, denom);
+ }
d.quot = numer / denom;
d.rem = numer % denom;
return d;
}
+CHECK_2(ldiv_t, {0}, ldiv, long int, long int)
+
/***
computes both the quotient and remainder of ARGUMENT(numer)
divided by ARGUMENT(denom).