是“线程存储持续时间”和“线程本地存储持续时间”同义词?

发布于 2025-01-23 04:22:23 字数 516 浏览 0 评论 0 原文

C11,6.2.4对象的存储持续时间,4(添加了重点):

用存储级规范符声明标识符的对象 _thread_local 具有线程存储持续时间

C11,7.5错误< errno.h> 2(添加了强调):

errno 扩展到可修改的lvalue 201),该201)具有 int

是“线程存储持续时间”和“线程本地存储持续时间”同义词?


额外注意:当前的支持 _thread_local 独立于 __ stdc_no_threads __ ,而它是(可能)预计将取决于

C11, 6.2.4 Storage durations of objects, 4 (emphasis added):

An object whose identifier is declared with the storage-class specifier _Thread_local has thread storage duration.

C11, 7.5 Errors <errno.h>, 2 (emphasis added):

errno which expands to a modifiable lvalue 201) that has type int and thread local storage
duration

Are "thread storage duration" and "thread local storage duration" the synonyms?


Extra note: currently the support of _Thread_local is independent of __STDC_NO_THREADS__ while it is (probably) expected to be dependent.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

野生奥特曼 2025-01-30 04:22:23

是“线程存储持续时间”和“线程本地存储持续时间”同义词?

这是我看到的唯一合理的解释,是的。规范第6.2.4/1段中存储持续时间的定义不包括“线程本地存储持续时间”:

有四个存储持续时间:静态,线程,自动和分配。

但是,线程存储持续时间是用 _thread_local 存储类规范声明的标识符的存储持续时间,在一般讨论中,描述与“线程local local”相关的对象相关的对象。在第7.5节中,我出现了“线程本地存储持续时间”(这是规格中该术语的唯一出现)构成编辑错误,但我认为预期的含义并不疑问。规格的说法强化了这一点

在程序启动时,初始线程中errno的值为零(其他线程中的ERRNO的初始值是不确定的值)

(C11 7.5/3)。

errno 在不同线程中可能具有不同的值可以通过两种方式解释:

  1. errno 具有线程存储持续时间,或者
  2. 这是 errno的特殊,独特的特征,除了具有线程存储持续时间以外的其他方式提供。

我发现(2)鉴于规格的整​​体,完全令人难以置信。

Are "thread storage duration" and "thread local storage duration" the synonyms?

That's the only plausible interpretation I see, yes. The definition of storage duration in paragraph 6.2.4/1 of the spec does not include a "thread local storage duration":

There are four storage durations: static, thread, automatic, and allocated.

However, thread storage duration is the storage duration of identifiers declared with the _Thread_local storage class specifier, and it is fairly common in general discussion to describe the objects associated with such identifiers as "thread local". I take the appearance of "thread local storage duration" in in section 7.5 -- which is the only appearance of that term in the spec -- to constitute an editorial error, but I don't think the intended meaning is in doubt. This is reinforced by the spec's remarks that

The value of errno in the initial thread is zero at program startup (the initial value of errno in other threads is an indeterminate value)

(C11 7.5/3).

That errno may have different values in different threads can be explained in only two ways:

  1. errno has thread storage duration, OR
  2. this is a special, unique characteristic of errno, provided by some means other than it having thread storage duration.

I find explanation (2) altogether implausible in light of the spec overall.

七度光 2025-01-30 04:22:23

是的。他们是同一件事。

C11库文件的规范 errno.h 告诉您, errno 的行为应为:声明为:

_Thread_local int errno;

存储持续时间规范告诉您什么 _thread_local < /代码>表示

Yes. They are the same thing.

The specification for the C11 library file errno.h is telling you that errno shall behave as if declared as:

_Thread_local int errno;

and the storage duration specification is telling you what _Thread_local means

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文