1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/Codecs/Src/Gsm610CodecCommon/basicop.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,726 @@
1.4 +// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "basicop.h"
1.20 +
1.21 +/*
1.22 +** int2 add( int2 var1, int2 var2 )
1.23 +**
1.24 +** Function performs the addition (var1+var2) with overflow control
1.25 +** and saturation; the result is set at +32767 when overflow occurs
1.26 +** or at -32768 when underflow occurs
1.27 +**
1.28 +** Input:
1.29 +** var1, var2
1.30 +** 16-bit variables to be summed
1.31 +**
1.32 +** Output:
1.33 +** Sum of var and var2, see description above
1.34 +**
1.35 +** Return value:
1.36 +** See above
1.37 +*/
1.38 +/*
1.39 +** One way to implement saturation control to add and sub is to
1.40 +** use temporary result that has enough bits to make overflow
1.41 +** impossible and the limit the final result
1.42 +*/
1.43 +int2 add( int2 var1, int2 var2 )
1.44 +{
1.45 + int4 L_temp;
1.46 +
1.47 + L_temp = (int4) var1 + var2;
1.48 +
1.49 + if ( L_temp < MININT2 )
1.50 + return MININT2;
1.51 + else if ( L_temp > MAXINT2 )
1.52 + return MAXINT2;
1.53 + else
1.54 + return (int2) L_temp;
1.55 +}
1.56 +
1.57 +
1.58 +/*
1.59 +** int2 sub( int2 var1, int2 var2 )
1.60 +**
1.61 +** Function performs the subtraction (var1-var2) with overflow control
1.62 +** and saturation; the result is set at +32767 when overflow occurs
1.63 +** or at -32768 when underflow occurs
1.64 +**
1.65 +** Input:
1.66 +** var1, var2
1.67 +** 16-bit variables to be summed
1.68 +**
1.69 +** Output:
1.70 +** Sum of var and var2, see description above
1.71 +**
1.72 +** Return value:
1.73 +** See above
1.74 +*/
1.75 +int2 sub( int2 var1, int2 var2 )
1.76 +{
1.77 + int4 L_temp;
1.78 +
1.79 + L_temp = (int4) var1 - var2;
1.80 +
1.81 + if ( L_temp < MININT2 )
1.82 + return MININT2;
1.83 + else if ( L_temp > MAXINT2 )
1.84 + return MAXINT2;
1.85 + else
1.86 + return (int2) L_temp;
1.87 +}
1.88 +
1.89 +
1.90 +
1.91 +/*
1.92 +** int2 mult( int2 var1, int2 var2 )
1.93 +**
1.94 +** Function performs the multiplication of var1 by var2 and gives a
1.95 +** 16-bit result which is scaled ie
1.96 +** mult( var1, var2 ) = (var1 times var2) >> 15
1.97 +** and
1.98 +** mult( -32768, -32768 ) = 32767
1.99 +**
1.100 +** Input:
1.101 +** var1, var2
1.102 +** 16-bit variables to be multiplied
1.103 +**
1.104 +** Output:
1.105 +** Scaled result of multiplication
1.106 +**
1.107 +** Return value:
1.108 +** See above
1.109 +*/
1.110 +int2 mult( int2 var1, int2 var2 )
1.111 +{
1.112 + if ( ( var1 == MININT2 ) && ( var1 == var2 ) )
1.113 + return MAXINT2;
1.114 + else
1.115 + /* Note int4 cast of var1 to force 32-bit arithmetic */
1.116 + return( (int2) ( ( (int4) var1 * var2 ) >> 15 ) );
1.117 +}
1.118 +
1.119 +
1.120 +/*
1.121 +** int2 abs_s( int2 var1 )
1.122 +**
1.123 +** Function returns absolute value of var1 with possible saturation:
1.124 +** abs( -32768 ) = 32767
1.125 +**
1.126 +** Input:
1.127 +** var1
1.128 +** 16-bit variable
1.129 +**
1.130 +** Output:
1.131 +** absolute value of var1
1.132 +**
1.133 +** Return value:
1.134 +** See above
1.135 +*/
1.136 +int2 abs_s( int2 var1 )
1.137 +{
1.138 + if ( var1 == MININT2 )
1.139 + return MAXINT2;
1.140 + else
1.141 + return ( var1 > 0 ) ? var1 : int2 (-var1);
1.142 +}
1.143 +
1.144 +
1.145 +#ifdef L_MULTF
1.146 +/* else implemented using macro (basicop.h) */
1.147 +
1.148 +/*
1.149 +** int4 L_mult( int2 var1, int2 var2 )
1.150 +**
1.151 +** Function performs the multiplication of var1 by var2 and gives a
1.152 +** 32-bit result which is scaled by shifting result one bit left ie
1.153 +** L_mult( var1, var2 ) = (var1 times var2) << 1
1.154 +**
1.155 +** L_mult( -32768, -32768 ) does not occur in algorithm
1.156 +**
1.157 +** Input:
1.158 +** var1, var2
1.159 +** 16-bit variables to be multiplied
1.160 +**
1.161 +** Output:
1.162 +** Scaled result of multiplication
1.163 +**
1.164 +** Return value:
1.165 +** See above
1.166 +*/
1.167 +int4 L_mult( int2 var1, int2 var2 )
1.168 +{
1.169 + /* Note int4 cast of var1 to force 32-bit arithmetic */
1.170 + return ( L_shl( (int4) var1 * var2 ), 1 );
1.171 +}
1.172 +#endif /* L_MULTF */
1.173 +
1.174 +
1.175 +
1.176 +/*
1.177 +** int2 shr( int2 var1, int2 var2 )
1.178 +**
1.179 +** Function makes arithmetic var2-bit shift right of var1. If var2 is
1.180 +** less than 0, this operation becomes arithmetic left shift of -var2
1.181 +**
1.182 +** Input:
1.183 +** var1
1.184 +** 16-bit variable to be shifted
1.185 +** var2
1.186 +** amount of bits to be shifted
1.187 +**
1.188 +** Output:
1.189 +** 16-bit value of shifted var1 is returned
1.190 +**
1.191 +** Return value:
1.192 +** See above
1.193 +*/
1.194 +int2 shr( int2 var1, int2 var2 )
1.195 +{
1.196 + return shl( var1, int2 (-var2) );
1.197 +}
1.198 +
1.199 +
1.200 +/*
1.201 +** int2 negate( int2 var1 )
1.202 +**
1.203 +** Function negates 16-bit variable var1.
1.204 +** negate( -32768 ) = 32767
1.205 +**
1.206 +** Input:
1.207 +** var1
1.208 +** 16-bit variable to be negated
1.209 +**
1.210 +** Output:
1.211 +** negated var1
1.212 +**
1.213 +** Return value:
1.214 +** See above
1.215 +*/
1.216 +int2 negate( int2 var1 )
1.217 +{
1.218 + if ( var1 == MININT2 )
1.219 + return MAXINT2;
1.220 + else
1.221 + return int2 (-var1);
1.222 +}
1.223 +
1.224 +
1.225 +/*
1.226 +** int2 extract_h( int4 L_var1 )
1.227 +**
1.228 +** Function returns upper word (16 most significat bits) of the
1.229 +** 32-bit variable L_var1
1.230 +**
1.231 +** Input:
1.232 +** L_var1
1.233 +** 32-bit variable
1.234 +**
1.235 +** Output:
1.236 +** upper word of the L_var1
1.237 +**
1.238 +** Return value:
1.239 +** See above
1.240 +*/
1.241 +int2 extract_h( int4 L_var1 )
1.242 +{
1.243 + return (int2) ( L_var1 >> 16 );
1.244 +}
1.245 +
1.246 +
1.247 +/*
1.248 +** int2 extract_l( int4 L_var1 )
1.249 +**
1.250 +** Function returns lower word (16 least significat bits) of the
1.251 +** 32-bit variable L_var1
1.252 +**
1.253 +** Input:
1.254 +** L_var1
1.255 +** 32-bit variable
1.256 +**
1.257 +** Output:
1.258 +** lower word of L_var1
1.259 +**
1.260 +** Return value:
1.261 +** See above
1.262 +*/
1.263 +int2 extract_l( int4 L_var1 )
1.264 +{
1.265 + return (int2) (L_var1 & 0x0000ffff);
1.266 +}
1.267 +
1.268 +
1.269 +/*
1.270 +** int4 L_mac( int4 L_var3, int2 var1, int2 var2 )
1.271 +**
1.272 +** Function multiplies var1 by var2 and shifts result left by one bit.
1.273 +** Shifted result of multiplication is then added to L_var3 and result
1.274 +** is returned. Summation is done with overflow control and saturation;
1.275 +** the result is set at 2147483647 when overflow occurs and at
1.276 +** -2147483648 when underflow occurs
1.277 +**
1.278 +** Input:
1.279 +** var1
1.280 +** 16-bit multiplicant
1.281 +** var2
1.282 +** 16-bit multiplier
1.283 +**
1.284 +** L_var3
1.285 +** 32-bit number that is summed with (var1*var2)<<1
1.286 +**
1.287 +** Output:
1.288 +** See description above
1.289 +**
1.290 +** Return value:
1.291 +** See above
1.292 +*/
1.293 +int4 L_mac( int4 L_var3, int2 var1, int2 var2 )
1.294 +{
1.295 + int4 L_temp;
1.296 +
1.297 + L_temp = ( (int4) var1 * var2 ) << 1;
1.298 + return L_add( L_var3, L_temp );
1.299 +}
1.300 +
1.301 +
1.302 +/*
1.303 +** int4 L_add( int4 L_var1, int4 L_var2 )
1.304 +**
1.305 +** Function performs 32-bit addition of two 32-bit variables
1.306 +** (L_var1 + L_var2) with overflow control and saturation; the
1.307 +** result is set at 2147483647 when overflow occurs and at
1.308 +** -2147483648 when underflow occurs
1.309 +**
1.310 +** Input:
1.311 +** L_var1, L_var2
1.312 +** 32-bit variables to be summed
1.313 +**
1.314 +** Output:
1.315 +** 32-bit result, see description above
1.316 +**
1.317 +** Return value:
1.318 +** See above
1.319 +*/
1.320 +int4 L_add( int4 L_var1, int4 L_var2 )
1.321 +{
1.322 + int4 L_temp1;
1.323 + int temp2; /* used for storing sign of L_var1 */
1.324 +
1.325 + L_temp1 = L_var1 + L_var2;
1.326 +
1.327 + /*
1.328 + * Overflow
1.329 + * if sign(L_var1)==sign(L_var2) && sign(L_var1)!=sign(L_temp1).
1.330 + */
1.331 +
1.332 + if ( ( temp2 = (L_var1 < 0) ) == ( L_var2 < 0 )
1.333 + && ( temp2 != ( L_temp1 < 0 ) ) ) {
1.334 + L_temp1 = temp2 ? MININT4 : MAXINT4;
1.335 + }
1.336 +
1.337 + return L_temp1;
1.338 +}
1.339 +
1.340 +
1.341 +/*
1.342 +** int4 L_sub( int4 L_var1, int4 L_var2 )
1.343 +**
1.344 +** Function performs 32-bit subtraction of two 32-bit variables
1.345 +** (L_var1 - L_var2) with overflow control and saturation; the
1.346 +** result is set at 2147483647 when overflow occurs and at
1.347 +** -2147483648 when underflow occurs
1.348 +**
1.349 +** Input:
1.350 +** L_var1, L_var2
1.351 +** 32-bit variables to be summed
1.352 +**
1.353 +** Output:
1.354 +** 32-bit result, see description above
1.355 +**
1.356 +** Return value:
1.357 +** See above
1.358 +*/
1.359 +int4 L_sub( int4 L_var1, int4 L_var2 )
1.360 +{
1.361 + int4 L_temp1;
1.362 + int temp2;
1.363 +
1.364 + L_temp1 = L_var1 - L_var2;
1.365 +
1.366 + /*
1.367 + * Overflow
1.368 + * if sign(L_var1)!=sign(L_var2) && sign(L_var1)!=sign(L_temp).
1.369 + */
1.370 +
1.371 + if ( ( temp2 = ( L_var1 < 0 ) ) != ( L_var2 < 0 )
1.372 + && ( temp2 != ( L_temp1 < 0 ) ) ) {
1.373 + L_temp1 = temp2 ? MININT4 : MAXINT4;
1.374 + }
1.375 +
1.376 + return L_temp1;
1.377 +}
1.378 +
1.379 +
1.380 +/*
1.381 +** int2 mult_r( int2 var1, int2 var2 )
1.382 +**
1.383 +** Function performs the multiplication of var1 by var2 and gives a
1.384 +** 16-bit result which is scaled with rounding ie
1.385 +** mult_r(var1, var2) = ((var1 times var2) + 16384) >> 15
1.386 +** and
1.387 +** mult_r( -32768, -32768 ) = 32767
1.388 +**
1.389 +** Input:
1.390 +** var1, var2
1.391 +** 16-bit variables to be multiplied
1.392 +**
1.393 +** Output:
1.394 +** 16-bit scaled result of multiplication
1.395 +**
1.396 +** Return value:
1.397 +** See above
1.398 +*/
1.399 +int2 mult_r( int2 var1, int2 var2 )
1.400 +{
1.401 + if ( ( var1 == MININT2 ) && ( var1 == var2 ) )
1.402 + return MAXINT2;
1.403 + else
1.404 + /* Note int4 cast of var1 to force 32-bit arithmetic */
1.405 + return( (int2) ( ( (int4) var1 * var2 + (int4) 16384 ) >> 15 ) );
1.406 +}
1.407 +
1.408 +/*
1.409 +** int4 L_shr( int4 L_var1, int2 var2 )
1.410 +**
1.411 +** Function makes arithmetic var2-bit shift right of var1. If var2 is
1.412 +** less than 0, this operation becomes arithmetic left shift of -var2
1.413 +**
1.414 +** Input:
1.415 +** L_var1
1.416 +** 32-bit variable to be shifted
1.417 +** var2
1.418 +** amount of bits to be shifted
1.419 +**
1.420 +** Output:
1.421 +** 16-bit value of shifted var1
1.422 +**
1.423 +** Return value:
1.424 +** See above
1.425 +*/
1.426 +int4 L_shr( int4 L_var1, int2 var2 )
1.427 +{
1.428 + return L_shl( L_var1, int2 (-var2) );
1.429 +}
1.430 +
1.431 +
1.432 +/*
1.433 +** int4 L_deposit_h( int2 var1 )
1.434 +**
1.435 +** Function deposits the 16-bit variable var1 into the 16 most
1.436 +** significant bits of the 32-bit word. The 16 least significant
1.437 +** bits of the result are zeroed.
1.438 +**
1.439 +** Input:
1.440 +** var1
1.441 +** 16-bit variable to be loaded to the upper 16 bits of
1.442 +** of the 32-bit variable
1.443 +**
1.444 +** Output:
1.445 +** 32-bit number, see description above
1.446 +**
1.447 +** Return value:
1.448 +** See above
1.449 +*/
1.450 +int4 L_deposit_h( int2 var1 )
1.451 +{
1.452 + return ( (int4) var1 ) << 16;
1.453 +}
1.454 +
1.455 +
1.456 +/*
1.457 +** int4 L_deposit_l( int2 var1 )
1.458 +**
1.459 +** Function deposits the 16-bit variable var1 into the 16 least
1.460 +** significant bits of the 32-bit word. The 16 most significant bits
1.461 +** of the result are sign extended.
1.462 +**
1.463 +** Input:
1.464 +** var1
1.465 +** 16-bit variable to be converted to 32-bit variable
1.466 +**
1.467 +** Output:
1.468 +** 32-bit variable that has same magnitude than var1
1.469 +**
1.470 +** Return value:
1.471 +** See above
1.472 +*/
1.473 +int4 L_deposit_l( int2 var1 )
1.474 +{
1.475 + return (int4) var1;
1.476 +}
1.477 +
1.478 +
1.479 +/*
1.480 +** int2 norm_s( int2 var1 )
1.481 +**
1.482 +** Function produces number of left shifts needed to normalize the
1.483 +** 16-bit variable var1 for positive values on the interval with
1.484 +** minimum of 16384 and maximum of 32767 and for negative
1.485 +** values on the interval with minimum of -32768 and maximum of
1.486 +** -16384; in order to normalize the result, the following
1.487 +** operation must be done:
1.488 +** norm_var1 = var1 << norm_s(var1)
1.489 +**
1.490 +** Input:
1.491 +** var1
1.492 +** 16-bit variable which normalization factor is solved
1.493 +**
1.494 +** Output:
1.495 +** see description above
1.496 +**
1.497 +** Return value:
1.498 +** See above
1.499 +*/
1.500 +int2 norm_s( int2 var1 )
1.501 +{
1.502 + int2 cntr = 0;
1.503 +
1.504 + /* Special case when L_var1 == -32768: shift leads to underflow */
1.505 + if ( var1 == MININT2 )
1.506 + return 0;
1.507 + /* Special case when var1 == 0: shift does not change the value */
1.508 + else if ( var1 == 0 )
1.509 + return 0;
1.510 + else {
1.511 + if ( var1 < 0 ) {
1.512 + for ( ; var1 >= -16384; var1 *= 2 )
1.513 + cntr++;
1.514 + }
1.515 + else {
1.516 + for ( ; var1 < 16384; var1 <<= 1 )
1.517 + cntr++;
1.518 + }
1.519 +
1.520 + return cntr;
1.521 + }
1.522 +}
1.523 +
1.524 +
1.525 +/*
1.526 +** int2 norm_l( int4 L_var1 )
1.527 +**
1.528 +** Function produces number of left shifts needed to normalize the
1.529 +** 32-bit variable L_var1 for positive values on the interval with
1.530 +** minimum of 1073741824 and maximum of 2147483647 and for negative
1.531 +** values on the interval with minimum of -2147483648 and maximum of
1.532 +** -1073741824; in order to normalize the result, the following
1.533 +** operation must be done:
1.534 +** L_norm_var1 = L_var1 << norm_l(L_var1)
1.535 +**
1.536 +** Input:
1.537 +** L_var1
1.538 +** 32-bit variable which normalization factor is solved
1.539 +**
1.540 +** Output:
1.541 +** see description above
1.542 +**
1.543 +** Return value:
1.544 +** See above
1.545 +*/
1.546 +int2 norm_l( int4 L_var1 )
1.547 +{
1.548 + int2 cntr = 0;
1.549 +
1.550 + /* Special case when L_var1 == -2147483648: shift leads to underflow */
1.551 + if ( L_var1 == MININT4 )
1.552 + return 0;
1.553 + /* Special case when L_var1 == 0: shift does not change the value */
1.554 + else if ( L_var1 == 0 )
1.555 + return 0;
1.556 + else {
1.557 + if ( L_var1 < 0 ) {
1.558 + for ( ; L_var1 >= (int4) -1073741824L; L_var1 *= 2 )
1.559 + cntr++;
1.560 + }
1.561 + else {
1.562 + for ( ; L_var1 < (int4) 1073741824L; L_var1 <<= 1 )
1.563 + cntr++;
1.564 + }
1.565 +
1.566 + return cntr;
1.567 + }
1.568 +}
1.569 +
1.570 +
1.571 +/*
1.572 +** int2 div_s( int2 num, int2 denum )
1.573 +**
1.574 +** Function produces a result which is the fractional integer division
1.575 +** of var1 by var2; var1 and var2 must be positive and var2 must be
1.576 +** greater or equal to var1; The result is positive (leading bit equal
1.577 +** to 0) and truncated to 16 bits. If var1 == var2 then
1.578 +** div_s( var1, var2 ) = 32767
1.579 +**
1.580 +** Input:
1.581 +** L_var1
1.582 +** 32-bit variable which normalization factor is solved
1.583 +**
1.584 +** Output:
1.585 +** 16-bit result, see description above
1.586 +**
1.587 +** Return value:
1.588 +** See above
1.589 +*/
1.590 +int2 div_s( int2 num, int2 denum )
1.591 +{
1.592 + if ( num == denum )
1.593 + return MAXINT2;
1.594 + else
1.595 + return (int2) ( ( ( (int4) num ) << 15 ) / denum );
1.596 +}
1.597 +
1.598 +
1.599 +/*
1.600 +** int2 shl( int2 var1, int2 var2 )
1.601 +**
1.602 +** Function makes arithmetic var2-bit shift left of var1. If var2 is
1.603 +** less than 0, this operation becomes arithmetic right shift of -var2
1.604 +**
1.605 +** Input:
1.606 +** var1
1.607 +** 16-bit variable to be shifted
1.608 +** var2
1.609 +** amount of bits to be shifted
1.610 +**
1.611 +** Output:
1.612 +** 16-bit value of shifted var1 is retuned
1.613 +**
1.614 +** Return value:
1.615 +** See above
1.616 +**
1.617 +** Notes:
1.618 +** ANSI C does not guarantee that right shift is arithmetical
1.619 +** (that sign extension is done during shifting). That is why in this
1.620 +** routine negative values are complemented before shifting.
1.621 +*/
1.622 +int2 shl( int2 var1, int2 var2 )
1.623 +{
1.624 + int2 result;
1.625 +
1.626 + if ( ( var1 == 0 ) || ( var2 == 0 ) ) {
1.627 + result = var1;
1.628 + }
1.629 +
1.630 + /* var2 > 0: Perform left shift */
1.631 + else if ( var2 > 0 ) {
1.632 + if ( var2 >= 15 ) {
1.633 + result = ( var1 < 0 ) ? int2(MININT2) : int2(MAXINT2);
1.634 + }
1.635 + else {
1.636 +
1.637 + int4 L_temp;
1.638 +
1.639 + L_temp = (int4) var1 << var2;
1.640 + if ( L_temp < MININT2 ) {
1.641 + result = MININT2;
1.642 + }
1.643 + else if ( L_temp > MAXINT2 ) {
1.644 + result = MAXINT2;
1.645 + }
1.646 + else {
1.647 + result = (int2) L_temp;
1.648 + }
1.649 + }
1.650 + }
1.651 + /* var2 < 0: Perform right shift */
1.652 + else {
1.653 + if ( -var2 >= 15 ) {
1.654 + result = ( var1 < 0 ) ? int2 (-1) : int2 (0);
1.655 + }
1.656 + else if ( var1 < 0 ) {
1.657 + result = int2 (~( (~var1) >> -var2 )); /* ~ used to ensure arith. shift */
1.658 + }
1.659 + else {
1.660 + result = int2 (var1 >> -var2);
1.661 + }
1.662 + }
1.663 +
1.664 + return result;
1.665 +
1.666 +}
1.667 +
1.668 +
1.669 +/*
1.670 +** int4 L_shl( int4 L_var1, int2 var2 )
1.671 +**
1.672 +** Function makes arithmetic var2-bit shift left of var1. If var2 is
1.673 +** less than 0, this operation becomes arithmetic right shift of -var2
1.674 +**
1.675 +** Input:
1.676 +** L_var1
1.677 +** 32-bit variable to be shifted
1.678 +** var2
1.679 +** amount of bits to be shifted
1.680 +**
1.681 +** Output:
1.682 +** 32-bit value of shifted var1 is retuned
1.683 +**
1.684 +** Return value:
1.685 +** See above
1.686 +**
1.687 +** Notes:
1.688 +** ANSI C does not guarantee that right shift is arithmetical
1.689 +** (that sign extension is done during shifting). That is why in this
1.690 +** routine negative values are complemented before shifting.
1.691 +*/
1.692 +
1.693 +int4 L_shl(int4 L_var1, int2 var2 )
1.694 +{
1.695 + if ( ( L_var1 == 0L ) || ( var2 == 0 ) ) {
1.696 + return L_var1;
1.697 + }
1.698 + /* var2 > 0: Perform left shift */
1.699 + else if ( var2 > 0 ) {
1.700 + if ( var2 >= 31 ) {
1.701 + return ( L_var1 < 0 ) ? MININT4 : MAXINT4;
1.702 + }
1.703 + else {
1.704 + for( ; var2 > 0; var2-- ) {
1.705 + if ( L_var1 > (MAXINT4 >> 1) )
1.706 + return MAXINT4;
1.707 + else if ( L_var1 < (MININT4 / 2) )
1.708 + return MININT4;
1.709 + else
1.710 + L_var1 *= 2;
1.711 + }
1.712 + return L_var1;
1.713 + }
1.714 + }
1.715 + /* var2 < 0: Perform right shift */
1.716 + else {
1.717 + if ( -var2 >= 31 ) {
1.718 + return ( L_var1 < 0 ) ? -1L : 0L;
1.719 + }
1.720 + else if ( L_var1 < 0 ) {
1.721 + return ~( (~L_var1) >> -var2 ); /* ~ used to ensure arith. shift */
1.722 + }
1.723 + else {
1.724 + return L_var1 >> -var2;
1.725 + }
1.726 + }
1.727 +
1.728 +}
1.729 +