/*
- * Handle gcc __attribute__ if available.
+ * #define away gcc __attribute__ if unavailable.
*/
#ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later. */
+ /* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (defined(__STRICT_ANSI__))
# define __attribute__(Spec) /* empty */
# endif
-/* The __-protected variants of `format' and `printf' attributes
- are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
+ /*
+ * The __-protected variants of `format' and `printf' attributes are
+ * accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+ */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-# define __format__ format
-# define __printf__ printf
+# define __format__ format
+# define __printf__ printf
+# define __noreturn__ noreturn
# endif
#endif
*/
/* coverity[+kill] */
static void
-default_callback(const char *, int, isc_assertiontype_t, const char *);
+default_callback(const char *, int, isc_assertiontype_t, const char *)
+ __attribute__ ((__noreturn__));
/*%
* Public.
#include <isc/lang.h>
#include <isc/platform.h>
+/*
+ * #define away gcc __attribute__ if unavailable.
+ */
+#ifndef __attribute__
+ /* This feature is available in gcc versions 2.5 and later. */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (defined(__STRICT_ANSI__))
+# define __attribute__(Spec) /* empty */
+# endif
+ /*
+ * The __-protected variants of `format' and `printf' attributes are
+ * accepted by gcc versions 2.6.4 (effectively 2.7) and later.
+ */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+# define __format__ format
+# define __printf__ printf
+# define __noreturn__ noreturn
+# endif
+#endif
+
ISC_LANG_BEGINDECLS
/*% isc assertion type */
} isc_assertiontype_t;
typedef void (*isc_assertioncallback_t)(const char *, int, isc_assertiontype_t,
- const char *);
+ const char *)
+ __attribute__ ((__noreturn__));
/* coverity[+kill] */
LIBISC_EXTERNAL_DATA extern isc_assertioncallback_t isc_assertion_failed;
)
{
char * cp;
- u_time ttmp; /* unsigned storage for seconds */
- int i;
+ u_int prec_u;
+ u_time secs_u;
+ u_int u;
long fraclimit;
int notneg; /* flag for non-negative value */
const char * fmt;
DEBUG_REQUIRE(prec != 0);
LIB_GETBUF(cp);
- ttmp = (u_time)secs;
+ secs_u = (u_time)secs;
fmt = "-%" UTIME_FORMAT ".%0*ld";
/* check if we need signed or unsigned mode */
notneg = (prec < 0);
- prec = abs(prec);
- /* fraclimit = (long)pow(10, prec); */
- for (fraclimit = 10, i = 1; i < prec; i++)
+ prec_u = abs(prec);
+ /* fraclimit = (long)pow(10, prec_u); */
+ for (fraclimit = 10, u = 1; u < prec_u; u++) {
+ DEBUG_INSIST(fraclimit < fraclimit * 10);
fraclimit *= 10;
- DEBUG_INSIST(fraclimit > 0);
+ }
/*
* Since conversion to string uses lots of divisions anyway,
qr.quot--;
qr.rem += fraclimit;
}
- ttmp += (time_t)qr.quot;
+ secs_u += (time_t)qr.quot;
frac = qr.rem;
}
- /* Get the absolute value of the time stamp. */
- notneg = notneg || ((time_t)ttmp >= 0);
+ /* Get the absolute value of the split representation time. */
+ notneg = notneg || ((time_t)secs_u >= 0);
if (notneg) {
- fmt++; /* skip sign char in format string */
+ fmt++; /* skip '-' */
} else {
- ttmp = ~ttmp;
- if (frac != 0)
- frac = fraclimit - frac;
+ secs_u = ~secs_u;
+ if (0 == frac)
+ secs_u++;
else
- ttmp += 1;
+ frac = fraclimit - frac;
}
/* finally format the data and return the result */
- snprintf(cp, LIB_BUFLENGTH, fmt, ttmp, prec, frac);
+ snprintf(cp, LIB_BUFLENGTH, fmt, secs_u, prec_u, frac);
return cp;
}
static void set_process_priority (void);
static void assertion_failed (const char *, int,
isc_assertiontype_t,
- const char *);
+ const char *)
+ __attribute__ ((__noreturn__));
static void library_fatal_error (const char *, int,
const char *, va_list)
ISC_FORMAT_PRINTF(3, 0);