On May 1, 2008, at 4:44 PM, Jim Jagielski wrote:

On Thu, May 01, 2008 at 04:18:32PM -0700, Roy T. Fielding wrote:
On May 1, 2008, at 3:33 PM, William A. Rowe, Jr. wrote:
Christopher Key wrote:

I'm not sure whether this has been covered already, and whether it
needs to go in during a major release, but is there any chance of
adding apr_int8_t and apr_uint8_t typedefs?

Why?  The type char is defined by the C standard to be an 8bit signed
integer.

Huh? 'char' may or may not be signed, the spec doesn't specify which,
except for the condition that if a "real" character is stored
in 'char' then that value is unsigned. But if I store, for example,
0xfb in there, (and 0xfb isn't a "real" character), then whether
the value of that char is positive or negative (and thus, whether
signed) is impl dependent.

The 'signed' qualifier is redundant for all types except 'char'

Er, except that compiler implementations since K&R1 do implement
char as signed because that's how the PDP-11 worked.  Portability
would suck otherwise due to integral types (including char) being
promoted to a signed integer when used in an integer context.

In any case, the patch as given will cause APR to fail compilation
on those platforms in which CHAR_BIT != 8 and there is no OS-defined
int8_t type (not required until C99).

+if test "$ac_cv_define_stdint_types" = "yes"; then
+    signed_byte_value=int8_t
+    unsigned_byte_value=uint8_t
+elif test "$ac_cv_define_char_bit_octet" = "yes"; then
+    signed_byte_value="signed char"
+    unsigned_byte_value="unsigned char"
+else
+    # no known value for 8 bit type
+    AC_ERROR([could not detect a 8-bit integer type])
+fi

The question is, why on earth would we want to break APR on all
pre-C99 platforms for which CHAR_BIT != 8 when we don't even
give a rat's ass how many bits are in a char type?  I still
don't know why APR would require an int8_t other than char.

I am curious if one of the EBCDIC platforms manages to do
integral promotion differently.  Try it yourself:

==========================================
% cat test_char.c
/* Test of char signedness
 *
 *     cc -o test_char test_char.c
 *
 * Roy Fielding, 2008
 */
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    int total;
    char c;

    c = 200;  /* E grave in iso-8859-1 */
    printf("Character c: %c\n", c);
    total = c + 1000;
    printf("c + 1000 = %d\n", total);

    exit(0);
}
% gcc -o test_char test_char.c
% ./test_char   # settings for term is utf-8
Character c: ?
c + 1000 = 944
%               # changed setting to iso-8859-1
% ./test_char
Character c: È
c + 1000 = 944

....Roy

Reply via email to