162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2012 Tobias Klauser <tklauser@distanz.ch> 462306a36Sopenharmony_ci * Copyright (C) 2011 Pyramid Technical Consultants, Inc. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General 762306a36Sopenharmony_ci * Public License. See the file COPYING in the main directory of this 862306a36Sopenharmony_ci * archive for more details. 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#ifndef _ASM_NIOS2_SWAB_H 1262306a36Sopenharmony_ci#define _ASM_NIOS2_SWAB_H 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#include <linux/types.h> 1562306a36Sopenharmony_ci#include <asm-generic/swab.h> 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#ifdef CONFIG_NIOS2_CI_SWAB_SUPPORT 1862306a36Sopenharmony_ci#ifdef __GNUC__ 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#define __nios2_swab(x) \ 2162306a36Sopenharmony_ci __builtin_custom_ini(CONFIG_NIOS2_CI_SWAB_NO, (x)) 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_cistatic inline __attribute__((const)) __u16 __arch_swab16(__u16 x) 2462306a36Sopenharmony_ci{ 2562306a36Sopenharmony_ci return (__u16) __nios2_swab(((__u32) x) << 16); 2662306a36Sopenharmony_ci} 2762306a36Sopenharmony_ci#define __arch_swab16 __arch_swab16 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_cistatic inline __attribute__((const)) __u32 __arch_swab32(__u32 x) 3062306a36Sopenharmony_ci{ 3162306a36Sopenharmony_ci return (__u32) __nios2_swab(x); 3262306a36Sopenharmony_ci} 3362306a36Sopenharmony_ci#define __arch_swab32 __arch_swab32 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#endif /* __GNUC__ */ 3662306a36Sopenharmony_ci#endif /* CONFIG_NIOS2_CI_SWAB_SUPPORT */ 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#endif /* _ASM_NIOS2_SWAB_H */ 39