2 * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
11 SM_IDSTR(id
, "@(#)$Id: t-types.c,v 1.18 2002/03/13 17:29:53 gshapiro Exp $")
13 #include <sm/limits.h>
15 #include <sm/string.h>
25 LONGLONG_T
volatile lt
;
30 sm_test_begin(argc
, argv
, "test standard integral types");
32 SM_TEST(sizeof(LONGLONG_T
) == sizeof(ULONGLONG_T
));
35 ** sendmail assumes that ino_t, off_t and void* can be cast
36 ** to ULONGLONG_T without losing information.
39 if (!SM_TEST(sizeof(ino_t
) <= sizeof(ULONGLONG_T
)) ||
40 !SM_TEST(sizeof(off_t
) <= sizeof(ULONGLONG_T
)) ||
41 !SM_TEST(sizeof(void*) <= sizeof(ULONGLONG_T
)))
43 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
, "\
44 Your C compiler appears to support a 64 bit integral type,\n\
45 but libsm is not configured to use it. You will need to set\n\
46 either SM_CONF_LONGLONG or SM_CONF_QUAD_T to 1. See libsm/README\n\
47 for more details.\n");
51 ** Most compilers notice that LLONG_MIN - 1 generate an underflow.
52 ** Some compiler generate code that will use the 'X' status bit
53 ** in a CPU and hence (LLONG_MIN - 1 > LLONG_MIN) will be false.
54 ** So we have to decide whether we want compiler warnings or
56 ** Question: where do we really need what this test tests?
59 #if SM_CONF_TEST_LLONG
61 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
, "\
62 Your C compiler maybe issued a warning during compilation,\n\
63 please IGNORE the compiler warning!.\n");
66 sm_snprintf(buf
, sizeof(buf
), "%llx", ll
);
68 if (!SM_TEST(buf
[0] == '8')
69 || !SM_TEST(strspn(&buf
[1], r
) == sizeof(ll
) * 2 - 1))
71 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
72 "oops: LLONG_MIN=%s\n", buf
);
78 sm_snprintf(buf
, sizeof(buf
), "%llx", ll
);
80 if (!SM_TEST(buf
[0] == '7')
81 || !SM_TEST(strspn(&buf
[1], r
) == sizeof(ll
) * 2 - 1))
83 (void) sm_io_fprintf(smioerr
, SM_TIME_DEFAULT
,
84 "oops: LLONG_MAX=%s\n", buf
);
86 #endif /* SM_CONF_TEST_LLONG */
89 SM_TEST(ull
+ 1 == 0);
90 sm_snprintf(buf
, sizeof(buf
), "%llx", ull
);
92 SM_TEST(strspn(buf
, r
) == sizeof(ll
) * 2);
95 ** If QUAD_MAX is defined by <limits.h> then quad_t is defined.
96 ** Make sure LONGLONG_T is at least as big as quad_t.
99 SM_TEST(QUAD_MAX
<= LLONG_MAX
);
102 return sm_test_end();