"restrict" macro for c++

since it does not have it, use __restrict instead
This commit is contained in:
Alug committed 2025-06-30 12:18:21 +02:00
1 parent d47e20b54e
commit 465fea8bb3
5 files changed
+32 -24

No files matched your search

+8
View File
@@ -566,6 +566,14 @@ UINT32 quickncasehash (const char *p, size_t n)
#define UNLIKELY(x) (x)
#endif
#ifdef __cplusplus
#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)
#define restrict __restrict
#else
#define restrict
#endif
#endif
// An assert-type mechanism.
#ifdef PARANOIA
#define I_Assert(e) ((e) ? (void)0 : I_Error("assert failed: %s, file %s, line %d", #e, __FILE__, __LINE__))
+8 -8
View File
@@ -31,7 +31,7 @@ enum DrawColumnType
};
template<DrawColumnType Type>
static constexpr UINT8 R_GetColumnTranslated(drawcolumndata_t* dc, UINT8 col, const UINT8 * __restrict colormap)
static constexpr UINT8 R_GetColumnTranslated(drawcolumndata_t* dc, UINT8 col, const UINT8 * restrict colormap)
{
if constexpr (Type & DrawColumnType::DC_COLORMAP)
{
@@ -42,7 +42,7 @@ static constexpr UINT8 R_GetColumnTranslated(drawcolumndata_t* dc, UINT8 col, co
}
template<DrawColumnType Type>
static constexpr UINT8 R_GetColumnTranslucent(drawcolumndata_t* dc, UINT8 * __restrict dest, UINT8 col, const UINT8 * __restrict colormap)
static constexpr UINT8 R_GetColumnTranslucent(drawcolumndata_t* dc, UINT8 * restrict dest, UINT8 col, const UINT8 * restrict colormap)
{
col = R_GetColumnTranslated<Type>(dc, col, colormap);
@@ -57,7 +57,7 @@ static constexpr UINT8 R_GetColumnTranslucent(drawcolumndata_t* dc, UINT8 * __re
}
template<DrawColumnType Type>
static constexpr UINT8 R_DrawColumnPixel(drawcolumndata_t* dc, UINT8 * __restrict dest, UINT32 bit, const __restrict UINT8 *source, const __restrict UINT8 *colormap)
static constexpr UINT8 R_DrawColumnPixel(drawcolumndata_t* dc, UINT8 * restrict dest, UINT32 bit, const restrict UINT8 *source, const restrict UINT8 *colormap)
{
UINT8 col = source[bit];
@@ -189,11 +189,11 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
const INT32 npow2max = dc->sourcelength;
const INT32 stride = vid.width;
const UINT8 * __restrict source = dc->source;
const lighttable_t * __restrict colormap = dc->colormap;
const UINT8 * restrict source = dc->source;
const lighttable_t * restrict colormap = dc->colormap;
// Framebuffer destination address.
UINT8 * __restrict dest = R_Address(dc->x, dc->yl);
UINT8 * restrict dest = R_Address(dc->x, dc->yl);
count++;
@@ -325,7 +325,7 @@ DEFINE_COLUMN_FUNC(R_Draw2sMultiPatchTranslucentColumn, DC_HOLES|DC_TRANSMAP)
void R_DrawFogColumn(drawcolumndata_t* dc)
{
INT32 count;
UINT8 * __restrict dest;
UINT8 * restrict dest;
count = dc->yh - dc->yl;
@@ -344,7 +344,7 @@ void R_DrawFogColumn(drawcolumndata_t* dc)
dest = R_Address(dc->x, dc->yl);
const INT32 stride = vid.width;
const lighttable_t * __restrict colormap = dc->colormap;
const lighttable_t * restrict colormap = dc->colormap;
// Determine scaling, which is the only mapping to be done.
do
+10 -10
View File
@@ -88,10 +88,10 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
UINT32 xstep, ystep;
UINT32 bit;
UINT8 * __restrict dest = R_Address(ds->x1, ds->y);
UINT8 * __restrict dsrc;
UINT8 * restrict dest = R_Address(ds->x1, ds->y);
UINT8 * restrict dsrc;
const UINT8 * __restrict deststop = vid.screens[0] + vid.rowbytes * vid.height;
const UINT8 * restrict deststop = vid.screens[0] + vid.rowbytes * vid.height;
if (dest+8 > deststop)
{
@@ -104,8 +104,8 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
xposition = ds->xfrac; yposition = ds->yfrac;
xstep = ds->xstep; ystep = ds->ystep;
const UINT8 * __restrict source = ds->source;
const UINT8 * __restrict colormap = ds->colormap;
const UINT8 * restrict source = ds->source;
const UINT8 * restrict colormap = ds->colormap;
if constexpr (Type & DS_RIPPLE)
{
@@ -202,8 +202,8 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
UINT32 u, v;
int i;
UINT8 * __restrict dest = R_Address(ds->x1, ds->y);
UINT8 * __restrict dsrc;
UINT8 * restrict dest = R_Address(ds->x1, ds->y);
UINT8 * restrict dsrc;
float startz, startu, startv;
float izstep, uzstep, vzstep;
@@ -382,8 +382,8 @@ DEFINE_SPAN_COMBO(R_DrawTranslucentWaterSpan, DS_TRANSMAP|DS_RIPPLE)
*/
void R_DrawFogSpan(drawspandata_t* ds)
{
const UINT8 * __restrict colormap = ds->colormap;
UINT8 * __restrict dest = R_Address(ds->x1, ds->y);
const UINT8 * restrict colormap = ds->colormap;
UINT8 * restrict dest = R_Address(ds->x1, ds->y);
intptr_t count = ds->x2 - ds->x1 + 1;
@@ -409,7 +409,7 @@ void R_DrawFogSpan_Tilted(drawspandata_t* ds)
{
int width = ds->x2 - ds->x1;
float iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
UINT8 * __restrict dest;
UINT8 * restrict dest;
local_for_thread INT32 *tiltlighting = NULL;
local_for_thread INT32 oldviewwidth = 0;
+1 -1
View File
@@ -88,7 +88,7 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
//
// killough 5/2/98: reformatted
//
FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t * __restrict node)
FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t * restrict node)
{
if (!node->dx)
return x <= node->x ? node->dy > 0 : node->dy < 0;
+5 -5
View File
@@ -100,7 +100,7 @@ static void R_ReallocPlaneBounds(visplane_t *pl)
{
pl->top_memory = static_cast<UINT16*>(Z_Realloc(pl->top_memory, sizeof(UINT16) * (viewwidth + 2), PU_STATIC, NULL));
pl->bottom_memory = static_cast<UINT16*>(Z_Realloc(pl->bottom_memory, sizeof(UINT16) * (viewwidth + 2), PU_STATIC, NULL));
pl->top = pl->top_memory + 1;
pl->top = pl->top_memory + 1;
pl->bottom = pl->bottom_memory + 1;
}
@@ -203,14 +203,14 @@ static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *localspanfunc, INT32
if (!R_CheckMapPlane(__func__, y, x1, x2))
return;
angle = (ds->currentplane->viewangle + ds->currentplane->plangle)>>ANGLETOFINESHIFT;
angle = (ds->currentplane->viewangle + ds->currentplane->plangle)>>ANGLETOFINESHIFT;
planecos = FINECOSINE(angle);
planesin = FINESINE(angle);
// [RH] Notice that I dumped the caching scheme used by Doom.
// It did not offer any appreciable speedup.
distance = FixedMul(ds->planeheight, yslope[y]);
span = abs(centery - y);
span = abs(centery - y);
if (span) // don't divide by zero
{
@@ -259,7 +259,7 @@ static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *localspanfunc, INT32
if (ds->currentplane->extra_colormap)
ds->colormap = ds->currentplane->extra_colormap->colormap + (ds->colormap - colormaps);
ds->y = y;
ds->y = y;
ds->x1 = x1;
ds->x2 = x2;
@@ -301,7 +301,7 @@ static void R_MapTiltedPlane(drawspandata_t *ds, spandrawfunc_t *localspanfunc,
ds->colormap += COLORMAP_REMAPOFFSET;
}
ds->y = y;
ds->y = y;
ds->x1 = x1;
ds->x2 = x2;