Navigation


Changeset 791:42fa209a8cc4 in freeDiameter for libfdproto


Ignore:
Timestamp:
Jul 13, 2012, 5:31:20 AM (12 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Attempt at fixing unaligned 64b direct memory access (sigbus on sparc)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/messages.c

    r765 r791  
    13231323        *(uint32_t *)(_bufptr) = htonl((uint32_t)(_u32data));                                   \
    13241324}
     1325
     1326/* The location is not on 64b boundary, so we split the writing in two operations to avoid sigbus */
    13251327#define PUT_in_buf_64( _u64data, _bufptr ) {                                                    \
    1326         *(uint64_t *)(_bufptr) = htonll((uint64_t)(_u64data));                                  \
     1328        uint64_t __v = htonll((uint64_t)(_u64data));                                            \
     1329        *(uint32_t *)(_bufptr) = (uint32_t)(__v);                                               \
     1330        *(((uint32_t *)(_bufptr))+1) = (uint32_t)(__v >> 32);                                   \
    13271331}
    13281332
     
    17741778       
    17751779                case AVP_TYPE_INTEGER64:
    1776                         avp->avp_storage.i64 = (int64_t)ntohll(*(uint64_t *)avp->avp_source);
     1780                        /* the storage might not be aligned on 64b boundary, so no direct indirection here is possible */
     1781                        {
     1782                                uint64_t __stor;
     1783                                memcpy(&__stor, avp->avp_source, sizeof(__stor));
     1784                                avp->avp_storage.i64 = (int64_t)ntohll(__stor);
     1785                        }
    17771786                        break;
    17781787       
     
    17841793                case AVP_TYPE_UNSIGNED64:
    17851794                case AVP_TYPE_FLOAT64: /* same as 32 bits */
    1786                         avp->avp_storage.u64 = (uint64_t)ntohll(*(uint64_t *)avp->avp_source);
     1795                        {
     1796                                uint64_t __stor;
     1797                                memcpy(&__stor, avp->avp_source, sizeof(__stor));
     1798                                avp->avp_storage.u64 = (uint64_t)ntohll(__stor);
     1799                        }
    17871800                        break;
    17881801       
Note: See TracChangeset for help on using the changeset viewer.