File: cacheprobe.c

package info (click to toggle)
dvdisaster 0.79.5-10
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 42,960 kB
  • sloc: ansic: 33,411; sh: 4,898; makefile: 138
file content (82 lines) | stat: -rw-r--r-- 1,834 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*  dvdisaster: Additional error correction for optical media.
 *  Copyright (C) 2004-2015 Carsten Gnoerlich.
 *
 *  Email: carsten@dvdisaster.org  -or-  cgnoerlich@fsfe.org
 *  Project homepage: http://www.dvdisaster.org
 *
 *  This file is part of dvdisaster.
 *
 *  dvdisaster is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  dvdisaster is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
 */

#include "dvdisaster.h"

#if defined(SYS_LINUX)

int ProbeCacheLineSize()
{  int cl_size = 0;

   cl_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);

   if(!cl_size)
     cl_size = sysconf(_SC_LEVEL2_CACHE_LINESIZE);

   if(cl_size < 16)
     cl_size = 64;

   return cl_size;
}

#elif defined(SYS_FREEBSD) || defined(SYS_KFREEBSD)

#include <sys/param.h>

int ProbeCacheLineSize()
{  int cl_size = CACHE_LINE_SIZE;

  /* Doing this at compile time may backfire,
     but let's just hope for the best. */

   if(cl_size < 16)
     cl_size = 64;

   return cl_size;
}

#elif defined(SYS_NETBSD)

#include <sys/param.h>

int ProbeCacheLineSize()
{  int cl_size = CACHE_LINE_SIZE;

  /* Doing this at compile time may backfire,
     but let's just hope for the best. */

   if(cl_size < 16)
     cl_size = 64;

   return cl_size;
}

#else /* SYS_UNKNOWN and others. */

int ProbeCacheLineSize()
{
  return 64;
}

#endif