Path: blob/main/lib/libc/powerpc64/string/bcopy_resolver.c
39530 views
/*-1* Copyright (c) 2018 Instituto de Pesquisas Eldorado2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. Neither the name of the author nor the names of its contributors may13* be used to endorse or promote products derived from this software14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*27*/2829#include <machine/cpu.h>30#include <machine/ifunc.h>3132#define _CAT(a,b) a##b33#define CAT(a,b) _CAT(a,b)34#define CAT3(a,b,c) CAT(CAT(a,b),c)3536#ifdef MEMCOPY37#define FN_NAME memcpy38#define FN_RET void *39#define FN_PARAMS (void *dst, const void *src, size_t len)4041#elif defined(MEMMOVE)42#define FN_NAME memmove43#define FN_RET void *44#define FN_PARAMS (void *dst, const void *src, size_t len)4546#else47#define FN_NAME bcopy48#define FN_RET void49#define FN_PARAMS (const void *src, void *dst, size_t len)50#endif5152#define FN_NAME_NOVSX CAT(__, FN_NAME)53#define FN_NAME_VSX CAT3(__, FN_NAME, _vsx)5455FN_RET FN_NAME_NOVSX FN_PARAMS;56FN_RET FN_NAME_VSX FN_PARAMS;5758DEFINE_UIFUNC(, FN_RET, FN_NAME, FN_PARAMS)59{60/* VSX instructions were added in POWER ISA 2.06,61* however it requires data to be word-aligned.62* Since POWER ISA 2.07B this is solved transparently63* by the hardware64*/65if (cpu_features & PPC_FEATURE_HAS_VSX)66return (FN_NAME_VSX);67else68return (FN_NAME_NOVSX);69}707172