blob: aef95b2bbca8481e9a3be996f0093716ed34e289 [file] [log] [blame]
Austin Schuhbb1338c2024-06-15 19:31:16 -07001/* 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 either:
13
14 * the GNU Lesser General Public License as published by the Free
15 Software Foundation; either version 3 of the License, or (at your
16 option) any later version.
17
18or
19
20 * the GNU General Public License as published by the Free Software
21 Foundation; either version 2 of the License, or (at your option) any
22 later version.
23
24or both in parallel, as here.
25
26The GNU MP Library is distributed in the hope that it will be useful, but
27WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
28or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
29for more details.
30
31You should have received copies of the GNU General Public License and the
32GNU Lesser General Public License along with the GNU MP Library. If not,
33see https://www.gnu.org/licenses/. */
34
35#include <stdio.h>
36#include <stdlib.h>
37#include "gmp-impl.h"
38
39
40void
41__gmp_assert_header (const char *filename, int linenum)
42{
43 if (filename != NULL && filename[0] != '\0')
44 {
45 fprintf (stderr, "%s:", filename);
46 if (linenum != -1)
47 fprintf (stderr, "%d: ", linenum);
48 }
49}
50
51void
52__gmp_assert_fail (const char *filename, int linenum,
53 const char *expr)
54{
55 __gmp_assert_header (filename, linenum);
56 fprintf (stderr, "GNU MP assertion failed: %s\n", expr);
57 abort();
58}