OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [pr43402.c] - Blame information for rev 328

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-O1 -fno-inline" } */
3
extern void abort (void);
4
 
5
static int something;
6
 
7
static int * converterData[2]={
8
    &something, &something,
9
};
10
 
11
static struct {
12
  const char *name;
13
  int type;
14
} const cnvNameType[] = {
15
  { "bocu1", 1 },
16
  { "utf7", 1 },
17
  { "utf8", 1 }
18
};
19
 
20
 
21
const int * getAlgorithmicTypeFromName(const char *realName);
22
const int *
23
getAlgorithmicTypeFromName(const char *realName)
24
{
25
    unsigned mid, start, limit;
26
    unsigned lastMid;
27
    int result;
28
    start = 0;
29
    limit = sizeof(cnvNameType)/sizeof(cnvNameType[0]);
30
    mid = limit;
31
    lastMid = 0xffffffff;
32
 
33
    for (;;) {
34
        mid = (start + limit) / 2;
35
        if (lastMid == mid) {   /* Have we moved? */
36
            break;  /* We haven't moved, and it wasn't found. */
37
        }
38
        lastMid = mid;
39
        result = __builtin_strcmp(realName, cnvNameType[mid].name);
40
 
41
        if (result < 0) {
42
            limit = mid;
43
        } else if (result > 0) {
44
            start = mid;
45
        } else {
46
            return converterData[cnvNameType[mid].type];
47
        }
48
    }
49
 
50
    return 0;
51
}
52
 
53
int main (void)
54
{
55
  if (!getAlgorithmicTypeFromName ("utf8"))
56
    abort ();
57
  return 0;
58
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.