GNU C中是否存在UNALIGNED属性? [英] Does UNALIGNED attribute exist in GNU C?

查看:111
本文介绍了GNU C中是否存在UNALIGNED属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


GNU C中__unaligned属性的等价物是什么?

我已经搜索了一段时间,似乎它只是做了不存在......


/ *

对于HP和新的Microsoft编译器,它的工作原理如下:

long_pointer =(some未对齐的地址)

long_value =(*(__ unaligned long *)long_pointer);


这会导致编译器发出获取值的代码

以一些缓慢但肯定的方式,但避免例外

* /


无需建议解决方法请...


问候

--PA

解决方案

-----开始PGP签名留言 - ----

哈希:SHA1


Pavel A. < PA ***** @ NOwritemeNO.com>写道:

什么相当于GNU C中的__unaligned属性?
我已经搜索了一段时间,它似乎不存在...




似乎没有。这可能是因为它不应该需要

,除非你的代码是错误的。如果你的代码是标准的C,编译器

应该很好地为你准备好一切。但是,你没有发布创建未对齐指针的代码



另外:

- - 一些CPU允许未对齐访问。

- - 某些操作系统可以透明地处理不支持它的

系统上的未对齐访问。

- - -

Roger Leigh

在GNU / Linux上打印? http://gimp-print.sourceforge.net/

Debian GNU / Linux http://www.debian.org/

GPG公钥:0x25BFB848。请签名并加密您的邮件。

----- BEGIN PGP SIGNATURE -----

版本:GnuPG v1.4.1(GNU / Linux)
评论:由Mailcrypt处理3.5.8< http://mailcrypt.sourceforge.net/>


iD8DBQFCjOFQVcFcaSW / uEgRAu + aAKDDQqLP5PeBpB4RHt2Wn8bGN4lEXwCfQa4U

MDJleeQZG8u63b7TJZExNog =

= XMLL

----- END PGP SIGNATURE -----


[fu-t set]

comp.lang.ci中的
读取:

GNU C中__unaligned属性的等价物是什么?我已经搜索了一段时间,它似乎不存在......




正确 - 没有什么标准。


-

a签名


感谢Roger的回复。

我是看看如何实现LoadUnalignedLong /

StoreUnalignedLong

等功能(这些需求显而易见......如果你得到未对齐的st文件结构

或网络等)。

无论如何都会这样做。


--PA


" Roger Leigh" <

Hello,

What is equivalent of __unaligned attribute in GNU C?
I''ve searched for some time and it seems that it just does not exist...

/*
For HP and new Microsoft compilers it works this way:
long_pointer = (some unaligned address)
long_value = (* (__unaligned long *) long_pointer );

This causes the compiler to emit code that gets the value
in some slow but sure way, but avoiding exceptions
*/

No need to suggest workarounds please...

Regards
--PA

解决方案

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Pavel A." <pa*****@NOwritemeNO.com> writes:

What is equivalent of __unaligned attribute in GNU C?
I''ve searched for some time and it seems that it just does not exist...



It appears not to. That''s probably because it should not be needed
unless your code is buggy. If your code is standard C, the compiler
should have aligned everything nicely for you. However, you didn''t
post the code that creates the unaligned pointer.

Also:
- - Some CPUs allow unaligned access.
- - Some operating systems can transparently handle unaligned access on
systems that don''t support it.
- --
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iD8DBQFCjOFQVcFcaSW/uEgRAu+aAKDDQqLP5PeBpB4RHt2Wn8bGN4lEXwCfQa4U
MDJleeQZG8u63b7TJZExNog=
=XMLL
-----END PGP SIGNATURE-----


[fu-t set]

in comp.lang.c i read:

What is equivalent of __unaligned attribute in GNU C?
I''ve searched for some time and it seems that it just does not exist...



correct -- there is nothing standard.

--
a signature


Thanks Roger for your reply.
I was looking how to implement functions like LoadUnalignedLong /
StoreUnalignedLong
(the need for these is obvious... if you get unaligned structure from file
or network etc).
So will do it anyway else.

--PA

"Roger Leigh" <


这篇关于GNU C中是否存在UNALIGNED属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