Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[r24]: LIME-examples / simple-test / sink.c Maximize Restore History

Download this file

sink.c    62 lines (51 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/****************************************************************
Simple sink to demonstrate LIME.
Uses state defined statically.
Copyright 2008 Pjotr Kourzanov
This file is part of LIME.
LIME is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
LIME 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 a copy of the GNU General Public License
along with LIME. If not, see <http://www.gnu.org/licenses/>.
****************************************************************/
#include LIME
#include LIME_stdio
#include <assert.h>
struct state;
static int CheckCount(unsigned int size,
const unsigned int *buf,
unsigned int *pCount);
static struct state _state;
actor process(const unsigned int buf[restrict BUF_SIZE])
{
int s=CheckCount(BUF_SIZE,buf,&_state.count);
if (s) printf("check OK\n");
else printf("check FAILED\n");
assert(s);
}
static int CheckCount(unsigned int size,
const unsigned int *buf,
unsigned int *pCount)
{
unsigned int i;
for (i=0; i < size; i++)
{
if (buf[i] != (*pCount))
{
return 0;
}
if (buf[i] >> 23)
{
return 0;
}
/* Wrap on signed 24 bits value */
(*pCount)++;
(*pCount) &= 0x7fffff;
}
return 1;
}