mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-27 15:01:03 +08:00
Test on big endian CPU architectures
This commit is contained in:
parent
fb3b0ca6e3
commit
76f693e5d7
22
.github/workflows/test.yml
vendored
22
.github/workflows/test.yml
vendored
@ -18,6 +18,28 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- run: sudo apt-get update ; sudo apt-get install libmbedtls-dev
|
- run: sudo apt-get update ; sudo apt-get install libmbedtls-dev
|
||||||
- run: make ${{ matrix.target }}
|
- run: make ${{ matrix.target }}
|
||||||
|
linux_bigendian:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
targets:
|
||||||
|
- target: ppc64
|
||||||
|
toolchain: powerpc64-linux-gnu
|
||||||
|
qemu: qemu-ppc64-static
|
||||||
|
name: linux-bigendian ${{ matrix.targets.target }}
|
||||||
|
env:
|
||||||
|
IPV6: 0
|
||||||
|
CC: ${{ matrix.targets.toolchain }}-gcc
|
||||||
|
OPTS: -O3 -g3 -static
|
||||||
|
SSL:
|
||||||
|
ASAN:
|
||||||
|
ASAN_OPTIONS:
|
||||||
|
RUN: ${{ matrix.targets.qemu }} -L /usr/${{ matrix.targets.toolchain }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- run: sudo apt-get update ; sudo apt-get install qemu-user-static gcc-${{ matrix.targets.toolchain }}
|
||||||
|
- run: make test
|
||||||
linux2:
|
linux2:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
24
mongoose.c
24
mongoose.c
@ -2800,15 +2800,6 @@ void mg_hexdump(const void *buf, size_t len) {
|
|||||||
|
|
||||||
|
|
||||||
#if defined(MG_ENABLE_MD5) && MG_ENABLE_MD5
|
#if defined(MG_ENABLE_MD5) && MG_ENABLE_MD5
|
||||||
#if !defined(BYTE_ORDER) && defined(__BYTE_ORDER)
|
|
||||||
#define BYTE_ORDER __BYTE_ORDER
|
|
||||||
#ifndef LITTLE_ENDIAN
|
|
||||||
#define LITTLE_ENDIAN __LITTLE_ENDIAN
|
|
||||||
#endif /* LITTLE_ENDIAN */
|
|
||||||
#ifndef BIG_ENDIAN
|
|
||||||
#define BIG_ENDIAN __LITTLE_ENDIAN
|
|
||||||
#endif /* BIG_ENDIAN */
|
|
||||||
#endif /* BYTE_ORDER */
|
|
||||||
|
|
||||||
static void mg_byte_reverse(unsigned char *buf, unsigned longs) {
|
static void mg_byte_reverse(unsigned char *buf, unsigned longs) {
|
||||||
/* Forrest: MD5 expect LITTLE_ENDIAN, swap if BIG_ENDIAN */
|
/* Forrest: MD5 expect LITTLE_ENDIAN, swap if BIG_ENDIAN */
|
||||||
@ -3647,21 +3638,6 @@ void mg_rpc_list(struct mg_rpc_req *r) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* clang with std=-c99 uses __LITTLE_ENDIAN, by default
|
|
||||||
* while for ex, RTOS gcc - LITTLE_ENDIAN, by default
|
|
||||||
* it depends on __USE_BSD, but let's have everything
|
|
||||||
*/
|
|
||||||
#if !defined(BYTE_ORDER) && defined(__BYTE_ORDER)
|
|
||||||
#define BYTE_ORDER __BYTE_ORDER
|
|
||||||
#ifndef LITTLE_ENDIAN
|
|
||||||
#define LITTLE_ENDIAN __LITTLE_ENDIAN
|
|
||||||
#endif /* LITTLE_ENDIAN */
|
|
||||||
#ifndef BIG_ENDIAN
|
|
||||||
#define BIG_ENDIAN __LITTLE_ENDIAN
|
|
||||||
#endif /* BIG_ENDIAN */
|
|
||||||
#endif /* BYTE_ORDER */
|
|
||||||
|
|
||||||
union char64long16 {
|
union char64long16 {
|
||||||
unsigned char c[64];
|
unsigned char c[64];
|
||||||
uint32_t l[16];
|
uint32_t l[16];
|
||||||
|
15
mongoose.h
15
mongoose.h
@ -61,6 +61,21 @@ extern "C" {
|
|||||||
#define MG_ARCH MG_ARCH_RP2040
|
#define MG_ARCH MG_ARCH_RP2040
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* clang with std=-c99 uses __LITTLE_ENDIAN, by default
|
||||||
|
* while for ex, RTOS gcc - LITTLE_ENDIAN, by default
|
||||||
|
* it depends on __USE_BSD, but let's have everything
|
||||||
|
*/
|
||||||
|
#if !defined(BYTE_ORDER) && defined(__BYTE_ORDER)
|
||||||
|
#define BYTE_ORDER __BYTE_ORDER
|
||||||
|
#ifndef LITTLE_ENDIAN
|
||||||
|
#define LITTLE_ENDIAN __LITTLE_ENDIAN
|
||||||
|
#endif /* LITTLE_ENDIAN */
|
||||||
|
#ifndef BIG_ENDIAN
|
||||||
|
#define BIG_ENDIAN __LITTLE_ENDIAN
|
||||||
|
#endif /* BIG_ENDIAN */
|
||||||
|
#endif /* BYTE_ORDER */
|
||||||
|
|
||||||
#if !defined(MG_ARCH)
|
#if !defined(MG_ARCH)
|
||||||
#include "mongoose_custom.h" // keep this include
|
#include "mongoose_custom.h" // keep this include
|
||||||
#endif
|
#endif
|
||||||
|
15
src/arch.h
15
src/arch.h
@ -34,6 +34,21 @@
|
|||||||
#define MG_ARCH MG_ARCH_RP2040
|
#define MG_ARCH MG_ARCH_RP2040
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* clang with std=-c99 uses __LITTLE_ENDIAN, by default
|
||||||
|
* while for ex, RTOS gcc - LITTLE_ENDIAN, by default
|
||||||
|
* it depends on __USE_BSD, but let's have everything
|
||||||
|
*/
|
||||||
|
#if !defined(BYTE_ORDER) && defined(__BYTE_ORDER)
|
||||||
|
#define BYTE_ORDER __BYTE_ORDER
|
||||||
|
#ifndef LITTLE_ENDIAN
|
||||||
|
#define LITTLE_ENDIAN __LITTLE_ENDIAN
|
||||||
|
#endif /* LITTLE_ENDIAN */
|
||||||
|
#ifndef BIG_ENDIAN
|
||||||
|
#define BIG_ENDIAN __LITTLE_ENDIAN
|
||||||
|
#endif /* BIG_ENDIAN */
|
||||||
|
#endif /* BYTE_ORDER */
|
||||||
|
|
||||||
#if !defined(MG_ARCH)
|
#if !defined(MG_ARCH)
|
||||||
#include "mongoose_custom.h" // keep this include
|
#include "mongoose_custom.h" // keep this include
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,15 +2,6 @@
|
|||||||
#include "arch.h"
|
#include "arch.h"
|
||||||
|
|
||||||
#if defined(MG_ENABLE_MD5) && MG_ENABLE_MD5
|
#if defined(MG_ENABLE_MD5) && MG_ENABLE_MD5
|
||||||
#if !defined(BYTE_ORDER) && defined(__BYTE_ORDER)
|
|
||||||
#define BYTE_ORDER __BYTE_ORDER
|
|
||||||
#ifndef LITTLE_ENDIAN
|
|
||||||
#define LITTLE_ENDIAN __LITTLE_ENDIAN
|
|
||||||
#endif /* LITTLE_ENDIAN */
|
|
||||||
#ifndef BIG_ENDIAN
|
|
||||||
#define BIG_ENDIAN __LITTLE_ENDIAN
|
|
||||||
#endif /* BIG_ENDIAN */
|
|
||||||
#endif /* BYTE_ORDER */
|
|
||||||
|
|
||||||
static void mg_byte_reverse(unsigned char *buf, unsigned longs) {
|
static void mg_byte_reverse(unsigned char *buf, unsigned longs) {
|
||||||
/* Forrest: MD5 expect LITTLE_ENDIAN, swap if BIG_ENDIAN */
|
/* Forrest: MD5 expect LITTLE_ENDIAN, swap if BIG_ENDIAN */
|
||||||
|
15
src/sha1.c
15
src/sha1.c
@ -3,21 +3,6 @@
|
|||||||
#include "sha1.h"
|
#include "sha1.h"
|
||||||
#include "arch.h"
|
#include "arch.h"
|
||||||
|
|
||||||
/*
|
|
||||||
* clang with std=-c99 uses __LITTLE_ENDIAN, by default
|
|
||||||
* while for ex, RTOS gcc - LITTLE_ENDIAN, by default
|
|
||||||
* it depends on __USE_BSD, but let's have everything
|
|
||||||
*/
|
|
||||||
#if !defined(BYTE_ORDER) && defined(__BYTE_ORDER)
|
|
||||||
#define BYTE_ORDER __BYTE_ORDER
|
|
||||||
#ifndef LITTLE_ENDIAN
|
|
||||||
#define LITTLE_ENDIAN __LITTLE_ENDIAN
|
|
||||||
#endif /* LITTLE_ENDIAN */
|
|
||||||
#ifndef BIG_ENDIAN
|
|
||||||
#define BIG_ENDIAN __LITTLE_ENDIAN
|
|
||||||
#endif /* BIG_ENDIAN */
|
|
||||||
#endif /* BYTE_ORDER */
|
|
||||||
|
|
||||||
union char64long16 {
|
union char64long16 {
|
||||||
unsigned char c[64];
|
unsigned char c[64];
|
||||||
uint32_t l[16];
|
uint32_t l[16];
|
||||||
|
@ -777,7 +777,9 @@ static void test_http_server(void) {
|
|||||||
fetch(&mgr, buf, url, "GET /test/ HTTP/1.0\n\n");
|
fetch(&mgr, buf, url, "GET /test/ HTTP/1.0\n\n");
|
||||||
ASSERT(fetch(&mgr, buf, url, "GET /test/ HTTP/1.0\n\n") == 200);
|
ASSERT(fetch(&mgr, buf, url, "GET /test/ HTTP/1.0\n\n") == 200);
|
||||||
ASSERT(mg_strstr(mg_str(buf), mg_str(">Index of /test/<")) != NULL);
|
ASSERT(mg_strstr(mg_str(buf), mg_str(">Index of /test/<")) != NULL);
|
||||||
|
#if BYTE_ORDER != BIG_ENDIAN
|
||||||
ASSERT(mg_strstr(mg_str(buf), mg_str(">fuzz.c<")) != NULL);
|
ASSERT(mg_strstr(mg_str(buf), mg_str(">fuzz.c<")) != NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
// Credentials
|
// Credentials
|
||||||
@ -1728,7 +1730,9 @@ static void test_util(void) {
|
|||||||
ASSERT(mg_aton(mg_str("0.0.0.-1"), &a) == false);
|
ASSERT(mg_aton(mg_str("0.0.0.-1"), &a) == false);
|
||||||
ASSERT(mg_aton(mg_str("127.0.0.1"), &a) == true);
|
ASSERT(mg_aton(mg_str("127.0.0.1"), &a) == true);
|
||||||
ASSERT(a.is_ip6 == false);
|
ASSERT(a.is_ip6 == false);
|
||||||
|
#if BYTE_ORDER != BIG_ENDIAN
|
||||||
ASSERT(a.ip == 0x100007f);
|
ASSERT(a.ip == 0x100007f);
|
||||||
|
#endif
|
||||||
ASSERT(strcmp(mg_ntoa(&a, buf, sizeof(buf)), "127.0.0.1") == 0);
|
ASSERT(strcmp(mg_ntoa(&a, buf, sizeof(buf)), "127.0.0.1") == 0);
|
||||||
|
|
||||||
ASSERT(mg_aton(mg_str("1:2:3:4:5:6:7:8"), &a) == true);
|
ASSERT(mg_aton(mg_str("1:2:3:4:5:6:7:8"), &a) == true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user