存档

2003年12月 的存档

还真有不是0的NULL,C语言的各种实现太乱了

2003年12月10日 hufey 2 条评论

5.17: Seriously, have any actual machines really used nonzero null
pointers, or different representations for pointers to different
types?
A: The Prime 50 series used segment 07777, offset 0 for the null
pointer, at least for PL/I. Later models used segment 0, offset
0 for null pointers in C, necessitating new instructions such as
TCNP (Test C Null Pointer), evidently as a sop to all the extant
poorly-written C code which made incorrect assumptions. Older,
word-addressed Prime machines were also notorious for requiring
larger byte pointers (char *’s) than word pointers (int *’s).
The Eclipse MV series from Data General has three
architecturally supported pointer formats (word, byte, and bit
pointers), two of which are used by C compilers: byte pointers
for char * and void *, and word pointers for everything else.
Some Honeywell-Bull mainframes use the bit pattern 06000 for
(internal) null pointers.
The CDC Cyber 180 Series has 48-bit pointers consisting of a
ring, segment, and offset. Most users (in ring 11) have null
pointers of 0xB00000000000. It was common on old CDC ones-
complement machines to use an all-one-bits word as a special
flag for all kinds of data, including invalid addresses.
The old HP 3000 series uses a different addressing scheme for
byte addresses than for word addresses; like several of the
machines above it therefore uses different representations for
char * and void * pointers than for other pointers.
The Symbolics Lisp Machine, a tagged architecture, does not even
have conventional numeric pointers; it uses the pair
(basically a nonexistent handle) as a C null
pointer.
Depending on the “memory model” in use, 8086-family processors
(PC compatibles) may use 16-bit data pointers and 32-bit
function pointers, or vice versa.
Some 64-bit Cray machines represent int * in the lower 48 bits
of a word; char * additionally uses the upper 16 bits to
indicate a byte address within a word.
References: K&R1 Sec. A14.4 p. 211.

分类: commenting 标签:

note of C FAQ

2003年12月8日 hufey 评论已被关闭

颠覆了我多年的观念
5.9: If NULL and 0 are equivalent as null pointer constants, which
should I use?
A: Many programmers believe that NULL should be used in all pointer
contexts, as a reminder that the value is to be thought of as a
pointer. Others feel that the confusion surrounding NULL and 0
is only compounded by hiding 0 behind a macro, and prefer to use
unadorned 0 instead. There is no one right answer. (See also
questions 9.2 and 17.10.) C programmers must understand that
NULL and 0 are interchangeable in pointer contexts, and that an
uncast 0 is perfectly acceptable. Any usage of NULL (as opposed
to 0) should be considered a gentle reminder that a pointer is
involved; programmers should not depend on it (either for their
own understanding or the compiler’s) for distinguishing pointer
0’s from integer 0’s.
NULL should *not* be used when another kind of 0 is required,
even though it might work, because doing so sends the wrong
stylistic message. (Furthermore, ANSI allows the definition of
NULL to be ((void *)0), which will not work at all in non-
pointer contexts.) In particular, do not use NULL when the
ASCII null character (NUL) is desired. Provide your own
definition
#define NUL ”
if you must.
References: K&R1 Sec. 5.4 pp. 97-8; K&R2 Sec. 5.4 p. 102.

分类: commenting 标签:

回到从前。。。。。。

2003年12月8日 hufey 评论已被关闭

前天干了件大事。
找到了我的破烂并口game pad的驱动
装了mame
开始到处找街机的ROM
找到了雷电、名将、战斧、铁钩船长
想起了上高中时的青春岁月。。。。。。
那会根本不想考什么大学
最大的理想是赶紧上班,赚钱,买台街机放家里。。。。。。
555555555555555,居然都十几年过去了

分类: chating 标签:

going down?

2003年12月5日 hufey 评论已被关闭

Don’t worry linuxers worldwide, SCO is going Down! IBM’s got our backs ;)
This is my first wallpaper so be nice.. ;)
I did the whole thing using Gimp. Most of it is just cut+paste of some pictures I found at google.com.
The background of the wallpaper is another wallpaper I found here called flung-plastic.
Hope you like it! :)

分类: 未分类 标签:

好帅的TabletPC,才999$

2003年12月3日 hufey 评论已被关闭


跑linux

阅读全文…

分类: watching 标签: