Home | History | Annotate | Download | only in jni
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 /* This program tests for a compiler bug that was found in the
     18  * arm-linux-androideabi-4.4.3 toolchain and fixed by the change at
     19  * https://review.source.android.com/#change,19474
     20  *
     21  * The bug generated an invalid sequence of thumb machine instructions
     22  * when signed chars were being used.
     23  */
     24 #include <stdio.h>
     25 
     26 int test(signed char anim_col)
     27 {
     28     if (anim_col >= 31) {
     29         return 1;
     30     } else if (anim_col <= -15) {
     31         return -2;
     32     }
     33     return 0;
     34 }
     35 
     36 int main(void)
     37 {
     38     const int testval = -7;
     39     const int expected = 0;
     40     int ret = test(testval);
     41 
     42     if (ret != expected) {
     43         fprintf(stderr, "ERROR: test(%d) returned %d instead of %d\n",
     44                         testval, ret, expected);
     45         return 1;
     46     }
     47     printf("OK: test(%d) returned %d\n", testval, expected);
     48     return 0;
     49 }
     50