unaligned.h revision b26fa1a2fbcfee7d03b0c8fd15ec3aa64ae70b9f
#pragma once
/***
This file is part of systemd.
Copyright 2014 Tom Gundersen
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <endian.h>
#include <stdint.h>
/* BE */
return (((uint16_t) u[0]) << 8) |
((uint16_t) u[1]);
}
}
}
u[0] = (uint8_t) (a >> 8);
u[1] = (uint8_t) a;
}
}
}
/* LE */
((uint16_t) u[0]);
}
((uint32_t) unaligned_read_le16(u));
}
((uint64_t) unaligned_read_le32(u));
}
u[0] = (uint8_t) a;
}
unaligned_write_le16(u, (uint16_t) a);
}
unaligned_write_le32(u, (uint32_t) a);
}