Skip to content
Snippets Groups Projects
Select Git revision
21 results Searching

fat-arm.c

Blame
  • Forked from Nettle / nettle
    Source project has a limited visibility.
    fat-arm.c 7.84 KiB
    /* fat-arm.c
    
       Copyright (C) 2015 Niels Möller
    
       This file is part of GNU Nettle.
    
       GNU Nettle is free software: you can redistribute it and/or
       modify it under the terms of either:
    
         * the GNU Lesser General Public License as published by the Free
           Software Foundation; either version 3 of the License, or (at your
           option) any later version.
    
       or
    
         * the GNU General Public License as published by the Free
           Software Foundation; either version 2 of the License, or (at your
           option) any later version.
    
       or both in parallel, as here.
    
       GNU Nettle is distributed in the hope that it will be useful,
       but WITHOUT ANY WARRANTY; without even the implied warranty of
       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       General Public License for more details.
    
       You should have received copies of the GNU General Public License and
       the GNU Lesser General Public License along with this program.  If
       not, see http://www.gnu.org/licenses/.
    */
    
    #if HAVE_CONFIG_H
    # include "config.h"
    #endif
    
    #include <assert.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    #include "nettle-types.h"
    
    #include "aes-internal.h"
    #include "fat-setup.h"
    
    struct arm_features
    {
      /* /proc/cpuinfo "CPU Architecture" doesn't correspond exactly to
         ARM architecture version, but it's good enough for our purposes.
         Will be set to 5, 6, 7 or 8. */
      unsigned arch_version;
      int have_neon;
    };
    
    #define SKIP(s, slen, literal, llen)				\
      (((slen) >= (llen) && memcmp ((s), (literal), llen) == 0)	\
       ? ((slen) -= (llen), (s) += (llen), 1) : 0)
    #define MATCH(s, slen, literal, llen)				\
      ((slen) == (llen) && memcmp ((s), (literal), llen) == 0)
    
    static void
    get_arm_features (struct arm_features *features)
    {
      const char *s;
      features->arch_version = 5;
      features->have_neon = 0;
    
      s = secure_getenv (ENV_OVERRIDE);
      if (s)
        for (;;)