/* contrib/arm-neon/linux.c * * Copyright (c) 2014, 2017 Glenn Randers-Pehrson * Written by John Bowler, 2014, 2017. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h * * SEE contrib/arm-neon/README before reporting bugs * * STATUS: SUPPORTED * BUG REPORTS: png-mng-implement@sourceforge.net * * png_have_neon implemented for Linux by reading the widely available * pseudo-file /proc/cpuinfo. * * This code is strict ANSI-C and is probably moderately portable; it does * however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
*/
if (f != NULL)
{ /* This is a simple state machine which reads the input byte-by-byte until * it gets a match on the 'neon' feature or reaches the end of the stream.
*/ staticconstchar ch_feature[] = { 70, 69, 65, 84, 85, 82, 69, 83 }; staticconstchar ch_neon[] = { 78, 69, 79, 78 };
for (state=StartLine, counter=0;;)
{ int ch = fgetc(f);
if (ch == EOF)
{ /* EOF means error or end-of-file, return false; neon at EOF is * assumed to be a mistake.
*/
fclose(f); return 0;
}
switch (state)
{ case StartLine: /* Match spaces at the start of line */ if (ch <= 32) /* skip control characters and space */ break;
counter=0;
state = Feature; /* FALLTHROUGH */
case Feature: /* Match 'FEATURE', ASCII case insensitive. */ if ((ch & ~0x20) == ch_feature[counter])
{ if (++counter == (sizeof ch_feature))
state = Colon; break;
}
/* did not match 'feature' */
state = SkipLine; /* FALLTHROUGH */
case SkipLine:
skipLine: /* Skip everything until we see linefeed or carriage return */ if (ch != 10 && ch != 13) break;
state = StartLine; break;
case Colon: /* Match any number of space or tab followed by ':' */ if (ch == 32 || ch == 9) break;
if (ch == 58) /* i.e. ':' */
{
state = StartTag; break;
}
/* Either a bad line format or a 'feature' prefix followed by * other characters.
*/
state = SkipLine; goto skipLine;
case StartTag: /* Skip space characters before a tag */ if (ch == 32 || ch == 9) break;
state = Neon;
counter = 0; /* FALLTHROUGH */
case Neon: /* Look for 'neon' tag */ if ((ch & ~0x20) == ch_neon[counter])
{ if (++counter == (sizeof ch_neon))
state = HaveNeon; break;
}
state = SkipTag; /* FALLTHROUGH */
case SkipTag: /* Skip non-space characters */ if (ch == 10 || ch == 13)
state = StartLine;
case HaveNeon: /* Have seen a 'neon' prefix, but there must be a space or new * line character to terminate it.
*/ if (ch == 10 || ch == 13 || ch == 32 || ch == 9)
{
fclose(f); return 1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.