Changeset 1287
- Timestamp:
- Mar 11, 2004, 4:05:55 AM (21 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 8 added
- 5 deleted
- 45 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/emx/syscalls.h
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r1286 r1287 136 136 int __dup (int handle); 137 137 int __dup2 (int handle1, int handle2); 138 int __endthread ( int tid);138 int __endthread (void *pvThrd); 139 139 int __execname (char *buf, size_t bufsize); 140 140 void __exit (int ret) __attribute__ ((__noreturn__)); … … 171 171 int __imphandle (int handle); 172 172 int __impsockhandle (int handle, int flags); 173 int __initthread (void *preg);174 173 int __ioctl1 (int handle, int code); 175 174 int __ioctl2 (int handle, unsigned long request, int arg); … … 226 225 int __write (int handle, __const__ void *buf, size_t nbyte); 227 226 228 229 230 227 #if defined (__cplusplus) 231 228 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/thread.h
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1286 r1287 1 /* emx/thread.h (emx+gcc) */ 2 3 #ifndef _EMX_THREAD_H 4 #define _EMX_THREAD_H 5 6 #if defined (__cplusplus) 7 extern "C" { 8 #endif 9 10 #include <time.h> /* struct tm; */ 11 12 struct _uheap; 13 14 struct _thread 15 { 16 int _th_errno; /* comes first, cf. errnofun.s */ 17 void * _th_arg; 18 void (*_th_start)(void *); 19 unsigned char * _th_strtok_ptr; 20 char _th_asctime_buf[26+2]; /* 2 chars for padding */ 21 char _th_tmpnam_buf[16]; /* cf. stdio.h */ 22 struct tm _th_gmtime_buf; 23 unsigned int _th_rand; /* Used by rand() */ 24 void * _th_store; /* Pointer to user data */ 25 char _th_vollabel[12]; /* Used by _getvol() */ 26 char _th_error[28]; /* Used by strerror() */ 27 struct _uheap * _th_rheap; /* Default regular heap */ 28 struct _uheap * _th_theap; /* Default tiled heap */ 29 char _th_ttyname[32]; /* Used by ttyname() */ 30 char _th_inetntoa[16]; /* Used by inetntoa() */ 31 int _th_reserved[974]; /* 4096 bytes, total */ 32 }; 33 34 struct _thread *_thread (void); 35 36 37 #if defined (__cplusplus) 38 } 39 #endif 40 41 #endif /* not _EMX_THREAD_H */ 1 #error "This file is dead. use InnoTekLIBC/thread.h!" -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/umalloc.h
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1286 r1287 606 606 /* Each thread has its own default heap. */ 607 607 608 #define _UM_DEFAULT_REGULAR_HEAP tp->_th_rheap609 #define _UM_DEFAULT_TILED_HEAP tp->_th_theap610 #define _UM_MT_DECL struct _thread *tp = _thread();608 #define _UM_DEFAULT_REGULAR_HEAP pThrd->pRegularHeap 609 #define _UM_DEFAULT_TILED_HEAP pThrd->pTiledHeap 610 #define _UM_MT_DECL __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 611 611 612 612 /* Note that _um_regular_heap is declared in <umalloc.h>. -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/tmpnam.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1286 r1287 4 4 #include "libc-alias.h" 5 5 #include <stdio.h> 6 #include < emx/thread.h>6 #include <InnoTekLIBC/thread.h> 7 7 #include "_tmp.h" 8 8 … … 12 12 if (string == NULL) 13 13 { 14 struct _thread *tp = _thread();15 string = tp->_th_tmpnam_buf;14 __LIBC_PTHREAD pThrd = __libc_threadCurrent (); 15 string = pThrd->szTmpNamBuf; 16 16 } 17 17 if (_tmpidxnam (string) >= 0) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/ttyname.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1286 r1287 4 4 #include <unistd.h> 5 5 #include <emx/syscalls.h> 6 #include < emx/thread.h>6 #include <InnoTekLIBC/thread.h> 7 7 8 8 char *_STD(ttyname) (int handle) 9 9 { 10 struct _thread *tp = _thread();10 __LIBC_PTHREAD pThrd = __libc_threadCurrent (); 11 11 12 if (__ttyname (handle, tp->_th_ttyname, sizeof (tp->_th_ttyname)) == 0)13 return tp->_th_ttyname;12 if (__ttyname (handle, pThrd->szTTYNameBuf, sizeof (pThrd->szTTYNameBuf)) == 0) 13 return pThrd->szTTYNameBuf; 14 14 else 15 15 return NULL; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.def
-
Property cvs2svn:cvs-rev
changed from
1.49
to1.50
r1286 r1287 46 46 "__streamv_rmutex" @26 47 47 "__streamvec_head" @27 48 "__thread_tab" @2848 ; fixme "" @28 49 49 "__tmpidx" @29 50 50 "__tzi" @30 … … 76 76 "__HUGE_VAL" @103 77 77 "__LHUGE_VAL" @104 78 "___alloc_thread" @10578 ; fixme "___alloc_thread" @105 79 79 "___atod" @106 80 80 "___chdir" @107 … … 89 89 "___dup" @116 90 90 "___dup2" @117 91 "___endthread" @11891 ; fixme "___endthread" @118 92 92 "___exit" @119 93 93 "___fcntl" @120 … … 110 110 "___init_app" @137 111 111 "___init_dll" @138 112 "___initthread" @139112 ; fixme "___initthread" @139 113 113 "___ioctl1" @140 114 114 "___ioctl2" @141 … … 134 134 "___lseek" @161 135 135 "___mkdir" @162 136 "___newthread" @163136 ; fixme "___newthread" @163 137 137 "___open" @164 138 138 "___pipe" @165 … … 741 741 "__swchar" @768 742 742 "__sys_dump_heap_objs" @769 743 "_ _sys_exception" @770743 "_sys_exception" @770 744 744 "__tcalloc" @771 745 745 "__tfree" @772 746 746 "__theapmin" @773 747 "__thread" @774747 ; fixme "__thread" @774 748 748 "__threadstore" @775 749 749 "__tmalloc" @776 … … 1078 1078 "___umoddi3" @1103 1079 1079 "__alloca" @1104 1080 "__std_usleep" @1105 1080 1081 1081 "__std_usleep" @1105 1082 "___libc_Back_threadCleanup" @1106 1083 "___libc_Back_threadEnd" @1107 1084 "___libc_Back_threadInit" @1108 1085 "___libc_Back_threadStartup" @1109 1086 "___libc_TLSAlloc" @1110 1087 "___libc_TLSFree" @1111 1088 "___libc_TLSGet" @1112 1089 "___libc_TLSSet" @1113 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/calloc.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1286 r1287 9 9 #include <sys/rmutex.h> 10 10 #include <emx/umalloc.h> 11 #include < emx/thread.h>11 #include <InnoTekLIBC/thread.h> 12 12 13 13 void *_STD(calloc) (size_t count, size_t size) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/heapchk.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1286 r1287 9 9 #include <sys/rmutex.h> 10 10 #include <emx/umalloc.h> 11 #include < emx/thread.h>11 #include <InnoTekLIBC/thread.h> 12 12 13 13 int _heapchk (void) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/heapmin.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1286 r1287 9 9 #include <sys/rmutex.h> 10 10 #include <emx/umalloc.h> 11 #include < emx/thread.h>11 #include <InnoTekLIBC/thread.h> 12 12 13 13 int _heapmin (void) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/heapset.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1286 r1287 9 9 #include <sys/rmutex.h> 10 10 #include <emx/umalloc.h> 11 #include < emx/thread.h>11 #include <InnoTekLIBC/thread.h> 12 12 13 13 int _heapset (unsigned fill) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/heapwalk.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1286 r1287 5 5 #include <umalloc.h> 6 6 #include <emx/umalloc.h> 7 #include < emx/thread.h>7 #include <InnoTekLIBC/thread.h> 8 8 9 9 int _heap_walk (_um_callback1 *callback) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/initr.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1286 r1287 5 5 #include <emx/umalloc.h> 6 6 #include <sys/smutex.h> 7 #include < emx/thread.h>7 #include <InnoTekLIBC/thread.h> 8 8 9 9 /** This is the default regular heap. */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/initt.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1286 r1287 4 4 #include <emx/umalloc.h> 5 5 #include <sys/smutex.h> 6 #include < emx/thread.h>6 #include <InnoTekLIBC/thread.h> 7 7 8 8 /** This is the default tiled heap. */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/malloc.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1286 r1287 9 9 #include <sys/rmutex.h> 10 10 #include <emx/umalloc.h> 11 #include < emx/thread.h>11 #include <InnoTekLIBC/thread.h> 12 12 13 13 void *_STD(malloc) (size_t size) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/posix_memalign.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1286 r1287 28 28 #include <umalloc.h> 29 29 #include <emx/umalloc.h> 30 #include < emx/thread.h>30 #include <InnoTekLIBC/thread.h> 31 31 #include <assert.h> 32 32 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/tcalloc.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1286 r1287 9 9 #include <sys/rmutex.h> 10 10 #include <emx/umalloc.h> 11 #include < emx/thread.h>11 #include <InnoTekLIBC/thread.h> 12 12 13 13 void *_tcalloc (size_t count, size_t size) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/theapmin.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1286 r1287 9 9 #include <sys/rmutex.h> 10 10 #include <emx/umalloc.h> 11 #include < emx/thread.h>11 #include <InnoTekLIBC/thread.h> 12 12 13 13 int _theapmin (void) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/tmalloc.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1286 r1287 9 9 #include <sys/rmutex.h> 10 10 #include <emx/umalloc.h> 11 #include < emx/thread.h>11 #include <InnoTekLIBC/thread.h> 12 12 13 13 void *_tmalloc (size_t size) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/trealloc.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1286 r1287 9 9 #include <sys/rmutex.h> 10 10 #include <emx/umalloc.h> 11 #include < emx/thread.h>11 #include <InnoTekLIBC/thread.h> 12 12 13 13 void *_trealloc (void *block, size_t new_size) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/udefault.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1286 r1287 9 9 #include <sys/rmutex.h> 10 10 #include <emx/umalloc.h> 11 #include < emx/thread.h>11 #include <InnoTekLIBC/thread.h> 12 12 13 13 Heap_t _udefault (Heap_t h) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/malloc/utdefaul.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1286 r1287 9 9 #include <sys/rmutex.h> 10 10 #include <emx/umalloc.h> 11 #include < emx/thread.h>11 #include <InnoTekLIBC/thread.h> 12 12 13 13 Heap_t _utdefault (Heap_t h) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/getvol.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1286 r1287 4 4 #include <stdlib.h> 5 5 #include <string.h> 6 #include < emx/thread.h>6 #include <InnoTekLIBC/thread.h> 7 7 #include <emx/syscalls.h> 8 8 #define INCL_DOSFILEMGR … … 13 13 char *_getvol (char drive) 14 14 { 15 struct _thread *tp = _thread();15 __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 16 16 FS_VAR(); 17 17 … … 33 33 if (rc != 0) 34 34 return NULL; 35 strcpy (tp->_th_vollabel, fsinfo.vol.szVolLabel); 36 37 return tp->_th_vollabel; 35 return strcpy (pThrd->szVolLabelBuf, fsinfo.vol.szVolLabel); 38 36 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/rand.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1286 r1287 3 3 #include "libc-alias.h" 4 4 #include <stdlib.h> 5 #include < emx/thread.h>5 #include <InnoTekLIBC/thread.h> 6 6 7 7 int _STD(rand) (void) 8 8 { 9 struct _thread *tp = _thread();10 tp->_th_rand = tp->_th_rand * 69069 + 5;11 return ( tp->_th_rand >> 16) & 0x7fff;9 __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 10 pThrd->iRand = pThrd->iRand * 69069 + 5; 11 return (pThrd->iRand >> 16) & 0x7fff; 12 12 } 13 13 14 14 void _STD(srand) (unsigned int seed) 15 15 { 16 struct _thread *tp = _thread();17 tp->_th_rand = seed;16 __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 17 pThrd->iRand = seed; 18 18 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/386/_errno.s
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1286 r1287 12 12 __errno: 13 13 __errno_fun: 14 fs 15 movl 12, %eax /* ptib2 */ 16 movl 0(%eax), %eax /* TID */ 17 movl __thread_tab(,%eax,4), %eax 18 / addl $0, %eax /* address of errno */ 14 movl ___libc_gpTLS, %eax 15 movl (%eax), %eax 16 orl %eax, %eax 17 jnz done 18 call ___libc_threadCurrentSlow 19 done: 19 20 EPILOGUE(_errno) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/beginthr.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1286 r1287 5 5 #include <string.h> 6 6 #include <errno.h> 7 #include <emx/thread.h>8 #include <emx/syscalls.h>9 7 #define INCL_DOSPROCESS 10 8 #define INCL_DOSERRORS … … 12 10 #define INCL_FSMACROS 13 11 #include <os2emx.h> 14 15 #define MAX_THREADS 1024 16 17 static struct _thread thread_1 = 18 { 19 0, /* _th_errno */ 20 NULL, /* _th_arg */ 21 NULL, /* _th_start */ 22 NULL, /* _th_strtok_ptr (must be NULL) */ 23 {0}, /* _th_asctime_buf */ 24 {0}, /* _th_tmpnam_buf */ 25 {0}, /* _th_gmtime_buf */ 26 1, /* _th_rand */ 27 NULL, /* _th_store */ 28 "", /* _th_vollabel */ 29 "", /* _th_error */ 30 NULL, /* _th_rheap */ 31 NULL, /* _th_theap */ 32 "" /* _th_ttyname */ 33 }; 34 35 struct _thread *_thread_tab[MAX_THREADS+1] = {NULL, &thread_1}; 12 #include <emx/syscalls.h> 13 #include <InnoTekLIBC/thread.h> 14 #include <InnoTekLIBC/backend.h> 36 15 37 16 38 struct _thread *__alloc_thread (void); /* used in thread.s */ 17 /** 18 * Thread wrapper routine. 19 * 20 * @param pThrd Pointer to thread structure allocated for this thread. 21 */ 22 static void _System threadWrapper(__LIBC_PTHREAD pThrd) 23 { 24 int tid; 25 EXCEPTIONREGISTRATIONRECORD reg; 26 FS_VAR(); 39 27 40 struct _thread *__alloc_thread (void) 41 { 42 struct _thread *tp; 43 ULONG rc; 44 FS_VAR(); 28 __libc_Back_threadStartup(®); 29 pThrd->u.startup.pfnStart(pThrd->u.startup.pvArg); 45 30 46 FS_SAVE_LOAD(); 47 rc = DosAllocMem ((PPVOID)&tp, sizeof (struct _thread), 48 PAG_COMMIT|PAG_READ|PAG_WRITE); 49 FS_RESTORE(); 50 if (rc != 0) 51 return NULL; 52 memset (tp, 0, sizeof (struct _thread)); 53 tp->_th_rand = 1; /* Initialize rand() */ 54 return tp; 31 FS_SAVE_LOAD(); 32 tid = _gettid(); 33 __libc_threadFree(pThrd); 34 __libc_Back_threadEnd(®); 35 for (;;) 36 DosExit(tid == 1 ? EXIT_PROCESS : EXIT_THREAD, 0); 55 37 } 56 38 57 39 58 static void start_thread (struct _thread *tp)40 int _beginthread(void (*pfnStart)(void *), void *pvStack, unsigned cbStack, void *pvArg) 59 41 { 60 EXCEPTIONREGISTRATIONRECORD reg; 42 APIRET rc; 43 TID tid; 44 __LIBC_PTHREAD pThrd; 45 FS_VAR(); 61 46 62 __initthread (®); 63 tp->_th_start (tp->_th_arg); 64 _endthread(); 47 /* 48 * Allocate a thread structure. 49 */ 50 pThrd = __libc_threadAlloc(); 51 if (!pThrd) 52 { 53 errno = ENOMEM; 54 return -1; 55 } 56 57 /* 58 * Set the startup thread info and create a new thread. 59 */ 60 pThrd->u.startup.pfnStart = pfnStart; 61 pThrd->u.startup.pvArg = pvArg; 62 FS_SAVE_LOAD(); 63 rc = DosCreateThread(&tid, 64 (PFNTHREAD)threadWrapper, 65 (ULONG)pThrd, 66 CREATE_READY | STACK_COMMITTED, 67 cbStack); 68 FS_RESTORE(); 69 if (!rc) 70 return tid; 71 72 /* 73 * Set errno and cleanup. 74 */ 75 if (rc == ERROR_NOT_ENOUGH_MEMORY) 76 errno = ENOMEM; 77 else if (rc == ERROR_MAX_THRDS_REACHED) 78 errno = EAGAIN; 79 else 80 errno = EINVAL; 81 __libc_threadFree(pThrd); 82 return -1; 65 83 } 66 84 67 85 68 int _beginthread (void (*start)(void *arg), void *stack, unsigned stack_size, 69 void *arg_list) 86 void _endthread(void) 70 87 { 71 ULONG rc; 72 TID tid; 73 struct _thread *tp; 74 FS_VAR(); 88 __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 89 int tid; 90 FS_VAR(); 75 91 76 tp = __alloc_thread (); 77 if (tp == NULL) 78 { 79 errno = ENOMEM; 80 return -1; 81 } 82 tp->_th_start = start; 83 tp->_th_arg = arg_list; 84 FS_SAVE_LOAD(); 85 rc = DosCreateThread (&tid, (PFNTHREAD)start_thread, (ULONG)tp, 86 CREATE_SUSPENDED | STACK_COMMITTED, stack_size); 87 if (rc != 0) 88 { 89 if (rc == ERROR_NOT_ENOUGH_MEMORY) 90 errno = ENOMEM; 91 else if (rc == ERROR_MAX_THRDS_REACHED) 92 errno = EAGAIN; 93 else 94 errno = EINVAL; 95 DosFreeMem (tp); 96 FS_RESTORE(); 97 return -1; 98 } 99 if (tid > MAX_THREADS) 100 { 101 DosKillThread (tid); 102 errno = EAGAIN; 103 DosFreeMem (tp); 104 FS_RESTORE(); 105 return -1; 106 } 107 if (__newthread (tid) != 0) 108 { 109 DosKillThread (tid); 110 DosFreeMem (tp); 111 FS_RESTORE(); 112 return -1; 113 } 114 _thread_tab[tid] = tp; 115 rc = DosResumeThread (tid); 116 if (rc != 0) 117 { 118 errno = ESRCH; 119 DosFreeMem (tp); 120 FS_RESTORE(); 121 return -1; 122 } 123 FS_RESTORE(); 124 return tid; 92 FS_SAVE_LOAD(); 93 tid = _gettid(); 94 __libc_threadFree(pThrd); 95 for (;;) 96 DosExit(tid == 1 ? EXIT_PROCESS : EXIT_THREAD, 0); 125 97 } 126 127 128 void _endthread (void)129 {130 struct _thread *tp;131 int tid;132 FS_VAR();133 134 tid = _gettid ();135 tp = _thread ();136 FS_SAVE_LOAD();137 if (tp != &thread_1)138 DosFreeMem (tp);139 _thread_tab[tid] = NULL;140 __endthread (tid);141 for (;;)142 DosExit ((tid == 1 ? EXIT_PROCESS : EXIT_THREAD), 0);143 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/threadst.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r1286 r1287 3 3 #include "libc-alias.h" 4 4 #include <stdlib.h> 5 #include < emx/thread.h>5 #include <InnoTekLIBC/thread.h> 6 6 7 /** 8 * @obsolete 9 */ 7 10 void **_threadstore (void) 8 11 { 9 return &_ thread()->_th_store;12 return &__libc_threadCurrent()->pvThreadStoreVar; 10 13 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/startup/startup.c
-
Property cvs2svn:cvs-rev
changed from
1.9
to1.10
r1286 r1287 43 43 44 44 45 /** @page Startup 45 /** @page Startup Startup 46 46 * 47 47 * Quick description of how we startup a process which modules uses LIBC. … … 57 57 * - __init_dll initiates _sys_pid and _sys_ppid globals. 58 58 * - __init_dll creates _sys_heap_fmutex and _sys_gmtxHimem. 59 * - __init_dll then initia lizes _sys_thread_table and calls __newthread() in60 * sys/__newthread.c to create the thread 1 entry.61 * - __newthread() will call __sys_newthread() which inits the high memory62 * heap (or low if no high mem) when calling _hmalloc().59 * - __init_dll then initiates __libc_gpTLS with an allocated TLS ULONG. 60 * The thread structure it self isn't initialized untill it's actually 61 * referenced, and when it is there is static structure for the first 62 * thread needing its per thread area. 63 63 * - __init_dll calls __init_environ() which initializes environ and _org_environ. 64 64 * - __init_environ() will call _hmalloc() thus initiating the high heap. -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strerror.c
-
Property cvs2svn:cvs-rev
changed from
1.9
to1.10
r1286 r1287 5 5 #include <stdlib.h> 6 6 #include <string.h> 7 #include < emx/thread.h>7 #include <InnoTekLIBC/thread.h> 8 8 #include <sys/errno.h> 9 9 … … 15 15 { 16 16 static char msg[] = "Unknown error "; 17 struct _thread *tp = _thread();18 memcpy ( tp->_th_error, msg, sizeof (msg) - 1);19 _itoa (errnum, tp->_th_error+ sizeof (msg) - 1, 10);17 __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 18 memcpy (pThrd->szStrErrorBuf, msg, sizeof (msg) - 1); 19 _itoa (errnum, pThrd->szStrErrorBuf + sizeof (msg) - 1, 10); 20 20 errno = EINVAL; /* this is actually an invalid error number. */ 21 return tp->_th_error;21 return pThrd->szStrErrorBuf; 22 22 } 23 23 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strerror_r.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1286 r1287 27 27 #include <stdlib.h> 28 28 #include <string.h> 29 #include < emx/thread.h>29 #include <InnoTekLIBC/thread.h> 30 30 #include <sys/errno.h> 31 31 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strtok.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1286 r1287 3 3 #include "libc-alias.h" 4 4 #include <string.h> 5 #include < emx/thread.h>5 #include <InnoTekLIBC/thread.h> 6 6 7 7 char *_STD(strtok) (char *string1, const char *string2) … … 9 9 char table[256]; 10 10 unsigned char *p, *result; 11 struct _thread *tp = _thread();11 __LIBC_PTHREAD pThrd = __libc_threadCurrent (); 12 12 if (string1 != NULL) 13 13 p = (unsigned char *)string1; 14 14 else 15 15 { 16 if ( tp->_th_strtok_ptr== NULL)16 if (pThrd->pszStrTokPos == NULL) 17 17 return NULL; 18 p = tp->_th_strtok_ptr;18 p = pThrd->pszStrTokPos; 19 19 } 20 20 memset (table, 0, 256); … … 32 32 if (p == result) 33 33 { 34 tp->_th_strtok_ptr= NULL;34 pThrd->pszStrTokPos = NULL; 35 35 return NULL; 36 36 } … … 38 38 else 39 39 *p++ = 0; 40 tp->_th_strtok_ptr= p;40 pThrd->pszStrTokPos = p; 41 41 return (char *)result; 42 42 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__init.c
-
Property cvs2svn:cvs-rev
changed from
1.11
to1.12
r1286 r1287 25 25 #include <emx/umalloc.h> 26 26 #include <alloca.h> 27 #include <InnoTekLIBC/thread.h> 27 28 28 29 … … 77 78 argc = 0; arg_size = 0; 78 79 /* argv[0] */ 79 PUTC( _ARG_NONZERO);80 PUTC((char)_ARG_NONZERO); 80 81 PUTV; 81 82 for (;;) … … 94 95 break; 95 96 flag_ptr = pool; 96 PUTC( _ARG_NONZERO);97 PUTC((char)_ARG_NONZERO); 97 98 PUTV; 98 99 bs = 0; quote = 0; … … 226 227 _sys_init_ret(pStackFrame); 227 228 228 failure:229 failure: 229 230 DosExit(EXIT_PROCESS, 255); 230 231 } … … 233 234 char const _sys_sig_valid[NSIG] = 234 235 { 235 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1236 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1 236 237 }; 237 238 238 239 struct sig_descr const sig_info[NSIG] = 239 240 { 240 {"SIG0", ST_TERM, ST_TERM},241 {"SIGHUP", ST_TERM, ST_IGNORE},242 {"SIGINT", ST_TERM, ST_IGNORE},243 {"SIGQUIT", ST_TERM, ST_IGNORE},244 {"SIGILL", ST_NEXT, ST_NEXT},245 {"SIGTRAP", ST_NEXT, ST_NEXT},246 {"SIGABRT", ST_TERM, ST_TERM},247 {"SIGEMT", ST_TERM, ST_TERM},248 {"SIGFPE", ST_NEXT, ST_NEXT},249 {"SIGKILL", ST_TERM, ST_TERM},250 {"SIGBUS", ST_TERM, ST_TERM},251 {"SIGSEGV", ST_NEXT, ST_NEXT},252 {"SIGSYS", ST_TERM, ST_TERM},253 {"SIGPIPE", ST_TERM, ST_IGNORE},254 {"SIGALRM", ST_TERM, ST_IGNORE},255 {"SIGTERM", ST_NEXT, ST_IGNORE},256 {"SIGUSR1", ST_IGNORE, ST_IGNORE},257 {"SIGUSR2", ST_IGNORE, ST_IGNORE},258 {"SIGCLD", ST_IGNORE, ST_IGNORE},259 {"SIG19", ST_TERM, ST_TERM},260 {"SIG20", ST_TERM, ST_TERM},261 {"SIGBREAK", ST_TERM, ST_IGNORE}241 {"SIG0", ST_TERM, ST_TERM}, 242 {"SIGHUP", ST_TERM, ST_IGNORE}, 243 {"SIGINT", ST_TERM, ST_IGNORE}, 244 {"SIGQUIT", ST_TERM, ST_IGNORE}, 245 {"SIGILL", ST_NEXT, ST_NEXT}, 246 {"SIGTRAP", ST_NEXT, ST_NEXT}, 247 {"SIGABRT", ST_TERM, ST_TERM}, 248 {"SIGEMT", ST_TERM, ST_TERM}, 249 {"SIGFPE", ST_NEXT, ST_NEXT}, 250 {"SIGKILL", ST_TERM, ST_TERM}, 251 {"SIGBUS", ST_TERM, ST_TERM}, 252 {"SIGSEGV", ST_NEXT, ST_NEXT}, 253 {"SIGSYS", ST_TERM, ST_TERM}, 254 {"SIGPIPE", ST_TERM, ST_IGNORE}, 255 {"SIGALRM", ST_TERM, ST_IGNORE}, 256 {"SIGTERM", ST_NEXT, ST_IGNORE}, 257 {"SIGUSR1", ST_IGNORE, ST_IGNORE}, 258 {"SIGUSR2", ST_IGNORE, ST_IGNORE}, 259 {"SIGCLD", ST_IGNORE, ST_IGNORE}, 260 {"SIG19", ST_TERM, ST_TERM}, 261 {"SIG20", ST_TERM, ST_TERM}, 262 {"SIGBREAK", ST_TERM, ST_IGNORE} 262 263 }; 263 264 264 265 265 static void say 266 { 267 __write(2, msg, strlen (msg));268 } ;269 270 271 static void _sys_terminate 272 { 273 FS_VAR();274 PPIB pPib;275 PTIB pTib;276 DosGetInfoBlocks(&pTib, &pPib);277 say("\r\n");278 say(pPib->pib_pchcmd);279 say(":");280 281 if (signo == SIGABRT)282 say("\r\nAbnormal program termination\r\n");283 else284 { 285 say("\r\nProcess terminated by ");286 say(sig_info[signo].name);287 say("\r\n");288 } 289 FS_SAVE_LOAD();290 while (1)291 DosExit(EXIT_PROCESS, 3);292 } 293 294 295 static void _sys_signal_acknowledge 296 { 297 FS_VAR();298 FS_SAVE_LOAD();299 switch (signo)300 { 301 case SIGINT:302 DosAcknowledgeSignalException(XCPT_SIGNAL_INTR);303 break;304 case SIGTERM:305 DosAcknowledgeSignalException(XCPT_SIGNAL_KILLPROC);306 break;307 case SIGBREAK:308 DosAcknowledgeSignalException(XCPT_SIGNAL_BREAK);309 break;310 } 311 FS_RESTORE();266 static void say(const char *msg) 267 { 268 __write(2, msg, strlen (msg)); 269 } 270 271 272 static void _sys_terminate(int signo) 273 { 274 PPIB pPib; 275 PTIB pTib; 276 FS_VAR(); 277 DosGetInfoBlocks(&pTib, &pPib); 278 say("\r\n"); 279 say(pPib->pib_pchcmd); 280 say(":"); 281 282 if (signo == SIGABRT) 283 say("\r\nAbnormal program termination\r\n"); 284 else 285 { 286 say("\r\nProcess terminated by "); 287 say(sig_info[signo].name); 288 say("\r\n"); 289 } 290 FS_SAVE_LOAD(); 291 while (1) 292 DosExit(EXIT_PROCESS, 3); 293 } 294 295 296 static void _sys_signal_acknowledge(int signo) 297 { 298 FS_VAR(); 299 FS_SAVE_LOAD(); 300 switch (signo) 301 { 302 case SIGINT: 303 DosAcknowledgeSignalException(XCPT_SIGNAL_INTR); 304 break; 305 case SIGTERM: 306 DosAcknowledgeSignalException(XCPT_SIGNAL_KILLPROC); 307 break; 308 case SIGBREAK: 309 DosAcknowledgeSignalException(XCPT_SIGNAL_BREAK); 310 break; 311 } 312 FS_RESTORE(); 312 313 } 313 314 … … 315 316 /* Called from OS/2 exception handler for signal exceptions. */ 316 317 317 static ULONG _sys_signal (int signo) 318 { 319 thread_data *tp; 320 321 tp = SYS_THREAD; 322 if (tp == NULL) 323 return XCPT_CONTINUE_SEARCH; 324 __sigaddset (&tp->sig_pending, signo); 325 _sys_signal_acknowledge (signo); 326 _sys_deliver_pending_signals (tp); 327 switch (sig_info[signo].fun_action) 328 { 329 case ST_TERM: 330 _sys_terminate (signo); 331 case ST_NEXT: 332 return XCPT_CONTINUE_SEARCH; 333 case ST_IGNORE: 334 return XCPT_CONTINUE_EXECUTION; 335 } 336 return XCPT_CONTINUE_SEARCH; /* Keep the optimizer happy */ 318 static ULONG _sys_signal(int signo) 319 { 320 __LIBC_PTHREAD pThrd = __libc_threadCurrentNoAuto(); 321 if (pThrd == NULL) 322 return XCPT_CONTINUE_SEARCH; 323 __sigaddset (&pThrd->b.sys.sig_pending, signo); 324 _sys_signal_acknowledge(signo); 325 _sys_deliver_pending_signals(pThrd); 326 switch (sig_info[signo].fun_action) 327 { 328 case ST_TERM: 329 _sys_terminate(signo); 330 case ST_NEXT: 331 return XCPT_CONTINUE_SEARCH; 332 case ST_IGNORE: 333 return XCPT_CONTINUE_EXECUTION; 334 } 335 return XCPT_CONTINUE_SEARCH; /* Keep the optimizer happy */ 337 336 } 338 337 … … 340 339 /* Called from OS/2 exception handler for traps. */ 341 340 342 static ULONG _sys_trap 343 { 344 thread_data *tp;345 void(*handler)(int signo);346 347 tp = SYS_THREAD;348 if (tp== NULL)349 return XCPT_CONTINUE_SEARCH;350 handler = tp->signals[signo].sa_handler;351 if (handler != SIG_IGN && handler != SIG_DFL)352 handler(signo);353 switch (sig_info[signo].fun_action)354 { 355 case ST_TERM:356 _sys_terminate(signo);357 case ST_NEXT:358 return XCPT_CONTINUE_SEARCH;359 case ST_IGNORE:360 return XCPT_CONTINUE_EXECUTION;361 } 362 return XCPT_CONTINUE_SEARCH; /* Keep the optimizer happy */363 } 364 365 366 static void _sys_deliver_signal (thread_data *tp, int signo)367 { 368 struct sigaction *p;369 void (*handler)(int signo);370 sigset_t mask, old_blocked;371 372 /* TODO: Critical section */373 374 mask = _SIGMASK(signo);375 p = &tp->signals[signo];376 377 tp->sig_pending &= ~mask;378 handler = p->sa_handler;379 380 if (handler == SIG_IGN)381 { 382 /* Ignore the signal. */383 } 384 else if (handler == SIG_DFL)385 { 386 if (sig_info[signo].dfl_action != ST_IGNORE)387 _sys_terminate(signo);388 } 389 else390 { 391 if (p->sa_flags & SA_SYSV)341 static ULONG _sys_trap(int signo) 342 { 343 __LIBC_PTHREAD pThrd; 344 void (*handler)(int signo); 345 346 pThrd = __libc_threadCurrentNoAuto(); 347 if (pThrd == NULL) 348 return XCPT_CONTINUE_SEARCH; 349 handler = pThrd->b.sys.signals[signo].sa_handler; 350 if (handler != SIG_IGN && handler != SIG_DFL) 351 handler(signo); 352 switch (sig_info[signo].fun_action) 353 { 354 case ST_TERM: 355 _sys_terminate(signo); 356 case ST_NEXT: 357 return XCPT_CONTINUE_SEARCH; 358 case ST_IGNORE: 359 return XCPT_CONTINUE_EXECUTION; 360 } 361 return XCPT_CONTINUE_SEARCH; /* Keep the optimizer happy */ 362 } 363 364 365 static void _sys_deliver_signal(__LIBC_PTHREAD pThrd, int signo) 366 { 367 struct sigaction *p; 368 void (*handler)(int signo); 369 sigset_t mask, old_blocked; 370 371 /* TODO: Critical section */ 372 373 mask = _SIGMASK(signo); 374 p = &pThrd->b.sys.signals[signo]; 375 376 pThrd->b.sys.sig_pending &= ~mask; 377 handler = p->sa_handler; 378 379 if (handler == SIG_IGN) 380 { 381 /* Ignore the signal. */ 382 } 383 else if (handler == SIG_DFL) 384 { 385 if (sig_info[signo].dfl_action != ST_IGNORE) 386 _sys_terminate(signo); 387 } 388 else 389 { 390 if (p->sa_flags & SA_SYSV) 392 391 { 393 p->sa_handler = SIG_DFL;394 handler(signo);392 p->sa_handler = SIG_DFL; 393 handler(signo); 395 394 } 396 else if (p->sa_flags & SA_ACK)395 else if (p->sa_flags & SA_ACK) 397 396 { 398 tp->sig_blocked |= mask;399 handler(signo);397 pThrd->b.sys.sig_blocked |= mask; 398 handler(signo); 400 399 } 401 else400 else 402 401 { 403 old_blocked = tp->sig_blocked;404 SET_BLOCKED (tp, tp->sig_blocked | mask | p->sa_mask);405 handler(signo);406 tp->sig_blocked = old_blocked;402 old_blocked = pThrd->b.sys.sig_blocked; 403 SET_BLOCKED(&pThrd->b.sys, pThrd->b.sys.sig_blocked | mask | p->sa_mask); 404 handler(signo); 405 pThrd->b.sys.sig_blocked = old_blocked; 407 406 } 408 407 } … … 410 409 411 410 412 void _sys_deliver_pending_signals (thread_data *tp)413 { 414 int signo;415 416 /* TODO: Critical section */417 while ((tp->sig_pending & ~tp->sig_blocked) != 0)418 { 419 for (signo = 1; signo < NSIG; ++signo)420 if (tp->sig_pending & ~tp->sig_blocked & _SIGMASK(signo))421 _sys_deliver_signal (tp, signo);411 void _sys_deliver_pending_signals(__LIBC_PTHREAD pThrd) 412 { 413 int signo; 414 415 /* TODO: Critical section */ 416 while ((pThrd->b.sys.sig_pending & ~pThrd->b.sys.sig_blocked) != 0) 417 { 418 for (signo = 1; signo < NSIG; ++signo) 419 if (pThrd->b.sys.sig_pending & ~pThrd->b.sys.sig_blocked & _SIGMASK(signo)) 420 _sys_deliver_signal(pThrd, signo); 422 421 } 423 422 } 424 423 425 424 /* from kLib/kHeapDbg.h */ 426 typedef enum { enmRead, enmWrite, enmUnknown } ENMACCESS; 425 typedef enum 426 { 427 enmRead, enmWrite, enmUnknown 428 } ENMACCESS; 427 429 extern BOOL _Optlink kHeapDbgException(void * pvAccess, 428 430 ENMACCESS enmAccess, … … 432 434 asm (".weak kHeapDbgException"); 433 435 434 ULONG _sys_exception (PEXCEPTIONREPORTRECORD report, 435 PEXCEPTIONREGISTRATIONRECORD registration, 436 PCONTEXTRECORD context, 437 PVOID whatever) 438 { 439 __asm__ ("cld"); /* Don't trust */ 440 if (report->fHandlerFlags & (EH_UNWINDING | EH_EXIT_UNWIND)) 436 ULONG _System _sys_exception(PEXCEPTIONREPORTRECORD report, 437 PEXCEPTIONREGISTRATIONRECORD registration, 438 PCONTEXTRECORD context, 439 PVOID whatever) 440 { 441 __asm__ ("cld"); /* Don't trust */ 442 if (report->fHandlerFlags & (EH_UNWINDING | EH_EXIT_UNWIND)) 443 return XCPT_CONTINUE_SEARCH; 444 switch (report->ExceptionNum) 445 { 446 case XCPT_SIGNAL: 447 if (report->cParameters >= 1) 448 { 449 if (report->ExceptionInfo[0] == XCPT_SIGNAL_INTR) 450 return _sys_signal(SIGINT); 451 else if (report->ExceptionInfo[0] == XCPT_SIGNAL_KILLPROC) 452 return _sys_signal(SIGTERM); 453 else if (report->ExceptionInfo[0] == XCPT_SIGNAL_BREAK) 454 return _sys_signal(SIGBREAK); 455 } 456 break; 457 case XCPT_ACCESS_VIOLATION: 458 /* If we're linking libc01.elh or someone is linking static libc 459 together with kLib the electric fence heap will get the opportunity 460 to check if any access violation was caused by someone touching any 461 of the electric fences. */ 462 if ( kHeapDbgException 463 && ( report->ExceptionInfo[0] == XCPT_READ_ACCESS 464 || report->ExceptionInfo[0] == XCPT_WRITE_ACCESS 465 || report->ExceptionInfo[0] == XCPT_EXECUTE_ACCESS 466 || report->ExceptionInfo[0] == XCPT_UNKNOWN_ACCESS) 467 ) 468 { 469 ENMACCESS enmAccess = enmRead; 470 switch (report->ExceptionInfo[0]) 471 { 472 case XCPT_WRITE_ACCESS: enmAccess = enmWrite; break; 473 case XCPT_UNKNOWN_ACCESS: enmAccess = enmUnknown; break; 474 } 475 /* This call returns true if the page was commited in order 476 to workaround the immediate problem. If it returns false 477 the default action should be taken. */ 478 if (kHeapDbgException((void*)report->ExceptionInfo[1], 479 enmAccess, 480 report->ExceptionAddress, 481 report)) 482 return XCPT_CONTINUE_EXECUTION; 483 } 484 case XCPT_DATATYPE_MISALIGNMENT: 485 return _sys_trap(SIGSEGV); 486 487 case XCPT_INTEGER_DIVIDE_BY_ZERO: 488 case XCPT_INTEGER_OVERFLOW: 489 case XCPT_ARRAY_BOUNDS_EXCEEDED: 490 case XCPT_FLOAT_DENORMAL_OPERAND: 491 case XCPT_FLOAT_DIVIDE_BY_ZERO: 492 case XCPT_FLOAT_INEXACT_RESULT: 493 case XCPT_FLOAT_INVALID_OPERATION: 494 case XCPT_FLOAT_OVERFLOW: 495 case XCPT_FLOAT_STACK_CHECK: 496 case XCPT_FLOAT_UNDERFLOW: 497 return _sys_trap(SIGFPE); 498 499 case XCPT_ILLEGAL_INSTRUCTION: 500 case XCPT_INVALID_LOCK_SEQUENCE: 501 case XCPT_PRIVILEGED_INSTRUCTION: 502 return _sys_trap(SIGILL); 503 } 441 504 return XCPT_CONTINUE_SEARCH; 442 switch (report->ExceptionNum) 443 { 444 case XCPT_SIGNAL: 445 if (report->cParameters >= 1) 446 { 447 if (report->ExceptionInfo[0] == XCPT_SIGNAL_INTR) 448 return _sys_signal (SIGINT); 449 else if (report->ExceptionInfo[0] == XCPT_SIGNAL_KILLPROC) 450 return _sys_signal (SIGTERM); 451 else if (report->ExceptionInfo[0] == XCPT_SIGNAL_BREAK) 452 return _sys_signal (SIGBREAK); 453 } 454 break; 455 case XCPT_ACCESS_VIOLATION: 456 /* If we're linking libc01.elh or someone is linking static libc 457 together with kLib the electric fence heap will get the opportunity 458 to check if any access violation was caused by someone touching any 459 of the electric fences. */ 460 if ( kHeapDbgException 461 && ( report->ExceptionInfo[0] == XCPT_READ_ACCESS 462 || report->ExceptionInfo[0] == XCPT_WRITE_ACCESS 463 || report->ExceptionInfo[0] == XCPT_EXECUTE_ACCESS 464 || report->ExceptionInfo[0] == XCPT_UNKNOWN_ACCESS) 465 ) 466 { 467 ENMACCESS enmAccess = enmRead; 468 switch (report->ExceptionInfo[0]) 469 { 470 case XCPT_WRITE_ACCESS: enmAccess = enmWrite; break; 471 case XCPT_UNKNOWN_ACCESS: enmAccess = enmUnknown; break; 472 } 473 /* This call returns true if the page was commited in order 474 to workaround the immediate problem. If it returns false 475 the default action should be taken. */ 476 if (kHeapDbgException((void*)report->ExceptionInfo[1], 477 enmAccess, 478 report->ExceptionAddress, 479 report)) 480 return XCPT_CONTINUE_EXECUTION; 481 } 482 case XCPT_DATATYPE_MISALIGNMENT: 483 return _sys_trap (SIGSEGV); 484 485 case XCPT_INTEGER_DIVIDE_BY_ZERO: 486 case XCPT_INTEGER_OVERFLOW: 487 case XCPT_ARRAY_BOUNDS_EXCEEDED: 488 case XCPT_FLOAT_DENORMAL_OPERAND: 489 case XCPT_FLOAT_DIVIDE_BY_ZERO: 490 case XCPT_FLOAT_INEXACT_RESULT: 491 case XCPT_FLOAT_INVALID_OPERATION: 492 case XCPT_FLOAT_OVERFLOW: 493 case XCPT_FLOAT_STACK_CHECK: 494 case XCPT_FLOAT_UNDERFLOW: 495 return _sys_trap (SIGFPE); 496 497 case XCPT_ILLEGAL_INSTRUCTION: 498 case XCPT_INVALID_LOCK_SEQUENCE: 499 case XCPT_PRIVILEGED_INSTRUCTION: 500 return _sys_trap (SIGILL); 501 } 502 return XCPT_CONTINUE_SEARCH; 503 } 504 505 506 void _sys_get_clock (unsigned long *ms) 507 { 508 ULONG val_ms; 509 FS_VAR(); 510 511 FS_SAVE_LOAD(); 512 DosQuerySysInfo (QSV_MS_COUNT, QSV_MS_COUNT, &val_ms, sizeof (val_ms)); 513 FS_RESTORE(); 514 *ms = val_ms; 515 } 516 517 518 void _sys_init_thread (thread_data *tp) 519 { 520 int n; 521 522 __sigemptyset (&tp->sig_blocked); 523 __sigemptyset (&tp->sig_pending); 524 for (n = 0; n < NSIG; ++n) 525 { 526 tp->signals[n].sa_handler = SIG_DFL; 527 tp->signals[n].sa_flags = SA_ACK; 528 __sigemptyset (&tp->signals[n].sa_mask); 529 } 530 tp->fd.hdir = HDIR_CREATE; 531 tp->fd.cFiles = 0; 532 } 505 } 506 507 508 void _sys_get_clock(unsigned long *ms) 509 { 510 ULONG val_ms; 511 FS_VAR(); 512 513 FS_SAVE_LOAD(); 514 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &val_ms, sizeof (val_ms)); 515 FS_RESTORE(); 516 *ms = val_ms; 517 } 518 519 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__initdll.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1286 r1287 11 11 */ 12 12 13 14 /*******************************************************************************15 * Defined Constants And Macros *16 *******************************************************************************/17 #define SYS_PRIVATE_HEAP_SIZE 0x10000018 13 19 14 /******************************************************************************* … … 35 30 #include <emx/umalloc.h> 36 31 #include <alloca.h> 37 38 32 #include "syscalls.h" 33 #include <InnoTekLIBC/thread.h> 39 34 40 35 /* Make this function an weak external. */ … … 45 40 * Global Variables * 46 41 *******************************************************************************/ 42 __LIBC_PPTHREAD __libc_gpTLS; 43 47 44 extern unsigned char _osminor; 48 45 extern unsigned char _osmajor; … … 59 56 PTIB ptib; 60 57 PPIB ppib; 61 int n;62 58 static int initialized = 0; 63 59 … … 110 106 111 107 /* 112 * Initialize thread table and entry for this thread.108 * Initialize TLS. 113 109 */ 114 /** @todo Remove this table, replace it with a pointer backed by TLS memory. */ 115 for (n = 0; n < MAX_THREADS; ++n) 116 _sys_thread_table[n] = NULL; 117 __newthread(ptib->tib_ptib2->tib2_ultid); 110 if (!__libc_gpTLS) /* !paranoia! */ 111 { 112 rc = DosAllocThreadLocalMemory(1, (PULONG*)&__libc_gpTLS); 113 if (rc) 114 return -1; 115 } 118 116 119 117 /* -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/filefind.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1286 r1287 12 12 #include <emx/syscalls.h> 13 13 #include "syscalls.h" 14 #include <InnoTekLIBC/thread.h> 14 15 15 16 /** … … 114 115 { 115 116 ULONG rc; 116 struct find_data *pFD = & SYS_THREAD->fd;117 struct find_data *pFD = &__libc_threadCurrent()->b.sys.fd; 117 118 FS_VAR(); 118 119 … … 145 146 FS_SAVE_LOAD(); 146 147 memset(&pFD->achBuffer[0], 0, sizeof(pFD->achBuffer)); 147 rc = DosFindFirst( pszName,148 rc = DosFindFirst((PCSZ)pszName, 148 149 &pFD->hdir, 149 150 attr & (FILE_NORMAL | FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED), … … 181 182 { 182 183 ULONG rc; 183 struct find_data *pFD = & SYS_THREAD->fd;184 struct find_data *pFD = &__libc_threadCurrent()->b.sys.fd; 184 185 FS_VAR(); 185 186 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/raise.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1286 r1287 7 7 #include <errno.h> 8 8 #include <emx/syscalls.h> 9 #include <InnoTekLIBC/thread.h> 9 10 #include "syscalls.h" 10 11 11 int _STD(raise) 12 int _STD(raise)(int signo) 12 13 { 13 thread_data *tp;14 __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 14 15 15 if (signo < 1 || signo >= NSIG || !_sys_sig_valid[signo])16 if (signo < 1 || signo >= NSIG || !_sys_sig_valid[signo]) 16 17 { 17 errno = EINVAL;18 return -1;18 errno = EINVAL; 19 return -1; 19 20 } 20 tp = SYS_THREAD; 21 if (tp == NULL) 21 if (pThrd->b.sys.signals[signo].sa_handler != SIG_IGN) 22 22 { 23 errno = EINVAL;24 return -1;23 __sigaddset(&pThrd->b.sys.sig_pending, signo); 24 _sys_deliver_pending_signals(pThrd); 25 25 } 26 if (tp->signals[signo].sa_handler != SIG_IGN) 27 { 28 __sigaddset (&tp->sig_pending, signo); 29 _sys_deliver_pending_signals (tp); 30 } 31 return 0; 26 return 0; 32 27 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/sigaction.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r1286 r1287 6 6 #include <errno.h> 7 7 #include <emx/syscalls.h> 8 #include <InnoTekLIBC/thread.h> 8 9 #include "syscalls.h" 9 10 10 int _STD(sigaction) 11 struct sigaction *oact)11 int _STD(sigaction)(int signo, const struct sigaction *iact, 12 struct sigaction *oact) 12 13 { 13 struct sigaction output, *s; 14 thread_data *tp; 14 struct sigaction output; 15 struct sigaction *s; 16 __LIBC_PTHREAD pThrd; 15 17 16 if (signo < 1 || signo >= NSIG || signo == SIGKILL || !_sys_sig_valid[signo])18 if (signo < 1 || signo >= NSIG || signo == SIGKILL || !_sys_sig_valid[signo]) 17 19 { 18 errno = EINVAL;19 return -1;20 errno = EINVAL; 21 return -1; 20 22 } 21 if (signo == SIGKILL && iact != NULL)23 if (signo == SIGKILL && iact != NULL) 22 24 { 23 errno = EINVAL;24 return -1;25 errno = EINVAL; 26 return -1; 25 27 } 26 tp = SYS_THREAD; 27 if (tp == NULL) 28 pThrd = __libc_threadCurrent(); 29 s = &pThrd->b.sys.signals[signo]; 30 output = *s; 31 if (iact != NULL) 28 32 { 29 errno = EINVAL; 30 return -1; 31 } 32 s = &tp->signals[signo]; 33 output = *s; 34 if (iact != NULL) 35 { 36 *s = *iact; 37 if ((s->sa_handler == SIG_DFL 38 && sig_info[signo].dfl_action != ST_IGNORE) 39 || s->sa_handler == SIG_IGN) 40 sigdelset (&tp->sig_pending, signo); 33 *s = *iact; 34 if ( ( s->sa_handler == SIG_DFL 35 && sig_info[signo].dfl_action != ST_IGNORE) 36 || s->sa_handler == SIG_IGN) 37 sigdelset(&pThrd->b.sys.sig_pending, signo); 41 38 } 42 39 43 if (oact != NULL)44 *oact = output;45 return 0;40 if (oact != NULL) 41 *oact = output; 42 return 0; 46 43 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/signal.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1286 r1287 7 7 #include <emx/syscalls.h> 8 8 #include "syscalls.h" 9 #include <InnoTekLIBC/thread.h> 9 10 10 typedef void sigfun 11 typedef void sigfun(int sig); 11 12 12 sigfun *_STD(signal) 13 sigfun *_STD(signal)(int sig, sigfun *handler) 13 14 { 14 if (handler == SIG_ACK)15 if (handler == SIG_ACK) 15 16 { 16 thread_data *tp;17 __LIBC_PTHREAD pThrd; 17 18 18 if (sig < 1 || sig >= NSIG || sig == SIGKILL || !_sys_sig_valid[sig])19 if (sig < 1 || sig >= NSIG || sig == SIGKILL || !_sys_sig_valid[sig]) 19 20 { 20 errno = EINVAL;21 return SIG_ERR;21 errno = EINVAL; 22 return SIG_ERR; 22 23 } 23 tp = SYS_THREAD;24 if (tp== NULL)25 return SIG_ERR;26 sigdelset (&tp->sig_blocked, sig);27 _sys_deliver_pending_signals (tp);28 return tp->signals[sig].sa_handler;24 pThrd = __libc_threadCurrent(); 25 if (pThrd == NULL) 26 return SIG_ERR; 27 sigdelset(&pThrd->b.sys.sig_blocked, sig); 28 _sys_deliver_pending_signals(pThrd); 29 return pThrd->b.sys.signals[sig].sa_handler; 29 30 } 30 else31 else 31 32 { 32 struct sigaction isa, osa;33 struct sigaction isa, osa; 33 34 34 isa.sa_handler = handler;35 isa.sa_mask = 0;36 isa.sa_flags = SA_ACK;37 if (sigaction(sig, &isa, &osa) != 0)38 return SIG_ERR;39 else40 return osa.sa_handler;35 isa.sa_handler = handler; 36 isa.sa_mask = 0; 37 isa.sa_flags = SA_ACK; 38 if (sigaction(sig, &isa, &osa) != 0) 39 return SIG_ERR; 40 else 41 return osa.sa_handler; 41 42 } 42 43 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/sigpending.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1286 r1287 6 6 #include <emx/syscalls.h> 7 7 #include "syscalls.h" 8 #include <InnoTekLIBC/thread.h> 8 9 9 10 int _STD(sigpending) (sigset_t *set) 10 11 { 11 thread_data *tp; 12 13 /* TODO: Critical section */ 14 tp = SYS_THREAD; 15 *set = tp->sig_blocked & tp->sig_pending; 16 return 0; 12 /* TODO: Critical section */ 13 __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 14 *set = pThrd->b.sys.sig_blocked & pThrd->b.sys.sig_pending; 15 return 0; 17 16 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/sigprocmask.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1286 r1287 7 7 #include <emx/syscalls.h> 8 8 #include "syscalls.h" 9 #include <InnoTekLIBC/thread.h> 9 10 10 int _STD(sigprocmask) 11 int _STD(sigprocmask)(int how, const sigset_t *iset, sigset_t *oset) 11 12 { 12 thread_data *tp;13 sigset_t temp, output;13 __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 14 sigset_t temp, output; 14 15 15 tp = SYS_THREAD; 16 output = tp->sig_blocked; 17 if (iset != NULL) 16 output = pThrd->b.sys.sig_blocked; 17 if (iset != NULL) 18 18 { 19 switch (how)19 switch (how) 20 20 { 21 case SIG_BLOCK:22 temp = tp->sig_blocked | *iset;23 break;24 case SIG_UNBLOCK:25 temp = tp->sig_blocked & ~*iset;26 break;27 case SIG_SETMASK:28 temp = *iset;29 break;30 default:31 errno = EINVAL;32 return -1;21 case SIG_BLOCK: 22 temp = pThrd->b.sys.sig_blocked | *iset; 23 break; 24 case SIG_UNBLOCK: 25 temp = pThrd->b.sys.sig_blocked & ~*iset; 26 break; 27 case SIG_SETMASK: 28 temp = *iset; 29 break; 30 default: 31 errno = EINVAL; 32 return -1; 33 33 } 34 SET_BLOCKED (tp, temp);34 SET_BLOCKED(&pThrd->b.sys, temp); 35 35 } 36 36 37 if (oset != NULL)38 *oset = output;37 if (oset != NULL) 38 *oset = output; 39 39 40 _sys_deliver_pending_signals (tp);41 return 0;40 _sys_deliver_pending_signals(pThrd); 41 return 0; 42 42 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/sigsuspend.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1286 r1287 7 7 #include <emx/syscalls.h> 8 8 #include "syscalls.h" 9 #include <InnoTekLIBC/thread.h> 9 10 10 11 int _STD(sigsuspend) (const sigset_t *mask) 11 12 { 12 sigset_t old_blocked; 13 thread_data *tp; 13 /* TODO: Critical section */ 14 __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 15 sigset_t old_blocked; 14 16 15 /* TODO: Critical section */ 16 tp = SYS_THREAD; 17 old_blocked = tp->sig_blocked; 18 SET_BLOCKED (tp, *mask); 19 pause (); 20 tp->sig_blocked = old_blocked; 21 errno = EINTR; 22 return -1; 17 old_blocked = pThrd->b.sys.sig_blocked; 18 SET_BLOCKED(&pThrd->b.sys, *mask); 19 pause(); 20 pThrd->b.sys.sig_blocked = old_blocked; 21 errno = EINTR; 22 return -1; 23 23 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/syscalls.h
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r1286 r1287 6 6 #include "libc-alias.h" 7 7 #include <sys/signal.h> 8 9 #ifndef __LIBC_THREAD_DECLARED 10 #define __LIBC_THREAD_DECLARED 11 struct __libc_threadCurrentSlow; 12 typedef struct __libc_threadCurrentSlow *__LIBC_PTHREAD, **__LIBC_PPTHREAD; 13 #endif 8 14 9 15 #if !defined (NULL) … … 102 108 #define FDATEZEROP(x) (*(PUSHORT)&(x) == 0) 103 109 104 /** Directory find data entry.105 * Used by __findfirst() and __findnext(). */106 struct find_data107 {108 /** Directory handle. HDIR_CREATE if no session opened. */109 HDIR hdir;110 /** Type of buffer content. FIL_STANDARDL or FIL_STANDARD,111 * i.e. FILEFINDBUF3 or FILEFINDBUF3L. */112 ULONG fType;113 /** Number of files left in the buffer. */114 ULONG cFiles;115 /** Pointer to the next entry. Don't test on this, test on cFiles! */116 const char *pchNext;117 /** Buffer. */118 char achBuffer[2048];119 };120 121 typedef struct122 {123 struct find_data fd;124 sigset_t sig_blocked;125 sigset_t sig_pending;126 struct sigaction signals[NSIG];127 } thread_data;128 129 110 #if defined (INCL_DOSEXCEPTIONS) 130 111 EXTERN PEXCEPTIONREGISTRATIONRECORD _sys_xreg INIT (NULL); 131 ULONG _ sys_exception (PEXCEPTIONREPORTRECORD report,112 ULONG _System _sys_exception (PEXCEPTIONREPORTRECORD report, 132 113 PEXCEPTIONREGISTRATIONRECORD registration, PCONTEXTRECORD context, 133 114 PVOID whatever); … … 154 135 extern struct sig_descr const sig_info[NSIG]; 155 136 156 long _sys_p2t (FTIME t, FDATE d); 157 void _sys_init_thread (thread_data *tp); 158 void _sys_deliver_pending_signals (thread_data *tp); 159 160 #define MAX_THREADS 1024 161 162 EXTERN thread_data *_sys_thread_table[MAX_THREADS]; 163 164 thread_data *_sys_thread (void); 165 #define SYS_THREAD (_sys_thread ()) 137 long _sys_p2t(FTIME t, FDATE d); 138 void _sys_deliver_pending_signals(__LIBC_PTHREAD pThrd); 166 139 167 140 #endif /* _OS2EMX_H */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/time/asctime.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1286 r1287 4 4 #include <string.h> 5 5 #include <time.h> 6 #include < emx/thread.h>6 #include <InnoTekLIBC/thread.h> 7 7 8 8 static char const months[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; … … 13 13 char *_STD(asctime) (const struct tm *t) 14 14 { 15 struct _thread *tp = _thread();16 return asctime_r(t, tp->_th_asctime_buf);15 __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 16 return asctime_r(t, pThrd->szAscTimeAndCTimeBuf); 17 17 } 18 18 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/time/gmtime.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1286 r1287 4 4 #include <stdlib.h> 5 5 #include <time.h> 6 #include < emx/thread.h>6 #include <InnoTekLIBC/thread.h> 7 7 #include <emx/time.h> 8 8 … … 69 69 struct tm *_STD(gmtime)(const time_t *t) 70 70 { 71 struct _thread *tp = _thread();72 return gmtime_r (t, & tp->_th_gmtime_buf);71 __LIBC_PTHREAD pThrd = __libc_threadCurrent (); 72 return gmtime_r (t, &pThrd->GmTimeAndLocalTimeBuf); 73 73 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/time/localtim.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r1286 r1287 3 3 #include "libc-alias.h" 4 4 #include <time.h> 5 #include < emx/thread.h>5 #include <InnoTekLIBC/thread.h> 6 6 #include <emx/time.h> 7 7 8 8 struct tm *_STD(localtime)(const time_t *t) 9 9 { 10 struct _thread *tp = _thread();11 return localtime_r(t, & tp->_th_gmtime_buf);10 __LIBC_PTHREAD pThrd = __libc_threadCurrent(); 11 return localtime_r(t, &pThrd->GmTimeAndLocalTimeBuf); 12 12 } 13 13 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/testcase/loadthread2.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1286 r1287 11 11 APIRET rc; 12 12 szObj[0] = '\0'; 13 rc = DosLoadModule(szObj, sizeof(szObj), "LIBC0 5.DLL", &hmod);13 rc = DosLoadModule(szObj, sizeof(szObj), "LIBC06.DLL", &hmod); 14 14 if (rc) 15 printf("DosLoadModule failed loading LIBC0 5.DLL. rc=%d szObj=%s\n", rc, szObj);15 printf("DosLoadModule failed loading LIBC06.DLL. rc=%d szObj=%s\n", rc, szObj); 16 16 else 17 printf("Successfully loaded LIBC0 5.DLL\n");17 printf("Successfully loaded LIBC06.DLL\n"); 18 18 grc = rc; 19 19 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/version.smak
-
Property cvs2svn:cvs-rev
changed from
1.13
to1.14
r1286 r1287 4 4 VH = 0 5 5 # Middle part of version number 6 VM = 56 VM = 6 7 7 # Low part of version number 8 8 VL = 0 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.