Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Feb 2005 18:06:49 +0200
From:      Peter Pentchev <roam@ringlet.net>
To:        Kathy Quinlan <kat-free@kaqelectronics.dyndns.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: clock.h
Message-ID:  <20050228160649.GC34617@straylight.m.ringlet.net>
In-Reply-To: <42233B48.4010108@kaqelectronics.dyndns.org>
References:  <42233B48.4010108@kaqelectronics.dyndns.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--H8ygTp4AXg6deix2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Feb 28, 2005 at 11:39:52PM +0800, Kathy Quinlan wrote:
> I have this:
>=20
> #include <machine/clock.h>
>=20
> In program I use this:
>=20
> DELAY(1000);
>=20
> I get this:
>=20
> undefined referance to 'DELAY'
>=20
> when I compile the program with GCC with flags -Wall -g -o com main.c
>=20
> ANY ideas ??
>=20
> I have looked in the relevent header and it seems to be there

Yes, it is in clock.h, but...

/*-
 * Kernel interface to machine-dependent clock driver.

That's the way that clock.h starts.  The 'kernel interface' part means
that this is a header file that declares functions that are used *only*
within the FreeBSD kernel - since they are only implemented in another
part of the kernel code.  You cannot use these definitions and functions
=66rom a userland program, as you are trying to do.

The reason that the DELAY() declaration seems to be in the header file,
yet the compiler does not see it, is the #ifdef _KERNEL at the top of
clock.h :)  This is just a level of protection that accomplishes exactly
that - no userland program should *ever* define the _KERNEL symbol, so
no userland program will be fooled into believing that there is a
DELAY() function that it could possibly use.  It simply cannot, since
the DELAY() function is declared within kernel code for use by the
kernel only.

If you want a high-precision delay/sleep interface in a userland
program, take a look at the usleep(2) and nanosleep(2) syscalls.

G'luck,
Peter

--=20
Peter Pentchev	roam@ringlet.net    roam@cnsys.bg    roam@FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
I am the meaning of this sentence.

--H8ygTp4AXg6deix2
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (FreeBSD)

iD8DBQFCI0GZ7Ri2jRYZRVMRAoktAJ9K/UpRs6avaaoTxWkTF9+AA8XUeACeOHRW
FNHGOEWopXiAhVRfgQZD0wo=
=JWPU
-----END PGP SIGNATURE-----

--H8ygTp4AXg6deix2--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050228160649.GC34617>