1    /*
     2     * Copyright (c) 2017 Texas Instruments Incorporated - https://www.ti.com
     3     * All rights reserved.
     4     *
     5     * Redistribution and use in source and binary forms, with or without
     6     * modification, are permitted provided that the following conditions
     7     * are met:
     8     *
     9     * *  Redistributions of source code must retain the above copyright
    10     *    notice, this list of conditions and the following disclaimer.
    11     *
    12     * *  Redistributions in binary form must reproduce the above copyright
    13     *    notice, this list of conditions and the following disclaimer in the
    14     *    documentation and/or other materials provided with the distribution.
    15     *
    16     * *  Neither the name of Texas Instruments Incorporated nor the names of
    17     *    its contributors may be used to endorse or promote products derived
    18     *    from this software without specific prior written permission.
    19     *
    20     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    21     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    22     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    23     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    24     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    25     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    26     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    27     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    28     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    29     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    30     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31     */
    32    
    33    /*
    34     *  ======== ReentSupport.xdc ========
    35     */
    36    
    37    package ti.sysbios.rts.ti;
    38    
    39    import xdc.runtime.Assert;
    40    import ti.sysbios.knl.Task;
    41    
    42    /*!
    43     *  ======== ReentSupport ========
    44     *  Provide thread local storage for POSIX implementation
    45     */
    46    
    47    @Template ("./ReentSupport.xdt")
    48    
    49    module ReentSupport
    50    {
    51        /*!
    52         *  ======== A_badThreadType ========
    53         *  Cannot make a call to C library from interrupt context
    54         *
    55         *  @_nodoc
    56         */
    57        config Assert.Id A_badThreadType = {
    58            msg: "A_badThreadType: Cannot call a C runtime library API from a Hwi or Swi thread."
    59        };
    60    
    61        /*
    62         *  ======== getReent ========
    63         *  Return a pointer to the current thread's errno location.
    64         *
    65         *  @b(returns) Address of the errno location in TLS.
    66         */
    67        Int *getReent();
    68    
    69    internal:   /* not for client use */
    70    
    71        /* -------- hook functions -------- */
    72    
    73        /*
    74         *  ======== taskRegHook ========
    75         *  Registration function for the module's hook
    76         *
    77         *  @param(id) The ID of the hook assigned to this module.
    78         */
    79        Void taskRegHook(Int id);
    80    
    81        /*
    82         *  ======== getTlsAddr ========
    83         *  Return address of thread-local storage buffer
    84         *
    85         *  This function is generated. It's implementation differs depending
    86         *  if SYS/BIOS is in ROM or not.
    87         */
    88        Int *getTlsAddr();
    89    
    90        /* -------- Internal Module Types -------- */
    91    
    92        struct Module_State {
    93            Int     taskHId;   /* task hook context ID for this module */
    94        };
    95    }