Re: cvs commit: src/lib/libc/sys tls.2

看板DFBSD_commit作者時間21年前 (2005/03/22 06:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串17/20 (看更多)
: The poin is, guys, that sizeof(some_ridiculously_large_structure_or_array_ : which_is_as_large_as_the_processes_entire_address_space) is just plain : ridiculous, and sizeof() should not have been made to return size_t : for something so silly. They could have added a usizeof() for the one : in a million chance that someone actually needed something like that, : but no... the idiots on the standard committee seem to believe that : sizeof() is only EVER used in calls to read() or write(), verses, say, : in generic exprssions that might, say, calculate an array index. : : for (i = 0; i < sizeof(ary)/sizeof(ary[0]); ++i) ... now, should i : be unsigned here, or an int? it should be an int, plain and simple, : for 99.99999% of the programs ever written. : : For the same reason, a TLS segment that is the size of the entire : address space (or even 1/2 the entire address space), is also ridiculous. : : -Matt Sorry, I'm going down a rabbit hole here. What I REALLY meant to say was that it should be signed... i.e. an int or a long, rather then unsigned. In the case of sizeof() I have to agree with chris... it should be an 'int' if it is small enough to fit, and a 'long' otherwise, and overflow values should not be allowed (generate a compile time error) or there should be separate keyword, like usizeof(), which returns the value as unsigned. -Matt Matthew Dillon <dillon@backplane.com>
文章代碼(AID): #12Fqjh00 (DFBSD_commit)
討論串 (同標題文章)
文章代碼(AID): #12Fqjh00 (DFBSD_commit)