Date: Fri, 19 Oct 2007 19:31:50 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 127792 for review Message-ID: <200710191931.l9JJVoPV077320@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=127792 Change 127792 by kmacy@kmacy_home:ethng on 2007/10/19 19:31:20 simple idr compat shim Affected files ... .. //depot/projects/ethng/src/sys/sys/linux_compat.h#4 edit Differences ... ==== //depot/projects/ethng/src/sys/sys/linux_compat.h#4 (text+ko) ==== @@ -82,4 +82,61 @@ } \ } while (0) + +/* + * idr emulation + */ + + + +struct idr { + struct idr *next; + unsigned int key; + void *value; +}; + + +#define DEFINE_IDR(x) struct idr *x; + +static inline void *idr_find(struct idr *x, uint32_t key) +{ + struct idr *i; + for (i=x;i;i=i->next) if (i->key==key) return(i->value); + return(0); +} + +static inline int idr_pre_get(struct idr *idp, unsigned int gfp){return(1);} +static inline int idr_get_new(struct idr **idp, void *ptr, int *id) +{ + struct idr *i=malloc(sizeof(struct idr),M_TEMP,M_WAITOK); + i->key=*id; + i->value=ptr; + i->next=*idp; + *idp=i; + return(0); +} + +static inline int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id) +{ + struct idr *i=malloc(sizeof(struct idr),M_TEMP,M_WAITOK); + i->key=*id; + i->value=ptr; + i->next=idp; + idp=i; + return(0); +} + +static inline void idr_remove(struct idr *idp, int id) +{ + /* leak */ + struct idr *i; + for (i=idp;i;i=((i)->next)) + if ((i)->key==id) { + i=(i)->next; + return; + } +} +static inline void idr_init(struct idr *idp){} + + #endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200710191931.l9JJVoPV077320>