Back to index

plt-scheme  4.2.1
debug.c
Go to the documentation of this file.
00001 /* -----------------------------------------------------------------------
00002    debug.c - Copyright (c) 1996 Red Hat, Inc.
00003 
00004    Permission is hereby granted, free of charge, to any person obtaining
00005    a copy of this software and associated documentation files (the
00006    ``Software''), to deal in the Software without restriction, including
00007    without limitation the rights to use, copy, modify, merge, publish,
00008    distribute, sublicense, and/or sell copies of the Software, and to
00009    permit persons to whom the Software is furnished to do so, subject to
00010    the following conditions:
00011 
00012    The above copyright notice and this permission notice shall be included
00013    in all copies or substantial portions of the Software.
00014 
00015    THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
00016    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00018    IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00019    OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00020    ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00021    OTHER DEALINGS IN THE SOFTWARE.
00022    ----------------------------------------------------------------------- */
00023 
00024 #include <ffi.h>
00025 #include <ffi_common.h>
00026 #include <stdlib.h>
00027 #include <stdio.h>
00028 
00029 /* General debugging routines */
00030 
00031 void ffi_stop_here(void)
00032 {
00033   /* This function is only useful for debugging purposes.
00034      Place a breakpoint on ffi_stop_here to be notified of
00035      significant events. */
00036 }
00037 
00038 /* This function should only be called via the FFI_ASSERT() macro */
00039 
00040 void ffi_assert(char *expr, char *file, int line)
00041 {
00042   fprintf(stderr, "ASSERTION FAILURE: %s at %s:%d\n", expr, file, line);
00043   ffi_stop_here();
00044   abort();
00045 }
00046 
00047 /* Perform a sanity check on an ffi_type structure */
00048 
00049 void ffi_type_test(ffi_type *a, char *file, int line)
00050 {
00051   FFI_ASSERT_AT(a != NULL, file, line);
00052 
00053   FFI_ASSERT_AT(a->type <= FFI_TYPE_LAST, file, line);
00054   FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->size > 0, file, line);
00055   FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->alignment > 0, file, line);
00056   FFI_ASSERT_AT(a->type != FFI_TYPE_STRUCT || a->elements != NULL, file, line);
00057 
00058 }