From owner-p4-projects@FreeBSD.ORG Fri Oct 19 19:31:50 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 91D4416A469; Fri, 19 Oct 2007 19:31:50 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 57C0316A421 for ; Fri, 19 Oct 2007 19:31:50 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 2C1F913C4A7 for ; Fri, 19 Oct 2007 19:31:50 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l9JJVoh3077323 for ; Fri, 19 Oct 2007 19:31:50 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l9JJVoPV077320 for perforce@freebsd.org; Fri, 19 Oct 2007 19:31:50 GMT (envelope-from kmacy@freebsd.org) Date: Fri, 19 Oct 2007 19:31:50 GMT Message-Id: <200710191931.l9JJVoPV077320@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 127792 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Oct 2007 19:31:50 -0000 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