Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 52942 invoked from network); 28 Jun 2006 22:34:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Jun 2006 22:34:31 -0000 Received: (qmail 40057 invoked by uid 500); 28 Jun 2006 22:34:30 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 39699 invoked by uid 500); 28 Jun 2006 22:34:29 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 39687 invoked by uid 99); 28 Jun 2006 22:34:28 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Jun 2006 15:34:28 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [69.17.117.6] (HELO mail4.sea5.speakeasy.net) (69.17.117.6) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Jun 2006 15:34:28 -0700 Received: (qmail 24778 invoked from network); 28 Jun 2006 22:34:07 -0000 Received: from dsl081-053-091.sfo1.dsl.speakeasy.net (HELO [64.81.53.91]) (duigou@[64.81.53.91]) (envelope-sender ) by mail4.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 28 Jun 2006 22:34:07 -0000 Message-ID: <44A303DE.9080209@duigou.org> Date: Wed, 28 Jun 2006 15:34:06 -0700 From: Mike Duigou User-Agent: Thunderbird 1.5.0.4 (X11/20060614) MIME-Version: 1.0 To: dev@apr.apache.org Subject: Re: apr_uint8_t and apr_int8_t? References: <44A1C6AF.6010601@duigou.org> <44A1C831.8060907@rowe-clan.net> <44A2B0B3.2000608@duigou.org> <44A2D544.3040301@rowe-clan.net> In-Reply-To: <44A2D544.3040301@rowe-clan.net> Content-Type: multipart/mixed; boundary="------------070503030300020100040107" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. --------------070503030300020100040107 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit A patch to add apr_uint8_t and apr_int8_t to apr.h is attached. It also ensures that CHAR_BIT is 8 bits (it normally is) and that short_value and long_value are defined. Mike William A. Rowe, Jr. wrote: > I can definitely see your point. Although it's not the highest priority, > we would certainly consider a patch to effect this behavior. > > Yours, > > Bill > > Mike Duigou wrote: >> I'm motivated to ask to this for wire protocols which are defined with >> specific bit sizes. char and unsigned char are not defined to be >> *exactly* 8 bits and are apparently not 8 bits in some esoteric >> environments. >> >> The C standard 5.2.4.2.1 requires that char and unsigned char be *at >> least* 8 bits but does not fix a value. So assuming that UCHAR_MAX is >> 255 is just as unwise as assuming that UINT_MAX is 65535 or 4294967295. >> >> This request is also partially for completeness with the other bit >> sized scalar typedefs. >> >> Mike >> >> William A. Rowe, Jr. wrote: >>> Can you give us any example where signed char, unsigned char don't >>> fit the bill? >>> >>> Bill >>> >>> Mike Duigou wrote: >>>> Hi! >>>> >>>> Would it be possible to add definitions for apr_uint8_t and >>>> apr_int8_t to apr.h? This appears to have been previously requested >>>> in 2001 >>>> (http://mail-archives.apache.org/mod_mbox/apr-dev/200105.mbox/%3CJLEGKKNELMHCJPNMOKHOGELPDOAA.striker@samba-tng.org%3E) >>>> but I don't see any response indicating why the change was never made. >>>> >>>> Mike >>>> >>>> . >>>> >>> >>> >>> >> >> >> > > --------------070503030300020100040107 Content-Type: text/x-patch; name="apr_uint8_t.417882.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="apr_uint8_t.417882.patch" Index: include/apr.h.in =================================================================== --- include/apr.h.in (revision 417882) +++ include/apr.h.in (working copy) @@ -254,8 +254,11 @@ /* Typedefs that APR needs. */ -typedef unsigned char apr_byte_t; +typedef unsigned @byte_value@ apr_byte_t; +typedef @byte_value@ apr_int8_t; +typedef unsigned @byte_value@ apr_uint8_t; + typedef @short_value@ apr_int16_t; typedef unsigned @short_value@ apr_uint16_t; Index: configure.in =================================================================== --- configure.in (revision 417882) +++ configure.in (working copy) @@ -1098,6 +1098,21 @@ fi dnl ----------------------------- Checks for standard typedefs +echo "${nl}Checking for Standard Typedefs..." + +dnl Check that CHAR_BIT is an octect (8-bits) in length. +AC_DEFUN([AC_C_CHAR_BIT_OCTET], +[AC_CACHE_CHECK([if CHAR_BIT is octet on this platform], ac_cv_decl_char_bit_octet, +[AC_EGREP_CPP(octet, +[#ifdef HAVE_LIMITS_H +#include +#endif +#if CHAR_BIT == 8 +octet +#endif], ac_cv_decl_char_bit_octet=yes, ac_cv_decl_char_bit_octet=no) +]) +]) + AC_TYPE_OFF_T AC_TYPE_PID_T AC_TYPE_SIZE_T @@ -1119,18 +1134,34 @@ fi dnl Checks for integer size +AC_C_CHAR_BIT_OCTET AC_CHECK_SIZEOF(char, 1) AC_CHECK_SIZEOF(int, 4) AC_CHECK_SIZEOF(long, 4) AC_CHECK_SIZEOF(short, 2) AC_CHECK_SIZEOF(long long, 8) +if test "$ac_cv_decl_char_bit_octet" = "yes"; then + byte_value=char +else + # no known value for 8 bit type + AC_ERROR([could not detect a 8-bit integer type]) +fi + if test "$ac_cv_sizeof_short" = "2"; then short_value=short +else + # no known value for 16 bit type + AC_ERROR([could not detect a 16-bit integer type]) fi + if test "$ac_cv_sizeof_int" = "4"; then int_value=int +else + # no known value for 32 bit type + AC_ERROR([could not detect a 32-bit integer type]) fi + # Now we need to find what apr_int64_t (sizeof == 8) will be. # The first match is our preference. if test "$ac_cv_sizeof_int" = "8"; then @@ -1360,6 +1391,7 @@ esac AC_SUBST(voidp_size) +AC_SUBST(byte_value) AC_SUBST(short_value) AC_SUBST(int_value) AC_SUBST(long_value) --------------070503030300020100040107--