Changeset f64ae82bd480bcd2c18ef07b13d7ed71cf55bcbb
- Timestamp:
- 02/23/11 21:09:32
(2 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1298495372 +0000
- git-parent:
[5042c383741464af8911a7c93c91a525e72e48c7]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1298495372 +0000
- Message:
strict-aliasing dance
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r5042c38 |
rf64ae82 |
|
| 1570 | 1570 | const char *, void *)) { |
|---|
| 1571 | 1571 | struct datastore_onlooker_list *nnode; |
|---|
| | 1572 | volatile void **vonlookers = (void *)&onlookers; |
|---|
| 1572 | 1573 | nnode = calloc(1, sizeof(*nnode)); |
|---|
| 1573 | 1574 | nnode->dispatch = f; |
|---|
| 1574 | 1575 | nnode->next = onlookers; |
|---|
| 1575 | | while(noit_atomic_casptr((volatile void **)&onlookers, |
|---|
| | 1576 | while(noit_atomic_casptr(vonlookers, |
|---|
| 1576 | 1577 | nnode, nnode->next) != (void *)nnode->next) |
|---|
| 1577 | 1578 | nnode->next = onlookers; |
|---|
| rcd3d910 |
rf64ae82 |
|
| 41 | 41 | #if defined(__GNUC__) |
|---|
| 42 | 42 | |
|---|
| 43 | | #if (SIZEOF_VOID_P == 4) |
|---|
| 44 | | #define noit_atomic_casptr(a,b,c) ((void *)noit_atomic_cas32((vpsized_int *)(a),(vpsized_int)(void *)(b),(vpsized_int)(void *)(c))) |
|---|
| 45 | | #elif (SIZEOF_VOID_P == 8) |
|---|
| 46 | | #define noit_atomic_casptr(a,b,c) ((void *)noit_atomic_cas64((vpsized_int *)(a),(vpsized_int)(void *)(b),(vpsized_int)(void *)(c))) |
|---|
| 47 | | #else |
|---|
| 48 | | #error unsupported pointer width |
|---|
| 49 | | #endif |
|---|
| 50 | | |
|---|
| 51 | | |
|---|
| 52 | 43 | typedef noit_atomic32_t noit_spinlock_t; |
|---|
| 53 | | |
|---|
| 54 | 44 | static inline noit_atomic32_t |
|---|
| 55 | 45 | noit_atomic_cas32(volatile noit_atomic32_t *ptr, |
|---|
| … | … | |
| 64 | 54 | return prev; |
|---|
| 65 | 55 | } |
|---|
| | 56 | |
|---|
| | 57 | #if (SIZEOF_VOID_P == 4) |
|---|
| | 58 | static inline void * |
|---|
| | 59 | noit_atomic_casptr(volatile void **ptr, |
|---|
| | 60 | volatile void *rpl, |
|---|
| | 61 | volatile void *curr) { |
|---|
| | 62 | void *prev; |
|---|
| | 63 | __asm__ volatile ( |
|---|
| | 64 | "lock; cmpxchgl %1, %2" |
|---|
| | 65 | : "=a" (prev) |
|---|
| | 66 | : "r" (rpl), "m" (*(ptr)), "0" (curr) |
|---|
| | 67 | : "memory"); |
|---|
| | 68 | return prev; |
|---|
| | 69 | } |
|---|
| | 70 | #endif |
|---|
| 66 | 71 | |
|---|
| 67 | 72 | #ifdef __x86_64__ |
|---|
| … | … | |
| 78 | 83 | return prev; |
|---|
| 79 | 84 | } |
|---|
| | 85 | #if (SIZEOF_VOID_P == 8) |
|---|
| | 86 | static inline void * |
|---|
| | 87 | noit_atomic_cas64(volatile void **ptr, |
|---|
| | 88 | volatile void *rpl, |
|---|
| | 89 | volatile void *curr) { |
|---|
| | 90 | void *prev; |
|---|
| | 91 | __asm__ volatile ( |
|---|
| | 92 | "lock; cmpxchgq %1, %2" |
|---|
| | 93 | : "=a" (prev) |
|---|
| | 94 | : "r" (rpl), "m" (*(ptr)), "0" (curr) |
|---|
| | 95 | : "memory"); |
|---|
| | 96 | return prev; |
|---|
| | 97 | } |
|---|
| | 98 | #endif |
|---|
| 80 | 99 | #else |
|---|
| 81 | 100 | static inline noit_atomic64_t |
|---|
| … | … | |
| 105 | 124 | return prev; |
|---|
| 106 | 125 | }; |
|---|
| | 126 | #if (SIZEOF_VOID_P == 8) |
|---|
| | 127 | /* This should never be triggered.. 8 byte pointers on 32bit machines */ |
|---|
| | 128 | #error "64bit pointers on a 32bit architecture?" |
|---|
| | 129 | #endif |
|---|
| 107 | 130 | #endif |
|---|
| 108 | 131 | |
|---|