Changeset f64ae82bd480bcd2c18ef07b13d7ed71cf55bcbb

Show
Ignore:
Timestamp:
02/23/11 21:09:32 (4 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
  • src/stratcon_datastore.c

    r5042c38 rf64ae82  
    15701570                                               const char *, void *)) { 
    15711571  struct datastore_onlooker_list *nnode; 
     1572  volatile void **vonlookers = (void *)&onlookers; 
    15721573  nnode = calloc(1, sizeof(*nnode)); 
    15731574  nnode->dispatch = f; 
    15741575  nnode->next = onlookers; 
    1575   while(noit_atomic_casptr((volatile void **)&onlookers, 
     1576  while(noit_atomic_casptr(vonlookers, 
    15761577                           nnode, nnode->next) != (void *)nnode->next) 
    15771578    nnode->next = onlookers; 
  • src/utils/noit_atomic.h

    rcd3d910 rf64ae82  
    4141#if defined(__GNUC__) 
    4242 
    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  
    5243typedef noit_atomic32_t noit_spinlock_t; 
    53  
    5444static inline noit_atomic32_t 
    5545noit_atomic_cas32(volatile noit_atomic32_t *ptr, 
     
    6454  return prev; 
    6555} 
     56 
     57#if (SIZEOF_VOID_P == 4) 
     58static inline void * 
     59noit_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 
    6671 
    6772#ifdef __x86_64__ 
     
    7883  return prev; 
    7984} 
     85#if (SIZEOF_VOID_P == 8) 
     86static inline void * 
     87noit_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 
    8099#else 
    81100static inline noit_atomic64_t 
     
    105124  return prev; 
    106125}; 
     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 
    107130#endif 
    108131