OSDN Git Service

Add - before rms to be more portable.
[pf3gnuchains/gcc-fork.git] / libffi / src / debug.c
1 /* -----------------------------------------------------------------------
2    debug.c - Copyright (c) 1996 Cygnus Solutions
3
4    $Id: debug.c,v 1.1.1.1 1998/11/29 16:48:16 green Exp $
5
6    Permission is hereby granted, free of charge, to any person obtaining
7    a copy of this software and associated documentation files (the
8    ``Software''), to deal in the Software without restriction, including
9    without limitation the rights to use, copy, modify, merge, publish,
10    distribute, sublicense, and/or sell copies of the Software, and to
11    permit persons to whom the Software is furnished to do so, subject to
12    the following conditions:
13
14    The above copyright notice and this permission notice shall be included
15    in all copies or substantial portions of the Software.
16
17    THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
18    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20    IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21    OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22    ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23    OTHER DEALINGS IN THE SOFTWARE.
24    ----------------------------------------------------------------------- */
25
26 #include <ffi.h>
27 #include <ffi_common.h>
28 #include <stdlib.h>
29 #include <stdio.h>
30
31 /* General debugging routines */
32
33 void ffi_stop_here(void)
34 {
35   /* This function is only useful for debugging purposes.
36      Place a breakpoint on ffi_stop_here to be notified of 
37      significant events. */
38 }
39
40 /* This function should only be called via the FFI_ASSERT() macro */
41
42 int ffi_assert(char *file, int line)
43 {
44   fprintf(stderr, "ASSERTION FAILURE: %s line %d\n", file, line);
45   ffi_stop_here();
46   abort();
47
48   /* This has to return something for the compiler not to complain */
49   /*@notreached@*/
50   return 0;
51 }
52
53 /* Perform a sanity check on an ffi_type structure */
54
55 bool ffi_type_test(ffi_type *a)
56 {
57   /*@-usedef@*/
58   FFI_ASSERT(a->type <= FFI_TYPE_LAST);
59   FFI_ASSERT(a->type > FFI_TYPE_VOID ? a->size > 0 : 1);
60   FFI_ASSERT(a->type > FFI_TYPE_VOID ? a->alignment > 0 : 1);
61   FFI_ASSERT(a->type == FFI_TYPE_STRUCT ? a->elements != NULL : 1);
62   /*@=usedef@*/
63
64   /* This is a silly thing to return, but it keeps the compiler from
65      issuing warnings about "a" not being used in non-debug builds. */
66   return (a != NULL);
67 }