# include/assert.h File Reference

Run-time assertion support. More...

`#include <debug.h>`

Include dependency graph for assert.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Defines
#define | assert(condition)
| Assert that condition is true at run time.
#define | unhandled_case(value)
| Assert that the case value will never need to be handled.
#define | build_assert(condition)
| Assert that condition is true at build time.

## Detailed Description

Run-time assertion support.

- Compiler: IAR EWAVR32 and GNU GCC for AVR32
- Supported devices: All devices
- AppNote:

Author:
  Atmel Corporation: http://www.atmel.com
  Support and FAQ: http://support.atmel.no/

Definition in file assert.h.

## Define Documentation

#define assert | ( | condition |  | ) |

Value:

    do {                                                            \
                    if (ASSERT_ENABLED && unlikely(!(condition))) {         \
                            dbg_printf_level(DEBUG_ASSERT,                  \
                                    "%s:%d: Assertion \"%s\" failed!\n",    \
                                    __FILE__, __LINE__, #condition);        \
                            abort();                                        \
                    }                                                       \
            } while (0)

Assert that condition is true at run time.

If condition is false, output a diagnostic message and hang.

If CONFIG_ASSERT is not set, this macro does nothing.

Definition at line 61 of file assert.h.

Referenced by aes_alloc_request(), aes_duplicate_buffer_refs(), aes_free(), aes_free_duplicate_buffers(), aes_free_request(), aes_get_cipher(), aes_init(), aes_load_init_vector(), aes_load_key(), aes_prepare_request(), aes_set_cipher(), aes_submit_request(), blk_req_get_blocks_xfered(), blk_req_get_bytes_xfered(), block_alloc_request(), block_copy_alloc(), block_copy_set_completion_callback(), block_copy_set_dest(), block_copy_set_progress_callback(), block_copy_set_source(), block_copy_submit(), block_free_request(), block_prepare_req(), block_submit_buf_list(), block_submit_req(), dma_pool_init_coherent_physmem(), extract_bitfield(), get_twis_irq(), get_twis_regs(), journal_clean_last_entry(), journal_close_entry(), journal_commit_card(), journal_entry_card_is_intact(), journal_entry_is_consistent(), journal_get_last_entry(), journal_init(), journal_is_empty(), journal_open_entry(), journal_prepare_entry(), mem_pool_alloc(), mem_pool_free(), mem_pool_init(), mem_pool_init_physmem(), msc_do_read(), msc_read_worker(), msc_write_worker(), pm_init_osc(), pm_priv_set_main_clock(), sdmmc_host_enable(), sdmmc_mcihost_load_data(), sdmmc_req_submit_buf_list(), slist_borrow_to_tail(), slist_peek_head_node(), slist_peek_next_node(), slist_peek_tail_node(), slist_pop_head_node(), softirq_enable(), softirq_priv_do_pending(), softirq_set_handler(), timer_add_task_ticks(), timer_do_pending(), timer_init(), timer_reset_task(), udc_ep0_expect_status(), udc_ep0_send_status(), udc_ep0_submit_in_req(), udc_ep0_submit_out_req(), udc_ep0_write_sync(), udc_ep_clear_wedge(), udc_ep_create(), udc_ep_destroy(), udc_ep_is_wedged(), udc_ep_set_wedge(), udc_ep_submit_in_req(), udc_ep_submit_out_req(), usb_func_add_config(), usb_func_add_interface(), usbb_udc_configure_ep(), usbb_udc_dma_interrupt(), usbb_udc_submit_in_queue(), usbb_udc_submit_out_queue(), workqueue_add_item(), workqueue_add_item_safe(), workqueue_do_one_item(), workqueue_get_data(), workqueue_init(), workqueue_is_empty(), workqueue_move_item(), and workqueue_remove_item().

#define build_assert | ( | condition |  | ) |

Value:

    do {                                                            \
                    char build_assert_test[2 * !!(condition) - 1];          \
                    (void)sizeof(build_assert_test);                        \
            } while (0)

Assert that condition is true at build time.

If condition is false, the compilation will abort with an error message. When using gcc, the error message will be

    <file>:<line>: error: size of array 'build_assert_test' is negative

Definition at line 97 of file assert.h.

Referenced by pm_priv_osc_startup(), softirq_set_handler(), and timer_init().

#define unhandled_case | ( | value |  | ) |

Value:

    do {                                                            \
                    if (ASSERT_ENABLED) {                                   \
                            dbg_printf_level(DEBUG_ASSERT,                  \
                                    "%s:%d: Unhandled case value %d\n",     \
                                    __FILE__, __LINE__, (value));           \
                            abort();                                        \
                    }                                                       \
            } while (0)

Assert that the case value will never need to be handled.

If the code expanded from this macro is ever reached, output a diagnostic message and hang.

If CONFIG_ASSERT is not set, this macro does nothing.

Definition at line 79 of file assert.h.

Referenced by aes_load_key(), aesblk_prepare_req(), get_twis_regs(), journal_find_last_entry(), and pm_init_osc().