From be8e1fea0eb0438fc1150bafc1a6d740c9a8919d Mon Sep 17 00:00:00 2001 From: Luigi Rizzo Date: Fri, 28 Sep 2001 00:05:11 +0000 Subject: [PATCH] namei.h: move "struct componentname" definition outside "struct nameidata", and provide a valid STDC/C++ definition for function NDINIT queue.h libkern.h: put explicit casts from void * in insque, remque and memset (for the records, these changes are necessary to let the files compile with g++, which is used to build a FreeBSD module for "Click" -- see www.pdos.lcs.mit.edu/click/ . Given that they have zero impact on our code, it is worthwhile to have them in. MFC after: 3 days --- sys/sys/libkern.h | 2 +- sys/sys/namei.h | 42 ++++++++++++++++++++++++++---------------- sys/sys/queue.h | 5 +++-- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h index a1008b828d60..ccaf7e73a097 100644 --- a/sys/sys/libkern.h +++ b/sys/sys/libkern.h @@ -105,7 +105,7 @@ memset(void *b, int c, size_t len) if (c == 0) bzero(b, len); else - for (bb = b; len--; ) + for (bb = (char *)b; len--; ) *bb++ = c; return (b); } diff --git a/sys/sys/namei.h b/sys/sys/namei.h index 69daed11dc87..5b133ccf1d5a 100644 --- a/sys/sys/namei.h +++ b/sys/sys/namei.h @@ -40,6 +40,23 @@ #include #include +struct componentname { + /* + * Arguments to lookup. + */ + u_long cn_nameiop; /* namei operation */ + u_long cn_flags; /* flags to namei */ + struct thread *cn_thread;/* thread requesting lookup */ + struct ucred *cn_cred; /* credentials */ + /* + * Shared between lookup and commit routines. + */ + char *cn_pnbuf; /* pathname buffer */ + char *cn_nameptr; /* pointer to looked up name */ + long cn_namelen; /* length of looked up component */ + long cn_consume; /* chars to consume in lookup() */ +}; + /* * Encapsulation of namei parameters. */ @@ -75,22 +92,7 @@ struct nameidata { * information from the nameidata structure that is passed * through the VOP interface. */ - struct componentname { - /* - * Arguments to lookup. - */ - u_long cn_nameiop; /* namei operation */ - u_long cn_flags; /* flags to namei */ - struct thread *cn_thread;/* thread requesting lookup */ - struct ucred *cn_cred; /* credentials */ - /* - * Shared between lookup and commit routines. - */ - char *cn_pnbuf; /* pathname buffer */ - char *cn_nameptr; /* pointer to looked up name */ - long cn_namelen; /* length of looked up component */ - long cn_consume; /* chars to consume in lookup() */ - } ni_cnd; + struct componentname ni_cnd; }; #ifdef _KERNEL @@ -149,12 +151,20 @@ struct nameidata { static void NDINIT __P((struct nameidata *, u_long, u_long, enum uio_seg, const char *, struct thread *)); static __inline void +#if defined(__STDC__) || defined(__cplusplus) +NDINIT(struct nameidata *ndp, + u_long op, u_long flags, + enum uio_seg segflg, + const char *namep, + struct thread *td) +#else NDINIT(ndp, op, flags, segflg, namep, td) struct nameidata *ndp; u_long op, flags; enum uio_seg segflg; const char *namep; struct thread *td; +#endif { ndp->ni_cnd.cn_nameiop = op; ndp->ni_cnd.cn_flags = flags; diff --git a/sys/sys/queue.h b/sys/sys/queue.h index a4f09b1c7dbc..be9b0c525697 100644 --- a/sys/sys/queue.h +++ b/sys/sys/queue.h @@ -422,7 +422,8 @@ struct quehead { static __inline void insque(void *a, void *b) { - struct quehead *element = a, *head = b; + struct quehead *element = (struct quehead *)a, + *head = (struct quehead *)b; element->qh_link = head->qh_link; element->qh_rlink = head; @@ -433,7 +434,7 @@ insque(void *a, void *b) static __inline void remque(void *a) { - struct quehead *element = a; + struct quehead *element = (struct quehead *)a; element->qh_link->qh_rlink = element->qh_rlink; element->qh_rlink->qh_link = element->qh_link;