Loading...
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * linux/arch/arm/include/asm/neon.h
4 *
5 * Copyright (C) 2013 Linaro Ltd <ard.biesheuvel@linaro.org>
6 */
7
8#include <asm/hwcap.h>
9
10#define cpu_has_neon() (!!(elf_hwcap & HWCAP_NEON))
11
12#ifdef __ARM_NEON__
13
14/*
15 * If you are affected by the BUILD_BUG below, it probably means that you are
16 * using NEON code /and/ calling the kernel_neon_begin() function from the same
17 * compilation unit. To prevent issues that may arise from GCC reordering or
18 * generating(1) NEON instructions outside of these begin/end functions, the
19 * only supported way of using NEON code in the kernel is by isolating it in a
20 * separate compilation unit, and calling it from another unit from inside a
21 * kernel_neon_begin/kernel_neon_end pair.
22 *
23 * (1) Current GCC (4.7) might generate NEON instructions at O3 level if
24 * -mpfu=neon is set.
25 */
26
27#define kernel_neon_begin() \
28 BUILD_BUG_ON_MSG(1, "kernel_neon_begin() called from NEON code")
29
30#else
31void kernel_neon_begin(void);
32#endif
33void kernel_neon_end(void);
1/*
2 * linux/arch/arm/include/asm/neon.h
3 *
4 * Copyright (C) 2013 Linaro Ltd <ard.biesheuvel@linaro.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <asm/hwcap.h>
12
13#define cpu_has_neon() (!!(elf_hwcap & HWCAP_NEON))
14
15#ifdef __ARM_NEON__
16
17/*
18 * If you are affected by the BUILD_BUG below, it probably means that you are
19 * using NEON code /and/ calling the kernel_neon_begin() function from the same
20 * compilation unit. To prevent issues that may arise from GCC reordering or
21 * generating(1) NEON instructions outside of these begin/end functions, the
22 * only supported way of using NEON code in the kernel is by isolating it in a
23 * separate compilation unit, and calling it from another unit from inside a
24 * kernel_neon_begin/kernel_neon_end pair.
25 *
26 * (1) Current GCC (4.7) might generate NEON instructions at O3 level if
27 * -mpfu=neon is set.
28 */
29
30#define kernel_neon_begin() \
31 BUILD_BUG_ON_MSG(1, "kernel_neon_begin() called from NEON code")
32
33#else
34void kernel_neon_begin(void);
35#endif
36void kernel_neon_end(void);