1 /* Shared header for testing memory leak false positives seen in OpenBLAS,
2 e.g. in lapacke_cgbbrd_work.c.
3
4 The code is of the form:
5
6 if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) {
7 pt_t = (lapack_complex_float*)
8 LAPACKE_malloc( sizeof(lapack_complex_float) *
9 ldpt_t * MAX(1,n) );
10 ...snip...
11 }
12
13 [...snip lots of code...]
14
15 if( LAPACKE_lsame( vect, 'b' ) || LAPACKE_lsame( vect, 'p' ) ) {
16 LAPACKE_free( pt_t );
17 }
18
19 where LAPACKE_lsame is a case-insensitive comparison, implemented in its
20 own source file. Without __attribute__((const)) on LAPACKE_lsame, the
21 analyzer considers the execution paths where the malloc is called, and
22 then the free is not called. With __attribute__((const)), the analyzer
23 ought to rule out such paths. */
24
25 #define NULL ((void *)0)
26 typedef __SIZE_TYPE__ size_t;
27
28 extern void *malloc (size_t __size)
29 __attribute__ ((__nothrow__ , __leaf__))
30 __attribute__ ((__malloc__))
31 __attribute__ ((__alloc_size__ (1)))
32 __attribute__ ((__warn_unused_result__));
33 extern void free (void *__ptr)
34 __attribute__ ((__nothrow__ , __leaf__));
35
36 /* Header adapted/reduced from
37 https://github.com/xianyi/OpenBLAS/
38 which has this license text. */
39
40 /*****************************************************************************
41 Copyright (c) 2014, Intel Corp.
42 All rights reserved.
43
44 Redistribution and use in source and binary forms, with or without
45 modification, are permitted provided that the following conditions are met:
46
47 * Redistributions of source code must retain the above copyright notice,
48 this list of conditions and the following disclaimer.
49 * Redistributions in binary form must reproduce the above copyright
50 notice, this list of conditions and the following disclaimer in the
51 documentation and/or other materials provided with the distribution.
52 * Neither the name of Intel Corporation nor the names of its contributors
53 may be used to endorse or promote products derived from this software
54 without specific prior written permission.
55
56 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
57 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
60 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
61 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
62 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
63 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
64 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
66 THE POSSIBILITY OF SUCH DAMAGE.
67 *****************************************************************************/
68
69 #define lapack_int int
70 #define lapack_logical lapack_int
71
72 #define LAPACKE_malloc( size ) malloc( size )
73 #define LAPACKE_free( p ) free( p )
74
75 #define LAPACK_ROW_MAJOR 101
76 #define LAPACK_COL_MAJOR 102
77
78 #define LAPACK_TRANSPOSE_MEMORY_ERROR -1011
79
80 #define MAX(x,y) (((x) > (y)) ? (x) : (y))
81
82 #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_
83
84 typedef float _Complex lapack_complex_float;
85
86 void LAPACKE_xerbla( const char *name, int info );
87
88 void LAPACKE_cgb_trans( int matrix_layout, int m, int n,
89 int kl, int ku,
90 const lapack_complex_float *in, int ldin,
91 lapack_complex_float *out, int ldout );
92 void LAPACKE_cge_trans( int matrix_layout, int m, int n,
93 const lapack_complex_float* in, int ldin,
94 lapack_complex_float* out, int ldout );
95
96 #define LAPACK_cgbbrd LAPACK_GLOBAL(cgbbrd,CGBBRD)
97 void LAPACK_cgbbrd(
98 char const* vect,
99 lapack_int const* m, lapack_int const* n, lapack_int const* ncc, lapack_int const* kl, lapack_int const* ku,
100 lapack_complex_float* AB, lapack_int const* ldab,
101 float* D,
102 float* E,
103 lapack_complex_float* Q, lapack_int const* ldq,
104 lapack_complex_float* PT, lapack_int const* ldpt,
105 lapack_complex_float* C, lapack_int const* ldc,
106 lapack_complex_float* work,
107 float* rwork,
108 lapack_int* info );