1/*
2 * Copyright 2014, General Dynamics C4 Systems
3 *
4 * This software may be distributed and modified according to the terms of
5 * the GNU General Public License version 2. Note that NO WARRANTY is provided.
6 * See "LICENSE_GPLv2.txt" for details.
7 *
8 * @TAG(GD_GPL)
9 */
10
11#ifndef __MACHINE_ASSEMBLER_H__
12#define __MACHINE_ASSEMBLER_H__
13
14/* This file contains useful macros for assembly code. */
15
16#ifdef __ASSEMBLER__
17
18/*
19 * Use BEGIN_FUNC(), END_FUNC() around assembly functions to annotate them
20 * correctly to the assembler.
21 */
22#define BEGIN_FUNC(_name) \
23    .global _name ; \
24    .type _name, %function ; \
25_name:
26
27#define END_FUNC(_name) \
28    .size _name, .-_name
29
30/*
31 * BEGIN_FUNC_STATIC() and END_FUNC_STATIC() do as above, but without making a
32 * global declaration. (c.f. static functions in C).
33 */
34#define BEGIN_FUNC_STATIC(_name) \
35    .type _name, %function ; \
36_name:
37
38#define END_FUNC_STATIC(_name) \
39    .size _name, .-_name
40
41#else /* !__ASSEMBLER__ */
42#warning "Including assembly-specific header in C code"
43#endif
44
45#endif /* __MACHINE_ASSEMBLER_H__ */
46
47