summaryrefslogblamecommitdiffstats
path: root/linux/errors.c
blob: 105d343bff90758ee69d311bbac64f2f1f1df3e6 (plain) (tree)
1
2
3
4
5
6
7
8
9
10







                                                                    

                                                                                                      


                                             
                                                       


                            

                                       














                                        



                                          





                                

                                      












                                   


                                               




                                 





                                          













                                        







                                               













                                      

                                    






                                       

                                          





                                  

                                        










                                               
                                                       

    
                            



                                
/* See LICENSE file for copyright and license details. */

/* This file is included from ../libsyscalls_get_syscall_errors.c */


#include "../generated/linux-errors.h"

static enum libsyscalls_error
get_linux_syscall_errors(enum libsyscalls_arch arch, const struct libsyscalls_named_number **errs_out,
                         size_t *nerrs_out, int *are_signed_out)
{
#define CASE(ARCH)\
	*errs_out = linux_errors_for_##ARCH;\
	*nerrs_out = ELEMSOF(linux_errors_for_##ARCH);\
	goto out

	switch ((int)arch) {
	case LIBSYSCALLS_ARCH_ALPHA_LE:
	case LIBSYSCALLS_ARCH_ALPHA_BE:
#ifdef LIST_LINUX_ERRORS_FOR_ALPHA
		CASE(alpha);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_AMD64:
	case LIBSYSCALLS_ARCH_AMD64_X32:
	case LIBSYSCALLS_ARCH_I386:
#ifdef LIST_LINUX_ERRORS_FOR_X86
		CASE(x86);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_ARM_OABI_LE:
	case LIBSYSCALLS_ARCH_ARM_OABI_BE:
	case LIBSYSCALLS_ARCH_ARM_EABI_LE:
	case LIBSYSCALLS_ARCH_ARM_EABI_BE:
#ifdef LIST_LINUX_ERRORS_FOR_ARM
		CASE(arm);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_IA64_LE:
	case LIBSYSCALLS_ARCH_IA64_BE:
#ifdef LIST_LINUX_ERRORS_FOR_IA64
		CASE(ia64);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_M68K:
#ifdef LIST_LINUX_ERRORS_FOR_M68K
		CASE(m68k);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_MICROBLAZE_32_LE:
	case LIBSYSCALLS_ARCH_MICROBLAZE_32_BE:
#ifdef LIST_LINUX_ERRORS_FOR_MICROBLAZE_32
		CASE(microblaze);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_MIPS_O32_LE:
	case LIBSYSCALLS_ARCH_MIPS_O32_BE:
	case LIBSYSCALLS_ARCH_MIPS_N32_LE:
	case LIBSYSCALLS_ARCH_MIPS_N32_BE:
	case LIBSYSCALLS_ARCH_MIPS_N64_LE:
	case LIBSYSCALLS_ARCH_MIPS_N64_BE:
#ifdef LIST_LINUX_ERRORS_FOR_MIPS
		CASE(mips);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_PARISC_32:
	case LIBSYSCALLS_ARCH_PARISC_64:
#ifdef LIST_LINUX_ERRORS_FOR_PARISC
		CASE(parisc);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_POWERPC_32_LE:
	case LIBSYSCALLS_ARCH_POWERPC_32_BE:
	case LIBSYSCALLS_ARCH_POWERPC_64_LE:
	case LIBSYSCALLS_ARCH_POWERPC_64_BE:
	case LIBSYSCALLS_ARCH_POWERPC_NOSPU_LE:
	case LIBSYSCALLS_ARCH_POWERPC_NOSPU_BE:
	case LIBSYSCALLS_ARCH_POWERPC_SPU_LE:
	case LIBSYSCALLS_ARCH_POWERPC_SPU_BE:
#ifdef LIST_LINUX_ERRORS_FOR_POWERPC
		CASE(powerpc);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_S390_32:
	case LIBSYSCALLS_ARCH_S390_64:
#ifdef LIST_LINUX_ERRORS_FOR_S390
		CASE(s390);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_SH_LE:
	case LIBSYSCALLS_ARCH_SH_BE:
#ifdef LIST_LINUX_ERRORS_FOR_SH
		CASE(sh);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_SPARC_32:
	case LIBSYSCALLS_ARCH_SPARC_64_LE:
	case LIBSYSCALLS_ARCH_SPARC_64_BE:
#ifdef LIST_LINUX_ERRORS_FOR_SPARC
		CASE(sparc);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_XTENSA_LE:
	case LIBSYSCALLS_ARCH_XTENSA_BE:
#ifdef LIST_LINUX_ERRORS_FOR_XTENSA
		CASE(xtensa);
#else
		break;
#endif

	default:
		return LIBSYSCALLS_E_ARCHNOSUP;
	}

	*errs_out = linux_errors_for_generic;
	*nerrs_out = ELEMSOF(linux_errors_for_generic);

out:
	*are_signed_out = 0;
	return LIBSYSCALLS_E_OK;

#undef CASE
}