我是靠谱客的博主 幸福书本,最近开发中收集的这篇文章主要介绍gcc -ftls-model (-qtls),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

https://www.ibm.com/docs/en/xl-c-and-cpp-linux/16.1.0?topic=descriptions-ftls-model-qtls


Category

Object code control

Pragma equivalent

None.

Purpose

Enables recognition of the __thread storage class specifier, which designates variables that are to be allocated thread-local storage; and specifies the threadlocal storage model to be used.

When this option is in effect, any variables marked with the __thread storage class specifier are treated as local to each thread in a multithreaded application. At run time, a copy of the variable is created for each thread that accesses it, and destroyed when the thread terminates. Like other high-level constructs that you can use to parallelize your applications, thread-local storage prevents race conditions to global data, without the need for low-level synchronization of threads.

Suboptions allow you to specify thread-local storage models, which provide better performance but are more restrictive in their applicability.

Syntax


        .-tls-model--+-=global-dynamic-+-.   
        |            +-=local-dynamic--+ |   
        |            +-=initial-exec---+ |   
        |            '-=local-exec-----' |   
>>- -f--+-no-tls-model-------------------+---------------------><


               .-=default--------.     
        .-tls--+-=global-dynamic-+-.   
        |      +-=initial-exec---+ |   
        |      +-=local-exec-----+ |   
        |      '-=local-dynamic--' |   
>>- -q--+-notls--------------------+---------------------------><

Defaults

-qtls=default

Specifying -qtls with no suboption is equivalent to specifying -qtls=default.

The default setting for -ftls-model is the same as the default setting for -qtls.

Parameters

default (-qtls only)

Uses the appropriate model depending on the setting of the -fPIC (-qpic) option, which determines whether position-independent code is generated or not. When -fPIC (-qpic) is in effect, this suboption results in -qtls=global-dynamic. When -fno-pic (-fno-PIC, -qnopic) is in effect, this suboption results in -qtls=initial-exec .

global-dynamic

This model is the most general, and can be used for all thread-local variables.

initial-exec

This model provides better performance than the global-dynamic or local-dynamic models, and can be used for thread-local variables defined in dynamically-loaded modules, provided that those modules are loaded at the same time as the executable. That is, it can only be used when all thread-local variables are defined in modules that are not loaded through dlopen.

local-dynamic

This model provides better performance than the global-dynamic model, and can be used for thread-local variables defined in dynamically-loaded modules. However, it can only be used when all references to thread-local variables are contained in the same module in which the variables are defined.

local-exec

This model provides the best performance of all of the models, but can only be used when all thread-local variables are defined and referenced by the main executable.

Predefined macros

None.

Related information

  • -fPIC (-qpic)
  • The __thread storage class specifier

Parent topic:

Individual option descriptions

最后

以上就是幸福书本为你收集整理的gcc -ftls-model (-qtls)的全部内容,希望文章能够帮你解决gcc -ftls-model (-qtls)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部