| Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2013 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 |  | 
| Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 17 | #include <stdio.h> | 
| Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 18 |  | 
|  | 19 | int test_level_four(int one, int two, int three, int four, | 
| Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 20 | void (*callback_func)(void*), void* data) { | 
| Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 21 | if (callback_func != NULL) { | 
| Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 22 | callback_func(data); | 
| Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 23 | } else { | 
|  | 24 | while (1) { | 
|  | 25 | } | 
|  | 26 | } | 
|  | 27 | return one + two + three + four; | 
|  | 28 | } | 
|  | 29 |  | 
|  | 30 | int test_level_three(int one, int two, int three, int four, | 
| Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 31 | void (*callback_func)(void*), void* data) { | 
|  | 32 | return test_level_four(one+3, two+6, three+9, four+12, callback_func, data) + 3; | 
| Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 33 | } | 
|  | 34 |  | 
|  | 35 | int test_level_two(int one, int two, int three, int four, | 
| Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 36 | void (*callback_func)(void*), void* data) { | 
|  | 37 | return test_level_three(one+2, two+4, three+6, four+8, callback_func, data) + 2; | 
| Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 38 | } | 
|  | 39 |  | 
|  | 40 | int test_level_one(int one, int two, int three, int four, | 
| Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 41 | void (*callback_func)(void*), void* data) { | 
|  | 42 | return test_level_two(one+1, two+2, three+3, four+4, callback_func, data) + 1; | 
| Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 43 | } | 
|  | 44 |  | 
| Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 45 | int test_recursive_call(int level, void (*callback_func)(void*), void* data) { | 
| Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 46 | if (level > 0) { | 
| Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 47 | return test_recursive_call(level - 1, callback_func, data) + level; | 
| Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 48 | } else if (callback_func != NULL) { | 
| Christopher Ferris | 17e91d4 | 2013-10-21 13:30:52 -0700 | [diff] [blame] | 49 | callback_func(data); | 
| Christopher Ferris | 7fb2287 | 2013-09-27 12:43:15 -0700 | [diff] [blame] | 50 | } else { | 
|  | 51 | while (1) { | 
|  | 52 | } | 
|  | 53 | } | 
|  | 54 | return 0; | 
|  | 55 | } |