blob: 8e2f15a63529b391affc44be5cdc5fffcb7542f1 [file] [log] [blame]
Macpaul Lin273d11e2011-12-01 12:32:10 +08001/*
Bin Menga1875592016-02-05 19:30:11 -08002 * U-Boot - linkage.h
Macpaul Lin273d11e2011-12-01 12:32:10 +08003 *
4 * Copyright (c) 2005-2007 Analog Devices Inc.
5 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Macpaul Lin273d11e2011-12-01 12:32:10 +08007 */
8
9#ifndef _LINUX_LINKAGE_H
10#define _LINUX_LINKAGE_H
11
12#include <asm/linkage.h>
Macpaul Lin273d11e2011-12-01 12:32:10 +080013
Chen Gang950cb9b2015-02-19 18:51:27 +030014/* Some toolchains use other characters (e.g. '`') to mark new line in macro */
15#ifndef ASM_NL
16#define ASM_NL ;
17#endif
18
Macpaul Lin273d11e2011-12-01 12:32:10 +080019#ifdef __cplusplus
20#define CPP_ASMLINKAGE extern "C"
21#else
22#define CPP_ASMLINKAGE
23#endif
24
Masahiro Yamadae6126a52014-12-03 17:36:57 +090025#ifndef asmlinkage
Macpaul Lin273d11e2011-12-01 12:32:10 +080026#define asmlinkage CPP_ASMLINKAGE
Masahiro Yamadae6126a52014-12-03 17:36:57 +090027#endif
Macpaul Lin273d11e2011-12-01 12:32:10 +080028
29#define SYMBOL_NAME_STR(X) #X
30#define SYMBOL_NAME(X) X
31#ifdef __STDC__
32#define SYMBOL_NAME_LABEL(X) X##:
33#else
34#define SYMBOL_NAME_LABEL(X) X:
35#endif
36
Aneesh V72455362012-03-08 07:20:17 +000037#ifndef __ALIGN
Macpaul Lin273d11e2011-12-01 12:32:10 +080038#define __ALIGN .align 4
Aneesh V72455362012-03-08 07:20:17 +000039#endif
40
41#ifndef __ALIGN_STR
Macpaul Lin273d11e2011-12-01 12:32:10 +080042#define __ALIGN_STR ".align 4"
Aneesh V72455362012-03-08 07:20:17 +000043#endif
Macpaul Lin273d11e2011-12-01 12:32:10 +080044
45#ifdef __ASSEMBLY__
46
47#define ALIGN __ALIGN
48#define ALIGN_STR __ALIGN_STR
49
50#define LENTRY(name) \
Chen Gang950cb9b2015-02-19 18:51:27 +030051 ALIGN ASM_NL \
Macpaul Lin273d11e2011-12-01 12:32:10 +080052 SYMBOL_NAME_LABEL(name)
53
54#define ENTRY(name) \
Chen Gang950cb9b2015-02-19 18:51:27 +030055 .globl SYMBOL_NAME(name) ASM_NL \
Macpaul Lin273d11e2011-12-01 12:32:10 +080056 LENTRY(name)
57
David Fengec4fa562013-12-14 11:47:31 +080058#define WEAK(name) \
Chen Gang950cb9b2015-02-19 18:51:27 +030059 .weak SYMBOL_NAME(name) ASM_NL \
David Fengec4fa562013-12-14 11:47:31 +080060 LENTRY(name)
61
Macpaul Lin273d11e2011-12-01 12:32:10 +080062#ifndef END
63#define END(name) \
64 .size name, .-name
65#endif
66
67#ifndef ENDPROC
68#define ENDPROC(name) \
Chen Gang950cb9b2015-02-19 18:51:27 +030069 .type name STT_FUNC ASM_NL \
Macpaul Lin273d11e2011-12-01 12:32:10 +080070 END(name)
71#endif
72
73#endif
74
75#endif