/usr/include/SuperCollider/plugin_interface/Unroll.h is in supercollider-dev 1:3.8.0~repack-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | /*
SuperCollider real time audio synthesis system
Copyright (c) 2002 James McCartney. All rights reserved.
http://www.audiosynth.com
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
These macros allow one to write code which can be compiled optimally depending on
what loop constructs the compiler can best generate code.
*/
#ifndef _Unroll_
#define _Unroll_
#include <string.h>
#include <cassert>
#if 1
// loop type
#define FOR_IS_FASTER 1
#define WHILE_IS_FASTER 0
// indexing type
#define PREINCREMENT_IS_FASTER 1
#define POSTINCREMENT_IS_FASTER 0
#else
// loop type
#define FOR_IS_FASTER 1
#define WHILE_IS_FASTER 0
// indexing type
#define PREINCREMENT_IS_FASTER 0
#define POSTINCREMENT_IS_FASTER 1
#endif
// LOOPING MACROS :
#if FOR_IS_FASTER
#define LOOP(length, stmt) for (int xxi=0; xxi<(length); ++xxi) { stmt; }
#elif WHILE_IS_FASTER
#define LOOP(length, stmt) \
{ int xxn = (length); \
while (--xxn) { \
stmt; \
} \
}
#endif
// above macros are not friendly to the debugger
#if FOR_IS_FASTER
#define LooP(length) for (int xxi=0; xxi<(length); ++xxi)
#elif WHILE_IS_FASTER
#define LooP(length) for (int xxi=(length); --xxi;)
#endif
/* faster loop macro, length is required to be larger than 0 */
#define LOOP1(length, stmt) \
{ int xxn = (length); \
assert(length); \
do { \
stmt; \
} while (--xxn); \
}
// LOOP INDEXING :
/*
meanings of the indexing macros:
ZXP = dereference and pre or post increment
ZX = dereference
PZ = preincrement (if applicable)
ZP = postincrement (if applicable)
ZOFF = offset from the pointer of the first element of the array
(preincrement requires a ZOFF of 1 which is pre-subtracted from the
base pointer. For other indexing types ZOFF is zero)
*/
#if PREINCREMENT_IS_FASTER
#define ZXP(z) (*++(z))
#define ZX(z) (*(z))
#define PZ(z) (++(z))
#define ZP(z) (z)
#define ZOFF (1)
#elif POSTINCREMENT_IS_FASTER
#define ZXP(z) (*(z)++)
#define ZX(z) (*(z))
#define PZ(z) (z)
#define ZP(z) ((z)++)
#define ZOFF (0)
#endif
// ACCESSING INLETS AND OUTLETS :
// unit inputs
#define ZIN(i) (IN(i) - ZOFF) // get buffer pointer offset for iteration
#define ZIN0(i) (IN(i)[0]) // get first sample
// unit outputs
#define ZOUT(i) (OUT(i) - ZOFF) // get buffer pointer offset for iteration
#define ZOUT0(i) (OUT(i)[0]) // get first sample
#include "SC_BoundsMacros.h"
#include <assert.h>
// Efficiency notes: Clear and Copy was benchmarked in October 2008.
// See http://www.mcld.co.uk/blog/blog.php?217 and http://www.mcld.co.uk/blog/blog.php?218
// Set floating-point data to all zeros
inline void Clear(int numSamples, float *out)
{
// The memset approach is valid on any system using IEEE floating-point. On other systems, please check...
memset(out, 0, numSamples * sizeof(float));
}
inline void Clear(int numSamples, double *out)
{
// The memset approach is valid on any system using IEEE floating-point. On other systems, please check...
memset(out, 0, numSamples * sizeof(double));
}
inline void Copy(int numSamples, float *out, float *in)
{
memcpy(out, in, numSamples * sizeof(float));
}
inline void Fill(int numSamples, float *out, float level)
{
out -= ZOFF;
LOOP(numSamples, ZXP(out) = level; );
}
inline void Fill(int numSamples, float *out, float level, float slope)
{
out -= ZOFF;
LOOP(numSamples, ZXP(out) = level; level += slope; );
}
inline void Accum(int numSamples, float *out, float *in)
{
in -= ZOFF;
out -= ZOFF;
LOOP(numSamples, ZXP(out) += ZXP(in); );
}
inline void Scale(int numSamples, float *out, float level)
{
out -= ZOFF;
LOOP(numSamples, ZXP(out) *= level;);
}
inline float Scale(int numSamples, float *out, float level, float slope)
{
out -= ZOFF;
LOOP(numSamples, ZXP(out) *= level; level += slope;);
return level;
}
inline float Scale(int numSamples, float *out, float *in, float level, float slope)
{
in -= ZOFF;
out -= ZOFF;
LOOP(numSamples, ZXP(out) = ZXP(in) * level; level += slope;);
return level;
}
inline float ScaleMix(int numSamples, float *out, float *in, float level, float slope)
{
in -= ZOFF;
out -= ZOFF;
LOOP(numSamples, ZXP(out) += ZXP(in) * level; level += slope;);
return level;
}
inline void Scale(int numSamples, float *out, float *in, float level)
{
in -= ZOFF;
out -= ZOFF;
LOOP(numSamples, ZXP(out) = ZXP(in) * level; );
}
// in these the pointers are assumed to already have been pre-offset.
inline void ZCopy(int numSamples, float *out, const float *in)
{
// pointers must be 8 byte aligned
//assert((((long)(out+ZOFF) & 7) == 0) && (((long)(in+ZOFF) & 7) == 0));
if (in == out) return;
if ((numSamples & 1) == 0) {
// copying doubles is faster on powerpc.
double *outd = (double*)(out + ZOFF) - ZOFF;
double *ind = (double*)(in + ZOFF) - ZOFF;
LOOP(numSamples >> 1, ZXP(outd) = ZXP(ind); );
} else {
LOOP(numSamples, ZXP(out) = ZXP(in); );
}
}
inline void ZClear(int numSamples, float *out)
{
// pointers must be 8 byte aligned
//assert((((long)(out+ZOFF) & 7) == 0) && (((long)(in+ZOFF) & 7) == 0));
if ((numSamples & 1) == 0) {
// copying doubles is faster on powerpc.
double *outd = (double*)(out + ZOFF) - ZOFF;
LOOP(numSamples >> 1, ZXP(outd) = 0.; );
} else {
LOOP(numSamples, ZXP(out) = 0.f; );
}
}
inline void ZAccum(int numSamples, float *out, float *in)
{
LOOP(numSamples, ZXP(out) += ZXP(in); );
}
template <typename Functor>
inline void loop(int length, Functor const & f)
{
for (int i=0; i < length; ++i)
f();
}
template <typename Functor>
inline void loop1(int length, Functor const & f)
{
assert(length > 0);
int i = length;
do {
f();
} while (--i);
}
#endif
|