1/* GMP assertion failure handler.
2
3   THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY.  THEY'RE ALMOST
4   CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
5   FUTURE GNU MP RELEASES.
6
7Copyright 2000, 2001 Free Software Foundation, Inc.
8
9This file is part of the GNU MP Library.
10
11The GNU MP Library is free software; you can redistribute it and/or modify
12it under the terms of the GNU Lesser General Public License as published by
13the Free Software Foundation; either version 3 of the License, or (at your
14option) any later version.
15
16The GNU MP Library is distributed in the hope that it will be useful, but
17WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
19License for more details.
20
21You should have received a copy of the GNU Lesser General Public License
22along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
23
24#include <stdio.h>
25#include <stdlib.h>
26#include "gmp.h"
27#include "gmp-impl.h"
28
29
30void
31__gmp_assert_header (const char *filename, int linenum)
32{
33  if (filename != NULL && filename[0] != '\0')
34    {
35      fprintf (stderr, "%s:", filename);
36      if (linenum != -1)
37        fprintf (stderr, "%d: ", linenum);
38    }
39}
40
41void
42__gmp_assert_fail (const char *filename, int linenum,
43                   const char *expr)
44{
45  __gmp_assert_header (filename, linenum);
46  fprintf (stderr, "GNU MP assertion failed: %s\n", expr);
47  abort();
48}
49