~ubuntu-branches/ubuntu/quantal/libgc/quantal

« back to all changes in this revision

Viewing changes to specific.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2011-03-02 13:43:18 UTC
  • mfrom: (1.2.5 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20110302134318-82ful0us5ce82qe8
Tags: 1:7.1-7
* Add ppc64 symbol file (Closes: #615469)
* Add sh4 symbol file (Closes: #614744)
* Add armhf symbol file
* Add powerpcspe symbol file
* Handle sparc64 the same as sparc
* Clear non-arch symbol file to support building on not yet captured
  architectures
* add -pthread to fix build with --no-add-needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 * modified is included with the above copyright notice.
12
12
 */
13
13
 
14
 
#include "private/gc_priv.h" /* For GC_compare_and_exchange, GC_memory_barrier */
15
 
 
16
 
#if defined(GC_LINUX_THREADS)
17
 
 
18
 
#include "private/specific.h"
 
14
#include "private/gc_priv.h"    /* For configuration, pthreads.h. */
 
15
#include "private/thread_local_alloc.h"
 
16
                                /* To determine type of tsd impl. */
 
17
                                /* Includes private/specific.h    */
 
18
                                /* if needed.                     */
 
19
 
 
20
#if defined(USE_CUSTOM_SPECIFIC)
 
21
 
 
22
#include "atomic_ops.h"
19
23
 
20
24
static tse invalid_tse = {INVALID_QTID, 0, 0, INVALID_THREADID};
21
 
                        /* A thread-specific data entry which will never        */
22
 
                        /* appear valid to a reader.  Used to fill in empty     */
23
 
                        /* cache entries to avoid a check for 0.                */
 
25
                        /* A thread-specific data entry which will never    */
 
26
                        /* appear valid to a reader.  Used to fill in empty */
 
27
                        /* cache entries to avoid a check for 0.            */
24
28
 
25
29
int PREFIXED(key_create) (tsd ** key_ptr, void (* destructor)(void *)) {
26
30
    int i;
57
61
    GC_ASSERT(entry -> qtid == INVALID_QTID);
58
62
    /* There can only be one writer at a time, but this needs to be     */
59
63
    /* atomic with respect to concurrent readers.                       */ 
60
 
    *(volatile tse **)(key -> hash + hash_val) = entry;
 
64
    AO_store_release((volatile AO_t *)(key -> hash + hash_val), (AO_t)entry);
61
65
    pthread_mutex_unlock(&(key -> lock));
62
66
    return 0;
63
67
}
125
129
    return entry -> value;
126
130
}
127
131
 
128
 
#endif /* GC_LINUX_THREADS */
 
132
#ifdef GC_ASSERTIONS
 
133
 
 
134
/* Check that that all elements of the data structure associated        */
 
135
/* with key are marked.                                                 */
 
136
void PREFIXED(check_tsd_marks) (tsd *key)
 
137
{
 
138
    int i;
 
139
    tse *p;
 
140
 
 
141
    if (!GC_is_marked(GC_base(key))) {
 
142
        ABORT("Unmarked thread-specific-data table");
 
143
    }
 
144
    for (i = 0; i < TS_HASH_SIZE; ++i) {
 
145
        for (p = key -> hash[i]; p != 0; p = p -> next) {
 
146
            if (!GC_is_marked(GC_base(p))) {
 
147
                GC_err_printf(
 
148
                        "Thread-specific-data entry at %p not marked\n",p);
 
149
                ABORT("Unmarked tse");
 
150
            }
 
151
        }
 
152
    }
 
153
    for (i = 0; i < TS_CACHE_SIZE; ++i) {
 
154
        p = key -> cache[i];
 
155
        if (p != &invalid_tse && !GC_is_marked(GC_base(p))) {
 
156
            GC_err_printf(
 
157
                "Cached thread-specific-data entry at %p not marked\n",p);
 
158
            ABORT("Unmarked cached tse");
 
159
        }
 
160
    }
 
161
}
 
162
 
 
163
#endif
 
164
 
 
165
#endif /* USE_CUSTOM_SPECIFIC */