1 /*
2 * Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification,
5 * are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific prior written
16 * permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 #define OK 0
31 #define NOK 1
32
It_dynlink_dowhile(int cnt,int * out)33 void It_dynlink_dowhile(int cnt, int *out)
34 {
35 int outParam = 0;
36 cnt += 1;
37
38 do {
39 ++outParam;
40 --cnt;
41 } while (cnt);
42
43 *out = outParam;
44 }
45
It_dynlink_while(int cnt,int * out)46 void It_dynlink_while(int cnt, int *out)
47 {
48 int index = 0;
49 int outParam = 0;
50 cnt += 1;
51
52 while ((index++) < cnt) {
53 outParam += 1;
54 }
55
56 *out = outParam;
57 }
58
It_dynlink_for(int cnt,int * out)59 void It_dynlink_for(int cnt, int *out)
60 {
61 int index = 0;
62 int outParam = 0;
63 cnt += 1;
64
65 for (; index < cnt; ++index) {
66 ++outParam;
67 }
68
69 *out = outParam;
70 }
71
It_dynlink_ifelse(int inVal,int * outVal)72 void It_dynlink_ifelse(int inVal, int *outVal)
73 {
74 int outParam;
75
76 if (inVal <= 101) {
77 outParam = 101;
78 } else if (inVal == 102) {
79 outParam = inVal;
80 } else if (inVal == 103) {
81 outParam = inVal;
82 } else if (inVal == 104) {
83 outParam = inVal;
84 } else if (inVal == 105) {
85 outParam = inVal;
86 } else if (inVal == 106) {
87 outParam = inVal;
88 } else if (inVal == 107) {
89 outParam = inVal;
90 } else if (inVal == 108) {
91 outParam = inVal + 1;
92 } else if (inVal == 109) {
93 outParam = 45;
94 } else {
95 outParam = 45;
96 }
97
98 *outVal = outParam;
99 }
100
It_dynlink_continue(int cnt,int * out)101 void It_dynlink_continue(int cnt, int *out)
102 {
103 int index = 0;
104 int outParam = 0;
105 cnt += 2;
106
107 for (; index < cnt; ++index) {
108 if (index % 2) {
109 continue;
110 } else {
111 ++outParam;
112 }
113 }
114
115 *out = outParam;
116 }
117
It_dynlink_switch(char * inVal,char * outVal)118 void It_dynlink_switch(char *inVal, char *outVal)
119 {
120 int i;
121 char outParam;
122
123 for (i = 0; i < 3; ++i) {
124 switch (inVal[i]) {
125 case 'A':
126 case 'a':
127 outParam = 'b';
128 break;
129 case 'B':
130 case 'b':
131 outParam = 'c';
132 break;
133 case 'C':
134 case 'c':
135 outParam = 'd';
136 break;
137 case 'D':
138 case 'd':
139 outParam = 'e';
140 break;
141 case 'E':
142 case 'e':
143 outParam = 'f';
144 break;
145 case 'F':
146 case 'f':
147 outParam = 'g';
148 break;
149 case 'G':
150 case 'g':
151 outParam = 'h';
152 break;
153 case 'H':
154 case 'h':
155 outParam = 'i';
156 break;
157 default:
158 outParam = 'z';
159 break;
160 }
161 outVal[i] = outParam;
162 }
163 }
164