Add support for Visual Studio 2019

This commit is contained in:
Marius Greuel
2020-01-18 19:05:50 +02:00
parent d4aeff190e
commit a9f311ba84
130 changed files with 32036 additions and 13 deletions

201
msvc/generated/ac_cfg.h Normal file
View File

@@ -0,0 +1,201 @@
/* ac_cfg.h. Generated from ac_cfg.h.in by configure. */
/* ac_cfg.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <ddk/hidsdi.h> header file. */
#define HAVE_DDK_HIDSDI_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
/* #undef HAVE_DLFCN_H */
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the `getaddrinfo' function. */
/* #undef HAVE_GETADDRINFO */
/* Define to 1 if you have the `gettimeofday' function. */
/* #undef HAVE_GETTIMEOFDAY */
/* Define to 1 if you have the <hidapi/hidapi.h> header file. */
/* #undef HAVE_HIDAPI_HIDAPI_H */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define if ELF support is enabled via libelf */
#define HAVE_LIBELF 1
/* Define to 1 if you have the <libelf.h> header file. */
#define HAVE_LIBELF_H 1
/* Define to 1 if you have the <libelf/libelf.h> header file. */
/* #undef HAVE_LIBELF_LIBELF_H */
/* Define if FTDI support is enabled via libftdi */
/* #undef HAVE_LIBFTDI */
/* Define if FTDI support is enabled via libftdi1 */
/* #undef HAVE_LIBFTDI1 */
/* Define if libftdi supports FT232H, libftdi version >= 0.20 */
/* #undef HAVE_LIBFTDI_TYPE_232H */
/* Define if HID support is enabled via the Win32 DDK */
#define HAVE_LIBHID 1
/* Define if HID support is enabled via libhidapi */
#define HAVE_LIBHIDAPI 1
/* Define to 1 if you have the `ncurses' library (-lncurses). */
/* #undef HAVE_LIBNCURSES */
/* Define to 1 if you have the `readline' library (-lreadline). */
/* #undef HAVE_LIBREADLINE */
/* Define to 1 if you have the `termcap' library (-ltermcap). */
/* #undef HAVE_LIBTERMCAP */
/* Define if USB support is enabled via libusb */
#define HAVE_LIBUSB 1
/* Define if USB support is enabled via a libusb-1.0 compatible libusb */
/* #undef HAVE_LIBUSB_1_0 */
/* Define to 1 if you have the <libusb-1.0/libusb.h> header file. */
/* #undef HAVE_LIBUSB_1_0_LIBUSB_H */
/* Define to 1 if you have the <libusb.h> header file. */
/* #undef HAVE_LIBUSB_H */
/* Define to 1 if you have the `ws2_32' library (-lws2_32). */
#define HAVE_LIBWS2_32 1
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Linux sysfs GPIO support enabled */
/* #undef HAVE_LINUXGPIO */
/* Define to 1 if you have the <lusb0_usb.h> header file. */
#define HAVE_LUSB0_USB_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if you have the <netinet/in.h> header file. */
/* #undef HAVE_NETINET_IN_H */
/* parallel port access enabled */
/* #undef HAVE_PARPORT */
/* Define to 1 if you have the <pthread.h> header file. */
/* #undef HAVE_PTHREAD_H */
/* Define to 1 if you have the `select' function. */
/* #undef HAVE_SELECT */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `strcasecmp' function. */
#define HAVE_STRCASECMP 1
/* Define to 1 if you have the `strdup' function. */
#define HAVE_STRDUP 1
/* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the `strncasecmp' function. */
#define HAVE_STRNCASECMP 1
/* Define to 1 if you have the `strtol' function. */
#define HAVE_STRTOL 1
/* Define to 1 if you have the `strtoul' function. */
#define HAVE_STRTOUL 1
/* Define to 1 if you have the <sys/ioctl.h> header file. */
/* #undef HAVE_SYS_IOCTL_H */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <termios.h> header file. */
/* #undef HAVE_TERMIOS_H */
/* Define to 1 if the system has the type `uint_t'. */
/* #undef HAVE_UINT_T */
/* Define to 1 if the system has the type `ulong_t'. */
/* #undef HAVE_ULONG_T */
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the <usb.h> header file. */
/* #undef HAVE_USB_H */
/* Define to 1 if you have the `usleep' function. */
#define HAVE_USLEEP 1
/* Define if lex/flex has yylex_destroy */
#define HAVE_YYLEX_DESTROY 1
/* Define to the sub-directory where libtool stores uninstalled libraries. */
/* #undef LT_OBJDIR */
/* Name of package */
#define PACKAGE "avrdude"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "avrdude-dev@nongnu.org"
/* Define to the full name of this package. */
#define PACKAGE_NAME "avrdude"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "avrdude 6.3.1.0-windows"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "avrdude"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "6.3.1.0-windows"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Version number of package */
#define VERSION "6.3.1.0-windows"
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
`char[]'. */
#define YYTEXT_POINTER 1
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */

3861
msvc/generated/config_gram.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,340 @@
/* A Bison parser, made by GNU Bison 3.5.1. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Undocumented macros, especially those whose name start with YY_,
are private implementation details. Do not rely on them. */
#ifndef YY_YY_CONFIG_GRAM_H_INCLUDED
# define YY_YY_CONFIG_GRAM_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
K_READ = 258,
K_WRITE = 259,
K_READ_LO = 260,
K_READ_HI = 261,
K_WRITE_LO = 262,
K_WRITE_HI = 263,
K_LOADPAGE_LO = 264,
K_LOADPAGE_HI = 265,
K_LOAD_EXT_ADDR = 266,
K_WRITEPAGE = 267,
K_CHIP_ERASE = 268,
K_PGM_ENABLE = 269,
K_MEMORY = 270,
K_PAGE_SIZE = 271,
K_PAGED = 272,
K_BAUDRATE = 273,
K_BS2 = 274,
K_BUFF = 275,
K_CHIP_ERASE_DELAY = 276,
K_CONNTYPE = 277,
K_DEDICATED = 278,
K_DEFAULT_BITCLOCK = 279,
K_DEFAULT_PARALLEL = 280,
K_DEFAULT_PROGRAMMER = 281,
K_DEFAULT_SAFEMODE = 282,
K_DEFAULT_SERIAL = 283,
K_DESC = 284,
K_FAMILY_ID = 285,
K_DEVICECODE = 286,
K_STK500_DEVCODE = 287,
K_AVR910_DEVCODE = 288,
K_EEPROM = 289,
K_ERRLED = 290,
K_FLASH = 291,
K_ID = 292,
K_IO = 293,
K_LOADPAGE = 294,
K_MAX_WRITE_DELAY = 295,
K_MCU_BASE = 296,
K_MIN_WRITE_DELAY = 297,
K_MISO = 298,
K_MOSI = 299,
K_NUM_PAGES = 300,
K_NVM_BASE = 301,
K_OCD_BASE = 302,
K_OCDREV = 303,
K_OFFSET = 304,
K_PAGEL = 305,
K_PARALLEL = 306,
K_PARENT = 307,
K_PART = 308,
K_PGMLED = 309,
K_PROGRAMMER = 310,
K_PSEUDO = 311,
K_PWROFF_AFTER_WRITE = 312,
K_RDYLED = 313,
K_READBACK_P1 = 314,
K_READBACK_P2 = 315,
K_READMEM = 316,
K_RESET = 317,
K_RETRY_PULSE = 318,
K_SERIAL = 319,
K_SCK = 320,
K_SIGNATURE = 321,
K_SIZE = 322,
K_USB = 323,
K_USBDEV = 324,
K_USBSN = 325,
K_USBPID = 326,
K_USBPRODUCT = 327,
K_USBVENDOR = 328,
K_USBVID = 329,
K_TYPE = 330,
K_VCC = 331,
K_VFYLED = 332,
K_NO = 333,
K_YES = 334,
K_TIMEOUT = 335,
K_STABDELAY = 336,
K_CMDEXEDELAY = 337,
K_HVSPCMDEXEDELAY = 338,
K_SYNCHLOOPS = 339,
K_BYTEDELAY = 340,
K_POLLVALUE = 341,
K_POLLINDEX = 342,
K_PREDELAY = 343,
K_POSTDELAY = 344,
K_POLLMETHOD = 345,
K_MODE = 346,
K_DELAY = 347,
K_BLOCKSIZE = 348,
K_READSIZE = 349,
K_HVENTERSTABDELAY = 350,
K_PROGMODEDELAY = 351,
K_LATCHCYCLES = 352,
K_TOGGLEVTG = 353,
K_POWEROFFDELAY = 354,
K_RESETDELAYMS = 355,
K_RESETDELAYUS = 356,
K_HVLEAVESTABDELAY = 357,
K_RESETDELAY = 358,
K_SYNCHCYCLES = 359,
K_HVCMDEXEDELAY = 360,
K_CHIPERASEPULSEWIDTH = 361,
K_CHIPERASEPOLLTIMEOUT = 362,
K_CHIPERASETIME = 363,
K_PROGRAMFUSEPULSEWIDTH = 364,
K_PROGRAMFUSEPOLLTIMEOUT = 365,
K_PROGRAMLOCKPULSEWIDTH = 366,
K_PROGRAMLOCKPOLLTIMEOUT = 367,
K_PP_CONTROLSTACK = 368,
K_HVSP_CONTROLSTACK = 369,
K_ALLOWFULLPAGEBITSTREAM = 370,
K_ENABLEPAGEPROGRAMMING = 371,
K_HAS_JTAG = 372,
K_HAS_DW = 373,
K_HAS_PDI = 374,
K_HAS_UPDI = 375,
K_HAS_TPI = 376,
K_IDR = 377,
K_IS_AT90S1200 = 378,
K_IS_AVR32 = 379,
K_RAMPZ = 380,
K_SPMCR = 381,
K_EECR = 382,
K_FLASH_INSTR = 383,
K_EEPROM_INSTR = 384,
TKN_COMMA = 385,
TKN_EQUAL = 386,
TKN_SEMI = 387,
TKN_TILDE = 388,
TKN_LEFT_PAREN = 389,
TKN_RIGHT_PAREN = 390,
TKN_NUMBER = 391,
TKN_NUMBER_REAL = 392,
TKN_STRING = 393
};
#endif
/* Tokens. */
#define K_READ 258
#define K_WRITE 259
#define K_READ_LO 260
#define K_READ_HI 261
#define K_WRITE_LO 262
#define K_WRITE_HI 263
#define K_LOADPAGE_LO 264
#define K_LOADPAGE_HI 265
#define K_LOAD_EXT_ADDR 266
#define K_WRITEPAGE 267
#define K_CHIP_ERASE 268
#define K_PGM_ENABLE 269
#define K_MEMORY 270
#define K_PAGE_SIZE 271
#define K_PAGED 272
#define K_BAUDRATE 273
#define K_BS2 274
#define K_BUFF 275
#define K_CHIP_ERASE_DELAY 276
#define K_CONNTYPE 277
#define K_DEDICATED 278
#define K_DEFAULT_BITCLOCK 279
#define K_DEFAULT_PARALLEL 280
#define K_DEFAULT_PROGRAMMER 281
#define K_DEFAULT_SAFEMODE 282
#define K_DEFAULT_SERIAL 283
#define K_DESC 284
#define K_FAMILY_ID 285
#define K_DEVICECODE 286
#define K_STK500_DEVCODE 287
#define K_AVR910_DEVCODE 288
#define K_EEPROM 289
#define K_ERRLED 290
#define K_FLASH 291
#define K_ID 292
#define K_IO 293
#define K_LOADPAGE 294
#define K_MAX_WRITE_DELAY 295
#define K_MCU_BASE 296
#define K_MIN_WRITE_DELAY 297
#define K_MISO 298
#define K_MOSI 299
#define K_NUM_PAGES 300
#define K_NVM_BASE 301
#define K_OCD_BASE 302
#define K_OCDREV 303
#define K_OFFSET 304
#define K_PAGEL 305
#define K_PARALLEL 306
#define K_PARENT 307
#define K_PART 308
#define K_PGMLED 309
#define K_PROGRAMMER 310
#define K_PSEUDO 311
#define K_PWROFF_AFTER_WRITE 312
#define K_RDYLED 313
#define K_READBACK_P1 314
#define K_READBACK_P2 315
#define K_READMEM 316
#define K_RESET 317
#define K_RETRY_PULSE 318
#define K_SERIAL 319
#define K_SCK 320
#define K_SIGNATURE 321
#define K_SIZE 322
#define K_USB 323
#define K_USBDEV 324
#define K_USBSN 325
#define K_USBPID 326
#define K_USBPRODUCT 327
#define K_USBVENDOR 328
#define K_USBVID 329
#define K_TYPE 330
#define K_VCC 331
#define K_VFYLED 332
#define K_NO 333
#define K_YES 334
#define K_TIMEOUT 335
#define K_STABDELAY 336
#define K_CMDEXEDELAY 337
#define K_HVSPCMDEXEDELAY 338
#define K_SYNCHLOOPS 339
#define K_BYTEDELAY 340
#define K_POLLVALUE 341
#define K_POLLINDEX 342
#define K_PREDELAY 343
#define K_POSTDELAY 344
#define K_POLLMETHOD 345
#define K_MODE 346
#define K_DELAY 347
#define K_BLOCKSIZE 348
#define K_READSIZE 349
#define K_HVENTERSTABDELAY 350
#define K_PROGMODEDELAY 351
#define K_LATCHCYCLES 352
#define K_TOGGLEVTG 353
#define K_POWEROFFDELAY 354
#define K_RESETDELAYMS 355
#define K_RESETDELAYUS 356
#define K_HVLEAVESTABDELAY 357
#define K_RESETDELAY 358
#define K_SYNCHCYCLES 359
#define K_HVCMDEXEDELAY 360
#define K_CHIPERASEPULSEWIDTH 361
#define K_CHIPERASEPOLLTIMEOUT 362
#define K_CHIPERASETIME 363
#define K_PROGRAMFUSEPULSEWIDTH 364
#define K_PROGRAMFUSEPOLLTIMEOUT 365
#define K_PROGRAMLOCKPULSEWIDTH 366
#define K_PROGRAMLOCKPOLLTIMEOUT 367
#define K_PP_CONTROLSTACK 368
#define K_HVSP_CONTROLSTACK 369
#define K_ALLOWFULLPAGEBITSTREAM 370
#define K_ENABLEPAGEPROGRAMMING 371
#define K_HAS_JTAG 372
#define K_HAS_DW 373
#define K_HAS_PDI 374
#define K_HAS_UPDI 375
#define K_HAS_TPI 376
#define K_IDR 377
#define K_IS_AT90S1200 378
#define K_IS_AVR32 379
#define K_RAMPZ 380
#define K_SPMCR 381
#define K_EECR 382
#define K_FLASH_INSTR 383
#define K_EEPROM_INSTR 384
#define TKN_COMMA 385
#define TKN_EQUAL 386
#define TKN_SEMI 387
#define TKN_TILDE 388
#define TKN_LEFT_PAREN 389
#define TKN_RIGHT_PAREN 390
#define TKN_NUMBER 391
#define TKN_NUMBER_REAL 392
#define TKN_STRING 393
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_CONFIG_GRAM_H_INCLUDED */

3092
msvc/generated/lexer.c Normal file

File diff suppressed because it is too large Load Diff

562
msvc/getopt.c Normal file
View File

@@ -0,0 +1,562 @@
/* $OpenBSD: getopt_long.c,v 1.23 2007/10/31 12:34:57 chl Exp $ */
/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */
/*
* Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Sponsored in part by the Defense Advanced Research Projects
* Agency (DARPA) and Air Force Research Laboratory, Air Force
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Dieter Baron and Thomas Klausner.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <stdarg.h>
#include <stdio.h>
#include <windows.h>
#define REPLACE_GETOPT /* use this getopt as the system getopt(3) */
#ifdef REPLACE_GETOPT
int opterr = 1; /* if error message should be printed */
int optind = 1; /* index into parent argv vector */
int optopt = '?'; /* character checked for validity */
#undef optreset /* see getopt.h */
#define optreset __mingw_optreset
int optreset; /* reset getopt */
char *optarg; /* argument associated with option */
#endif
#define PRINT_ERROR ((opterr) && (*options != ':'))
#define FLAG_PERMUTE 0x01 /* permute non-options to the end of argv */
#define FLAG_ALLARGS 0x02 /* treat non-options as args to option "-1" */
#define FLAG_LONGONLY 0x04 /* operate as getopt_long_only */
/* return values */
#define BADCH (int)'?'
#define BADARG ((*options == ':') ? (int)':' : (int)'?')
#define INORDER (int)1
#ifndef __CYGWIN__
#define __progname __argv[0]
#else
extern char __declspec(dllimport) *__progname;
#endif
#ifdef __CYGWIN__
static char EMSG[] = "";
#else
#define EMSG ""
#endif
static int getopt_internal(int, char * const *, const char *,
const struct option *, int *, int);
static int parse_long_options(char * const *, const char *,
const struct option *, int *, int);
static int gcd(int, int);
static void permute_args(int, int, int, char * const *);
static char *place = EMSG; /* option letter processing */
/* XXX: set optreset to 1 rather than these two */
static int nonopt_start = -1; /* first non option argument (for permute) */
static int nonopt_end = -1; /* first option after non options (for permute) */
/* Error messages */
static const char recargchar[] = "option requires an argument -- %c";
static const char recargstring[] = "option requires an argument -- %s";
static const char ambig[] = "ambiguous option -- %.*s";
static const char noarg[] = "option doesn't take an argument -- %.*s";
static const char illoptchar[] = "unknown option -- %c";
static const char illoptstring[] = "unknown option -- %s";
static void
_vwarnx(const char *fmt,va_list ap)
{
(void)fprintf(stderr,"%s: ",__progname);
if (fmt != NULL)
(void)vfprintf(stderr,fmt,ap);
(void)fprintf(stderr,"\n");
}
static void
warnx(const char *fmt,...)
{
va_list ap;
va_start(ap,fmt);
_vwarnx(fmt,ap);
va_end(ap);
}
/*
* Compute the greatest common divisor of a and b.
*/
static int
gcd(int a, int b)
{
int c;
c = a % b;
while (c != 0) {
a = b;
b = c;
c = a % b;
}
return (b);
}
/*
* Exchange the block from nonopt_start to nonopt_end with the block
* from nonopt_end to opt_end (keeping the same order of arguments
* in each block).
*/
static void
permute_args(int panonopt_start, int panonopt_end, int opt_end,
char * const *nargv)
{
int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
char *swap;
/*
* compute lengths of blocks and number and size of cycles
*/
nnonopts = panonopt_end - panonopt_start;
nopts = opt_end - panonopt_end;
ncycle = gcd(nnonopts, nopts);
cyclelen = (opt_end - panonopt_start) / ncycle;
for (i = 0; i < ncycle; i++) {
cstart = panonopt_end+i;
pos = cstart;
for (j = 0; j < cyclelen; j++) {
if (pos >= panonopt_end)
pos -= nnonopts;
else
pos += nopts;
swap = nargv[pos];
/* LINTED const cast */
((char **) nargv)[pos] = nargv[cstart];
/* LINTED const cast */
((char **)nargv)[cstart] = swap;
}
}
}
/*
* parse_long_options --
* Parse long options in argc/argv argument vector.
* Returns -1 if short_too is set and the option does not match long_options.
*/
static int
parse_long_options(char * const *nargv, const char *options,
const struct option *long_options, int *idx, int short_too)
{
char *current_argv, *has_equal;
size_t current_argv_len;
int i, ambiguous, match;
#define IDENTICAL_INTERPRETATION(_x, _y) \
(long_options[(_x)].has_arg == long_options[(_y)].has_arg && \
long_options[(_x)].flag == long_options[(_y)].flag && \
long_options[(_x)].val == long_options[(_y)].val)
current_argv = place;
match = -1;
ambiguous = 0;
optind++;
if ((has_equal = strchr(current_argv, '=')) != NULL) {
/* argument found (--option=arg) */
current_argv_len = has_equal - current_argv;
has_equal++;
} else
current_argv_len = strlen(current_argv);
for (i = 0; long_options[i].name; i++) {
/* find matching long option */
if (strncmp(current_argv, long_options[i].name,
current_argv_len))
continue;
if (strlen(long_options[i].name) == current_argv_len) {
/* exact match */
match = i;
ambiguous = 0;
break;
}
/*
* If this is a known short option, don't allow
* a partial match of a single character.
*/
if (short_too && current_argv_len == 1)
continue;
if (match == -1) /* partial match */
match = i;
else if (!IDENTICAL_INTERPRETATION(i, match))
ambiguous = 1;
}
if (ambiguous) {
/* ambiguous abbreviation */
if (PRINT_ERROR)
warnx(ambig, (int)current_argv_len,
current_argv);
optopt = 0;
return (BADCH);
}
if (match != -1) { /* option found */
if (long_options[match].has_arg == no_argument
&& has_equal) {
if (PRINT_ERROR)
warnx(noarg, (int)current_argv_len,
current_argv);
/*
* XXX: GNU sets optopt to val regardless of flag
*/
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
return (BADARG);
}
if (long_options[match].has_arg == required_argument ||
long_options[match].has_arg == optional_argument) {
if (has_equal)
optarg = has_equal;
else if (long_options[match].has_arg ==
required_argument) {
/*
* optional argument doesn't use next nargv
*/
optarg = nargv[optind++];
}
}
if ((long_options[match].has_arg == required_argument)
&& (optarg == NULL)) {
/*
* Missing argument; leading ':' indicates no error
* should be generated.
*/
if (PRINT_ERROR)
warnx(recargstring,
current_argv);
/*
* XXX: GNU sets optopt to val regardless of flag
*/
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
--optind;
return (BADARG);
}
} else { /* unknown option */
if (short_too) {
--optind;
return (-1);
}
if (PRINT_ERROR)
warnx(illoptstring, current_argv);
optopt = 0;
return (BADCH);
}
if (idx)
*idx = match;
if (long_options[match].flag) {
*long_options[match].flag = long_options[match].val;
return (0);
} else
return (long_options[match].val);
#undef IDENTICAL_INTERPRETATION
}
/*
* getopt_internal --
* Parse argc/argv argument vector. Called by user level routines.
*/
static int
getopt_internal(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx, int flags)
{
char *oli; /* option letter list index */
int optchar, short_too;
static int posixly_correct = -1;
if (options == NULL)
return (-1);
/*
* XXX Some GNU programs (like cvs) set optind to 0 instead of
* XXX using optreset. Work around this braindamage.
*/
if (optind == 0)
optind = optreset = 1;
/*
* Disable GNU extensions if POSIXLY_CORRECT is set or options
* string begins with a '+'.
*
* CV, 2009-12-14: Check POSIXLY_CORRECT anew if optind == 0 or
* optreset != 0 for GNU compatibility.
*/
if (posixly_correct == -1 || optreset != 0)
posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
if (*options == '-')
flags |= FLAG_ALLARGS;
else if (posixly_correct || *options == '+')
flags &= ~FLAG_PERMUTE;
if (*options == '+' || *options == '-')
options++;
optarg = NULL;
if (optreset)
nonopt_start = nonopt_end = -1;
start:
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc) { /* end of argument vector */
place = EMSG;
if (nonopt_end != -1) {
/* do permutation, if we have to */
permute_args(nonopt_start, nonopt_end,
optind, nargv);
optind -= nonopt_end - nonopt_start;
}
else if (nonopt_start != -1) {
/*
* If we skipped non-options, set optind
* to the first of them.
*/
optind = nonopt_start;
}
nonopt_start = nonopt_end = -1;
return (-1);
}
if (*(place = nargv[optind]) != '-' ||
(place[1] == '\0' && strchr(options, '-') == NULL)) {
place = EMSG; /* found non-option */
if (flags & FLAG_ALLARGS) {
/*
* GNU extension:
* return non-option as argument to option 1
*/
optarg = nargv[optind++];
return (INORDER);
}
if (!(flags & FLAG_PERMUTE)) {
/*
* If no permutation wanted, stop parsing
* at first non-option.
*/
return (-1);
}
/* do permutation */
if (nonopt_start == -1)
nonopt_start = optind;
else if (nonopt_end != -1) {
permute_args(nonopt_start, nonopt_end,
optind, nargv);
nonopt_start = optind -
(nonopt_end - nonopt_start);
nonopt_end = -1;
}
optind++;
/* process next argument */
goto start;
}
if (nonopt_start != -1 && nonopt_end == -1)
nonopt_end = optind;
/*
* If we have "-" do nothing, if "--" we are done.
*/
if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
optind++;
place = EMSG;
/*
* We found an option (--), so if we skipped
* non-options, we have to permute.
*/
if (nonopt_end != -1) {
permute_args(nonopt_start, nonopt_end,
optind, nargv);
optind -= nonopt_end - nonopt_start;
}
nonopt_start = nonopt_end = -1;
return (-1);
}
}
/*
* Check long options if:
* 1) we were passed some
* 2) the arg is not just "-"
* 3) either the arg starts with -- we are getopt_long_only()
*/
if (long_options != NULL && place != nargv[optind] &&
(*place == '-' || (flags & FLAG_LONGONLY))) {
short_too = 0;
if (*place == '-')
place++; /* --foo long option */
else if (*place != ':' && strchr(options, *place) != NULL)
short_too = 1; /* could be short option too */
optchar = parse_long_options(nargv, options, long_options,
idx, short_too);
if (optchar != -1) {
place = EMSG;
return (optchar);
}
}
if ((optchar = (int)*place++) == (int)':' ||
(optchar == (int)'-' && *place != '\0') ||
(oli = strchr(options, optchar)) == NULL) {
/*
* If the user specified "-" and '-' isn't listed in
* options, return -1 (non-option) as per POSIX.
* Otherwise, it is an unknown option character (or ':').
*/
if (optchar == (int)'-' && *place == '\0')
return (-1);
if (!*place)
++optind;
if (PRINT_ERROR)
warnx(illoptchar, optchar);
optopt = optchar;
return (BADCH);
}
if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
/* -W long-option */
if (*place) /* no space */
/* NOTHING */;
else if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
warnx(recargchar, optchar);
optopt = optchar;
return (BADARG);
} else /* white space */
place = nargv[optind];
optchar = parse_long_options(nargv, options, long_options,
idx, 0);
place = EMSG;
return (optchar);
}
if (*++oli != ':') { /* doesn't take argument */
if (!*place)
++optind;
} else { /* takes (optional) argument */
optarg = NULL;
if (*place) /* no white space */
optarg = place;
else if (oli[1] != ':') { /* arg not optional */
if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
warnx(recargchar, optchar);
optopt = optchar;
return (BADARG);
} else
optarg = nargv[optind];
}
place = EMSG;
++optind;
}
/* dump back option letter */
return (optchar);
}
#ifdef REPLACE_GETOPT
/*
* getopt --
* Parse argc/argv argument vector.
*
* [eventually this will replace the BSD getopt]
*/
int
getopt(int nargc, char * const *nargv, const char *options)
{
/*
* We don't pass FLAG_PERMUTE to getopt_internal() since
* the BSD getopt(3) (unlike GNU) has never done this.
*
* Furthermore, since many privileged programs call getopt()
* before dropping privileges it makes sense to keep things
* as simple (and bug-free) as possible.
*/
return (getopt_internal(nargc, nargv, options, NULL, NULL, 0));
}
#endif /* REPLACE_GETOPT */
/*
* getopt_long --
* Parse argc/argv argument vector.
*/
int
getopt_long(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx)
{
return (getopt_internal(nargc, nargv, options, long_options, idx,
FLAG_PERMUTE));
}
/*
* getopt_long_only --
* Parse argc/argv argument vector.
*/
int
getopt_long_only(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx)
{
return (getopt_internal(nargc, nargv, options, long_options, idx,
FLAG_PERMUTE|FLAG_LONGONLY));
}

95
msvc/getopt.h Normal file
View File

@@ -0,0 +1,95 @@
#ifndef __GETOPT_H__
/**
* DISCLAIMER
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
*
* The mingw-w64 runtime package and its code is distributed in the hope that it
* will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR
* IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to
* warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#define __GETOPT_H__
/* All the headers include this file. */
#include <crtdefs.h>
#ifdef __cplusplus
extern "C" {
#endif
extern int optind; /* index of first non-option in argv */
extern int optopt; /* single option character, as parsed */
extern int opterr; /* flag to enable built-in diagnostics... */
/* (user may set to zero, to suppress) */
extern char *optarg; /* pointer to argument of current option */
extern int getopt(int nargc, char * const *nargv, const char *options);
#ifdef _BSD_SOURCE
/*
* BSD adds the non-standard `optreset' feature, for reinitialisation
* of `getopt' parsing. We support this feature, for applications which
* proclaim their BSD heritage, before including this header; however,
* to maintain portability, developers are advised to avoid it.
*/
# define optreset __mingw_optreset
extern int optreset;
#endif
#ifdef __cplusplus
}
#endif
/*
* POSIX requires the `getopt' API to be specified in `unistd.h';
* thus, `unistd.h' includes this header. However, we do not want
* to expose the `getopt_long' or `getopt_long_only' APIs, when
* included in this manner. Thus, close the standard __GETOPT_H__
* declarations block, and open an additional __GETOPT_LONG_H__
* specific block, only when *not* __UNISTD_H_SOURCED__, in which
* to declare the extended API.
*/
#endif /* !defined(__GETOPT_H__) */
#if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
#define __GETOPT_LONG_H__
#ifdef __cplusplus
extern "C" {
#endif
struct option /* specification for a long form option... */
{
const char *name; /* option name, without leading hyphens */
int has_arg; /* does it take an argument? */
int *flag; /* where to save its status, or NULL */
int val; /* its associated status value */
};
enum /* permitted values for its `has_arg' field... */
{
no_argument = 0, /* option never takes an argument */
required_argument, /* option always requires an argument */
optional_argument /* option may take an argument */
};
extern int getopt_long(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx);
extern int getopt_long_only(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx);
/*
* Previous MinGW implementation had...
*/
#ifndef HAVE_DECL_GETOPT
/*
* ...for the long form API only; keep this for compatibility.
*/
# define HAVE_DECL_GETOPT 1
#endif
#ifdef __cplusplus
}
#endif
#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */

