pdf-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pdf-devel] pdf-i64 macros


From: Aleksander Morgado
Subject: Re: [pdf-devel] pdf-i64 macros
Date: Tue, 24 Jun 2008 23:19:22 +0200
User-agent: Thunderbird 2.0.0.14 (Macintosh/20080421)

Hoola Daniel,


Anyhow, I've committed the sources (pdf-types.c , pdf-types.h) with
the new macros and their associated test files. From my side,
everything compiles and works with and without macros. If we change
our minds regarding this issue, we can always go back to previous
versions of the sources.

Find attached a patch including macros for the new functions I included last week in the 64bit module (those with more 32bit number support).

I also modified some of your macros:

* Those macros with a single line to be executed do not really need the do{x}while(0);

* pdf_i64_cmp macro should not really call return. Please check my proposal for that function.

Regards!
-Aleksander


Index: src/base/pdf-types.h
===================================================================
RCS file: /cvsroot/pdf/libgnupdf/src/base/pdf-types.h,v
retrieving revision 1.15
diff -r1.15 pdf-types.h
108d107
< /*Definition of the pdf_i64_t type*/
170a170,208
> 
> /* Add a pdf_i64_t and a pdf_i32_t */
> pdf_status_t 
> pdf_i64_add_i32(pdf_i64_t *dest, const pdf_i64_t addend1, const pdf_i32_t 
> addend2);
> 
> /* Compare a pdf_i64_t and a pdf_i32_t */
> int pdf_i64_cmp_i32(const pdf_i64_t number_1, const pdf_i32_t number_2);
> 
> /* Subtract a pdf_i64_t and a pdf_i32_t variable */
> pdf_status_t 
> pdf_i64_subtraction_i32_min(pdf_i64_t *dest, const pdf_i32_t minuend, const 
> pdf_i64_t subtrahend);
> pdf_status_t 
> pdf_i64_subtraction_i32_sub(pdf_i64_t *dest, const pdf_i64_t minuend, const 
> pdf_i32_t subtrahend);
> 
> /* Multiply a pdf_i64_t and a pdf_i32_t */
> pdf_status_t 
> pdf_i64_mult_i32(pdf_i64_t *dest, const pdf_i64_t factor_1, const pdf_i32_t 
> factor_2);
> 
> /* Divide a pdf_i64_t and a pdf_i32_t */
> pdf_status_t 
> pdf_i64_div_i32_dividend(pdf_i64_t *dest, const pdf_i32_t dividend, const 
> pdf_i64_t divisor);
> pdf_status_t 
> pdf_i64_div_i32_divisor(pdf_i64_t *dest, const pdf_i64_t dividend, const 
> pdf_i32_t divisor);
> 
> 
> /* Modulus between a pdf_i64_t and a pdf_i32_t */
> pdf_status_t 
> pdf_i64_mod_i32_dividend(pdf_i64_t *dest, const pdf_i32_t dividend, const 
> pdf_i64_t divisor);
> pdf_status_t 
> pdf_i64_mod_i32_divisor(pdf_i64_t *dest, const pdf_i64_t dividend, const 
> pdf_i32_t divisor);
> 
> 
> /* Get number as pdf_i32_t. Note that if the pdf_i64_t variable is holding a 
>  * number which can't be represented in 32bits, the result is undefined... so
>  * use it with caution. */
> pdf_i32_t
> pdf_i64_to_i32(const pdf_i64_t bignum);
> 
> 
188,191c226
<   do{\
<     *bignum = value; \
<   }\
<   while (0)
---
>     *bignum = value
195,198c230
<   do                                                                  \
<     {                     \
<       *copy=orig;           \
<     } while (0)
---
>     *copy = orig
202,205c234
<   do                                                                  \
<     {                          \
<       *dest = addend1 + addend2; \
<     }while(0) 
---
>     *dest = addend1 + addend2
209,223c238
<   do                                                                  \
<     { \
<       if (number_1 > number_2)                   \
<       {                                       \
<           return 1;                           \
<       }                                       \
<       else if (number_1 < number_2)           \
<       {                             \
<           return -1;                \
<       }                             \
<       else                          \
<       {                             \
<         return 0;                   \
<       }                             \
<     }while(0)
---
>   ((number_1 > number_2) ? 1 : ((number_1 < number_2) ? -1 : 0))
227,230c242
<   do                                          \
<     {                                         \
<       *dest = abs(number);                    \
<     }while(0)
---
>       *dest = abs(number)
234,237c246
<     do                                                \
<     {                                         \
<       *dest = -number;                                \
<     }while(0)
---
>       *dest = -number
241,244c250
<     do                                                \
<       {                                               \
<       *dest = minuend - subtrahend;           \
<       }while (0)
---
>       *dest = minuend - subtrahend
248,251c254
<     do                                                \
<       {                                               \
<       *dest = factor_1 * factor_2;            \
<       }while(0)
---
>       *dest = factor_1 * factor_2
255,258c258
<     do                                                \
<       {                                               \
<       *dest = dividend/divisor;               \
<       }while (0)
---
>       *dest = dividend/divisor
262,269c262
<   do                                          \
<     {                                         \
<       *dest = dividend%divisor;                       \
<     }while (0)
< 
< 
< #endif
< 
---
>       *dest = dividend%divisor
273,274c266
< pdf_status_t 
< pdf_i64_add_i32(pdf_i64_t *dest, const pdf_i64_t addend1, const pdf_i32_t 
addend2);
---
> #define pdf_i64_add_i32 pdf_i64_add
277c269
< int pdf_i64_cmp_i32(const pdf_i64_t number_1, const pdf_i32_t number_2);
---
> #define pdf_i64_cmp_i32 pdf_i64_cmp
280,283c272,273
< pdf_status_t 
< pdf_i64_subtraction_i32_min(pdf_i64_t *dest, const pdf_i32_t minuend, const 
pdf_i64_t subtrahend);
< pdf_status_t 
< pdf_i64_subtraction_i32_sub(pdf_i64_t *dest, const pdf_i64_t minuend, const 
pdf_i32_t subtrahend);
---
> #define pdf_i64_subtraction_i32_min pdf_i64_subtraction
> #define pdf_i64_subtraction_i32_sub pdf_i64_subtraction
286,287c276
< pdf_status_t 
< pdf_i64_mult_i32(pdf_i64_t *dest, const pdf_i64_t factor_1, const pdf_i32_t 
factor_2);
---
> #define pdf_i64_mult_i32 pdf_i64_mult
290,293c279,280
< pdf_status_t 
< pdf_i64_div_i32_dividend(pdf_i64_t *dest, const pdf_i32_t dividend, const 
pdf_i64_t divisor);
< pdf_status_t 
< pdf_i64_div_i32_divisor(pdf_i64_t *dest, const pdf_i64_t dividend, const 
pdf_i32_t divisor);
---
> #define pdf_i64_div_i32_dividend pdf_i64_div
> #define pdf_i64_div_i32_divisor pdf_i64_div
297,300c284,285
< pdf_status_t 
< pdf_i64_mod_i32_dividend(pdf_i64_t *dest, const pdf_i32_t dividend, const 
pdf_i64_t divisor);
< pdf_status_t 
< pdf_i64_mod_i32_divisor(pdf_i64_t *dest, const pdf_i64_t dividend, const 
pdf_i32_t divisor);
---
> #define pdf_i64_mod_i32_dividend pdf_i64_mod
> #define pdf_i64_mod_i32_divisor pdf_i64_mod
306,310c291
< pdf_i32_t
< pdf_i64_to_i32(const pdf_i64_t bignum);
< 
< 
< 
---
> #define pdf_i64_to_i32(bignum) bignum
311a293
> #endif

reply via email to

[Prev in Thread] Current Thread [Next in Thread]