Date: Mon, 14 Apr 2008 23:00:56 +0200 From: Mel <fbsd.questions@rachie.is-a-geek.net> To: freebsd-questions@freebsd.org Cc: Brother Seamus <brother_seamus@btinternet.com> Subject: Re: advanced programming unix environment Message-ID: <200804142300.57120.fbsd.questions@rachie.is-a-geek.net> In-Reply-To: <710052.69744.qm@web86512.mail.ird.yahoo.com> References: <710052.69744.qm@web86512.mail.ird.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 14 April 2008 22:02:22 Brother Seamus wrote: > Hi Mel, > > Thanks for your reply - very insightful - i have beendelving into the c > library files - which is after all why i am readingthis book, though still > at the beginning 8). > > On the pracct.c source file I have found it sufficient just to change line > 31 > > from > struct acct acdata; > to > struct acctv1 acdata; I changed it like this, to be compatible with other OS's: --- proc/pracct.c~ 2005-05-24 03:59:41.000000000 -0800 +++ proc/pracct.c 2008-04-14 12:53:41.000000000 -0800 @@ -13,6 +13,12 @@ #define AXSIG 0 #endif +#ifdef HAVE_ACCTV1 +typedef struct acctv1 acct_t; +#else +typedef struct acct acct_t; +#endif + static unsigned long compt2ulong(comp_t comptime) /* convert comp_t to unsigned long */ { @@ -28,7 +34,7 @@ int main(int argc, char *argv[]) { - struct acct acdata; + acct_t acdata; FILE *fp; if (argc != 2) And added HAVE_ACCTV1 to CFLAGS in Make.defines.freebsd :) > > this leaves me with only 1 error which I have side stepped but not fixed. > > > error: +++++++++++++++++++++++++++++++++++++ > > bsdexit2.c: In function 'thr_fn2'; > bsdexit2.c:31: Warning format '%d' expects type 'int', but argument 2 has > type 'pthread_t' +++++++++++++++++++++++++++++++++++++++++ > > line 31of threads/bsdexit2.c reads: > > printf("thread 2: ID is %d\n", pthread_self > > which I have commented this line and Make finishes building. > > however which "% ?" operater would I use to display pthread_self. > In the c library pthread.h it says it is of "pthread_t" type. Yes, it's a structure, so it's not an integer. pthread_self() returns the structure, not the thread id. The thread id is burried in the structure and you shouldn't make any assumptions about it's size or type, since it's opaque to you. However, you can cast it to int and get away with it ;) So make it: printf("thread 2: ID is %d\n", (int)pthread_self()); -- Mel Problem with today's modular software: they start with the modules and never get to the software part.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200804142300.57120.fbsd.questions>