This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/52268] tls support should be added for darwin11


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52268

Jeremy Huddleston Sequoia <jeremyhu at macports dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jeremyhu at macports dot org

--- Comment #8 from Jeremy Huddleston Sequoia <jeremyhu at macports dot org> ---
Seems to work to me in gcc-4.6:

~ $ cat test_thread.c 
#include <pthread.h>
#include <stdio.h>

#define NUM_THREADS 5

int __thread value;

void * test_thread(void *arg) {
    return &value;
}

int main(void) {
    int i;
    pthread_t thread[NUM_THREADS];

    for(i=0; i < 5; i++) {
        pthread_create(&thread[i], NULL, test_thread, NULL);
    }

    for(i=0; i < 5; i++) {
        void *loc;
        pthread_join(thread[i], &loc);
        printf("%p\n", loc);
    }

    return 0;
}

$ gcc-mp-4.6 test_thread.c 

$ ./a.out
0x7fc7b3d00118
0x7fc7b3e00118
0x7fc7b3f00118
0x7fc7b3d00118
0x7fc7b3c03b28

$ gcc-mp-4.6 --version
gcc-mp-4.6 (MacPorts gcc46 4.6.4_5+universal) 4.6.4
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]