view test/inline.c @ 935:7672a37e7545 default tip

Raspbery PI ARM support begin
author kono
date Sat, 24 Dec 2016 03:02:57 +0000
parents 5313ed059cee
children
line wrap: on
line source

const int a = 5,b = -3;
int kkkk = 333;
static const int as = 5,bs = -3;
const char hoo[] = "test";
char hoo0[] = "test";
static const char haa[] = "test";
static inline const int f(int k);


extern int printf(const char *,...);
inline int
main0(int ac, char **av)
{
    volatile const int i = 3;
    volatile const int j = 3;
    switch(i) {
    case 1: printf("#0016:1\n"); break;
    case 2: printf("#0017:2\n"); break;
    case 3: printf("#0018:3\n"); break;
    case 4: printf("#0019:4\n"); break;
    }
    switch(j) {
    case 1: printf("#0022:1\n"); break;
    default:
    case 2: printf("#0024:2\n"); break;
    case 3: printf("#0025:3\n"); break;
    case 4: printf("#0026:4\n"); break;
    }
    return 0;
}

inline int
main3(int ac, char **av)
{
    const int i = 3;
    const int j = 3;
    switch(i) {
    case 1: printf("#0037:1\n"); break;
    case 2: printf("#0038:2\n"); break;
    case 3: printf("#0039:3\n"); break;
    case 4: printf("#0040:4\n"); break;
    }
    switch(j) {
    case 1: printf("#0043:1\n"); break;
    case 2: printf("#0044:2\n"); break;
    case 3: printf("#0045:3\n"); break;
    case 4: printf("#0046:4\n"); break;
    }
    return 0;
}

int
main1(int ac, char **av)
{
    volatile const int i = 3;
    volatile const int j = 3;
    switch(i) {
    case 1: printf("#0057:1\n"); break;
    case 2: printf("#0058:2\n"); break;
    case 3: printf("#0059:3\n"); break;
    case 4: printf("#0060:4\n"); break;
    }
    switch(j) {
    case 1: printf("#0063:1\n"); break;
    case 2: printf("#0064:2\n"); break;
    case 3: printf("#0065:3\n"); break;
    case 4: printf("#0066:4\n"); break;
    }
    return 0;
}

int
main2(int ac, char **av)
{
    const int j = 3;
    const int i = 3;
    switch(a) {
    case 1: printf("#0077:1\n"); break;
    default:
    case 2: printf("#0079:2\n"); break;
    case 3: printf("#0080:3\n"); break;
    case 5: printf("#0081:4\n"); break;
    }
    switch(j) {
    case 1: printf("#0084:1\n"); break;
    default:
    case 2: printf("#0086:2\n"); break;
    case 3: printf("#0087:3\n"); break;
    case 4: printf("#0088:4\n"); break;
    }
    return 0;
}


extern int printf(const char *,...);

static inline const int f(const int k)
{
    return k+1;
}

inline int in1(const int i,const int j)
{
   if (i>j) return j;
   else return i;
}

static
inline int ins(const int i,const int j)
{
   printf("#0110:%d %d\n",i,j);
   if (f(i)>j) return j;
   else return i;
}

static
inline int ins1(const int i,const int j, const int k)
{
   printf("#0118:%d %d %d\n",i,j,k);
   if (f(i)>j) return j;
   else return i;
}

