49834ccd0a80f23c37096507eca72d951a213df3
[openafs.git] / src / util / assert.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* ReallyAbort:  called from assert. May/85 */
11 #include <afsconfig.h>
12 #include <afs/param.h>
13 #include <stdlib.h>
14 #ifdef HAVE_SYS_TIME_H
15 #include <sys/time.h>
16 #endif
17 #include <string.h>
18
19
20 #include <stdio.h>
21 #include "afsutil.h"
22
23 #ifdef AFS_NT40_ENV
24 void
25 afs_NTAbort(void)
26 {
27     DebugBreak();
28 }
29 #endif
30
31 #define TIMESTAMP_BUFFER_SIZE 26  /* including the null */
32 #define TIMESTAMP_NEWLINE_POS 24  /* offset to the newline placed by ctime */
33
34 void
35 AssertionFailed(char *file, int line)
36 {
37     char tdate[TIMESTAMP_BUFFER_SIZE];
38     time_t when;
39
40     time(&when);
41     (void)afs_ctime(&when, tdate, sizeof(tdate));
42     tdate[TIMESTAMP_NEWLINE_POS] = ' ';
43     fprintf(stderr, "%sAssertion failed! file %s, line %d.\n", tdate, file,
44             line);
45     fflush(stderr);
46     afs_abort();
47 }