76
msvc/gettimeofday.c Normal file
View File

@@ -0,0 +1,76 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <time.h>
#include <sys/time.h>
#include <sys/timeb.h>
#include <errno.h>
#include <windows.h>
#define FILETIME_1970 116444736000000000ull /* seconds between 1/1/1601 and 1/1/1970 */
#define HECTONANOSEC_PER_SEC 10000000ull
int getntptimeofday(struct timespec *, struct timezone *);
int getntptimeofday(struct timespec *tp, struct timezone *z)
{
int res = 0;
union
{
unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */
FILETIME ft;
} _now;
TIME_ZONE_INFORMATION TimeZoneInformation;
DWORD tzi;
if (z != NULL)
{
if ((tzi = GetTimeZoneInformation(&TimeZoneInformation)) != TIME_ZONE_ID_INVALID)
{
z->tz_minuteswest = TimeZoneInformation.Bias;
if (tzi == TIME_ZONE_ID_DAYLIGHT)
z->tz_dsttime = 1;
else
z->tz_dsttime = 0;
}
else
{
z->tz_minuteswest = 0;
z->tz_dsttime = 0;
}
}
if (tp != NULL)
{
GetSystemTimeAsFileTime(&_now.ft); /* 100-nanoseconds since 1-1-1601 */
/* The actual accuracy on XP seems to be 125,000 nanoseconds = 125 microseconds = 0.125 milliseconds */
_now.ns100 -= FILETIME_1970; /* 100 nano-seconds since 1-1-1970 */
tp->tv_sec = _now.ns100 / HECTONANOSEC_PER_SEC; /* seconds since 1-1-1970 */
tp->tv_nsec = (long)(_now.ns100 % HECTONANOSEC_PER_SEC) * 100; /* nanoseconds */
}
return res;
}
int __cdecl gettimeofday(struct timeval *p, void *z)
{
struct timespec tp;
if (getntptimeofday(&tp, (struct timezone *) z))
return -1;
p->tv_sec = (long)tp.tv_sec;
p->tv_usec = (tp.tv_nsec / 1000);
return 0;
}
int __cdecl mingw_gettimeofday(struct timeval *p, struct timezone *z)
{
struct timespec tp;
if (getntptimeofday(&tp, z))
return -1;
p->tv_sec = (long)tp.tv_sec;
p->tv_usec = (tp.tv_nsec / 1000);
return 0;
}

