File tree Expand file tree Collapse file tree 7 files changed +663
-23
lines changed
include/aws/checksums/private Expand file tree Collapse file tree 7 files changed +663
-23
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,7 @@ jobs:
232232 id : test
233233 uses :
cross-platform-actions/[email protected] 234234 with :
235+ # note: sanitizer seems to be broken on s390x (fails trying to allocate several tbs of mem) and package manager works slightly differently that on regular ubuntu
235236 operating_system : freebsd
236237 architecture : x86-64
237238 version : ' 14.0'
@@ -243,6 +244,30 @@ jobs:
243244 chmod a+x builder
244245 ./builder build -p ${{ env.PACKAGE_NAME }}
245246
247+ s390x : # big-endian
248+ runs-on : ubuntu-24.04
249+ steps :
250+ - uses : actions/checkout@v4
251+ - uses : uraimo/run-on-arch-action@v2
252+ name : Run commands
253+ id : runcmd
254+ with :
255+ arch : s390x
256+ distro : ubuntu22.04
257+ install : |
258+ apt-get update -q -y
259+ apt-get -y install sudo
260+ apt-get -y install cmake
261+ apt-get -y install make
262+ apt-get -y install g++
263+ apt-get -y install python3
264+ apt-get -y install git
265+ run : |
266+ lscpu | grep Endian
267+ python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
268+ chmod a+x builder
269+ ./builder build -p ${{ env.PACKAGE_NAME }} --variant s390x --cmake-extra=-DENABLE_SANITIZERS=OFF
270+
246271 openbsd :
247272 runs-on : ubuntu-24.04 # latest
248273 strategy :
Original file line number Diff line number Diff line change 1010 "test_steps" : [
1111 " test" ,
1212 " {install_dir}/bin/checksum-profile{exe}"
13- ]
13+ ],
14+
15+ "variants" : {
16+ "s390x" : {
17+ "hosts" : {
18+ "ubuntu" : {
19+ "!pkg_setup" : []
20+ }
21+ }
22+ }
23+ }
1424}
Original file line number Diff line number Diff line change 55 * SPDX-License-Identifier: Apache-2.0.
66 */
77
8+ #include <aws/common/byte_order.h>
89#include <aws/common/stdint.h>
910#include <limits.h>
11+ #include <stdlib.h>
1012
1113#define large_buffer_apply_impl (Name , T ) \
1214 static T aws_large_buffer_apply_##Name( \
2123 return val; \
2224 }
2325
26+ /* helper function to reverse byte order on big-endian platforms*/
27+ static inline uint32_t aws_bswap32_if_be (uint32_t x ) {
28+ if (!aws_is_big_endian ()) {
29+ return x ;
30+ }
31+
32+ #if _MSC_VER
33+ return _byteswap_ulong (x );
34+ #elif defined(__GNUC__ ) || defined(__clang__ )
35+ return __builtin_bswap32 (x );
36+ #else
37+ return (
38+ ((x & 0xff000000u ) >> 24 ) | ((x & 0x00ff0000u ) >> 8 ) | ((x & 0x0000ff00u ) << 8 ) | ((x & 0x000000ffu ) << 24 ));
39+ #endif
40+ }
41+
42+ /* Reverse the bytes in a 64-bit word. */
43+ static inline uint64_t aws_bswap64_if_be (uint64_t x ) {
44+ if (!aws_is_big_endian ()) {
45+ return x ;
46+ }
47+
48+ #if _MSC_VER
49+ return _byteswap_uint64 (x );
50+ #elif defined(__GNUC__ ) || defined(__clang__ )
51+ return __builtin_bswap64 (x );
52+ #else
53+ return ((x << 56 ) & 0xff00000000000000ULL ) | ((x << 40 ) & 0x00ff000000000000ULL ) |
54+ ((x << 24 ) & 0x0000ff0000000000ULL ) | ((x << 8 ) & 0x000000ff00000000ULL ) |
55+ ((x >> 8 ) & 0x00000000ff000000ULL ) | ((x >> 24 ) & 0x0000000000ff0000ULL ) |
56+ ((x >> 40 ) & 0x000000000000ff00ULL ) | ((x >> 56 ) & 0x00000000000000ffULL );
57+ #endif
58+ }
59+
2460#endif /* AWS_CHECKSUMS_PRIVATE_CRC_UTIL_H */
You can’t perform that action at this time.
0 commit comments