Skip to content

Commit

Permalink
Use GCC 10
Browse files Browse the repository at this point in the history
  • Loading branch information
lhmouse committed Jan 12, 2024
1 parent f5508a6 commit 5306c31
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ on:
jobs:
ubuntu:
name: Ubuntu native build (x86-64)
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: >-
sudo apt-get install -y --no-install-recommends autoconf automake
libtool g++ gettext make libpcre2-dev libssl-dev zlib1g-dev
libtool g++-10 gettext make libpcre2-dev libssl-dev zlib1g-dev
libmysqlclient-dev libmongoc-dev
- name: Build and install asteria
run: |
git submodule update --init asteria
pushd asteria
autoreconf -ifv
./configure --disable-repl
./configure CXX='g++-10' --disable-repl
make -j$(nproc)
rm -f *.deb
./makedeb.sh
Expand All @@ -41,12 +41,12 @@ jobs:
git submodule update --init http-parser
pushd http-parser
autoreconf -ifv
./configure
./configure CXX='g++-10'
make -j$(nproc)
rm -f *.deb
./makedeb.sh
sudo dpkg -i libhttp-parser_*.deb
popd
- name: Run tests
run: ./ci/build.sh
run: CXX='g++-10' ./ci/build.sh
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# The Poseidon Server Framework

![GNU nano for the win!](https://raw.githubusercontent.com/lhmouse/poseidon/master/GNU-nano-FTW.png)
|Compiler |Category |
|:------------|:--------------------------|
|**GCC 10** |:1st_place_medal:Primary |
|**Clang 11** |:2nd_place_medal:Secondary |

![GNU nano for the win!](GNU-nano-FTW.png)

# Features

Expand Down
25 changes: 11 additions & 14 deletions poseidon/base/uuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,28 +157,25 @@ print_partial(char* str) const noexcept
// xdigit := val + '0' + ((val > 9) ? 7 : 0)
tval = _mm_and_si128(_mm_cmpgt_epi8(hi, _mm_set1_epi8(9)), _mm_set1_epi8(7));
hi = _mm_add_epi8(_mm_add_epi8(hi, _mm_set1_epi8('0')), tval);

tval = _mm_and_si128(_mm_cmpgt_epi8(lo, _mm_set1_epi8(9)), _mm_set1_epi8(7));
lo = _mm_add_epi8(_mm_add_epi8(lo, _mm_set1_epi8('0')), tval);

// Insert dashes first. Instead of writing four dashes into `str[8]`,
// `str[13]`, `str[18]` and `str[23]`, we can overwrite that 16-byte range
// with a single store operation.
_mm_storeu_si128((__m128i*) (str + 8), _mm_set1_epi8('-'));

// Write digits.
tval = _mm_unpacklo_epi8(hi, lo);
_mm_storeu_si64(str, tval);
_mm_storeu_si32(str + 9, _mm_bsrli_si128(tval, 8));
_mm_storeu_si32(str + 14, _mm_bsrli_si128(tval, 12));

str[8] = '-';
_mm_storeu_si64(str + 9, _mm_bsrli_si128(tval, 8));
str[13] = '-';
_mm_storeu_si64(str + 14, _mm_bsrli_si128(tval, 12));
str[18] = '-';
tval = _mm_unpackhi_epi8(hi, lo);
_mm_storeu_si32(str + 19, tval);
_mm_storeu_si32(str + 24, _mm_bsrli_si128(tval, 4));
_mm_storeu_si64(str + 19, tval);
str[23] = '-';
_mm_storeu_si64(str + 24, _mm_bsrli_si128(tval, 4));
_mm_storeu_si64(str + 28, _mm_bsrli_si128(tval, 8));

// Return the number of characters that have been written, not including
// the null terminator.
str[36] = 0;

// Return the number of characters, not including the null terminator.
return 36;
}

Expand Down
4 changes: 2 additions & 2 deletions poseidon/http/websocket_frame_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mask_payload(char* data, size_t size) noexcept
if(!this->mask)
return 0;

__m128i exmask = _mm_set1_epi32((int32_t) this->mask_key_u32);
__m128i exmask = _mm_set1_epi32(this->mask_key_i32);
char* cur = data;
char* esdata = data + size;

Expand All @@ -68,7 +68,7 @@ mask_payload(char* data, size_t size) noexcept
// bytewise
*cur ^= this->mask_key[0];
exmask = _mm_srli_si128(exmask, 1);
_mm_storeu_si32(this->mask_key, exmask);
this->mask_key_i32 = _mm_cvtsi128_si32(exmask);
cur ++;
}

Expand Down
1 change: 1 addition & 0 deletions poseidon/http/websocket_frame_header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct WebSocket_Frame_Header
union {
char mask_key[4];
uint32_t mask_key_u32;
int32_t mask_key_i32;
};
uint64_t payload_len;
};
Expand Down

0 comments on commit 5306c31

Please sign in to comment.