Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / opr / assert.c
1 #include <afsconfig.h>
2 #include <afs/param.h>
3
4 #include <roken.h>
5 #include "opr.h"
6
7 #ifdef AFS_NT40_ENV
8 void
9 opr_NTAbort(void)
10 {
11 DebugBreak();
12 }
13 #endif
14
15 #define TIMESTAMP_BUFFER_SIZE 26 /* including the null */
16 void
17 opr_AssertionFailed(const char *file, int line)
18 {
19 char tdate[TIMESTAMP_BUFFER_SIZE];
20 time_t when;
21 struct tm tm;
22
23 when = time(NULL);
24 strftime(tdate, sizeof(tdate), "%a %b %d %H:%M:%S %Y",
25 localtime_r(&when, &tm));
26 fprintf(stderr, "%s Assertion failed! file %s, line %d.\n", tdate, file,
27 line);
28 fflush(stderr);
29 opr_abort();
30 }
31
32 void
33 opr_AssertFailU(const char *expr, const char *file, int line)
34 {
35 fprintf(stderr, "Fatal Rx error: assertion failed: %s, "
36 "file: %s, line: %d\n",
37 expr, file, line);
38 fflush(stderr);
39 fflush(stdout);
40 opr_abort();
41 }
42