GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
xerbla.c
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include <stdio.h>
28 
29 #include "f77-fcn.h"
30 
31 typedef void (*xerbla_handler_fptr) (void);
32 
33 /* Pointer to function to call to handle error. In the Octave
34  interpreter we set this to a function that throws an exception and
35  transfers control to the enclosing try/catch block. That is
36  typically at the top-level REPL.
37 
38  We must use a function pointer instead of simply calling error
39  directly here because this function is called by LAPACK and BLAS
40  subroutines. To build shared libraries of those packages on Windows
41  requires that all symbols be known when the shared library is
42  constructed. If we call error directly, that would mean that the
43  BLAS and LAPACK libraries would have to depend on Octave... */
44 
46 
47 void
49 {
51 }
52 
53 /* Replacement for BLAS and LAPACK XERBLA subroutine that calls an
54  optionally installed handler function. */
55 
57 F77_FUNC (xerbla, XERBLA) (F77_CONST_CHAR_ARG_DEF (s_arg, len),
58  const F77_INT *info
59  F77_CHAR_ARG_LEN_DEF (len))
60 {
61  const char *s = F77_CHAR_ARG_USE (s_arg);
62  int slen = F77_CHAR_ARG_LEN_USE (s_arg, len);
63 
64  fprintf (stderr, "%.*s: parameter number %ld is invalid\n", slen, s,
65  (long) (*info));
66 
67  if (xerbla_handler)
68  (*xerbla_handler) ();
69 
70  F77_RETURN (0)
71 }
void octave_set_xerbla_handler(xerbla_handler_fptr fcn)
Definition: xerbla.c:48
s
Definition: file-io.cc:2729
F77_RET_T(F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, const F77_INT &, const F77_INT &, const F77_INT &, F77_INT &, F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_DBLE *, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_INT *, F77_INT &F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL)
octave_function * fcn
Definition: ov-class.cc:1754
F77_RET_T F77_FUNC(xerbla, XERBLA)
Definition: xerbla.c:57
static xerbla_handler_fptr xerbla_handler
Definition: xerbla.c:45
void(* xerbla_handler_fptr)(void)
Definition: xerbla.c:31
octave_f77_int_type F77_INT
Definition: f77-fcn.h:305