summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.Merijn Brand <h.m.brand@xs4all.nl>2009-11-06 07:56:01 +0100
committerH.Merijn Brand <h.m.brand@xs4all.nl>2009-11-06 07:56:01 +0100
commitc193ef60f6a5fd42aabc316c80c3fc0f431e71ad (patch)
tree3aa273295ef2285c47ee5252998c67f6fc1e686a
parentcb39f75f02caa9f23c14dfcac8a46fb1bd154b4f (diff)
downloadperl-c193ef60f6a5fd42aabc316c80c3fc0f431e71ad.tar.gz
Detection (and warning) of char size in bits
-rwxr-xr-xConfigure86
-rw-r--r--Cross/config.sh-arm-linux1
-rw-r--r--NetWare/config.wc1
-rw-r--r--Porting/Glossary8
-rw-r--r--Porting/config.sh1
-rwxr-xr-xconfig_h.SH6
-rw-r--r--configure.com1
-rw-r--r--epoc/config.sh1
-rw-r--r--plan9/config_sh.sample1
-rw-r--r--symbian/config.sh1
-rwxr-xr-xuconfig.sh1
-rw-r--r--win32/config.bc1
-rw-r--r--win32/config.ce1
-rw-r--r--win32/config.gc1
-rw-r--r--win32/config.vc1
-rw-r--r--win32/config.vc641
16 files changed, 112 insertions, 1 deletions
diff --git a/Configure b/Configure
index f1123f384a..25ce689d76 100755
--- a/Configure
+++ b/Configure
@@ -28,7 +28,7 @@
# $Id: Head.U 6 2006-08-25 22:21:46Z rmanfredi $
#
-# Generated on Thu Nov 5 21:01:50 CET 2009 [metaconfig 3.5 PL0]
+# Generated on Fri Nov 6 07:43:05 CET 2009 [metaconfig 3.5 PL0]
# (with additional metaconfig patches by perlbug@perl.org)
cat >c1$$ <<EOF
@@ -351,6 +351,8 @@ optimize=''
cf_email=''
cf_by=''
cf_time=''
+charbits=''
+charsize=''
contains=''
cpp_stuff=''
cpplast=''
@@ -18819,6 +18821,86 @@ esac
: set the base revision
baserev=5.0
+: check for length of character
+echo " "
+case "$charsize" in
+'')
+ echo "Checking to see how big your characters are (hey, you never know)..." >&4
+ $cat >try.c <<EOCP
+#include <stdio.h>
+#$i_stdlib I_STDLIB
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+int main()
+{
+ printf("%d\n", (int)sizeof(char));
+ exit(0);
+}
+EOCP
+ set try
+ if eval $compile_ok; then
+ dflt=`$run ./try`
+ else
+ dflt='1'
+ echo "(I can't seem to compile the test program. Guessing...)"
+ fi
+ ;;
+*)
+ dflt="$charsize"
+ ;;
+esac
+rp="What is the size of a character (in bytes)?"
+. ./myread
+charsize="$ans"
+$rm_try
+
+: Check for the number of bits in a character
+case "$charbits" in
+'') echo "Checking how long a character is (in bits)..." >&4
+ $cat >try.c <<EOCP
+#include <stdio.h>
+int main ()
+{
+ int n;
+ unsigned char c;
+ for (c = 1, n = 0; c; c <<= 1, n++) ;
+ printf ("%d\n", n);
+ return (0);
+ }
+EOCP
+ set try
+ if eval $compile_ok; then
+ dflt=`$run ./try`
+ else
+ dflt='8'
+ echo "(I can't seem to compile the test program. Guessing...)"
+ fi
+ ;;
+*)
+ dflt="$charbits"
+ ;;
+esac
+rp="What is the length of a character (in bits)?"
+. ./myread
+charbits="$ans"
+$rm_try
+case "$charbits" in
+8) ;;
+*) cat >&4 << EOM
+Your system has an unsigned character size of $charbits bits, which
+is rather unusual (normally it is 8 bits). Perl likely will not work
+correctly on your system, with subtle bugs in various places.
+EOM
+ rp='Do you really want to continue?'
+ dflt='n'
+ . ./myread
+ case "$ans" in
+ [yY]) echo >&4 "Okay, continuing." ;;
+ *) exit 1 ;;
+ esac
+esac
+
: how do we concatenate cpp tokens here?
echo " "
echo "Checking to see how your cpp does stuff like concatenate tokens..." >&4
@@ -22213,6 +22295,8 @@ ccversion='$ccversion'
cf_by='$cf_by'
cf_email='$cf_email'
cf_time='$cf_time'
+charbits='$charbits'
+charsize='$charsize'
chgrp='$chgrp'
chmod='$chmod'
chown='$chown'
diff --git a/Cross/config.sh-arm-linux b/Cross/config.sh-arm-linux
index 61011ab408..9c9c3962d3 100644
--- a/Cross/config.sh-arm-linux
+++ b/Cross/config.sh-arm-linux
@@ -64,6 +64,7 @@ ccversion=''
cf_by='red'
cf_email='red@criticalintegration.com'
cf_time='Wed Sep 3 22:24:58 EDT 2003'
+charbits='8'
chgrp=''
chmod='chmod'
chown=''
diff --git a/NetWare/config.wc b/NetWare/config.wc
index 533a59fcd9..e63d41c828 100644
--- a/NetWare/config.wc
+++ b/NetWare/config.wc
@@ -51,6 +51,7 @@ ccsymbols=''
cf_by='nobody'
cf_email='nobody@no.where.net'
cf_time=''
+charbits='8'
chgrp=''
chmod=''
chown=''
diff --git a/Porting/Glossary b/Porting/Glossary
index 167d4d3e5a..b810a7f9f3 100644
--- a/Porting/Glossary
+++ b/Porting/Glossary
@@ -249,6 +249,14 @@ cf_time (cf_who.U):
Holds the output of the "date" command when the configuration file was
produced. This is used to tag both config.sh and config_h.SH.
+charbits (charsize.U):
+ This variable contains the value of the CHARBITS symbol, which
+ indicates to the C program how many bits there are in a character.
+
+charsize (charsize.U):
+ This variable contains the value of the CHARSIZE symbol, which
+ indicates to the C program how many bytes there are in a character.
+
chgrp (Loc.U):
This variable is defined but not used by Configure.
The value is the empty string and is not useful.
diff --git a/Porting/config.sh b/Porting/config.sh
index c18faa4876..ab0a29bca0 100644
--- a/Porting/config.sh
+++ b/Porting/config.sh
@@ -77,6 +77,7 @@ ccversion=''
cf_by='merijn'
cf_email='yourname@yourhost.yourplace.com'
cf_time='Wed Jan 23 09:43:56 CET 2008'
+charbits='8'
chgrp=''
chmod='chmod'
chown=''
diff --git a/config_h.SH b/config_h.SH
index ccb7f10ea0..ff4c86092a 100755
--- a/config_h.SH
+++ b/config_h.SH
@@ -2943,6 +2943,12 @@ sed <<!GROK!THIS! >$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un
#define BYTEORDER 0x$byteorder /* large digits for MSB */
#endif /* NeXT */
+/* CHARBITS:
+ * This symbol contains the size of a char, so that the C preprocessor
+ * can make decisions based on it.
+ */
+#define CHARBITS $charbits /**/
+
/* CASTI32:
* This symbol is defined if the C compiler can cast negative
* or large floating point numbers to 32-bit ints.
diff --git a/configure.com b/configure.com
index d5ea93253c..934633e1b0 100644
--- a/configure.com
+++ b/configure.com
@@ -5854,6 +5854,7 @@ $ WC "ccversion='" + ccversion + "'"
$ WC "cf_by='" + cf_by + "'"
$ WC "cf_email='" + cf_email + "'"
$ WC "cf_time='" + cf_time + "'"
+$ WC "charbits='8'"
$ WC "config_args='" + config_args + "'"
$ WC "config_sh='" + config_sh + "'"
$ WC "cpp_stuff='" + cpp_stuff + "'"
diff --git a/epoc/config.sh b/epoc/config.sh
index 8623a8519f..57dc276a6a 100644
--- a/epoc/config.sh
+++ b/epoc/config.sh
@@ -58,6 +58,7 @@ ccsymbols=''
cf_by='olaf'
cf_email='o.flebbe@gmx.de'
cf_time='Dec 2001'
+charbits='8'
chgrp=''
chmod=''
chown=''
diff --git a/plan9/config_sh.sample b/plan9/config_sh.sample
index 763f7aaf75..0fba47e383 100644
--- a/plan9/config_sh.sample
+++ b/plan9/config_sh.sample
@@ -64,6 +64,7 @@ ccversion=''
cf_by='9trouble'
cf_email='9trouble@plan9.bell-labs.com'
cf_time='Sun Nov 24 20:57:48 EST 2002'
+charbits='8'
chgrp=''
chmod='chmod'
chown=''
diff --git a/symbian/config.sh b/symbian/config.sh
index 9885d4df36..a7eda34952 100644
--- a/symbian/config.sh
+++ b/symbian/config.sh
@@ -22,6 +22,7 @@ cccdlflags=''
ccdlflags=''
cf_by='root@localhost'
cf_time='Thu Jan 1 00:00:00 GMT 1970'
+charbits='8'
clocktype='clock_t'
cpp_stuff='42'
cpplast=''
diff --git a/uconfig.sh b/uconfig.sh
index f4cefcbcab..7d67f19b38 100755
--- a/uconfig.sh
+++ b/uconfig.sh
@@ -15,6 +15,7 @@ byteorder='1234'
castflags='0'
cf_by='root@localhost'
cf_time='Thu Jan 1 00:00:00 GMT 1970'
+charbits='8'
clocktype='clock_t'
cpplast='-'
cppminus='-'
diff --git a/win32/config.bc b/win32/config.bc
index 6743f14de7..ed5654ab64 100644
--- a/win32/config.bc
+++ b/win32/config.bc
@@ -51,6 +51,7 @@ ccversion=''
cf_by='nobody'
cf_email='nobody@no.where.net'
cf_time=''
+charbits='8'
chgrp=''
chmod=''
chown=''
diff --git a/win32/config.ce b/win32/config.ce
index cee1175077..9bbbe287de 100644
--- a/win32/config.ce
+++ b/win32/config.ce
@@ -51,6 +51,7 @@ ccsymbols=''
cf_by='nobody'
cf_email='nobody@no.where.net'
cf_time=''
+charbits='8'
chgrp=''
chmod=''
chown=''
diff --git a/win32/config.gc b/win32/config.gc
index 018f17499f..5199e26d84 100644
--- a/win32/config.gc
+++ b/win32/config.gc
@@ -51,6 +51,7 @@ ccversion=''
cf_by='nobody'
cf_email='nobody@no.where.net'
cf_time=''
+charbits='8'
chgrp=''
chmod=''
chown=''
diff --git a/win32/config.vc b/win32/config.vc
index e0c6354051..b66c3341f3 100644
--- a/win32/config.vc
+++ b/win32/config.vc
@@ -51,6 +51,7 @@ ccversion=''
cf_by='nobody'
cf_email='nobody@no.where.net'
cf_time=''
+charbits='8'
chgrp=''
chmod=''
chown=''
diff --git a/win32/config.vc64 b/win32/config.vc64
index 44ab7f297c..bf80c7b1b0 100644
--- a/win32/config.vc64
+++ b/win32/config.vc64
@@ -51,6 +51,7 @@ ccversion=''
cf_by='nobody'
cf_email='nobody@no.where.net'
cf_time=''
+charbits='8'
chgrp=''
chmod=''
chown=''