export size_t __getcachelinesize(void) for memset()
This commit is contained in:
parent
341742a7e9
commit
4907369a14
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: syncicache.c,v 1.11 2002/11/26 21:14:04 thorpej Exp $ */
|
/* $NetBSD: syncicache.c,v 1.12 2003/08/11 02:11:23 matt Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 1995-1997, 1999 Wolfgang Solfrank.
|
* Copyright (C) 1995-1997, 1999 Wolfgang Solfrank.
|
||||||
|
@ -57,24 +57,27 @@ static struct cache_info _cache_info = {
|
||||||
#else
|
#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static void getcachelinesize (void);
|
size_t __getcachelinesize (void);
|
||||||
|
|
||||||
static int _cachelinesize = 0;
|
static int _cachelinesize = 0;
|
||||||
|
|
||||||
static struct cache_info _cache_info;
|
static struct cache_info _cache_info;
|
||||||
#define CACHEINFO _cache_info
|
#define CACHEINFO _cache_info
|
||||||
|
|
||||||
static void
|
size_t
|
||||||
getcachelinesize(void)
|
__getcachelinesize(void)
|
||||||
{
|
{
|
||||||
static int cachemib[] = { CTL_MACHDEP, CPU_CACHELINE };
|
static int cachemib[] = { CTL_MACHDEP, CPU_CACHELINE };
|
||||||
static int cacheinfomib[] = { CTL_MACHDEP, CPU_CACHEINFO };
|
static int cacheinfomib[] = { CTL_MACHDEP, CPU_CACHEINFO };
|
||||||
size_t clen = sizeof(_cache_info);
|
size_t clen = sizeof(_cache_info);
|
||||||
|
|
||||||
|
if (_cachelinesize)
|
||||||
|
return _cachelinesize;
|
||||||
|
|
||||||
if (sysctl(cacheinfomib, sizeof(cacheinfomib) / sizeof(cacheinfomib[0]),
|
if (sysctl(cacheinfomib, sizeof(cacheinfomib) / sizeof(cacheinfomib[0]),
|
||||||
&_cache_info, &clen, NULL, 0) == 0) {
|
&_cache_info, &clen, NULL, 0) == 0) {
|
||||||
_cachelinesize = _cache_info.dcache_line_size;
|
_cachelinesize = _cache_info.dcache_line_size;
|
||||||
return;
|
return _cachelinesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try older deprecated sysctl */
|
/* Try older deprecated sysctl */
|
||||||
|
@ -88,8 +91,12 @@ getcachelinesize(void)
|
||||||
_cache_info.dcache_line_size = _cachelinesize;
|
_cache_info.dcache_line_size = _cachelinesize;
|
||||||
_cache_info.icache_size = _cachelinesize;
|
_cache_info.icache_size = _cachelinesize;
|
||||||
_cache_info.icache_line_size = _cachelinesize;
|
_cache_info.icache_line_size = _cachelinesize;
|
||||||
|
|
||||||
/* If there is no cache, indicate we have issued the sysctl. */
|
/* If there is no cache, indicate we have issued the sysctl. */
|
||||||
if (!_cachelinesize) _cachelinesize = 1;
|
if (!_cachelinesize)
|
||||||
|
_cachelinesize = 1;
|
||||||
|
|
||||||
|
return _cachelinesize;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -102,7 +109,7 @@ __syncicache(void *from, size_t len)
|
||||||
|
|
||||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||||
if (!_cachelinesize)
|
if (!_cachelinesize)
|
||||||
getcachelinesize();
|
__getcachelinesize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (CACHEINFO.dcache_size > 0) {
|
if (CACHEINFO.dcache_size > 0) {
|
||||||
|
|
Loading…
Reference in New Issue