unaligned-funcs.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* EABI unaligned read/write functions.
  2. Copyright (C) 2005-2022 Free Software Foundation, Inc.
  3. Contributed by CodeSourcery, LLC.
  4. This file is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 3, or (at your option) any
  7. later version.
  8. This file is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. Under Section 7 of GPL version 3, you are granted additional
  13. permissions described in the GCC Runtime Library Exception, version
  14. 3.1, as published by the Free Software Foundation.
  15. You should have received a copy of the GNU General Public License and
  16. a copy of the GCC Runtime Library Exception along with this program;
  17. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  18. <http://www.gnu.org/licenses/>. */
  19. int __aeabi_uread4 (void *);
  20. int __aeabi_uwrite4 (int, void *);
  21. long long __aeabi_uread8 (void *);
  22. long long __aeabi_uwrite8 (long long, void *);
  23. struct __attribute__((packed)) u4 { int data; };
  24. struct __attribute__((packed)) u8 { long long data; };
  25. int
  26. __aeabi_uread4 (void *ptr)
  27. {
  28. return ((struct u4 *) ptr)->data;
  29. }
  30. int
  31. __aeabi_uwrite4 (int data, void *ptr)
  32. {
  33. ((struct u4 *) ptr)->data = data;
  34. return data;
  35. }
  36. long long
  37. __aeabi_uread8 (void *ptr)
  38. {
  39. return ((struct u8 *) ptr)->data;
  40. }
  41. long long
  42. __aeabi_uwrite8 (long long data, void *ptr)
  43. {
  44. ((struct u8 *) ptr)->data = data;
  45. return data;
  46. }