Date: Fri, 18 Jan 2013 09:59:01 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r245595 - in projects/counters/sys: amd64/include sys Message-ID: <201301180959.r0I9x1aP042112@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Fri Jan 18 09:59:01 2013 New Revision: 245595 URL: http://svnweb.freebsd.org/changeset/base/245595 Log: Split the counter.h into MI and MD part. Only amd64 MD is implemented right now. Added: projects/counters/sys/amd64/include/counter.h (contents, props changed) Modified: projects/counters/sys/sys/counter.h Added: projects/counters/sys/amd64/include/counter.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/counters/sys/amd64/include/counter.h Fri Jan 18 09:59:01 2013 (r245595) @@ -0,0 +1,59 @@ +/*- + * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef __MACHINE_COUNTER_H__ +#define __MACHINE_COUNTER_H__ + +#include <sys/pcpu.h> + +extern struct pcpu __pcpu[1]; + +static __inline void +counter_u64_inc(counter_u64_t c, uint64_t inc) +{ + + __asm __volatile("addq\t%1,%%gs:(%0)" + : + : "r" ((char *)c - (char *)&__pcpu[0]), "r" (inc) + : "memory", "cc"); +} + +static __inline void +counter_u64_dec(counter_u64_t c, uint64_t dec) +{ + + __asm __volatile("subq\t%1,%%gs:(%0)" + : + : "r" ((char *)c - (char *)&__pcpu[0]), "r" (dec) + : "memory", "cc"); +} + +#endif /* ! __MACHINE_COUNTER_H__ */ Modified: projects/counters/sys/sys/counter.h ============================================================================== --- projects/counters/sys/sys/counter.h Fri Jan 18 09:56:50 2013 (r245594) +++ projects/counters/sys/sys/counter.h Fri Jan 18 09:59:01 2013 (r245595) @@ -33,33 +33,9 @@ #define __SYS_COUNTER_H__ #include <sys/param.h> -#include <sys/pcpu.h> -#include <sys/smp.h> +#include <machine/counter.h> -typedef uint64_t * counter_u64_t; - -/* - * XXXGL: to be MD. Just testing now. - */ -extern struct pcpu __pcpu[1]; - -static __inline void -counter_u64_inc(counter_u64_t c, uint64_t inc) -{ - - __asm __volatile("addq\t%1,%%gs:(%0)" : : - "r" ((char *)c - (char *)&__pcpu[0]), - "r" (inc)); -} - -static __inline void -counter_u64_dec(counter_u64_t c, uint64_t dec) -{ - - __asm __volatile("subq\t%1,%%gs:(%0)" : : - "r" ((char *)c - (char *)&__pcpu[0]), - "r" (dec)); -} +typedef uint64_t *counter_u64_t; counter_u64_t counter_u64_alloc(int); void counter_u64_free(counter_u64_t);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201301180959.r0I9x1aP042112>