且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

抗锯齿

更新时间:2023-01-18 10:16:23

Malcolm McLean写道:
Malcolm McLean wrote:

建议的新函数


int别名(void * ptr1,size_t len1,void * ptr1,size_t len2)


如果指针重叠,则返回true。
A proposed new function

int alias(void *ptr1, size_t len1, void *ptr1, size_t len2)

Returns true if the pointers overlap.



谁将指定len1和len2参数?

Who will specify the len1 and len2 parameters?




" Malcolm McLean" < re ******* @ btinternet.com写信息

新闻:4 _ *********************** ******* @ bt.com ...

"Malcolm McLean" <re*******@btinternet.comwrote in message
news:4_******************************@bt.com...

>建议的新功能


int别名(void * ptr1,size_t len1,void * ptr1,size_t len2)


如果指针重叠,则返回true。


在大多数机器上可以琐碎实施。但是它必须是一个

标准库函数,因为从不同的对象中比较两个地址并不一定合法。


优势:


如果传递了不需要的别名,非智能实现只会执行用户的错误处理

代码。智能实现可以检测到两个指针不可能是别名,并生成moe

高效代码。


但是限制不会渗透到调用代码。没有

需要声明每个指针参数restict只是因为某个地方

你调用了一个库字符串副本。
>A proposed new function

int alias(void *ptr1, size_t len1, void *ptr1, size_t len2)

Returns true if the pointers overlap.

On most machines it can be trivially implemented. However it has to be a
standard library function because it is not necessarily legal to compare
two address from different objects.

The advantages:

An unintelligent implementation simply executes the user''s error-handling
code if an unwanted alias is passed. An intelligent implementation can
detect that the two pointers cannot possibly be aliases, and generate moe
efficient code.

However the restrictions do not percolate up to calling code. There is no
need to declare every pointer parameter "restict" just because somewhere
you call a library string copy.



不确定是否使用了这样的功能。别名是关于编译时间

优化。您希望编译器生成如下代码:


if(别名(...))

{

// do &QUOT;缓慢&QUOT;代码

}

其他

{

//做快"代码

}


不确定这是否会加快速度:)

Not sure about the use of such a function. aliasing is about compiletime
optimization. You want a compiler to generate code like:

if (alias(...))
{
// do "slow" code
}
else
{
// do "fast" code
}

not sure if that would speed things up :)


Malcolm McLean说:
Malcolm McLean said:

建议的新函数


int别名(void * ptr1,size_t len1,void * ptr1,size_t len2)
A proposed new function

int alias(void *ptr1, size_t len1, void *ptr1, size_t len2)



入侵我的命名空间。请将其称为其他内容,例如isalias。


谢谢。


-

Richard Heathfield

" Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上述域名中, - www。

invades my namespace. Please call it something else, e.g. isalias.

Thanks.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.