Skip to content

Commit

Permalink
Fix some windows warnings, update make-maintainer a little
Browse files Browse the repository at this point in the history
  • Loading branch information
Alcaro committed Mar 15, 2023
1 parent 582ca7b commit fdd5c6e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
25 changes: 19 additions & 6 deletions libbps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,19 @@ struct bpsinfo bps_get_info(file* patch, bool changefrac)

#include <stdio.h>

#ifdef _WIN32
# ifdef _WIN64
# ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wformat"
# endif
# define z "I"
# else
# define z ""
# endif
#else
# define z "z"
#endif

void bps_disassemble(struct mem patch, FILE* out)
{
#define read8() (*(patchat++))
Expand Down Expand Up @@ -528,13 +541,13 @@ void bps_disassemble(struct mem patch, FILE* out)
{
case SourceRead:
{
fprintf(out, "SourceRead %zu from %zu to %zu\n", length, outat, outat);
fprintf(out, "SourceRead %" z "u from %" z "u to %" z "u\n", length, outat, outat);
outat += length;
}
break;
case TargetRead:
{
fprintf(out, "TargetRead %zu to %zu\n", length, outat);
fprintf(out, "TargetRead %" z "u to %" z "u\n", length, outat);
patchat += length;
outat += length;
}
Expand All @@ -547,7 +560,7 @@ void bps_disassemble(struct mem patch, FILE* out)
if ((encodeddistance&1)==0) inreadat+=distance;
else inreadat-=distance;

fprintf(out, "SourceCopy %zu from %zu to %zu (rel %+zi)\n", length, inreadat, outat, inreadat-outat);
fprintf(out, "SourceCopy %" z "u from %" z "u to %" z "u (rel %+" z "i)\n", length, inreadat, outat, inreadat-outat);
inreadat += length;
outat += length;
}
Expand All @@ -560,7 +573,7 @@ void bps_disassemble(struct mem patch, FILE* out)
if ((encodeddistance&1)==0) outreadat+=distance;
else outreadat-=distance;

fprintf(out, "TargetCopy %zu from %zu to %zu (rel %+zi)\n", length, outreadat, outat, outreadat-outat);
fprintf(out, "TargetCopy %" z "u from %" z "u to %" z "u (rel %+" z "i)\n", length, outreadat, outat, outreadat-outat);
outreadat += length;
outat += length;
}
Expand All @@ -569,9 +582,9 @@ void bps_disassemble(struct mem patch, FILE* out)
}

if (patchat != patchend)
fprintf(out, "WARNING: patch pointer at %zu != %zu, corrupt patch?\n", patchat-patch.ptr, patchend-patch.ptr);
fprintf(out, "WARNING: patch pointer at %" z "u != %" z "u, corrupt patch?\n", patchat-patch.ptr, patchend-patch.ptr);
if (outat != outlen)
fprintf(out, "WARNING: output pointer at %zu != %zu, corrupt patch?\n", outat, outlen);
fprintf(out, "WARNING: output pointer at %" z "u != %" z "u, corrupt patch?\n", outat, outlen);
#undef read8
#undef decodeto
}
Expand Down
21 changes: 9 additions & 12 deletions make-maintainer.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

if [ "$HOME" != "/home/alcaro" ]; then
if [ "$HOME" != "/home/walrus" ]; then
#This script is for making official releases, including a Windows build.
#If you're intending to fork Floating IPS, or take over maintenance, you're welcome to edit this script.
#If not, you don't want it. make.sh enables all optimizations for a local build.
Expand All @@ -16,24 +16,21 @@ mv flips flips-linux
7z a floating.zip flips-linux
mv ./flips-linux ~/bin/flips

#create windows binary
mingwver 64 || true # this is a script that sets the Wine PATH
#if trying to make a 32bit Flips, add -Wl,--large-address-aware
#wmake64 is
# #!/bin/sh
# export WINEPATH=$(winepath -w ~/tools/mingw64-11.2.0/bin/)
# exec wine mingw32-make "$@"

#I am not completely sure if this is a good idea.
#FLAGS=$FLAGS' -fopenmp'
#FLAGS=$FLAGS' Z:/home/alcaro/tools/mingw64-8.1.0/lib/gcc/x86_64-w64-mingw32/8.1.0/libgomp.a'
#FLAGS=$FLAGS' Z:/home/alcaro/tools/mingw64-8.1.0/lib/gcc/x86_64-w64-mingw32/8.1.0/libgcc_eh.a'
#FLAGS=$FLAGS' Z:/home/alcaro/tools/mingw64-8.1.0/x86_64-w64-mingw32/lib/libwinpthread.a'
#if trying to make a 32bit Flips, add -Wl,--large-address-aware

echo 'Windows (1/3)'
rm obj/* flips.exe; wine mingw32-make TARGET=windows CFLAGS="$FLAGS -fprofile-generate -lgcov"
rm -r obj/* flips.exe; wmake64 TARGET=windows CFLAGS="$FLAGS -fprofile-generate -lgcov"
[ -e flips.exe ] || exit
echo 'Windows (2/3)'
/usr/bin/time --verbose wine flips.exe --create --bps-delta profile/firefox-10.0esr.tar profile/firefox-17.0esr.tar /dev/null
/usr/bin/time --verbose wine flips.exe --create --bps-delta-moremem profile/firefox-10.0esr.tar profile/firefox-17.0esr.tar /dev/null
echo 'Windows (3/3)'
rm flips.exe; wine mingw32-make TARGET=windows CFLAGS="$FLAGS -fprofile-use -s"
rm flips.exe; wmake64 TARGET=windows CFLAGS="$FLAGS -fprofile-use -s"

#verify that there are no unexpected dependencies
objdump -p flips.exe | grep 'DLL Name' | \
Expand All @@ -50,7 +47,7 @@ echo Finishing
7z a floating.zip flips.exe
zipcrush floating.zip
#The random numbers are the size of Lunar IPS v1.02, which I wish to stay below.
#(Or wished a while ago, but my feature set is so much greater than Lunar that I'll accept being bigger.)
#(Or wished a while ago, but my feature set is so much bigger than Lunar that I'll accept being bigger.)
echo Size: $(stat -c%s flips.exe)/155648
echo \(Linux: $(stat -c%s ~/bin/flips)\)
echo \(Zipped: $(stat -c%s floating.zip)/59881\)
Expand Down

0 comments on commit fdd5c6e

Please sign in to comment.