pdf-devel
[Top][All Lists]
Advanced

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

Re: [pdf-devel] System 64-bit types


From: jemarch
Subject: Re: [pdf-devel] System 64-bit types
Date: Tue, 13 May 2008 19:45:50 +0200
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/23.0.60 (powerpc-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO)

Hi.

   If 64bit types are available in the system, shouldn't we use them? 
   Something like re-defining the functions if 64bit types are available:

   #ifdef int64_t
     #define PDF_USE_BUILTIN_64BIT_SUPPORT 0
   #else
     #define PDF_USE_BUILTIN_64BIT_SUPPORT 1
   #endif

Ok.
   #if PDF_USE_BUILTIN_64BIT_SUPPORT

   pdf_status_t pdf_i64_copy(const pdf_i64_t orig, pdf_i64_t *copy)
   {
      if (copy == NULL)
        {
          return PDF_ERROR;
        }
      copy->high = orig.high;
      copy->low = orig.low;
      return PDF_OK;

   }/*end pdf_i64_copy*/

   #else

   pdf_status_t pdf_i64_copy(const pdf_i64_t orig, pdf_i64_t *copy)
   {
      *copy=orig;
      return PDF_OK;
   }

   #endif

I would put the conditional code in the code using 64bit integers
instead of the 'pdf_i64' implementation:

/* We need a 64bit number */
pdf_i64_t number;  /* May be a native scalar type or a pdf_i64
                      variable */

...
#ifdef PDF_USE_BUILTIN_64BIT_SUPPORT
/* Use the pdf_i64 implementation */
pdf_i64_set (number, 20);
#else
/* Simply use the scalar type */
number = 20;
#endif

Your approach has the advantage of providing a uniform interface for
the modules using 'pdf_i64', but I am thinking more in the efficiency
of the code and in the fact that most 32bit machines/OS/compilers
provides a native 64bit scalar type (such as long long).

What do you think?

-- 
Jose E. Marchesi  <address@hidden>
                  <address@hidden>

GNU Spain         http://es.gnu.org
GNU Project       http://www.gnu.org




reply via email to

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