50
msvc/msvc_compat.h Normal file
View File

@@ -0,0 +1,50 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2018 Marius Greuel
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdio.h>
#include <string.h>
#include <io.h>
#pragma warning(disable : 4018) // signed/unsigned mismatch
#pragma warning(disable : 4244) // conversion from '...' to '...', possible loss of data
#pragma warning(disable : 4267) // conversion from '...' to '...', possible loss of data
#pragma comment(lib, "hid.lib")
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "setupapi.lib")
#define PATH_MAX _MAX_PATH
#define setvbuf msvc_setvbuf
static inline int msvc_setvbuf(
FILE* const public_stream,
char* const buffer,
int const type,
size_t const buffer_size_in_bytes
)
{
// Just ignore calls to setvbuf with invalid buffer size.
// Purpose of setvbuf calls unknown, probably in an attempt to fix broken
// programs that capture stdout and stderr using separate stream handles?
return 0;
}
static inline int strcasecmp(const char *s1, const char *s2) { return _stricmp(s1, s2); }
static inline int strncasecmp(const char *s1, const char *s2, size_t n) { return _strnicmp(s1, s2, n); }

28
msvc/sys/time.h Normal file
View File

@@ -0,0 +1,28 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2018 Marius Greuel
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TIME_H_
#define _TIME_H_
struct timezone
{
int tz_minuteswest;
int tz_dsttime;
};
#endif

