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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [pr43402.c] - Blame information for rev 818

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

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

powered by: WebSVN 2.1.0

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