[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: source(builtin) and read(2)
From: |
Clive D.W. Feather |
Subject: |
Re: source(builtin) and read(2) |
Date: |
Mon, 26 Mar 2007 08:39:43 +0100 |
User-agent: |
Mutt/1.5.3i |
Schwarz, Konrad said:
> While we're at it, I would be interested in the rational for "inventing"
> ssize_t and not using ptrdiff_t instead, if anyone would care to
> comment.
size_t has to be able to hold the size of the largest object. It is an
unsigned type.
ptrdiff_t has to be able to hold the largest difference between two
pointers; it is a signed type.
The two need not be a signed/unsigned pair. For example, if a system has a
maximum object size of 64,000 bytes, then size_t needs to be at least 16
bits but ptrdiff_t needs to be at least 17 bits. Thus it would be
legitimate for size_t to be (16 bit) unsigned short but ptrdiff_t to be
(32 bit) signed int.
ssize_t is the signed type corresponding to size_t. In the above example,
it is required to be signed short. It's possible for a legitimate
subtraction of two pointers to generate a value that can't fit in ssize_t.
However, because size_t and ssize_t are a signed/unsigned pair, they have
useful properties (for example, when dealing with varargs lists).
--
Clive D.W. Feather | Work: <address@hidden> | Tel: +44 20 8495 6138
Internet Expert | Home: <address@hidden> | Fax: +44 870 051 9937
Demon Internet | WWW: http://www.davros.org | Mobile: +44 7973 377646
THUS plc | |
- Re: source(builtin) and read(2), Eric Blake, 2007/03/23
- Re: source(builtin) and read(2), Paul Eggert, 2007/03/23
- Re: source(builtin) and read(2), Bruno Haible, 2007/03/23
- Re: source(builtin) and read(2), Eric Blake, 2007/03/24
- RE: source(builtin) and read(2), Schwarz, Konrad, 2007/03/26
- Re: source(builtin) and read(2),
Clive D.W. Feather <=
- RE: source(builtin) and read(2), Schwarz, Konrad, 2007/03/26
- Re: source(builtin) and read(2), Clive D.W. Feather, 2007/03/26
- RE: source(builtin) and read(2), Nick Stoughton, 2007/03/27
- Re: source(builtin) and read(2), Clive D.W. Feather, 2007/03/27
- Re: source(builtin) and read(2), Matthew Woehlke, 2007/03/27
- RE: source(builtin) and read(2), Matthew Woehlke, 2007/03/27
- Re: source(builtin) and read(2), Paul Eggert, 2007/03/29
- Re: source(builtin) and read(2), Geoff Clare, 2007/03/30