Skip to content

Commit

Permalink
MSVC compile correctly (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkUaTeR authored and radare committed May 12, 2017
1 parent 11e8da3 commit 28f785d
Show file tree
Hide file tree
Showing 60 changed files with 683 additions and 399 deletions.
6 changes: 5 additions & 1 deletion binr/radare2/radare2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

#define USE_THREADS 1
#define UNCOLORIZE_NONTTY 0

#ifdef _MSC_VER
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#endif
#include <sdb.h>
#include <r_core.h>
#include <r_io.h>
Expand Down
7 changes: 6 additions & 1 deletion libr/asm/arch/arc/gnu/arc-ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@

#include "arc-ext.h"
#include "arc.h"
#ifndef _MSC_VER
// if one of this files are includes they make a #define const .....
// the const prefix is used bellow for api definitions.
// If u define the new value of const this dont match with previus const int arc-ext.h api definition
// giving a compiler error under MSVC
#include "libiberty.h"
#include "sysdep.h"

#endif

/******************************************************************************/
/* */
Expand Down
4 changes: 1 addition & 3 deletions libr/asm/arch/arc/gnu/arc-ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,14 @@ enum ExtReadWrite

/* constructor function */
extern void build_ARC_extmap (void* text_bfd);
#ifndef _MSC_VER
/* accessor functions */
extern enum ExtReadWrite arcExtMap_coreReadWrite (int regnum);
extern const char* arcExtMap_coreRegName (int regnum);
extern const char* arcExtMap_auxRegName (long regnum);
extern const char* arcExtMap_condCodeName (int code);
extern const char* arcExtMap_instName (int opcode, int insn, int* flags);
#endif
/* dump function (for debugging) */
extern void dump_ARC_extmap (void);
void dump_ARC_extmap (void);

#endif /* ARC_EXTENSIONS_H */
/******************************************************************************/
2 changes: 1 addition & 1 deletion libr/asm/arch/avr/avr_disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "avr_disasm.h"
#include "errorcodes.h"
#include "avr_instructionset.c"

#include <r_types.h>
/* AVR instructionSet is defined in avrinstructionset.c */
//extern instructionInfo instructionSet[AVR_TOTAL_INSTRUCTIONS];

Expand Down
7 changes: 6 additions & 1 deletion libr/asm/arch/include/libiberty.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,12 @@ extern double physmem_available (void);
as new/delete and new[]/delete[]. */

/* Scalar allocators. */

#ifdef _MSC_VER
#include <stdlib.h>
#define xmalloc malloc
#define xcalloc calloc
#define xrealloc realloc
#endif
#define XNEW(T) ((T *) xmalloc (sizeof (T)))
#define XCNEW(T) ((T *) xcalloc (1, sizeof (T)))
#define XDELETE(P) free ((void*) (P))
Expand Down
10 changes: 0 additions & 10 deletions libr/asm/arch/xtensa/gnu/xtensa-dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,7 @@
#include "ansidecl.h"
#include <setjmp.h>
#include "dis-asm.h"
#ifndef _MSC_VER
#include "libiberty.h"
#else
#include <stdlib.h>
#define XNEWVEC(T, N) ((T *) malloc (sizeof (T) * (N)))
#define XCNEWVEC(T, N) ((T *) calloc ((N), sizeof (T)))
#define XNEW(T) ((T *) malloc (sizeof (T)))
#define xmalloc malloc
#endif



extern xtensa_isa xtensa_default_isa;

Expand Down
3 changes: 0 additions & 3 deletions libr/asm/arch/z80/z80asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@

#include <stdio.h>
#include <string.h>
#ifndef _MSC_VER
#include <strings.h>
#endif
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
Expand Down
11 changes: 6 additions & 5 deletions libr/bin/mangling/cxx/libiberty.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,12 @@ extern unsigned int xcrc32 (const unsigned char *, int, unsigned int);
as new/delete and new[]/delete[]. */

/* Scalar allocators. */

#ifdef _MSC_VER
#include <stdlib.h>
#define xmalloc malloc
#define xcalloc calloc
#define xrealloc realloc
#endif
#define XALLOCA(T) ((T *) alloca (sizeof (T)))
#define XNEW(T) ((T *) xmalloc (sizeof (T)))
#define XCNEW(T) ((T *) xcalloc (1, sizeof (T)))
Expand Down Expand Up @@ -658,11 +663,7 @@ extern void *C_alloca (size_t) ATTRIBUTE_MALLOC;
char *const libiberty_nptr = (char *const) alloca (libiberty_len); \
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len); }))
#else
#ifdef _MSC_VER
# define alloca(x) _alloca(x)
#else
# define alloca(x) C_alloca(x)
#endif
# undef USE_C_ALLOCA
# define USE_C_ALLOCA 1
# undef C_ALLOCA
Expand Down
2 changes: 1 addition & 1 deletion libr/bin/mangling/swift-sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static char *swift_demangle_cmd(const char *s) {
return NULL;
}

char *r_bin_demangle_swift(const char *s, int syscmd) {
R_API char *r_bin_demangle_swift(const char *s, int syscmd) {
#define STRCAT_BOUNDS(x) if ((x + 2 + strlen (out)) > sizeof (out)) break;
char out[1024];
int i, len, is_generic = 0;
Expand Down
2 changes: 1 addition & 1 deletion libr/bin/pdb/pdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ static void print_gvars(R_PDB *pdb, ut64 img_base, int format) {
}

///////////////////////////////////////////////////////////////////////////////
bool init_pdb_parser(R_PDB *pdb, const char *filename) {
R_API bool init_pdb_parser(R_PDB *pdb, const char *filename) {
char *signature = NULL;
int bytes_read = 0;

Expand Down
3 changes: 1 addition & 2 deletions libr/core/cbin.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ static void pair_str(const char *a, const char *b, int mode, int last) {
}

#define STR(x) (x)?(x):""
// XXX - this may lead to conflicts with set by name
static int r_core_bin_set_cur(RCore *core, RBinFile *binfile);
R_API int r_core_bin_set_cur (RCore *core, RBinFile *binfile);

static ut64 rva(RBin *bin, ut64 paddr, ut64 vaddr, int va) {
if (va == VA_TRUE) {
Expand Down
4 changes: 4 additions & 0 deletions libr/debug/p/debug_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ static const char *r_debug_native_reg_profile (RDebug *dbg) {
#if __WINDOWS__ && !__CYGWIN__
static int windows_step (RDebug *dbg) {
/* set TRAP flag */
#if _MSC_VER
CONTEXT regs;
#else
CONTEXT regs __attribute__ ((aligned (16)));
#endif
r_debug_native_reg_read (dbg, R_REG_TYPE_GPR, (ut8 *)&regs, sizeof (regs));
regs.EFlags |= 0x100;
r_debug_native_reg_write (dbg, R_REG_TYPE_GPR, (ut8 *)&regs, sizeof (regs));
Expand Down
Loading

0 comments on commit 28f785d

Please sign in to comment.