Skip to content

Commit

Permalink
Revert "Compilation warnings on OpenBSD"
Browse files Browse the repository at this point in the history
Restore the old stack alignment in order to provide AVX2
compatibility.

This reverts commit 8be9856.

Signed-off-by: hololeap <[email protected]>
  • Loading branch information
hololeap committed Oct 17, 2024
1 parent 897d9c2 commit f2592f1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cbits/decaf/include/decaf/point_448.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern "C" {
/** @brief Galois field element internal structure */
typedef struct crypton_gf_448_s {
crypton_decaf_word_t limb[512/CRYPTON_DECAF_WORD_BITS];
} __attribute__((aligned(16))) crypton_gf_448_s, crypton_gf_448_t[1];
} __attribute__((aligned(32))) cryptonite_gf_448_s, cryptonite_gf_448_t[1];
#endif /* __CRYPTON_DECAF_448_GF_DEFINED__ */
/** @endcond */

Expand Down
2 changes: 1 addition & 1 deletion cbits/decaf/p448/f_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define SER_BYTES 56
typedef struct crypton_gf_448_s {
word_t limb[NLIMBS];
} __attribute__((aligned(16))) crypton_gf_448_s, crypton_gf_448_t[1];
} __attribute__((aligned(32))) cryptonite_gf_448_s, cryptonite_gf_448_t[1];

#define GF_LIT_LIMB_BITS 56
#define GF_BITS 448
Expand Down
14 changes: 0 additions & 14 deletions cbits/decaf/tools/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
# * code related to SHAKE is replaced by crypton code, referenced from
# a custom shake.h. As a consequence, portable_endian.h is not needed.
#
# * aligned(32) attributes used for stack alignment are replaced by
# aligned(16). This removes warnings on OpenBSD with GCC 4.2.1, and makes
# sure we get at least 16-byte alignment. 32-byte alignment is necessary
# only for AVX2 and arch_x86_64, which we don't have.
#
# * visibility("hidden") attributes are removed, as this is not supported
# on Windows/MinGW, and we have name mangling instead
#
Expand All @@ -49,19 +44,10 @@ fi

convert() {
local FILE_NAME="`basename "$1"`"
local REPL

if [ "$FILE_NAME" = word.h ]; then
REPL='__attribute__((aligned(32)))'
else
REPL='__attribute__((aligned(16)))'
fi

sed <"$1" >"$2/$FILE_NAME" \
-e 's/ __attribute((visibility("hidden")))//g' \
-e 's/ __attribute__((visibility("hidden")))//g' \
-e 's/ __attribute__ ((visibility ("hidden")))//g' \
-e "s/__attribute__((aligned(32)))/$REPL/g" \
-e 's/decaf_/crypton_decaf_/g' \
-e 's/DECAF_/CRYPTON_DECAF_/g' \
-e 's/gf_/crypton_gf_/g' \
Expand Down

0 comments on commit f2592f1

Please sign in to comment.