Mailing List Archive


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

Re: [tlug] It's time_t to Party!



>>>>> "Jim" == Jim  <jep200404@example.com> writes:

    Jim> Unfortunately, I don't know how to say:

    Jim>    printf("%(type_t)d...",ts.tv_sec);

#if sizeof(type_t)==sizeof(long)
#define TYPE_T_F "%ld"
#endif

    printf (TYPE_T_F "...", ts.tv_sec);

or something like that would work, I think.

    Jim> Some things are just best done in Emacs.

>From XEmacs's lisp.h:

/************************************************************************/
/**                     Definitions of basic types                     **/
/************************************************************************/

/* ------------- generic 8/16/32/64/128-bit integral types ------------ */

#if SIZEOF_SHORT == 2
#define INT_16_BIT short
#define UINT_16_BIT unsigned short
#elif SIZEOF_INT == 2
/* Bwa ha ha.  As if XEmacs could actually support such systems. */
#define INT_16_BIT int
#define UINT_16_BIT unsigned int
#else
#error Unable to find a 16-bit integral type
#endif

#if SIZEOF_INT == 4
#define INT_32_BIT int
#define UINT_32_BIT unsigned int
#define MAKE_32_BIT_UNSIGNED_CONSTANT(num) num##U
#elif SIZEOF_LONG == 4
/* Bwa ha ha again. */
#define INT_32_BIT long
#define UINT_32_BIT unsigned long
#define MAKE_32_BIT_UNSIGNED_CONSTANT(num) num##UL
#elif SIZEOF_SHORT == 4
/* And again. */
#define INT_32_BIT short
#define UINT_32_BIT unsigned short
#define MAKE_32_BIT_UNSIGNED_CONSTANT(num) num##U
#elif 1 /* Unable to find a 32-bit integral type! */
#error What kind of strange-ass system are you running on?
#endif

#if SIZEOF_LONG == 8
#define INT_64_BIT long
#define UINT_64_BIT unsigned long
#define MAKE_64_BIT_UNSIGNED_CONSTANT(num) num##UL
#elif SIZEOF_LONG_LONG == 8
#define INT_64_BIT long long
#define UINT_64_BIT unsigned long long
#define MAKE_64_BIT_UNSIGNED_CONSTANT(num) num##ULL
/* No error otherwise; just leave undefined */
#endif

#if SIZEOF_LONG_LONG == 16
#define INT_128_BIT long long
#define UINT_128_BIT unsigned long long
#define MAKE_128_BIT_UNSIGNED_CONSTANT(num) num##ULL
/* No error otherwise; just leave undefined */
#endif

/* #### Fill this in for other systems */
#if defined (INT_64_BIT) && !(defined (i386) || defined (__i386__))
#define EFFICIENT_INT_64_BIT INT_64_BIT
#define EFFICIENT_UINT_64_BIT UINT_64_BIT
#endif

#if defined (INT_128_BIT)
#define EFFICIENT_INT_128_BIT INT_128_BIT
#define EFFICIENT_UINT_128_BIT UINT_128_BIT
#endif

#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#elif defined (HAVE_INTPTR_T_IN_SYS_TYPES_H)
/* included elsewhere */
#elif SIZEOF_VOID_P == SIZEOF_INT
typedef int intptr_t;
typedef unsigned int uintptr_t;
#elif SIZEOF_VOID_P == SIZEOF_LONG
typedef long intptr_t;
typedef unsigned long uintptr_t;
#elif defined (SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG
typedef long long intptr_t;
typedef unsigned long long uintptr_t;
#else
/* Just pray. May break, may not. */
typedef long intptr_t;
typedef unsigned long uintptr_t;
#endif



-- 
School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links