[libcxx-commits] [PATCH] D158216: [libc++] Assume that __BYTE_ORDER__ is always present
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Sep 1 08:43:14 PDT 2023
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.
LGTM with suggestion applied.
================
Comment at: libcxx/include/__config:428
-# ifdef __LITTLE_ENDIAN__
-# if __LITTLE_ENDIAN__
-# define _LIBCPP_LITTLE_ENDIAN
-# endif // __LITTLE_ENDIAN__
-# endif // __LITTLE_ENDIAN__
-
-# ifdef __BIG_ENDIAN__
-# if __BIG_ENDIAN__
-# define _LIBCPP_BIG_ENDIAN
-# endif // __BIG_ENDIAN__
-# endif // __BIG_ENDIAN__
-
-# ifdef __BYTE_ORDER__
-# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-# define _LIBCPP_LITTLE_ENDIAN
-# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-# define _LIBCPP_BIG_ENDIAN
-# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-# endif // __BYTE_ORDER__
-
-# ifdef __FreeBSD__
-# include <osreldate.h>
-# include <sys/endian.h>
-# if _BYTE_ORDER == _LITTLE_ENDIAN
-# define _LIBCPP_LITTLE_ENDIAN
-# else // _BYTE_ORDER == _LITTLE_ENDIAN
-# define _LIBCPP_BIG_ENDIAN
-# endif // _BYTE_ORDER == _LITTLE_ENDIAN
-# endif // __FreeBSD__
-
-# if defined(__NetBSD__) || defined(__OpenBSD__)
-# include <sys/endian.h>
-# if _BYTE_ORDER == _LITTLE_ENDIAN
-# define _LIBCPP_LITTLE_ENDIAN
-# else // _BYTE_ORDER == _LITTLE_ENDIAN
-# define _LIBCPP_BIG_ENDIAN
-# endif // _BYTE_ORDER == _LITTLE_ENDIAN
-# endif // defined(__NetBSD__) || defined(__OpenBSD__)
+# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+# define _LIBCPP_LITTLE_ENDIAN
----------------
Can we do something like
```
#ifndef __BYTE_ORDER__
#error "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform
#endif
```
This will catch any failure to satisfy our assumptions here.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158216/new/
https://reviews.llvm.org/D158216
More information about the libcxx-commits
mailing list