[comp.lang.c] caddr_t

scairns@citib.com (Scott Cairns) (03/09/91)

Can anyone give me a consise description of exactly
what "caddr_t" is?  It's not in K & R (version 1).

boyd@necisa.ho.necisa.oz.au (Boyd Roberts) (03/11/91)

In article <1991Mar8.192533.717@citib.com> scairns@citib.com (Scott Cairns) writes:
>Can anyone give me a consise description of exactly
>what "caddr_t" is?  It's not in K & R (version 1).

It's usually typedef-ed to be `char *'.

It's used in the kernel, so if you're not coding for the kernel, don't
use it.  The `wchan' argument to sleep()% is a `caddr_t'.


Boyd Roberts			boyd@necisa.ho.necisa.oz.au

``When the going gets wierd, the weird turn pro...''

% Kernel sleep routine, not sleep(3).

sarima@tdatirv.UUCP (Stanley Friesen) (03/12/91)

In article <1991Mar8.192533.717@citib.com> scairns@citib.com (Scott Cairns) writes:
>Can anyone give me a consise description of exactly
>what "caddr_t" is?  It's not in K & R (version 1).

It is not a fundamental type, it is a typedef.  It is used in the UNIX kernel
as the type of an arbitrary machine address (of arbitrary type).
It is *usually* define as (char *), but it may be something else if (char *)
will not hold all possible addresses.
-- 
---------------
uunet!tdatirv!sarima				(Stanley Friesen)

berny@tndsyd.oz.au (Berny Goodheart) (03/12/91)

In article <1991Mar8.192533.717@citib.com> scairns@citib.com (Scott Cairns) writes:
>Can anyone give me a consise description of exactly
>what "caddr_t" is?  It's not in K & R (version 1).
> 

Here is a list of defined kernel data types:

caddr_t		Byte aligned Virtual memory address.
daddr_t		Block number of a block device.
dev_t		Major-Minor device number.
label_t		Data block for 'setjmp'
off_t		Byte offset in file.
paddr_t		Physical memory address

These and other data types are defined in "types.h" and should only
be used in kernel code such as device drivers.

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (03/12/91)

In article <692@tndsyd.oz.au> berny@tndsyd.oz.au (Berny Goodheart) writes:
> caddr_t		Byte aligned Virtual memory address.
> daddr_t		Block number of a block device.
> dev_t		Major-Minor device number.
> label_t		Data block for 'setjmp'
> off_t		Byte offset in file.
> paddr_t		Physical memory address
> These and other data types are defined in "types.h" and should only
> be used in kernel code such as device drivers.

Uh, no. On most UNIX systems, st_dev in a struct st has type dev_t, and
you'd better use that if you want portable code. off_t is also used
outside the kernel (for, e.g., lseek()), though I've seen systems where
it doesn't exist. caddr_t is used in many outside libraries.

POSIX defines dev_t, gid_t, ino_t, mode_t, nlink_t, off_t, pid_t, and
uid_t. I wouldn't recommend that you use most of these in portable code.

---Dan

mike (03/13/91)

In an article, tndsyd.oz.au!berny (Berny Goodheart) writes:
>These and other data types are defined in "types.h" and should only
>be used in kernel code such as device drivers.

I beg your pardon.  I use these quite frequently, in my never-ending quest
for increasingly portable code (outside of device drivers, even!) :-)
-- 
Michael Stefanik, MGI Inc., Los Angeles| Opinions stated are not even my own.
Title of the week: Systems Engineer    | UUCP: ...!uunet!bria!mike
-------------------------------------------------------------------------------
Remember folks: If you can't flame MS-DOS, then what _can_ you flame?