1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-09-20 12:36:05 +08:00

TF2 win64 + Ambuild tier1/mathlib + long=devil (#198)

* Fix compilation for windows, setup ambuild

* Add built tier1 and mathlib for win64

* Ensure compilation is working on windows and linux

* Add -fPIC

* Add compiled libs, with optimisation enabled

* Added windows lib

* Fix hl2sdk for windows

* Longs are the devil

* Fix up threadtools functions

* Add updated libs

* Rework lib naming, and package script

* Update lib directory according to new packaging

---------

Co-authored-by: Kenzzer <kenzzer@users.noreply.github.com>
This commit is contained in:
Benoist
2024-03-09 04:57:12 +01:00
committed by GitHub
parent dcf515fea8
commit 8a6d1c6cd2
82 changed files with 830 additions and 1933 deletions

View File

@ -5,6 +5,7 @@
#if !defined(_STATIC_LINKED) || defined(_SHARED_LIB)
#include "mathlib/IceKey.H"
#include <cstdint>
#ifdef _MSC_VER
#pragma warning(disable: 4244)
@ -13,12 +14,12 @@
/* Structure of a single round subkey */
class IceSubkey {
public:
unsigned long val[3];
uint32_t val[3];
};
/* The S-boxes */
static unsigned long ice_sbox[4][1024];
static uint32_t ice_sbox[4][1024];
static int ice_sboxes_initialised = 0;
@ -37,7 +38,7 @@ static const int ice_sxor[4][4] = {
{0xea, 0xcb, 0x2e, 0x04}};
/* Permutation values for the P-box */
static const unsigned long ice_pbox[32] = {
static const uint32_t ice_pbox[32] = {
0x00000001, 0x00000080, 0x00000400, 0x00002000,
0x00080000, 0x00200000, 0x01000000, 0x40000000,
0x00000008, 0x00000020, 0x00000100, 0x00004000,
@ -61,11 +62,11 @@ static const int ice_keyrot[16] = {
static unsigned int
gf_mult (
register unsigned int a,
register unsigned int b,
register unsigned int m
unsigned int a,
unsigned int b,
unsigned int m
) {
register unsigned int res = 0;
unsigned int res = 0;
while (b) {
if (b & 1)
@ -87,12 +88,12 @@ gf_mult (
* Raise the base to the power of 7, modulo m.
*/
static unsigned long
static uint32_t
gf_exp7 (
register unsigned int b,
unsigned int b,
unsigned int m
) {
register unsigned int x;
unsigned int x;
if (b == 0)
return (0);
@ -108,12 +109,12 @@ gf_exp7 (
* Carry out the ICE 32-bit P-box permutation.
*/
static unsigned long
static uint32_t
ice_perm32 (
register unsigned long x
uint32_t x
) {
register unsigned long res = 0;
register const unsigned long *pbox = ice_pbox;
uint32_t res = 0;
const uint32_t *pbox = ice_pbox;
while (x) {
if (x & 1)
@ -134,12 +135,12 @@ ice_perm32 (
static void
ice_sboxes_init (void)
{
register int i;
int i;
for (i=0; i<1024; i++) {
int col = (i >> 1) & 0xff;
int row = (i & 0x1) | ((i & 0x200) >> 8);
unsigned long x;
uint32_t x;
x = gf_exp7 (col ^ ice_sxor[0][row], ice_smod[0][row]) << 24;
ice_sbox[0][i] = ice_perm32 (x);
@ -201,13 +202,13 @@ IceKey::~IceKey ()
* The single round ICE f function.
*/
static unsigned long
static uint32_t
ice_f (
register unsigned long p,
uint32_t p,
const IceSubkey *sk
) {
unsigned long tl, tr; /* Expanded 40-bit values */
unsigned long al, ar; /* Salted expanded 40-bit values */
uint32_t tl, tr; /* Expanded 40-bit values */
uint32_t al, ar; /* Salted expanded 40-bit values */
/* Left half expansion */
tl = ((p >> 16) & 0x3ff) | (((p >> 14) | (p << 18)) & 0xffc00);
@ -241,15 +242,15 @@ IceKey::encrypt (
unsigned char *ctext
) const
{
register int i;
register unsigned long l, r;
int i;
uint32_t l, r;
l = (((unsigned long) ptext[0]) << 24)
| (((unsigned long) ptext[1]) << 16)
| (((unsigned long) ptext[2]) << 8) | ptext[3];
r = (((unsigned long) ptext[4]) << 24)
| (((unsigned long) ptext[5]) << 16)
| (((unsigned long) ptext[6]) << 8) | ptext[7];
l = (((uint32_t) ptext[0]) << 24)
| (((uint32_t) ptext[1]) << 16)
| (((uint32_t) ptext[2]) << 8) | ptext[3];
r = (((uint32_t) ptext[4]) << 24)
| (((uint32_t) ptext[5]) << 16)
| (((uint32_t) ptext[6]) << 8) | ptext[7];
for (i = 0; i < _rounds; i += 2) {
l ^= ice_f (r, &_keysched[i]);
@ -276,15 +277,15 @@ IceKey::decrypt (
unsigned char *ptext
) const
{
register int i;
register unsigned long l, r;
int i;
uint32_t l, r;
l = (((unsigned long) ctext[0]) << 24)
| (((unsigned long) ctext[1]) << 16)
| (((unsigned long) ctext[2]) << 8) | ctext[3];
r = (((unsigned long) ctext[4]) << 24)
| (((unsigned long) ctext[5]) << 16)
| (((unsigned long) ctext[6]) << 8) | ctext[7];
l = (((uint32_t) ctext[0]) << 24)
| (((uint32_t) ctext[1]) << 16)
| (((uint32_t) ctext[2]) << 8) | ctext[3];
r = (((uint32_t) ctext[4]) << 24)
| (((uint32_t) ctext[5]) << 16)
| (((uint32_t) ctext[6]) << 8) | ctext[7];
for (i = _rounds - 1; i > 0; i -= 2) {
l ^= ice_f (r, &_keysched[i]);
@ -314,20 +315,20 @@ IceKey::scheduleBuild (
int i;
for (i=0; i<8; i++) {
register int j;
register int kr = keyrot[i];
int j;
int kr = keyrot[i];
IceSubkey *isk = &_keysched[n + i];
for (j=0; j<3; j++)
isk->val[j] = 0;
for (j=0; j<15; j++) {
register int k;
unsigned long *curr_sk = &isk->val[j % 3];
int k;
uint32_t *curr_sk = &isk->val[j % 3];
for (k=0; k<4; k++) {
unsigned short *curr_kb = &kb[(kr + k) & 3];
register int bit = *curr_kb & 1;
int bit = *curr_kb & 1;
*curr_sk = (*curr_sk << 1) | bit;
*curr_kb = (*curr_kb >> 1) | ((bit ^ 1) << 15);