source: trunk/third/sendmail/libsm/t-types.c @ 19204

Revision 19204, 2.7 KB checked in by zacheiss, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r19203, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers.
3 *      All rights reserved.
4 *
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.
8 */
9
10#include <sm/gen.h>
11SM_IDSTR(id, "@(#)$Id: t-types.c,v 1.1.1.1 2003-04-08 15:07:10 zacheiss Exp $")
12
13#include <sm/limits.h>
14#include <sm/io.h>
15#include <sm/string.h>
16#include <sm/test.h>
17#include <sm/types.h>
18
19int
20main(argc, argv)
21        int argc;
22        char **argv;
23{
24        LONGLONG_T ll;
25        LONGLONG_T volatile lt;
26        ULONGLONG_T ull;
27        char buf[128];
28        char *r;
29
30        sm_test_begin(argc, argv, "test standard integral types");
31
32        SM_TEST(sizeof(LONGLONG_T) == sizeof(ULONGLONG_T));
33
34        /*
35        **  sendmail assumes that ino_t, off_t and void* can be cast
36        **  to ULONGLONG_T without losing information.
37        */
38
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)))
42        {
43                (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "\
44Your C compiler appears to support a 64 bit integral type,\n\
45but libsm is not configured to use it.  You will need to set\n\
46either SM_CONF_LONGLONG or SM_CONF_QUAD_T to 1.  See libsm/README\n\
47for more details.\n");
48        }
49
50        /*
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
55        **  a wrong test...
56        **  Question: where do we really need what this test tests?
57        */
58
59#if SM_CONF_TEST_LLONG
60        ll = LLONG_MIN;
61        (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "\
62Your C compiler maybe issued a warning during compilation,\n\
63please IGNORE the compiler warning!.\n");
64        lt = LLONG_MIN - 1;
65        SM_TEST(lt > ll);
66        sm_snprintf(buf, sizeof(buf), "%llx", ll);
67        r = "0";
68        if (!SM_TEST(buf[0] == '8')
69            || !SM_TEST(strspn(&buf[1], r) == sizeof(ll) * 2 - 1))
70        {
71                (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
72                        "oops: LLONG_MIN=%s\n", buf);
73        }
74
75        ll = LLONG_MAX;
76        lt = ll + 1;
77        SM_TEST(lt < ll);
78        sm_snprintf(buf, sizeof(buf), "%llx", ll);
79        r = "f";
80        if (!SM_TEST(buf[0] == '7')
81            || !SM_TEST(strspn(&buf[1], r) == sizeof(ll) * 2 - 1))
82        {
83                (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
84                        "oops: LLONG_MAX=%s\n", buf);
85        }
86#endif /* SM_CONF_TEST_LLONG */
87
88        ull = ULLONG_MAX;
89        SM_TEST(ull + 1 == 0);
90        sm_snprintf(buf, sizeof(buf), "%llx", ull);
91        r = "f";
92        SM_TEST(strspn(buf, r) == sizeof(ll) * 2);
93
94        /*
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.
97        */
98#ifdef QUAD_MAX
99        SM_TEST(QUAD_MAX <= LLONG_MAX);
100#endif
101
102        return sm_test_end();
103}
Note: See TracBrowser for help on using the repository browser.