uClibc_uwchar.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Copyright (C) 2003 Manuel Novoa III
  2. *
  3. * This library is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU Library General Public
  5. * License as published by the Free Software Foundation; either
  6. * version 2 of the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * Library General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Library General Public
  14. * License along with this library; if not, write to the Free
  15. * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17. /* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
  18. *
  19. * Besides uClibc, I'm using this code in my libc for elks, which is
  20. * a 16-bit environment with a fairly limited compiler. It would make
  21. * things much easier for me if this file isn't modified unnecessarily.
  22. * In particular, please put any new or replacement functions somewhere
  23. * else, and modify the makefile to use your version instead.
  24. * Thanks. Manuel
  25. *
  26. * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */
  27. /* Define an internal unsigned int type __uwchar_t just large enough
  28. * to hold a wchar_t.
  29. */
  30. #ifndef _UCLIBC_UWCHAR_H
  31. #define _UCLIBC_UWCHAR_H
  32. #include <limits.h>
  33. #include <stdint.h>
  34. #if WCHAR_MIN == 0
  35. typedef wchar_t __uwchar_t;
  36. #elif WCHAR_MAX <= USHRT_MAX
  37. typedef unsigned short __uwchar_t;
  38. #elif WCHAR_MAX <= UINT_MAX
  39. typedef unsigned int __uwchar_t;
  40. #elif WCHAR_MAX <= ULONG_MAX
  41. typedef unsigned long __uwchar_t;
  42. #elif defined(ULLONG_MAX) && (WCHAR_MAX <= ULLONG_MAX)
  43. typedef unsigned long long __uwchar_t;
  44. #elif WCHAR_MAX <= UINTMAX_MAX
  45. typedef uintmax_t __uwchar_t;
  46. #else
  47. #error Can not determine an appropriate type for __uwchar_t!
  48. #endif
  49. #endif /* _UCLIBC_UWCHAR_H */