From owner-cvs-all Sun Jun 4 8:19:32 2000 Delivered-To: cvs-all@freebsd.org Received: from localhost (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 251C037C35E; Sun, 4 Jun 2000 08:19:18 -0700 (PDT) (envelope-from green@FreeBSD.org) Date: Sun, 4 Jun 2000 11:19:17 -0400 (EDT) From: Brian Fundakowski Feldman X-Sender: green@green.dyndns.org To: Bruce Evans Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/sys mbuf.h In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, 4 Jun 2000, Bruce Evans wrote: > I don't know how you learned that from me. I've always said that caddr_t > should have started going away around 1980 when K&R compilers started > supporting void *. > > Bruce Okay, let me see if I interpret your sparse explanation correctly =) The caddr_t type was created decades ago to represent a generic "core address". It was originally defined to be equivalent to a pointer to a char, as there was no type available which was more correct; caddr_t became the pseudo- more correct type. Over the years, as more compilers started supporting a pointer to a void, caddr_t was increasingly used so that the proper type would be a type definition away. With caddr_t, old compilers could get the very moldy "everything can be represented as a pointer to a char", and the new ones would get the standardized: [#1] A pointer to void may be converted to or from a pointer to any incomplete or object type. A pointer to any incomplete or object type may be converted to a pointer to void and back again; the result shall compare equal to the original pointer. Therefore, caddr_t is a historical relic which, in its time, was but a placeholder which made it easy to wait for proper implementation of the feature desired. It was always improper as a pointer to a char, as the char * type was never guaranteed to be large enough to cast to or from any other pointer type. However, char * was all that existed in all compilers. The void * type was created to duplicate what was wanted in a generic address type (such as arithmetical semantics), while correctly demonstrating that the type contained was an "unknown". The caddr_t type should be phased out now since only an infinitesimal amount of compilers can't support void *, and the void * type itself gives better type checking then the caddr_t type definition. In all cases, void * is to be used instead of caddr_t in new code. How's my interpretation? Be gentle, because I don't have any actual knowledge to go on ;) -- Brian Fundakowski Feldman \ FreeBSD: The Power to Serve! / green@FreeBSD.org `------------------------------' To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message