93
msvc/unistd.cpp Normal file
View File

@@ -0,0 +1,93 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2018 Marius Greuel
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "unistd.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")
class MicroSleep
{
public:
MicroSleep()
{
if (::timeBeginPeriod(timerPeriod) == TIMERR_NOERROR)
{
m_resetTimerPeriod = true;
}
}
~MicroSleep()
{
if (m_resetTimerPeriod)
{
::timeEndPeriod(timerPeriod);
}
}
int Sleep(DWORD us)
{
if (us == 0)
{
return 0;
}
LARGE_INTEGER frequency;
if (QueryPerformanceFrequency(&frequency))
{
LARGE_INTEGER start;
QueryPerformanceCounter(&start);
if (us > 10000)
{
::Sleep((us - 5000) / 1000);
}
LARGE_INTEGER end;
end.QuadPart = start.QuadPart + (frequency.QuadPart * us / 1000000);
while (true)
{
LARGE_INTEGER current;
QueryPerformanceCounter(&current);
if (current.QuadPart >= end.QuadPart)
{
break;
}
}
}
else
{
::Sleep((us / 1000) + 1);
}
return 0;
}
private:
static const UINT timerPeriod = 1; // 1ms
bool m_resetTimerPeriod = false;
};
int usleep(unsigned int us)
{
static MicroSleep microSleep;
return microSleep.Sleep(us);
}

37
msvc/unistd.h Normal file
View File

@@ -0,0 +1,37 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2018 Marius Greuel
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _UNISTD_H
#define _UNISTD_H
#define STDIN_FILENO _fileno(stdin)
#define STDERR_FILENO _fileno(stderr)
#include <getopt.h>
#ifdef __cplusplus
extern "C" {
#endif
int usleep(unsigned int us);
#ifdef __cplusplus
}
#endif
#endif