Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site allegra.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!jpl From: jpl@allegra.UUCP (John P. Linderman) Newsgroups: net.unix,net.lang.c Subject: Re: Portablity using structures and malloc - Help Message-ID: <4781@allegra.UUCP> Date: Sun, 21-Jul-85 16:08:53 EDT Article-I.D.: allegra.4781 Posted: Sun Jul 21 16:08:53 1985 Date-Received: Mon, 22-Jul-85 08:20:09 EDT References: <81@drux1.UUCP> <907@umcp-cs.UUCP> <4772@allegra.UUCP> Organization: AT&T Bell Laboratories, Murray Hill Lines: 43 Xref: watmath net.unix:5098 net.lang.c:5721 >>> The answer is simple: malloc has been written by someone who knows >>> the hardware alignment constraints of the machine, and it returns >>> a pointer that is aligned for *any* use. >>> >>> In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) > > malloc knows, but it's a pity that you can't make malloc tell. > If there were a nice > > int malign() {return ALIGNMENT_MULTIPLE;} > > entry in the malloc package, I could do my own storage allocation. > A totally trivial one-liner that would make it much easier to write > portable software. How about it, system implementors? > > John P. Linderman The much-maligned allegra!jpl Close, but no cigar, fish-breath. Don't put the problem on malloc's doorstep. Both you and malloc should be able to determine this value, and a host of others, like minimum alignment required to avoid core dumps, bits per byte, which release of whose UN*X, paging/non-paging, big/little endian, host name, number of file descriptors, maximum lengths for directory entries, path names, arguments passed to exec*, space available per process, and so on, without building them into your programs. Some values, like bits per byte, are unlikely to change without forcing a recompilation, so they could live in a header like /usr/include/portable.h Others, like host name and number of file descriptors, might reasonably be expected to differ between binary-compatible machines or over time, so they should be determinable at execution time. Most of these values are already available if you know where to look, but knowing where to look is not portable. Responsible people on the net [that leaves you out, John] should collect a list of these values that make porting difficult, and decide how they can be made known in a standard way. I suggest that those interested in kicking these issues around move the discussion to mod.unix, since there is likely to be a lot of overlap of proposed additions [whence the mod] and since the problems are more those of UN*X than C [whence the unix]. And why don't you look for a job commensurate with your skills, Linderman, like waxing VAXes? John P. Linderman Departments of Schizophrenia allegra!jpl