gst_plugins_base/gst/audioresample/fixed_debug.h
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
     1 /* Copyright (C) 2003 Jean-Marc Valin */
       
     2 /**
       
     3    @file fixed_debug.h
       
     4    @brief Fixed-point operations with debugging
       
     5 */
       
     6 /*
       
     7    Redistribution and use in source and binary forms, with or without
       
     8    modification, are permitted provided that the following conditions
       
     9    are met:
       
    10    
       
    11    - Redistributions of source code must retain the above copyright
       
    12    notice, this list of conditions and the following disclaimer.
       
    13    
       
    14    - Redistributions in binary form must reproduce the above copyright
       
    15    notice, this list of conditions and the following disclaimer in the
       
    16    documentation and/or other materials provided with the distribution.
       
    17    
       
    18    - Neither the name of the Xiph.org Foundation nor the names of its
       
    19    contributors may be used to endorse or promote products derived from
       
    20    this software without specific prior written permission.
       
    21    
       
    22    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
       
    23    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
       
    24    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
       
    25    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
       
    26    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
       
    27    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
       
    28    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
       
    29    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
       
    30    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
       
    31    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
       
    32    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    33 */
       
    34 
       
    35 #ifndef FIXED_DEBUG_H
       
    36 #define FIXED_DEBUG_H
       
    37 
       
    38 #include <stdio.h>
       
    39 
       
    40 extern long long spx_mips;
       
    41 #define MIPS_INC spx_mips++,
       
    42 
       
    43 #define QCONST16(x,bits) ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
       
    44 #define QCONST32(x,bits) ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
       
    45 
       
    46 
       
    47 #define VERIFY_SHORT(x) ((x)<=32767&&(x)>=-32768)
       
    48 #define VERIFY_INT(x) ((x)<=2147483647LL&&(x)>=-2147483648LL)
       
    49 
       
    50 static inline short
       
    51 NEG16 (int x)
       
    52 {
       
    53   int res;
       
    54   if (!VERIFY_SHORT (x)) {
       
    55     fprintf (stderr, "NEG16: input is not short: %d\n", (int) x);
       
    56   }
       
    57   res = -x;
       
    58   if (!VERIFY_SHORT (res))
       
    59     fprintf (stderr, "NEG16: output is not short: %d\n", (int) res);
       
    60   spx_mips++;
       
    61   return res;
       
    62 }
       
    63 
       
    64 static inline int
       
    65 NEG32 (long long x)
       
    66 {
       
    67   long long res;
       
    68   if (!VERIFY_INT (x)) {
       
    69     fprintf (stderr, "NEG16: input is not int: %d\n", (int) x);
       
    70   }
       
    71   res = -x;
       
    72   if (!VERIFY_INT (res))
       
    73     fprintf (stderr, "NEG16: output is not int: %d\n", (int) res);
       
    74   spx_mips++;
       
    75   return res;
       
    76 }
       
    77 
       
    78 #define EXTRACT16(x) _EXTRACT16(x, __FILE__, __LINE__)
       
    79 static inline short
       
    80 _EXTRACT16 (int x, char *file, int line)
       
    81 {
       
    82   int res;
       
    83   if (!VERIFY_SHORT (x)) {
       
    84     fprintf (stderr, "EXTRACT16: input is not short: %d in %s: line %d\n", x,
       
    85         file, line);
       
    86   }
       
    87   res = x;
       
    88   spx_mips++;
       
    89   return res;
       
    90 }
       
    91 
       
    92 #define EXTEND32(x) _EXTEND32(x, __FILE__, __LINE__)
       
    93 static inline int
       
    94 _EXTEND32 (int x, char *file, int line)
       
    95 {
       
    96   int res;
       
    97   if (!VERIFY_SHORT (x)) {
       
    98     fprintf (stderr, "EXTEND32: input is not short: %d in %s: line %d\n", x,
       
    99         file, line);
       
   100   }
       
   101   res = x;
       
   102   spx_mips++;
       
   103   return res;
       
   104 }
       
   105 
       
   106 #define SHR16(a, shift) _SHR16(a, shift, __FILE__, __LINE__)
       
   107 static inline short
       
   108 _SHR16 (int a, int shift, char *file, int line)
       
   109 {
       
   110   int res;
       
   111   if (!VERIFY_SHORT (a) || !VERIFY_SHORT (shift)) {
       
   112     fprintf (stderr, "SHR16: inputs are not short: %d >> %d in %s: line %d\n",
       
   113         a, shift, file, line);
       
   114   }
       
   115   res = a >> shift;
       
   116   if (!VERIFY_SHORT (res))
       
   117     fprintf (stderr, "SHR16: output is not short: %d in %s: line %d\n", res,
       
   118         file, line);
       
   119   spx_mips++;
       
   120   return res;
       
   121 }
       
   122 
       
   123 #define SHL16(a, shift) _SHL16(a, shift, __FILE__, __LINE__)
       
   124 static inline short
       
   125 _SHL16 (int a, int shift, char *file, int line)
       
   126 {
       
   127   int res;
       
   128   if (!VERIFY_SHORT (a) || !VERIFY_SHORT (shift)) {
       
   129     fprintf (stderr, "SHL16: inputs are not short: %d %d in %s: line %d\n", a,
       
   130         shift, file, line);
       
   131   }
       
   132   res = a << shift;
       
   133   if (!VERIFY_SHORT (res))
       
   134     fprintf (stderr, "SHL16: output is not short: %d in %s: line %d\n", res,
       
   135         file, line);
       
   136   spx_mips++;
       
   137   return res;
       
   138 }
       
   139 
       
   140 static inline int
       
   141 SHR32 (long long a, int shift)
       
   142 {
       
   143   long long res;
       
   144   if (!VERIFY_INT (a) || !VERIFY_SHORT (shift)) {
       
   145     fprintf (stderr, "SHR32: inputs are not int: %d %d\n", (int) a, shift);
       
   146   }
       
   147   res = a >> shift;
       
   148   if (!VERIFY_INT (res)) {
       
   149     fprintf (stderr, "SHR32: output is not int: %d\n", (int) res);
       
   150   }
       
   151   spx_mips++;
       
   152   return res;
       
   153 }
       
   154 
       
   155 static inline int
       
   156 SHL32 (long long a, int shift)
       
   157 {
       
   158   long long res;
       
   159   if (!VERIFY_INT (a) || !VERIFY_SHORT (shift)) {
       
   160     fprintf (stderr, "SHL32: inputs are not int: %d %d\n", (int) a, shift);
       
   161   }
       
   162   res = a << shift;
       
   163   if (!VERIFY_INT (res)) {
       
   164     fprintf (stderr, "SHL32: output is not int: %d\n", (int) res);
       
   165   }
       
   166   spx_mips++;
       
   167   return res;
       
   168 }
       
   169 
       
   170 #define PSHR16(a,shift) (SHR16(ADD16((a),((1<<((shift))>>1))),shift))
       
   171 #define PSHR32(a,shift) (SHR32(ADD32((a),((EXTEND32(1)<<((shift))>>1))),shift))
       
   172 #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift)))
       
   173 
       
   174 #define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
       
   175 #define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
       
   176 
       
   177 //#define SHR(a,shift) ((a) >> (shift))
       
   178 //#define SHL(a,shift) ((a) << (shift))
       
   179 
       
   180 #define ADD16(a, b) _ADD16(a, b, __FILE__, __LINE__)
       
   181 static inline short
       
   182 _ADD16 (int a, int b, char *file, int line)
       
   183 {
       
   184   int res;
       
   185   if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
       
   186     fprintf (stderr, "ADD16: inputs are not short: %d %d in %s: line %d\n", a,
       
   187         b, file, line);
       
   188   }
       
   189   res = a + b;
       
   190   if (!VERIFY_SHORT (res)) {
       
   191     fprintf (stderr, "ADD16: output is not short: %d+%d=%d in %s: line %d\n", a,
       
   192         b, res, file, line);
       
   193   }
       
   194   spx_mips++;
       
   195   return res;
       
   196 }
       
   197 
       
   198 #define SUB16(a, b) _SUB16(a, b, __FILE__, __LINE__)
       
   199 static inline short
       
   200 _SUB16 (int a, int b, char *file, int line)
       
   201 {
       
   202   int res;
       
   203   if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
       
   204     fprintf (stderr, "SUB16: inputs are not short: %d %d in %s: line %d\n", a,
       
   205         b, file, line);
       
   206   }
       
   207   res = a - b;
       
   208   if (!VERIFY_SHORT (res))
       
   209     fprintf (stderr, "SUB16: output is not short: %d in %s: line %d\n", res,
       
   210         file, line);
       
   211   spx_mips++;
       
   212   return res;
       
   213 }
       
   214 
       
   215 #define ADD32(a, b) _ADD32(a, b, __FILE__, __LINE__)
       
   216 static inline int
       
   217 _ADD32 (long long a, long long b, char *file, int line)
       
   218 {
       
   219   long long res;
       
   220   if (!VERIFY_INT (a) || !VERIFY_INT (b)) {
       
   221     fprintf (stderr, "ADD32: inputs are not int: %d %d in %s: line %d\n",
       
   222         (int) a, (int) b, file, line);
       
   223   }
       
   224   res = a + b;
       
   225   if (!VERIFY_INT (res)) {
       
   226     fprintf (stderr, "ADD32: output is not int: %d in %s: line %d\n", (int) res,
       
   227         file, line);
       
   228   }
       
   229   spx_mips++;
       
   230   return res;
       
   231 }
       
   232 
       
   233 static inline int
       
   234 SUB32 (long long a, long long b)
       
   235 {
       
   236   long long res;
       
   237   if (!VERIFY_INT (a) || !VERIFY_INT (b)) {
       
   238     fprintf (stderr, "SUB32: inputs are not int: %d %d\n", (int) a, (int) b);
       
   239   }
       
   240   res = a - b;
       
   241   if (!VERIFY_INT (res))
       
   242     fprintf (stderr, "SUB32: output is not int: %d\n", (int) res);
       
   243   spx_mips++;
       
   244   return res;
       
   245 }
       
   246 
       
   247 #define ADD64(a,b) (MIPS_INC(a)+(b))
       
   248 
       
   249 /* result fits in 16 bits */
       
   250 static inline short
       
   251 MULT16_16_16 (int a, int b)
       
   252 {
       
   253   int res;
       
   254   if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
       
   255     fprintf (stderr, "MULT16_16_16: inputs are not short: %d %d\n", a, b);
       
   256   }
       
   257   res = a * b;
       
   258   if (!VERIFY_SHORT (res))
       
   259     fprintf (stderr, "MULT16_16_16: output is not short: %d\n", res);
       
   260   spx_mips++;
       
   261   return res;
       
   262 }
       
   263 
       
   264 #define MULT16_16(a, b) _MULT16_16(a, b, __FILE__, __LINE__)
       
   265 static inline int
       
   266 _MULT16_16 (int a, int b, char *file, int line)
       
   267 {
       
   268   long long res;
       
   269   if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
       
   270     fprintf (stderr, "MULT16_16: inputs are not short: %d %d in %s: line %d\n",
       
   271         a, b, file, line);
       
   272   }
       
   273   res = ((long long) a) * b;
       
   274   if (!VERIFY_INT (res))
       
   275     fprintf (stderr, "MULT16_16: output is not int: %d in %s: line %d\n",
       
   276         (int) res, file, line);
       
   277   spx_mips++;
       
   278   return res;
       
   279 }
       
   280 
       
   281 #define MAC16_16(c,a,b)     (spx_mips--,ADD32((c),MULT16_16((a),(b))))
       
   282 #define MAC16_16_Q11(c,a,b)     (EXTRACT16(ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),11)))))
       
   283 #define MAC16_16_Q13(c,a,b)     (EXTRACT16(ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),13)))))
       
   284 #define MAC16_16_P13(c,a,b)     (EXTRACT16(ADD32((c),SHR32(ADD32(4096,MULT16_16((a),(b))),13))))
       
   285 
       
   286 
       
   287 #define MULT16_32_QX(a, b, Q) _MULT16_32_QX(a, b, Q, __FILE__, __LINE__)
       
   288 static inline int
       
   289 _MULT16_32_QX (int a, long long b, int Q, char *file, int line)
       
   290 {
       
   291   long long res;
       
   292   if (!VERIFY_SHORT (a) || !VERIFY_INT (b)) {
       
   293     fprintf (stderr,
       
   294         "MULT16_32_Q%d: inputs are not short+int: %d %d in %s: line %d\n", Q,
       
   295         (int) a, (int) b, file, line);
       
   296   }
       
   297   if (ABS32 (b) >= (EXTEND32 (1) << (15 + Q)))
       
   298     fprintf (stderr,
       
   299         "MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n", Q,
       
   300         (int) a, (int) b, file, line);
       
   301   res = (((long long) a) * (long long) b) >> Q;
       
   302   if (!VERIFY_INT (res))
       
   303     fprintf (stderr,
       
   304         "MULT16_32_Q%d: output is not int: %d*%d=%d in %s: line %d\n", Q,
       
   305         (int) a, (int) b, (int) res, file, line);
       
   306   spx_mips += 5;
       
   307   return res;
       
   308 }
       
   309 
       
   310 static inline int
       
   311 MULT16_32_PX (int a, long long b, int Q)
       
   312 {
       
   313   long long res;
       
   314   if (!VERIFY_SHORT (a) || !VERIFY_INT (b)) {
       
   315     fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d\n", Q,
       
   316         (int) a, (int) b);
       
   317   }
       
   318   if (ABS32 (b) >= (EXTEND32 (1) << (15 + Q)))
       
   319     fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d\n", Q,
       
   320         (int) a, (int) b);
       
   321   res = ((((long long) a) * (long long) b) + ((EXTEND32 (1) << Q) >> 1)) >> Q;
       
   322   if (!VERIFY_INT (res))
       
   323     fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d\n", Q, (int) a,
       
   324         (int) b, (int) res);
       
   325   spx_mips += 5;
       
   326   return res;
       
   327 }
       
   328 
       
   329 
       
   330 #define MULT16_32_Q11(a,b) MULT16_32_QX(a,b,11)
       
   331 #define MAC16_32_Q11(c,a,b) ADD32((c),MULT16_32_Q11((a),(b)))
       
   332 #define MULT16_32_Q12(a,b) MULT16_32_QX(a,b,12)
       
   333 #define MULT16_32_Q13(a,b) MULT16_32_QX(a,b,13)
       
   334 #define MULT16_32_Q14(a,b) MULT16_32_QX(a,b,14)
       
   335 #define MULT16_32_Q15(a,b) MULT16_32_QX(a,b,15)
       
   336 #define MULT16_32_P15(a,b) MULT16_32_PX(a,b,15)
       
   337 #define MAC16_32_Q15(c,a,b) ADD32((c),MULT16_32_Q15((a),(b)))
       
   338 
       
   339 static inline int
       
   340 SATURATE (int a, int b)
       
   341 {
       
   342   if (a > b)
       
   343     a = b;
       
   344   if (a < -b)
       
   345     a = -b;
       
   346   return a;
       
   347 }
       
   348 
       
   349 static inline int
       
   350 MULT16_16_Q11_32 (int a, int b)
       
   351 {
       
   352   long long res;
       
   353   if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
       
   354     fprintf (stderr, "MULT16_16_Q11: inputs are not short: %d %d\n", a, b);
       
   355   }
       
   356   res = ((long long) a) * b;
       
   357   res >>= 11;
       
   358   if (!VERIFY_INT (res))
       
   359     fprintf (stderr, "MULT16_16_Q11: output is not short: %d*%d=%d\n", (int) a,
       
   360         (int) b, (int) res);
       
   361   spx_mips += 3;
       
   362   return res;
       
   363 }
       
   364 
       
   365 static inline short
       
   366 MULT16_16_Q13 (int a, int b)
       
   367 {
       
   368   long long res;
       
   369   if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
       
   370     fprintf (stderr, "MULT16_16_Q13: inputs are not short: %d %d\n", a, b);
       
   371   }
       
   372   res = ((long long) a) * b;
       
   373   res >>= 13;
       
   374   if (!VERIFY_SHORT (res))
       
   375     fprintf (stderr, "MULT16_16_Q13: output is not short: %d*%d=%d\n", a, b,
       
   376         (int) res);
       
   377   spx_mips += 3;
       
   378   return res;
       
   379 }
       
   380 
       
   381 static inline short
       
   382 MULT16_16_Q14 (int a, int b)
       
   383 {
       
   384   long long res;
       
   385   if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
       
   386     fprintf (stderr, "MULT16_16_Q14: inputs are not short: %d %d\n", a, b);
       
   387   }
       
   388   res = ((long long) a) * b;
       
   389   res >>= 14;
       
   390   if (!VERIFY_SHORT (res))
       
   391     fprintf (stderr, "MULT16_16_Q14: output is not short: %d\n", (int) res);
       
   392   spx_mips += 3;
       
   393   return res;
       
   394 }
       
   395 
       
   396 static inline short
       
   397 MULT16_16_Q15 (int a, int b)
       
   398 {
       
   399   long long res;
       
   400   if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
       
   401     fprintf (stderr, "MULT16_16_Q15: inputs are not short: %d %d\n", a, b);
       
   402   }
       
   403   res = ((long long) a) * b;
       
   404   res >>= 15;
       
   405   if (!VERIFY_SHORT (res)) {
       
   406     fprintf (stderr, "MULT16_16_Q15: output is not short: %d\n", (int) res);
       
   407   }
       
   408   spx_mips += 3;
       
   409   return res;
       
   410 }
       
   411 
       
   412 static inline short
       
   413 MULT16_16_P13 (int a, int b)
       
   414 {
       
   415   long long res;
       
   416   if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
       
   417     fprintf (stderr, "MULT16_16_P13: inputs are not short: %d %d\n", a, b);
       
   418   }
       
   419   res = ((long long) a) * b;
       
   420   res += 4096;
       
   421   if (!VERIFY_INT (res))
       
   422     fprintf (stderr, "MULT16_16_P13: overflow: %d*%d=%d\n", a, b, (int) res);
       
   423   res >>= 13;
       
   424   if (!VERIFY_SHORT (res))
       
   425     fprintf (stderr, "MULT16_16_P13: output is not short: %d*%d=%d\n", a, b,
       
   426         (int) res);
       
   427   spx_mips += 4;
       
   428   return res;
       
   429 }
       
   430 
       
   431 static inline short
       
   432 MULT16_16_P14 (int a, int b)
       
   433 {
       
   434   long long res;
       
   435   if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
       
   436     fprintf (stderr, "MULT16_16_P14: inputs are not short: %d %d\n", a, b);
       
   437   }
       
   438   res = ((long long) a) * b;
       
   439   res += 8192;
       
   440   if (!VERIFY_INT (res))
       
   441     fprintf (stderr, "MULT16_16_P14: overflow: %d*%d=%d\n", a, b, (int) res);
       
   442   res >>= 14;
       
   443   if (!VERIFY_SHORT (res))
       
   444     fprintf (stderr, "MULT16_16_P14: output is not short: %d*%d=%d\n", a, b,
       
   445         (int) res);
       
   446   spx_mips += 4;
       
   447   return res;
       
   448 }
       
   449 
       
   450 static inline short
       
   451 MULT16_16_P15 (int a, int b)
       
   452 {
       
   453   long long res;
       
   454   if (!VERIFY_SHORT (a) || !VERIFY_SHORT (b)) {
       
   455     fprintf (stderr, "MULT16_16_P15: inputs are not short: %d %d\n", a, b);
       
   456   }
       
   457   res = ((long long) a) * b;
       
   458   res += 16384;
       
   459   if (!VERIFY_INT (res))
       
   460     fprintf (stderr, "MULT16_16_P15: overflow: %d*%d=%d\n", a, b, (int) res);
       
   461   res >>= 15;
       
   462   if (!VERIFY_SHORT (res))
       
   463     fprintf (stderr, "MULT16_16_P15: output is not short: %d*%d=%d\n", a, b,
       
   464         (int) res);
       
   465   spx_mips += 4;
       
   466   return res;
       
   467 }
       
   468 
       
   469 #define DIV32_16(a, b) _DIV32_16(a, b, __FILE__, __LINE__)
       
   470 
       
   471 static inline int
       
   472 _DIV32_16 (long long a, long long b, char *file, int line)
       
   473 {
       
   474   long long res;
       
   475   if (b == 0) {
       
   476     fprintf (stderr, "DIV32_16: divide by zero: %d/%d in %s: line %d\n",
       
   477         (int) a, (int) b, file, line);
       
   478     return 0;
       
   479   }
       
   480   if (!VERIFY_INT (a) || !VERIFY_SHORT (b)) {
       
   481     fprintf (stderr,
       
   482         "DIV32_16: inputs are not int/short: %d %d in %s: line %d\n", (int) a,
       
   483         (int) b, file, line);
       
   484   }
       
   485   res = a / b;
       
   486   if (!VERIFY_SHORT (res)) {
       
   487     fprintf (stderr,
       
   488         "DIV32_16: output is not short: %d / %d = %d in %s: line %d\n", (int) a,
       
   489         (int) b, (int) res, file, line);
       
   490     if (res > 32767)
       
   491       res = 32767;
       
   492     if (res < -32768)
       
   493       res = -32768;
       
   494   }
       
   495   spx_mips += 20;
       
   496   return res;
       
   497 }
       
   498 
       
   499 #define DIV32(a, b) _DIV32(a, b, __FILE__, __LINE__)
       
   500 static inline int
       
   501 _DIV32 (long long a, long long b, char *file, int line)
       
   502 {
       
   503   long long res;
       
   504   if (b == 0) {
       
   505     fprintf (stderr, "DIV32: divide by zero: %d/%d in %s: line %d\n", (int) a,
       
   506         (int) b, file, line);
       
   507     return 0;
       
   508   }
       
   509 
       
   510   if (!VERIFY_INT (a) || !VERIFY_INT (b)) {
       
   511     fprintf (stderr, "DIV32: inputs are not int/short: %d %d in %s: line %d\n",
       
   512         (int) a, (int) b, file, line);
       
   513   }
       
   514   res = a / b;
       
   515   if (!VERIFY_INT (res))
       
   516     fprintf (stderr, "DIV32: output is not int: %d in %s: line %d\n", (int) res,
       
   517         file, line);
       
   518   spx_mips += 36;
       
   519   return res;
       
   520 }
       
   521 
       
   522 #define PDIV32(a,b) DIV32(ADD32((a),(b)>>1),b)
       
   523 #define PDIV32_16(a,b) DIV32_16(ADD32((a),(b)>>1),b)
       
   524 
       
   525 #endif