Release calc version 2.10.3t5.45

This commit is contained in:
Landon Curt Noll
1997-10-04 20:06:29 -07:00
parent 4618313a82
commit 6e10e97592
300 changed files with 38279 additions and 8584 deletions

View File

@@ -2,7 +2,13 @@
* longbits - Determine the number if bits in a char, short, int or long
*
* usage:
* longbits
* longbits [long_bit_size]
*
* long_bit_size force size of long (must be 32 or 64)
*
* NOTE: If long_bit_size arg is empty (0 chars long) or it begins with
* a whitespace character, it will be ignored and no forcing will
* be done.
*
* Not all (in fact very few) C pre-processors can do:
*
@@ -13,7 +19,7 @@
* This prog outputs several defines and typedefs:
*
* LONG_BITS
* Numbre of bits in a long. Not all (in fact very few) C
* Number of bits in a long. Not all (in fact very few) C
* pre-processors can do #if sizeof(long) == 8.
*
* USB8 unsigned 8 bit value
@@ -30,6 +36,10 @@
* and SB64 (signed 64 bit value)
* undefined ==> do not use USB64 nor SB64
*
* BOOL_B84
* If HAVE_B64 undefined ==> FALSE
* If HAVE_B64 defined ==> TRUE
*
* USB64 unsigned 64 bit value if HAVE_B64 is defined
* SB64 signed 64 bit value if HAVE_B64 is defined
*
@@ -73,12 +83,18 @@
*/
#include <stdio.h>
#include <ctype.h>
#include "have_unistd.h"
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#include "have_stdlib.h"
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include "longlong.h"
char *program; /* our name */
@@ -87,15 +103,37 @@ MAIN
main(int argc, char **argv)
{
int exitcode = 0; /* how we will exit */
int long_bits = 0; /* bit length of a long */
int forced_size = 0; /* 1 => size of long was forced via arg */
char value; /* signed or maybe unsigned character */
/*
* parse args
*/
program = argv[0];
if (argc != 1) {
fprintf(stderr, "usage: %s\n", program);
exit(1);
switch (argc) {
case 1:
long_bits = sizeof(long)*8;
break;
case 2:
/* ignore empty or leading space args */
if (argv[1][0] == '\0' ||
(isascii(argv[1][0]) && isspace(argv[1][0]))) {
long_bits = sizeof(long)*8;
/* process the forced size arg */
} else {
forced_size = 1;
long_bits = atoi(argv[1]);
if (long_bits != 32 && long_bits != 64) {
fprintf(stderr,
"usage: %s [32 or 64]\n", program);
exit(1);
}
}
break;
default:
fprintf(stderr, "usage: %s [32 or 64]\n", program);
exit(2);
}
/*
@@ -103,9 +141,90 @@ main(int argc, char **argv)
*/
printf("#undef LONG_BITS\n");
printf("#define LONG_BITS %d\t\t%c%s%c\n",
(int)(sizeof(long)*8), '/', "* bit length of a long *", '/');
long_bits, '/', "* bit length of a long *", '/');
putchar('\n');
/*
* If we are forcing the size of a long, then do not check
* sizes of other values but instead assume that the user
* knows what they are doing.
*/
if (forced_size) {
/*
* note that the size was forced
*/
printf("%c%s%c\n\n", '/', "* size of long was forced *", '/');
/*
* forced forming of USB8, SB8, USB16 and SB16
*/
printf("typedef unsigned char USB8;\t%c%s%c\n",
'/', "* unsigned 8 bits *", '/');
printf("typedef signed char SB8;\t%c%s%c\n\n",
'/', "* signed 8 bits *", '/');
printf("typedef unsigned short USB16;\t%c%s%c\n",
'/', "* unsigned 16 bits *", '/');
printf("typedef short SB16;\t\t%c%s%c\n\n",
'/', "* signed 16 bits *", '/');
/*
* forced forming of USB32 and SB32
*/
if (long_bits == 32) {
/* forced 32 bit long mode assumptions */
printf("typedef unsigned long USB32;\t%c%s%c\n",
'/', "* unsigned 32 bits *", '/');
printf("typedef long SB32;\t\t%c%s%c\n\n",
'/', "* signed 32 bits *", '/');
} else {
/* forced 64 bit long mode assumptions */
printf("typedef unsigned int USB32;\t%c%s%c\n",
'/', "* unsigned 32 bits *", '/');
printf("typedef int SB32;\t\t%c%s%c\n\n",
'/', "* signed 32 bits *", '/');
}
/*
* forced forming of HAVE_B64, USB64, SB64, U(x) and L(x)
*/
#if defined(HAVE_LONGLONG) && LONGLONG_BITS == 64
printf("#undef HAVE_B64\n");
printf("#define HAVE_B64\t\t%c%s%c\n",
'/', "* have USB64 and SB64 types *", '/');
printf("#define BOOL_B64 TRUE\n");
printf("typedef unsigned long long USB64;\t%c%s%c\n",
'/', "* unsigned 64 bits *", '/');
printf("typedef long long SB64;\t\t%c%s%c\n",
'/', "* signed 64 bits *", '/');
putchar('\n');
printf("%c%s%c\n", '/',"* how to form 64 bit constants *",'/');
#if defined(__STDC__) && __STDC__ != 0
printf("#define U(x) x ## ULL\n");
printf("#define L(x) x ## LL\n");
#else
printf("#define U(x) ((unsigned long long)x)\n");
printf("#define L(x) ((long long)x)\n");
#endif
#else
printf("#undef HAVE_B64\t\t\t%c%s%c\n",
'/', "* we have no USB64 and no SB64 types *", '/');
printf("#define BOOL_B64 FALSE\n");
putchar('\n');
printf("%c%s%c\n", '/', "* no 64 bit constants *", '/');
printf("#define U(x) no 33 to 64 bit constants %s\n",
"- do not use this macro!");
printf("#define L(x) no 33 to 64 bit constants %s\n",
"- do not use this macro!");
#endif
/*
* all done
*/
exit(0);
}
/*
* look for 8 bit values
*/
@@ -124,7 +243,7 @@ main(int argc, char **argv)
printf("typedef signed char SB8;\t%c* XX%s%c -=*#*=-\n",
'/', "X - should be 8 signed bits but is not *", '/');
}
exitcode = 2;
exitcode = 3;
} else {
printf("typedef unsigned char USB8;\t%c%s%c\n",
'/', "* unsigned 8 bits *", '/');
@@ -150,7 +269,7 @@ main(int argc, char **argv)
'/', "X - should be 16 unsigned bits but is not *", '/');
printf("typedef signed char SB16;\t%c* XX%s%c -=*#*=-\n",
'/', "X - should be 16 signed bits but is not *", '/');
exitcode = 3;
exitcode = 4;
} else {
printf("typedef unsigned short USB16;\t%c%s%c\n",
'/', "* unsigned 16 bits *", '/');
@@ -179,7 +298,7 @@ main(int argc, char **argv)
'/', "X - should be 32 unsigned bits but is not *", '/');
printf("typedef signed int SB32;\t%c* XX%s%c -=*#*=-\n",
'/', "X - should be 32 signed bits but is not *", '/');
exitcode = 4;
exitcode = 5;
}
putchar('\n');
@@ -190,6 +309,7 @@ main(int argc, char **argv)
printf("#undef HAVE_B64\n");
printf("#define HAVE_B64\t\t%c%s%c\n",
'/', "* have USB64 and SB64 types *", '/');
printf("#define BOOL_B64 TRUE\n");
printf("typedef unsigned long USB64;\t%c%s%c\n",
'/', "* unsigned 64 bits *", '/');
printf("typedef long SB64;\t\t%c%s%c\n",
@@ -208,6 +328,7 @@ main(int argc, char **argv)
printf("#undef HAVE_B64\n");
printf("#define HAVE_B64\t\t%c%s%c\n",
'/', "* have USB64 and SB64 types *", '/');
printf("#define BOOL_B64 TRUE\n");
printf("typedef unsigned long long USB64;\t%c%s%c\n",
'/', "* unsigned 64 bits *", '/');
printf("typedef long long SB64;\t\t%c%s%c\n",
@@ -224,6 +345,7 @@ main(int argc, char **argv)
#else
printf("#undef HAVE_B64\t\t\t%c%s%c\n",
'/', "* we have no USB64 and no SB64 types *", '/');
printf("#define BOOL_B64 FALSE\n");
putchar('\n');
printf("%c%s%c\n", '/', "* no 64 bit constants *", '/');
printf("#define U(x) no 33 to 64 bit constants %s\n",