| 791 | } |
| 792 | |
| 793 | static int pthread_create(pthread_t *th, pthread_attr_t *attr, void *(* func)(void *), void *arg) |
| 794 | { |
| 795 | struct _pthread_v *tv = (struct _pthread_v *)malloc(sizeof(struct _pthread_v)); |
| 796 | unsigned ssize = 0; |
| 797 | |
| 798 | if (!tv) return 1; |
| 799 | |
| 800 | *th = tv; |
| 801 | |
| 802 | /* Save data in pthread_t */ |
| 803 | tv->ret_arg = arg; |
| 804 | tv->func = func; |
| 805 | tv->clean = NULL; |
| 806 | tv->cancelled = 0; |
| 807 | tv->p_state = PTHREAD_DEFAULT_ATTR; |
| 808 | tv->keymax = 0; |
| 809 | tv->keyval = NULL; |
| 810 | tv->h = (HANDLE) -1; |
| 811 | |
| 812 | if (attr) |
| 813 | { |
| 814 | tv->p_state = attr->p_state; |
| 815 | ssize = (unsigned int)attr->s_size; |
| 816 | } |
| 817 | |
| 818 | /* Make sure tv->h has value of -1 */ |
| 819 | _ReadWriteBarrier(); |
| 820 | |
| 821 | tv->h = (HANDLE) _beginthreadex(NULL, ssize, (_beginthreadex_proc_type)pthread_create_wrapper, tv, 0, NULL); |
| 822 | |
| 823 | /* Failed */ |
| 824 | if (!tv->h) return 1; |
| 825 | |
| 826 | if (tv->p_state & PTHREAD_CREATE_DETACHED) |
| 827 | { |
| 828 | CloseHandle(tv->h); |
| 829 | _ReadWriteBarrier(); |
| 830 | tv->h = 0; |
| 831 | } |
| 832 | |
| 833 | return 0; |
| 834 | } |
| 835 | |
| 836 | static int pthread_join(pthread_t t, void **res) |
| 837 | { |
no outgoing calls
no test coverage detected