Jon Beniston
2009-Dec-18 12:45 UTC
[ogg-dev] [PATCH] Fix a couple of problems for compilers where int is 16-bits
Hi, The attached patch changes occurrences of serialno to use the type ogg_int32_t, rather than int, as int can be too small on targets where it is only 16-bits. Cheers, Jon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/ogg-dev/attachments/20091218/bb17e83b/attachment-0001.htm -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: patch.txt Url: http://lists.xiph.org/pipermail/ogg-dev/attachments/20091218/bb17e83b/attachment-0001.txt
Michael Crawford
2010-Feb-25 12:37 UTC
[ogg-dev] [PATCH] Fix a couple of problems for compilers where int is 16-bits
On Fri, Dec 18, 2009 at 3:20 AM, Jon Beniston <jon at beniston.com> wrote:> The attached patch changes occurrences of serialno to use the type > ogg_int32_t, rather than int, as int can be too small on targets where it is > only 16-bits.In the early days of the Classic Macintosh, there was much wailing and gnashing of teeth, because Apple's Macintosh Programmer's Workshop had 32-bit ints, while LightspeedC - later ThinkC - had 16-bit ints. Both compilers built code for the exact same Mac OS API; it's just that the Mac System API did not include any ints. Apple's argument was that the 68000 had 32-bit registers. Think's argument was that while the 68k did indeed have 32-bit registers, it only had a 16-bit data bus, so two memory access cycles were required to transfer an Apple int to or from main memory, but only one for a Think int. The early Mac was profoundly memory constrained - cramming a full graphic GUI into 128 kb of RAM - and so filled with all manner of hacks that enabled more efficient use of what little memory was available. So Think added an additional argument, that if one were to have a lot of ints around in a program's memory, Think ints required half that of an Apple int. To this day, I still meet old-time Mac programmers that sternly warn one never, ever to use an int, not for any purpose whatsoever. Instead they advise that every integral variable use a typedef for an explicit number of bits. Mike -- Michael David Crawford mdcrawford at gmail dot com GoingWare's Bag of Programming Tricks http://www.goingware.com/tips/
Ralph Giles
2010-Feb-25 22:31 UTC
[ogg-dev] [PATCH] Fix a couple of problems for compilers where int is 16-bits
On 18 December 2009 03:20, Jon Beniston <jon at beniston.com> wrote:> The attached patch changes occurrences of serialno to use the type > ogg_int32_t, rather than int, as int can be too small on targets where it is > only 16-bits.Sorry, your post got stuck in the moderation queue for a while. Good catch about the long vs. int mismatch in the api. However, this is an ABI breaking change. Do you have an actual platform with 16 bit ints you needed this for? -r