Changeset b2ee119f in rtems


Ignore:
Timestamp:
Dec 15, 2014, 7:01:59 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
5063e1a
Parents:
f42d429
git-author:
Sebastian Huber <sebastian.huber@…> (12/15/14 07:01:59)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/15/14 07:27:32)
Message:

sys/endian.h: Fix 16-bit int problems

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/sys/endian.h

    rf42d429 rb2ee119f  
    9292        uint8_t const *p = (uint8_t const *)pp;
    9393
    94         return ((p[0] << 8) | p[1]);
     94        return (((unsigned)p[0] << 8) | p[1]);
    9595}
    9696
     
    100100        uint8_t const *p = (uint8_t const *)pp;
    101101
    102         return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
     102        return (((uint32_t)p[0] << 24) | ((uint32_t)p[1] << 16) |
     103    ((uint32_t)p[2] << 8) | p[3]);
    103104}
    104105
     
    116117        uint8_t const *p = (uint8_t const *)pp;
    117118
    118         return ((p[1] << 8) | p[0]);
     119        return (((unsigned)p[1] << 8) | p[0]);
    119120}
    120121
     
    124125        uint8_t const *p = (uint8_t const *)pp;
    125126
    126         return (((unsigned)p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
     127        return (((uint32_t)p[3] << 24) | ((uint32_t)p[2] << 16) |
     128    ((uint32_t)p[1] << 8) | p[0]);
    127129}
    128130
Note: See TracChangeset for help on using the changeset viewer.