stddef.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /****************************************************************************
  2. * include/stddef.h
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __INCLUDE_STDDEF_H
  21. #define __INCLUDE_STDDEF_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <sys/types.h>
  26. /****************************************************************************
  27. * Pre-processor Definitions
  28. ****************************************************************************/
  29. /* The <stddef.h> header shall define the following macros:
  30. *
  31. * NULL
  32. * The null pointer constant.
  33. *
  34. * NOTE: Currently the definition of NULL is in sys/types.h but should
  35. * be moved here sometime.
  36. *
  37. * offsetof(type, member-designator)
  38. * Integer constant expression of type size_t, the value of which is the
  39. * offset in bytes to the structure member (member-designator), from the
  40. * beginning of its structure (type).
  41. *
  42. * NOTE: This version of offsetof() depends on behaviors that could be
  43. * undefined for some compilers. It would be better to use a builtin
  44. * function if one exists.
  45. *
  46. * Reference: Opengroup.org
  47. */
  48. #define offsetof(a, b) ((size_t)(&(((a *)(0))->b)))
  49. /****************************************************************************
  50. * Type Definitions
  51. ****************************************************************************/
  52. /* The <stddef.h> header shall define the following types:
  53. *
  54. * ptrdiff_t
  55. * Signed integer type of the result of subtracting two pointers.
  56. *
  57. * wchar_t
  58. * Integer type whose range of values can represent distinct wide-character
  59. * codes for all members of the largest character set specified among the
  60. * locales supported by the compilation environment: the null character has
  61. * the code value 0 and each member of the portable character set has a
  62. * code value equal to its value when used as the lone character in an
  63. * integer character constant.
  64. *
  65. * size_t
  66. * Unsigned integer type of the result of the sizeof operator.
  67. *
  68. * NOTE: Currently the type definitions of ptrdiff_t, wchar_t, and size_t are
  69. * in sys/types.h but should be moved here sometime.
  70. *
  71. * The implementation shall support one or more programming environments in
  72. * which the widths of ptrdiff_t, size_t, and wchar_t are no greater than the
  73. * width of type long. The names of these programming environments can be
  74. * obtained using the confstr() function or the getconf utility.
  75. *
  76. * Reference: Opengroup.org
  77. */
  78. /* Type whose alignment is supported in every context and is at least
  79. * as great as that of any standard type not using alignment specifiers.
  80. */
  81. typedef struct
  82. {
  83. #if defined(CONFIG_HAVE_LONG_LONG)
  84. long long max_align_i;
  85. #else
  86. long max_align_i;
  87. #endif
  88. #if defined(CONFIG_HAVE_LONG_DOUBLE)
  89. long double max_align_f;
  90. #elif defined(CONFIG_HAVE_DOUBLE)
  91. double max_align_f;
  92. #elif defined(CONFIG_HAVE_FLOAT)
  93. float max_align_f;
  94. #endif
  95. } max_align_t;
  96. #endif /* __INCLUDE_STDDEF_H */