The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/x86/include/tls.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (C) 2003 David Xu <davidxu@freebsd.org>
    5  * Copyright (c) 2001 Daniel Eischen <deischen@freebsd.org>
    6  * All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Neither the name of the author nor the names of its contributors
   14  *    may be used to endorse or promote products derived from this software
   15  *    without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  */
   29 
   30 #ifndef _MACHINE_TLS_H_
   31 #define _MACHINE_TLS_H_
   32 
   33 #include <x86/sysarch.h>
   34 
   35 #define TLS_VARIANT_II
   36 
   37 struct pthread;
   38 
   39 /*
   40  * Variant II tcb, first two members are required by rtld,
   41  * %fs (amd64) / %gs (i386) points to the structure.
   42  */
   43 struct tcb {
   44         struct tcb              *tcb_self;      /* required by rtld */
   45         uintptr_t               *tcb_dtv;       /* required by rtld */
   46         struct pthread          *tcb_thread;
   47 };
   48 
   49 #define TLS_DTV_OFFSET  0
   50 #ifdef __amd64__
   51 #define TLS_TCB_ALIGN   16
   52 #else
   53 #define TLS_TCB_ALIGN   4
   54 #endif
   55 #define TLS_TCB_SIZE    sizeof(struct tcb)
   56 #define TLS_TP_OFFSET   0
   57 
   58 static __inline void
   59 _tcb_set(struct tcb *tcb)
   60 {
   61 #ifdef __amd64__
   62         amd64_set_fsbase(tcb);
   63 #else
   64         i386_set_gsbase(tcb);
   65 #endif
   66 }
   67 
   68 static __inline struct tcb *
   69 _tcb_get(void)
   70 {
   71         struct tcb *tcb;
   72 
   73 #ifdef __amd64__
   74         __asm __volatile("movq %%fs:0, %0" : "=r" (tcb));
   75 #else
   76         __asm __volatile("movl %%gs:0, %0" : "=r" (tcb));
   77 #endif
   78         return (tcb);
   79 }
   80 
   81 #endif /* !_MACHINE_TLS_H_ */

Cache object: 0db1816d12b51b1cc8f8b07828d45ea8


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.