This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Detection (and warning) of char size in bits
authorH.Merijn Brand <h.m.brand@xs4all.nl>
Fri, 6 Nov 2009 06:56:01 +0000 (07:56 +0100)
committerH.Merijn Brand <h.m.brand@xs4all.nl>
Fri, 6 Nov 2009 06:56:01 +0000 (07:56 +0100)
16 files changed:
Configure
Cross/config.sh-arm-linux
NetWare/config.wc
Porting/Glossary
Porting/config.sh
config_h.SH
configure.com
epoc/config.sh
plan9/config_sh.sample
symbian/config.sh
uconfig.sh
win32/config.bc
win32/config.ce
win32/config.gc
win32/config.vc
win32/config.vc64

index f1123f3..25ce689 100755 (executable)
--- 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'
index 61011ab..9c9c396 100644 (file)
@@ -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=''
index 533a59f..e63d41c 100644 (file)
@@ -51,6 +51,7 @@ ccsymbols=''
 cf_by='nobody'
 cf_email='nobody@no.where.net'
 cf_time=''
+charbits='8'
 chgrp=''
 chmod=''
 chown=''
index 167d4d3..b810a7f 100644 (file)
@@ -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.
index c18faa4..ab0a29b 100644 (file)
@@ -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=''
index ccb7f10..ff4c860 100755 (executable)
@@ -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.
index d5ea932..934633e 100644 (file)
@@ -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 + "'"
index 8623a85..57dc276 100644 (file)
@@ -58,6 +58,7 @@ ccsymbols=''
 cf_by='olaf'
 cf_email='o.flebbe@gmx.de'
 cf_time='Dec 2001'
+charbits='8'
 chgrp=''
 chmod=''
 chown=''
index 763f7aa..0fba47e 100644 (file)
@@ -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=''
index 9885d4d..a7eda34 100644 (file)
@@ -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=''
index f4cefcb..7d67f19 100755 (executable)
@@ -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='-'
index 6743f14..ed5654a 100644 (file)
@@ -51,6 +51,7 @@ ccversion=''
 cf_by='nobody'
 cf_email='nobody@no.where.net'
 cf_time=''
+charbits='8'
 chgrp=''
 chmod=''
 chown=''
index cee1175..9bbbe28 100644 (file)
@@ -51,6 +51,7 @@ ccsymbols=''
 cf_by='nobody'
 cf_email='nobody@no.where.net'
 cf_time=''
+charbits='8'
 chgrp=''
 chmod=''
 chown=''
index 018f174..5199e26 100644 (file)
@@ -51,6 +51,7 @@ ccversion=''
 cf_by='nobody'
 cf_email='nobody@no.where.net'
 cf_time=''
+charbits='8'
 chgrp=''
 chmod=''
 chown=''
index e0c6354..b66c334 100644 (file)
@@ -51,6 +51,7 @@ ccversion=''
 cf_by='nobody'
 cf_email='nobody@no.where.net'
 cf_time=''
+charbits='8'
 chgrp=''
 chmod=''
 chown=''
index 44ab7f2..bf80c7b 100644 (file)
@@ -51,6 +51,7 @@ ccversion=''
 cf_by='nobody'
 cf_email='nobody@no.where.net'
 cf_time=''
+charbits='8'
 chgrp=''
 chmod=''
 chown=''