Change occurences of u_intX into uintX types and provide variants of usleep, frealtime, mkdir for [ 1838732 ] EXE built with MinGW

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1169 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Kolja Waschk 17 years ago
parent de70664578
commit b6684fa685

@ -1,3 +1,10 @@
2008-04-13 Kolja Waschk <kawk>
* src/tap/parport/ftd2xx.c, src/tap/usbconn/libusb.c, src/lib/fclock.c,
src/jtag.c, src/flash/amd_flash.c, src/flash/amd.c, src/flash/jedec.c,
src/svf/svf.c, configure.ac, doc/UrJTAG.txt: Provide variants of
usleep, frealtime, mkdir for [ 1838732 ] EXE built with MinGW
2008-04-11 Kolja Waschk <kawk>
* src/bsdl/bsdl.c, src/tap/parport/ftd2xx.c, src/tap/parport/ftdi.c,

@ -209,7 +209,7 @@ AS_IF([test "x$with_ftd2xx" == xyes -o "x$with_ftd2xx" = xcheck], [
AS_IF([test "x$with_ftd2xx" != xno], [
HAVELIBFTD2XX=yes
case $host in
*cygwin*)
*cygwin*|*mingw*)
CFLAGS="$CFLAGS -I$with_ftd2xx"
AS_IF([test -d "$with_ftd2xx/i386"], [
FTD2XXLIB="$with_ftd2xx/i386/ftd2xx.lib"

@ -381,6 +381,19 @@ might give problems if the path contains spaces, as "Program Files" does!):
./configure --with-libusb="/cygdrive/c/Programme/LibUSB-Win32/"
==== Compiling with MinGW ====
UrJTAG may be compiled into a Windows executable using the MinGW compiler
(http://www.mingw.org). This has the advantage over running in a Cygwin
environment that you don't need to install anything else but the jtag.exe.
However, because support for MinGW is quite new in UrJTAG, it may lack some
features (e.g. readline support) or run a little slower.
It is even possible to cross-compile and build the executable on a Linux
host:
./configure --host=i586-mingw32msvc --with-ftd2xx=/tmp/cdm-drivers
make
==== Driver tailoring ====

@ -43,6 +43,11 @@
#include <flash.h>
#include <bus.h>
#ifdef __MINGW32__
#include <windows.h>
#define usleep(x) Sleep(x/1E3)
#endif
static int dbg = 0;
static int amd_flash_erase_block( cfi_array_t *cfi_array, uint32_t adr );

@ -39,6 +39,11 @@
#include <flash.h>
#include <bus.h>
#ifdef __MINGW32__
#include <windows.h>
#define usleep(x) Sleep(x/1E3)
#endif
//write specific
#define AMD_SECTOR_PROTECTED

@ -60,9 +60,9 @@
#define AUTOSELECT_NUM 2
struct mtd_erase_region_info {
u_int32_t offset; /* At which this region starts, from the beginning of the MTD */
u_int32_t erasesize; /* For this region */
u_int32_t numblocks; /* Number of blocks of erasesize in this region */
uint32_t offset; /* At which this region starts, from the beginning of the MTD */
uint32_t erasesize; /* For this region */
uint32_t numblocks; /* Number of blocks of erasesize in this region */
};
struct amd_flash_info {
@ -70,7 +70,7 @@ struct amd_flash_info {
const int dev_id;
const char *name;
const long size;
const u_int8_t interface_width;
const uint8_t interface_width;
const int as_method;
const int numeraseregions;
const struct mtd_erase_region_info regions[4];

@ -82,7 +82,11 @@ jtag_create_jtagdir( void )
strcat( jdir, JTAGDIR );
/* Create the directory if it doesn't exists. */
#ifdef __MINGW32__
mkdir( jdir );
#else
mkdir( jdir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH );
#endif
free( jdir );
}
@ -285,11 +289,13 @@ main( int argc, char *const argv[] )
jtag_argv0 = argv[0];
#ifndef __MINGW32__
if(geteuid()==0 && getuid()!=0)
{
printf (_("'%s' must not be run suid root!\n"), "jtag");
return(-1);
}
#endif
#ifdef ENABLE_NLS
/* l10n support */

@ -26,16 +26,94 @@
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#ifndef __MINGW32__
#include <sys/times.h>
#endif
#include <math.h>
#include <assert.h>
/* ------------------------------------------------------------------ */
#ifdef __APPLE__
#include <mach/mach_time.h>
#include <sys/types.h>
#include <sys/time.h>
#endif
long double
frealtime()
{
long double result;
static uint64_t start_mat;
static long double start_time;
static double multiplier;
mach_timebase_info_data_t mtid;
struct timeval tv;
if(!mtid.denom == 0) {
mach_timebase_info(&mtid);
multiplier = (double)mtid.numer / (double)mtid.denom;
gettimeofday(&tv, NULL);
start_time = (long double)tv.tv_sec + (long double)tv.tv_usec * 1000.0;
start_mat = mach_absolute_time();
}
result = start_time + (mach_absolute_time() - start_mat) * multiplier;
assert(isnormal(result));
assert(result > 0);
return result;
}
#else /* def __APPLE__ */
/* ------------------------------------------------------------------ */
#ifdef _POSIX_TIMERS
long double
frealtime()
{
long double result;
struct timespec t;
if (clock_gettime(CLOCK_REALTIME, &t)==-1) {
perror("frealtime (clock_gettime)");
exit(EXIT_FAILURE);
}
result = (long double)t.tv_sec + (long double)t.tv_nsec*(long double)1e-9;
assert(isnormal(result));
assert(result > 0);
return result;
}
#else /* def _POSIX_TIMERS */
/* ------------------------------------------------------------------ */
#ifdef __MINGW32__
#include <sys/timeb.h>
long double
frealtime()
{
long double result;
struct timeb t;
ftime(&t);
result = (long double)t.time + (long double)t.millitm * (long double)1e-3;
assert(isnormal(result));
assert(result > 0);
return result;
}
#else /* def __MINGW32__ */
/* ------------------------------------------------------------------ */
#ifndef CLK_TCK
static clock_t CLK_TCK = 0;
@ -51,37 +129,12 @@ static void set_clk_tck(void)
}
#endif
long double
frealtime()
{
long double result;
#ifdef __APPLE__
static uint64_t start_mat;
static long double start_time;
static double multiplier;
mach_timebase_info_data_t mtid;
struct timeval tv;
if(!mtid.denom == 0) {
mach_timebase_info(&mtid);
multiplier = (double)mtid.numer / (double)mtid.denom;
gettimeofday(&tv, NULL);
start_time = (long double)tv.tv_sec + (long double)tv.tv_usec * 1000.0;
start_mat = mach_absolute_time();
}
result = start_time + (mach_absolute_time() - start_mat) * multiplier;
#else
#ifdef _POSIX_TIMERS
struct timespec t;
if (clock_gettime(CLOCK_REALTIME, &t)==-1) {
perror("frealtime (clock_gettime)");
exit(EXIT_FAILURE);
}
result = (long double)t.tv_sec + (long double)t.tv_nsec*(long double)1e-9;
#else
struct tms t;
clock_t c=times(&t);
if (c==(clock_t)-1) {
@ -89,23 +142,14 @@ frealtime()
exit(EXIT_FAILURE);
}
result = (long double)c/CLK_TCK;
#endif
#endif
assert(isnormal(result));
assert(result > 0);
return result;
}
#endif
#endif
#endif
long double
fcputime()
{
struct tms t;
clock_t c=times(&t);
if (c==(clock_t)-1) {
perror("fcputime (times)");
exit(EXIT_FAILURE);
}
return ((long double)t.tms_utime+t.tms_stime)/CLK_TCK;
}

@ -51,6 +51,10 @@
#include "svf.h"
#include "svf_bison.h"
#ifdef __MINGW__
#include "fclock.h"
#endif
int svfparse(parser_priv_t *priv_data, chain_t *chain);
@ -654,6 +658,20 @@ svf_runtest(chain_t *chain, parser_priv_t *priv, struct runtest *params)
svf_goto_state(chain, priv->runtest_run_state);
#ifdef __MINGW32__
if (params->max_time > 0.0) {
double maxt = frealtime() + params->max_time;
while (run_count-- > 0 && frealtime() < maxt) {
chain_clock(chain, 0, 0, 1);
}
}
else
chain_clock(chain, 0, 0, run_count);
svf_goto_state(chain, priv->runtest_end_state);
#else
/* set up the timer for max_time */
if (params->max_time > 0.0) {
struct sigaction sa;
@ -694,6 +712,7 @@ svf_runtest(chain_t *chain, parser_priv_t *priv, struct runtest *params)
exit(EXIT_FAILURE);
}
}
#endif
return(1);
}

@ -31,7 +31,7 @@
#include <fcntl.h>
#include <unistd.h>
#if __CYGWIN__
#if __CYGWIN__ || __MINGW32__
#include <windows.h>
#endif
#ifdef HAVE_STROPTS_H
@ -213,8 +213,8 @@ ftd2xx_generic_open( parport_t *parport )
ftd2xx_params_t *p = parport->params;
FT_STATUS status;
#if !__CYGWIN__
/* Add non-standard Vid/Pid to the linux driver */
#if !__CYGWIN__ && !__MINGW32__
/* Add non-standard Vid/Pid to the linux driver */
if ((status = FT_SetVIDPID(p->vendor_id, p->product_id)) != FT_OK)
fprintf( stderr, "Warning: couldn't add %4.4x:%4.4x", p->vendor_id, p->product_id );
#endif

@ -29,7 +29,7 @@
#ifdef HAVE_LIBUSB
#include <fcntl.h>
#if __CYGWIN__
#if __CYGWIN__ || __MINGW32__
#include <windows.h>
#endif
#include <stdio.h>

Loading…
Cancel
Save