Skip to content

Commit

Permalink
mosh: fix PowerPC build
Browse files Browse the repository at this point in the history
  • Loading branch information
barracuda156 authored and herbygillot committed Jun 5, 2024
1 parent 1288269 commit a910a13
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/mosh/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ checksums rmd160 e5a06cbdee39cdf0259a4db08fe7919561ce52c5 \

compiler.cxx_standard 2011

patchfiles-append patch-fix-AltiVec.diff

perl5.require_variant yes
perl5.conflict_variants yes
perl5.branches 5.34
Expand Down
65 changes: 65 additions & 0 deletions net/mosh/files/patch-fix-AltiVec.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
--- src/crypto/ocb_internal.cc 2022-08-04 09:34:20.000000000 +0800
+++ src/crypto/ocb_internal.cc 2024-06-04 23:09:15.000000000 +0800
@@ -220,12 +220,12 @@
}
#elif __ALTIVEC__ && _CALL_ELF != 2
#include <altivec.h>
- typedef vector unsigned block;
+ typedef __vector unsigned block;
#define xor_block(x,y) vec_xor(x,y)
#define zero_block() vec_splat_u32(0)
#define unequal_blocks(x,y) vec_any_ne(x,y)
#define swap_if_le(b) (b)
- #if __PPC64__
+ #if defined(__PPC64__) || defined(__ppc64__)
static block gen_offset(uint64_t KtopStr[3], unsigned bot) {
union {uint64_t u64[2]; block bl;} rval;
rval.u64[0] = (KtopStr[0] << bot) | (KtopStr[1] >> (64-bot));
@@ -235,34 +235,34 @@
#else
/* Special handling: Shifts are mod 32, and no 64-bit types */
static block gen_offset(uint64_t KtopStr[3], unsigned bot) {
- const vector unsigned k32 = {32,32,32,32};
- vector unsigned hi = *(vector unsigned *)(KtopStr+0);
- vector unsigned lo = *(vector unsigned *)(KtopStr+2);
- vector unsigned bot_vec;
+ const __vector unsigned k32 = {32,32,32,32};
+ __vector unsigned hi = *(__vector unsigned *)(KtopStr+0);
+ __vector unsigned lo = *(__vector unsigned *)(KtopStr+2);
+ __vector unsigned bot_vec;
if (bot < 32) {
lo = vec_sld(hi,lo,4);
} else {
- vector unsigned t = vec_sld(hi,lo,4);
+ __vector unsigned t = vec_sld(hi,lo,4);
lo = vec_sld(hi,lo,8);
hi = t;
bot = bot - 32;
}
if (bot == 0) return hi;
*(unsigned *)&bot_vec = bot;
- vector unsigned lshift = vec_splat(bot_vec,0);
- vector unsigned rshift = vec_sub(k32,lshift);
+ __vector unsigned lshift = vec_splat(bot_vec,0);
+ __vector unsigned rshift = vec_sub(k32,lshift);
hi = vec_sl(hi,lshift);
lo = vec_sr(lo,rshift);
return vec_xor(hi,lo);
}
#endif
static inline block double_block(block b) {
- const vector unsigned char mask = {135,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
- const vector unsigned char perm = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0};
- const vector unsigned char shift7 = vec_splat_u8(7);
- const vector unsigned char shift1 = vec_splat_u8(1);
- vector unsigned char c = (vector unsigned char)b;
- vector unsigned char t = vec_sra(c,shift7);
+ const __vector unsigned char mask = {135,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
+ const __vector unsigned char perm = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0};
+ const __vector unsigned char shift7 = vec_splat_u8(7);
+ const __vector unsigned char shift1 = vec_splat_u8(1);
+ __vector unsigned char c = (__vector unsigned char)b;
+ __vector unsigned char t = vec_sra(c,shift7);
t = vec_and(t,mask);
t = vec_perm(t,t,perm);
c = vec_sl(c,shift1);

0 comments on commit a910a13

Please sign in to comment.