Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtksh / ksh93 / src / lib / libast / feature / int.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: int.c /main/3 1995/11/01 17:26:00 rswiston $ */
24 /***************************************************************
25 *                                                              *
26 *                      AT&T - PROPRIETARY                      *
27 *                                                              *
28 *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF        *
29 *                    AT&T BELL LABORATORIES                    *
30 *         AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN         *
31 *            ACCORDANCE WITH APPLICABLE AGREEMENTS             *
32 *                                                              *
33 *          Copyright (c) 1994 AT&T Bell Laboratories           *
34 *              Unpublished & Not for Publication               *
35 *                     All Rights Reserved                      *
36 *                                                              *
37 *       The copyright notice above does not evidence any       *
38 *      actual or intended publication of such source code      *
39 *                                                              *
40 *               This software was created by the               *
41 *           Software Engineering Research Department           *
42 *                    AT&T Bell Laboratories                    *
43 *                                                              *
44 *               For further information contact                *
45 *                   advsoft@research.att.com                   *
46 *                 Randy Hackbarth 908-582-5245                 *
47 *                  Dave Belanger 908-582-7427                  *
48 *                                                              *
49 ***************************************************************/
50
51 /* : : generated by proto : : */
52
53 #line 1
54
55 #if !defined(__PROTO__)
56 #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
57 #if defined(__cplusplus)
58 #define __MANGLE__      "C"
59 #else
60 #define __MANGLE__
61 #endif
62 #define __STDARG__
63 #define __PROTO__(x)    x
64 #define __OTORP__(x)
65 #define __PARAM__(n,o)  n
66 #if !defined(__STDC__) && !defined(__cplusplus)
67 #if !defined(c_plusplus)
68 #define const
69 #endif
70 #define signed
71 #define void            int
72 #define volatile
73 #define __V_            char
74 #else
75 #define __V_            void
76 #endif
77 #else
78 #define __PROTO__(x)    ()
79 #define __OTORP__(x)    x
80 #define __PARAM__(n,o)  o
81 #define __MANGLE__
82 #define __V_            char
83 #define const
84 #define signed
85 #define void            int
86 #define volatile
87 #endif
88 #if defined(__cplusplus) || defined(c_plusplus)
89 #define __VARARG__      ...
90 #else
91 #define __VARARG__
92 #endif
93 #if defined(__STDARG__)
94 #define __VA_START__(p,a)       va_start(p,a)
95 #else
96 #define __VA_START__(p,a)       va_start(p)
97 #endif
98 #endif
99
100 #line 9
101 #include "FEATURE/types"
102
103 #define elementsof(x)   (sizeof(x)/sizeof(x[0]))
104
105 extern __MANGLE__ int           printf __PROTO__((const char*, ...));
106
107 static char             i_char = 1;
108 static short            i_short = 1;
109 static int              i_int = 1;
110 static long             i_long = 1;
111 #if _typ_long_long
112 static long long        i_long_long = 1;
113 #endif
114
115 static struct
116 {
117         char*   name;
118         int     size;
119         char*   swap;
120 } type[] = 
121 {
122         "char",         sizeof(char),           (char*)&i_char,
123         "short",        sizeof(short),          (char*)&i_short,
124         "int",          sizeof(int),            (char*)&i_int,
125         "long",         sizeof(long),           (char*)&i_long,
126 #if _typ_long_long
127         "long long",    sizeof(long long),      (char*)&i_long_long,
128 #endif
129 };
130
131 static int      size[] = { 1, 2, 4, 8 };
132
133 main()
134 {
135         register int    t;
136         register int    s;
137         register int    m = 1;
138
139         for (s = 0; s < elementsof(size); s++)
140         {
141                 for (t = 0; t < elementsof(type) && type[t].size < size[s]; t++);
142                 if (t < elementsof(type))
143                 {
144                         m = size[s];
145                         printf("#ifndef int_%d\n", m);
146                         printf("#define int_%d          %s\n", m, type[t].name);
147                         printf("#endif\n");
148                 }
149         }
150         printf("#ifndef int_max\n");
151         printf("#define int_max         int_%d\n", m);
152         printf("#endif\n");
153         for (t = 0; t < elementsof(type) - 1 && *type[t + 1].swap; t++);
154         printf("#ifndef int_swap\n");
155         printf("#define int_swap        %d\n", t ? type[t].size : 0);
156         printf("#endif\n");
157         return(0);
158 }