OSDN Git Service

* exceptions.cc (set_signal_mask): Redefine to not pass by address. Report
[pf3gnuchains/sourceware.git] / winsup / cygwin / cygtls.h
1 /* cygtls.h
2
3    Copyright 2003 Red Hat, Inc.
4
5 This software is a copyrighted work licensed under the terms of the
6 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
7 details. */
8
9 #ifndef _CYGTLS_H
10 #define _CYGTLS_H
11
12 #include <signal.h>
13 #include <pwd.h>
14 #include <grp.h>
15 #include <sys/time.h>
16 #define _NOMNTENT_FUNCS
17 #include <mntent.h>
18 #undef _NOMNTENT_FUNCS
19
20 #define CYGTLS_INITIALIZED 0x43227
21 #define CYGTLS_EXCEPTION (0x43227 + true)
22
23 #ifndef CYG_MAX_PATH
24 # define CYG_MAX_PATH 260
25 #endif
26
27 #ifndef UNLEN
28 # define UNLEN 256
29 #endif
30
31 #pragma pack(push,4)
32 struct _local_storage
33 {
34   /*
35      Needed for the group functions
36    */
37   struct __group16 grp;
38   char *namearray[2];
39   int grp_pos;
40
41   /* console.cc */
42   unsigned rarg;
43
44   /* dlfcn.cc */
45   int dl_error;
46   char dl_buffer[256];
47
48   /* passwd.cc */
49   struct passwd res;
50   char pass[_PASSWORD_LEN];
51   int pw_pos;
52
53   /* path.cc */
54   struct mntent mntbuf;
55   int iteration;
56   unsigned available_drives;
57   char mnt_type[80];
58   char mnt_opts[80];
59   char mnt_fsname[CYG_MAX_PATH];
60   char mnt_dir[CYG_MAX_PATH];
61
62   /* strerror */
63   char strerror_buf[20];
64
65   /* sysloc.cc */
66   char *process_ident;
67   int process_logopt;
68   int process_facility;
69   int process_logmask;
70
71   /* times.cc */
72   char timezone_buf[20];
73   struct tm _localtime_buf;
74
75   /* uinfo.cc */
76   char username[UNLEN + 1];
77
78   /* net.cc */
79   char *ntoa_buf;
80   struct protoent *protoent_buf;
81   struct servent *servent_buf;
82   struct hostent *hostent_buf;
83 };
84
85 /* Please keep this file simple.  Changes to the below structure may require
86    acompanying changes to the very simple parser in the perl script
87    'gentls_offsets' (<<-- start parsing here).  */
88
89 typedef __uint32_t __stack_t;
90 struct _threadinfo
91 {
92   void (*func) /*gentls_offsets*/(int)/*gentls_offsets*/;
93   int saved_errno;
94   int sa_flags;
95   sigset_t oldmask;
96   sigset_t newmask;
97   HANDLE event;
98   int *errno_addr;
99   unsigned initialized;
100   sigset_t sigmask;
101   sigset_t sigwait_mask;
102   siginfo_t *sigwait_info;
103   siginfo_t infodata;
104   struct pthread *tid;
105   struct _reent local_clib;
106   struct _local_storage locals;
107   struct _threadinfo *prev, *next;
108   __stack_t stack[8];
109   int sig;
110   __stack_t *stackptr;
111
112   /*gentls_offsets*/
113   static CRITICAL_SECTION protect_linked_list;
114   static void init ();
115   void init_thread (void *) __attribute__ ((regparm (2)));
116   static void call (DWORD (*) (void *, void *), void *) __attribute__ ((regparm (3)));
117   static void call2 (DWORD (*) (void *, void *), void *, void *) __attribute__ ((regparm (3)));
118   static struct _threadinfo *find_tls (int sig);
119   void remove ();
120   void push (__stack_t, bool = false);
121   __stack_t pop ();
122   bool isinitialized () {return initialized == CYGTLS_INITIALIZED || initialized == CYGTLS_EXCEPTION;}
123   void set_state (bool);
124   void reset_exception ();
125   bool interrupt_now (CONTEXT *, int, void *, struct sigaction&)
126     __attribute__((regparm(3)));
127   void __stdcall interrupt_setup (int sig, void *handler, struct sigaction& siga, __stack_t retaddr)
128     __attribute__((regparm(3)));
129   operator HANDLE () const {return tid->win32_obj_id;}
130   /*gentls_offsets*/
131 };
132 #pragma pack(pop)
133
134 extern char *_tlsbase __asm__ ("%fs:4");
135 extern char *_tlstop __asm__ ("%fs:8");
136 #define _my_tls (((_threadinfo *) _tlsbase)[-1])
137 extern _threadinfo *_main_tls;
138
139 #define __getreent() (&_my_tls.local_clib)
140
141 #define CYGTLS_PADSIZE (sizeof (_threadinfo))
142 #endif /*_CYGTLS_H*/