1#include <math.h>
2#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
3long double logbl(long double x) {
4    return logb(x);
5}
6#else
7long double logbl(long double x) {
8    if (!isfinite(x))
9        return x * x;
10    if (x == 0)
11        return -1 / (x * x);
12    return ilogbl(x);
13}
14#endif
15