inline __attribute__((always_inline)) int in2(const int p,int i,const int j)
{
    int k = -20,m;
    int order=1;
    do {
        order <<= 4; order|=0;
        k += 3;
        order <<= 4; order|=7;
    } while ( k < j);
    printf("#0132: %d do %d %x\n",p,k,order);

    while (k > j) {
        order <<= 4; order|=0;
        k -= 3;
        order <<= 4; order|=7;
    } 
    printf("#0139: %d while %d %x\n",p,k,order);

    m = 0;
    for(k=0;k<j;k++) {
        order <<= 4; order|=0;
        m += k;
        order <<= 4; order|=7;
        if (k&1) {
            order <<= 4; order|=0;
            m += k;
            order <<= 4; order|=7;
        } else {
            order <<= 4; order|=5;
            m += k;
            order <<= 4; order|=10;
        }
        printf("#0155: %x\n",order);
    }
    printf("#0157: %d for %d\n",p,m);


    switch(i) {
    case 1: k = 1;
        break;
    case 2: k = 2;
        break;
    case 3: k = 3;
        break;
    case 4: k = 4;
        break;
    default: k = 5;
    }
    printf("#0171: %d switch %d\n",p,k);

    for(k=0;k<j;k++) {
        i += k;
        if (k<3) continue;
    }
    printf("#0177: %d for %d\n",p,i);
    goto hoge;
hage:
    goto hage;
hoge:
    return 0;

}

int (*fnp)(int i,int j,int k);

int (*fnp3)(int i,int j,int k);

void
a0(int k,int j)
{
    int k1,j1;
    const int v=3,x=6;
    // a = 10;

    k1 = in1(a,b);
    printf("#0198:%d %d %d\n",a,b,k1);
    j1 = in1(k,j-6)+f(k1);
    printf("#0200:%d %d %s\n",k1,j1,hoo);
    k1 = &v-&x>0? &v-&x : &x-&v;
    printf("#0202:v-x: %d\n",k1);

    k1 = ins(a,b);
    j1 = ins(k,j-6)+f(k1);
    printf("#0206:%d %d %s\n",k1,j1,haa);

    k1 = ins(as,bs);
    j1 = ins(k,j-6)+f(k1);
    printf("#0210:%d %d %s\n",k1,j1,haa);

    k1 = ins(v,x);
    j1 = ins(k,j-6)+f(v);
    printf("#0214:%d %d %s\n",k1,j1,haa);

    k1 = fnp(v,x,5);
    j1 = ins1(k,j-6,6)+f(v);
    printf("#0218:%d %d %s\n",k1,j1,haa);
}

void
a1(int k,int j)
{
    in2(1,k,j);
    in2(2,3,10);
    in2(3,k,10);
    in2(4,2,j);
    in2(5,2,1);
    in2(6,0,2);
    in2(8,j*3,in2(7,k+3,10-j));
    fnp3(9,0,2);
}

static
inline int order(int a0,int a1,int a2, int a3, int a4)
{
    printf("#0237:order  %d %d %d %d %d\n",a0,a1,a2,a3,a4);
}

static
inline int order1(int a0,int a1,int a2, int a3, int a4)
{
    printf("#0243:orderp %d %d %d %d %d\n",a0,a1,a2,a3,a4);
}

int (*order1p)(int a0,int a1,int a2, int a3, int a4) = order1;

static inline int inmain(int ac,char *av[])
{
     fnp = ins1;
     order(11,12,13,14,15);
     order1p(11,12,13,14,15);
     a0(15,16);
     a0(-19,16);
     fnp3 = in2;
     a1(19,110);
     main0(ac,av);
     return 0;
}

inline
void
main5()
{
 printf("#0265:test1 " " test2\n");
 printf("#0266:test3 "
     " test4\n");
#if 0
  // error
 //printf("#0270:test5 
 //     test6\n");
#endif
 printf("#0273:test7  \
      test8\n");
}

int
main(int ac,char *av[])
{
  void (*f)() = main5;
  const int i = 3;

     fnp = ins1;
     printf("#0284:%d\n",(1,2,3,4,5));
     order(1,2,3,4,5);
     order1p(1,2,3,4,5);
     a0(5,6);
     a0(-9,6);
     fnp3 = in2;
     a1(9,10);
     main0(ac,av);
     main1(ac,av);
     inmain(ac,av);
     main2(ac,av);
     main3(ac,av);

 printf("#0297:test1 " " test2\n");


  switch(i) { 
  case 1: printf("#0301:1\n"); break;
  default:
  case 2: printf("#0303:2\n"); break;
  case 3: printf("#0304:3\n"); break;
  }

    main5();
    f();
     return 0;
}