Skip to content

Commit

Permalink
Merge branch 'win64' into bfgminer
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Feb 6, 2013
2 parents dab1454 + 9ea9ead commit 5248737
Show file tree
Hide file tree
Showing 17 changed files with 187 additions and 77 deletions.
24 changes: 24 additions & 0 deletions compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include "config.h"

#ifdef WIN32
#include <winsock2.h>
#endif

#include <stdbool.h>

// NOTE: Nested preprocessor checks since the latter isn't defined at all without the former
Expand Down Expand Up @@ -49,6 +53,26 @@
} while (0)
#endif

// localtime is thread-safe on Windows
// We also use this with timeval.tv_sec, which is incorrectly smaller than time_t on Windows
// Need to cast to time_t* to suppress warning - actual problem shouldn't be possible in practice
#define localtime_r(timep, result) ( \
memcpy(result, \
( \
(sizeof(*timep) == sizeof(time_t)) \
? localtime((time_t*)timep) \
: localtime_convert(*timep) \
), \
sizeof(*result) \
) \
)

static inline
struct tm *localtime_convert(time_t t)
{
return localtime(&t);
}

static inline int nanosleep(const struct timespec *req, struct timespec *rem)
{
struct timeval tstart;
Expand Down
4 changes: 2 additions & 2 deletions driver-bitforce.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* any later version. See COPYING for more details.
*/

#include "config.h"

#include <limits.h>
#include <pthread.h>
#include <stdint.h>
Expand All @@ -16,8 +18,6 @@
#include <sys/time.h>
#include <unistd.h>

#include "config.h"

#include "compat.h"
#include "miner.h"
#include "fpgautils.h"
Expand Down
4 changes: 4 additions & 0 deletions driver-icarus.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@

#include "config.h"

#ifdef WIN32
#include <winsock2.h>
#endif

#include <limits.h>
#include <pthread.h>
#include <stdio.h>
Expand Down
4 changes: 4 additions & 0 deletions driver-opencl.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

#include "config.h"

#ifdef WIN32
#include <winsock2.h>
#endif

#ifdef HAVE_CURSES
#include <curses.h>
#endif
Expand Down
4 changes: 4 additions & 0 deletions driver-x6500.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

#include "config.h"

#ifdef WIN32
#include <winsock2.h>
#endif

#include <math.h>
#include <sys/time.h>

Expand Down
2 changes: 2 additions & 0 deletions driver-ztex.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* along with this program; if not, see http://www.gnu.org/licenses/.
**/

#include "config.h"

#include <unistd.h>
#include <sha2.h>

Expand Down
2 changes: 2 additions & 0 deletions dynclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* any later version. See COPYING for more details.
*/

#include "config.h"

#include "dynclock.h"
#include "miner.h"

Expand Down
2 changes: 1 addition & 1 deletion elist.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static inline void list_splice_init(struct list_head *list,
* @member: the name of the list_struct within the struct.
*/
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
((type *)((char *)(ptr)-(intptr_t)(&((type *)0)->member)))

/**
* list_for_each - iterate over a list
Expand Down
6 changes: 5 additions & 1 deletion fpgautils.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

#include "config.h"

#ifdef WIN32
#include <winsock2.h>
#endif

#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
Expand Down Expand Up @@ -661,7 +665,7 @@ int serial_open(const char *devpath, unsigned long baud, uint8_t timeout, bool p
PurgeComm(hSerial, PURGE_TXCLEAR);
}

return _open_osfhandle((LONG)hSerial, 0);
return _open_osfhandle((intptr_t)hSerial, 0);
#else
int fdDev = open(devpath, O_RDWR | O_CLOEXEC | O_NOCTTY);

Expand Down
4 changes: 4 additions & 0 deletions ft232r.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

#include "config.h"

#ifdef WIN32
#include <winsock2.h>
#endif

#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
Expand Down
4 changes: 4 additions & 0 deletions jtag.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

#include "config.h"

#ifdef WIN32
#include <winsock2.h>
#endif

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
Expand Down
6 changes: 4 additions & 2 deletions logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <unistd.h>

#include "compat.h"
#include "logging.h"
#include "miner.h"

Expand Down Expand Up @@ -92,11 +93,12 @@ static void log_generic(int prio, const char *fmt, va_list ap)
char *f;
int len;
struct timeval tv = {0, 0};
struct tm *tm;
struct tm _tm;
struct tm *tm = &_tm;

gettimeofday(&tv, NULL);

tm = localtime(&tv.tv_sec);
localtime_r(&tv.tv_sec, tm);

len = 40 + strlen(fmt) + 22;
f = alloca(len);
Expand Down
141 changes: 85 additions & 56 deletions make-release
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,22 @@ tag="$1"; shift
sw="$1"; shift || true
[ -n "$sw" ] || sw="$tag"

builds=(win32 win64)

win32_machine='i686-pc-mingw32'
win32_CFLAGS='-march=i686'

win64_machine='x86_64-w64-mingw32'
win64_CFLAGS=''

IDIR="$PWD"
ZIPNAME="${sw}-win32"
OUTDIR="$PWD/w32zip/$ZIPNAME"
TMPDIR="${OUTDIR}-tmp"
OUTDIR="$PWD"
TMPROOT="$PWD/make-release-tmp"
TMPDIR="${TMPROOT}/${sw}-tmp"

set -e
mkdir -v "$OUTDIR"
dlls='
pdcurses.dll
libcurl-4.dll
pthreadGC2.dll
libjansson-4.dll
libusb-1.0.dll
zlib1.dll
'
cp -v \
-L \
$dlls \
"$OUTDIR/"
for dll in $dlls; do
i686-pc-mingw32-strip "$OUTDIR/$dll"
done
mkdir -vp "$TMPDIR"

# Source release
git branch TMP "$tag"
git clone . "$TMPDIR" -b TMP --depth 1
git branch -D TMP
Expand All @@ -43,42 +37,77 @@ NOSUBMODULES=1 \
NOCONFIGURE=1 \
./autogen.sh
cd ..
zip -r "$IDIR/${sw}.zip" "$sw"
tar cjvpf "$IDIR/${sw}.tbz2" "$sw"
zip -r "$OUTDIR/${sw}.zip" "$sw"
tar cjvpf "$OUTDIR/${sw}.tbz2" "$sw"
SRCDIR="$TMPDIR/$sw"
for txt in AUTHORS COPYING NEWS README API-README FPGA-README SCRYPT-README; do
sed 's/$/\r/' <"$txt" >"$OUTDIR/${txt}.txt"

dlls='
pdcurses.dll
libcurl-4.dll
pthreadGC2.dll
libjansson-4.dll
libusb-1.0.dll
zlib1.dll
'
docs='
AUTHORS
COPYING
NEWS
README
API-README
FPGA-README
SCRYPT-README
'
for build in "${builds[@]}"; do
PKGNAME="${sw}-${build}"
PKGDIR="$TMPDIR/$PKGNAME"
cd "$TMPDIR"
mkdir -vp "$PKGDIR"
for v in machine CFLAGS; do
eval "${v}"="$(eval echo "\${${build}_${v}}")"
done
libdir="/usr/$machine/usr/bin/$dll"
for dll in $dlls; do
libdir="/usr/$machine/usr/lib"
[ -e "$libdir/$dll" ] ||
libdir="/usr/$machine/usr/bin"
cp -v -L "$libdir/$dll" "$PKGDIR"
"$machine"-strip "$PKGDIR/$dll"
done
for doc in $docs; do
sed 's/$/\r/' <"$doc" >"$PKGDIR/${doc}.txt"
done
cp -av "bitstreams" "$PKGDIR/"

NOCONFIGURE=1 \
./autogen.sh
./configure \
--prefix='C:\\Program Files\\BFGMiner\\' \
CFLAGS="${CFLAGS} -Wall" \
--disable-cpumining \
--enable-opencl \
--enable-adl \
--enable-bitforce \
--enable-icarus \
--enable-modminer \
--enable-ztex \
--enable-scrypt \
--host="$machine"
make $MAKEOPTS
"$machine"-strip \
libblkmaker/.libs/*.dll \
*.exe
cp -v \
*.exe \
libblkmaker/.libs/*.dll \
*.cl \
example.conf \
windows-build.txt \
API.class \
miner.php \
"$PKGDIR/"
make clean
cd "$PKGDIR/.."
zip -r "$OUTDIR/$PKGNAME.zip" "$PKGNAME"
done
cp -av "bitstreams" "$OUTDIR/"
NOCONFIGURE=1 \
./autogen.sh
./configure \
--prefix='C:\\Program Files\\BFGMiner\' \
CFLAGS='-march=i686 -Wall' \
--disable-cpumining \
--enable-opencl \
--enable-adl \
--enable-bitforce \
--enable-icarus \
--enable-modminer \
--enable-ztex \
--enable-scrypt \
--build=i686-pc-linux-gnu \
--host=i686-pc-mingw32
make -j4
i686-pc-mingw32-strip \
libblkmaker/.libs/*.dll \
bfgminer.exe
cp -v \
bfgminer.exe \
libblkmaker/.libs/*.dll \
*.cl \
example.conf \
windows-build.txt \
API.class \
miner.php \
"$OUTDIR/" -v
cd "$OUTDIR"
cd ..
zip -r "$IDIR/${ZIPNAME}.zip" "${ZIPNAME}"
cd "$IDIR"
Loading

0 comments on commit 5248737

Please sign in to comment.