DragonFly BSD
DragonFly kernel List (threaded) for 2005-02
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: How to get started down the path...


From: Max Okumoto <okumoto@xxxxxxxx>
Date: Fri, 11 Feb 2005 13:30:30 -0800

walt wrote:

On Fri, 11 Feb 2005, Max Okumoto wrote:



 2.3 Write stub functions for thing you don't want to
     bring in.


Great post, Max, thanks!  I've seen 'stub' used often when
talking about libraries, but I've never really understood
what it means.  Could you give me a concrete example of
what a stub is and why I might want to use one?

A stub function is a function with the same signature as the 'real' function. For instance libc contains a function called syslog(). A stub function for syslog would take the same parameters types, and return the same type.

int
syslog(int type, char *bufp, int len)
{
	/* no code is here */

assert(0); /* please impliment me! */

	return 0;	/* bogus return value */
}

The reason you write stub functions is that you don't
have the code to impliment the the functionality, but
you need the function to compile the code.

This might be the case if you were moving an application
that used syslog to an embeded system, that didn't have
syslogd running nor the library function for syslog().

Max



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]