18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2012 Tobias Klauser <tklauser@distanz.ch> 48c2ecf20Sopenharmony_ci * Copyright (C) 2011 Pyramid Technical Consultants, Inc. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General 78c2ecf20Sopenharmony_ci * Public License. See the file COPYING in the main directory of this 88c2ecf20Sopenharmony_ci * archive for more details. 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef _ASM_NIOS2_SWAB_H 128c2ecf20Sopenharmony_ci#define _ASM_NIOS2_SWAB_H 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/types.h> 158c2ecf20Sopenharmony_ci#include <asm-generic/swab.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#ifdef CONFIG_NIOS2_CI_SWAB_SUPPORT 188c2ecf20Sopenharmony_ci#ifdef __GNUC__ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define __nios2_swab(x) \ 218c2ecf20Sopenharmony_ci __builtin_custom_ini(CONFIG_NIOS2_CI_SWAB_NO, (x)) 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistatic inline __attribute__((const)) __u16 __arch_swab16(__u16 x) 248c2ecf20Sopenharmony_ci{ 258c2ecf20Sopenharmony_ci return (__u16) __nios2_swab(((__u32) x) << 16); 268c2ecf20Sopenharmony_ci} 278c2ecf20Sopenharmony_ci#define __arch_swab16 __arch_swab16 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistatic inline __attribute__((const)) __u32 __arch_swab32(__u32 x) 308c2ecf20Sopenharmony_ci{ 318c2ecf20Sopenharmony_ci return (__u32) __nios2_swab(x); 328c2ecf20Sopenharmony_ci} 338c2ecf20Sopenharmony_ci#define __arch_swab32 __arch_swab32 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#endif /* __GNUC__ */ 368c2ecf20Sopenharmony_ci#endif /* CONFIG_NIOS2_CI_SWAB_SUPPORT */ 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#endif /* _ASM_NIOS2_SWAB_H */ 39