Skip to content

Commit

Permalink
MSC compile fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TurkeyMan committed Aug 13, 2012
1 parent 56b6747 commit b801f37
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/backend/cdef.h
Expand Up @@ -606,7 +606,7 @@ typedef int bool;

// gcc defines this for us, dmc doesn't, so look for it's __I86__
#if ! (defined(LITTLE_ENDIAN) || defined(BIG_ENDIAN) )
#if defined(__I86__) || defined(i386) || defined(__x86_64__)
#if defined(__I86__) || defined(i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) || defined(_M_I86) || defined(_M_AMD64)
#define LITTLE_ENDIAN 1
#else
#error unknown platform, so unknown endianness
Expand Down
8 changes: 8 additions & 0 deletions src/backend/mscoff.h
@@ -1,6 +1,10 @@
/* Microsoft COFF object file format */

#if defined(_MSC_VER) || defined(_QC) || defined(__WATCOM__)
#pragma pack(push, 1)
#elif defined(__DMC__) || defined(__ZTC__)
#pragma ZTC align 1
#endif

/***********************************************/

Expand Down Expand Up @@ -248,4 +252,8 @@ union auxent

/***********************************************/

#if defined(_MSC_VER) || defined(_QC) || defined(__WATCOM__)
#pragma pack(pop)
#elif defined(__DMC__) || defined(__ZTC__)
#pragma ZTC align
#endif
4 changes: 3 additions & 1 deletion src/backend/mscoffobj.c
Expand Up @@ -686,7 +686,9 @@ void MsCoffObj::term()

header.f_magic = I64 ? IMAGE_FILE_MACHINE_AMD64 : IMAGE_FILE_MACHINE_I386;
header.f_nscns = scnhdr_cnt;
time(&header.f_timdat);
time_t f_timedat = 0;
time(&f_timedat);
header.f_timdat = (long)f_timedat;
header.f_symptr = 0; // offset to symbol table
header.f_nsyms = 0;
header.f_opthdr = 0;
Expand Down
11 changes: 7 additions & 4 deletions src/libmscoff.c
Expand Up @@ -228,8 +228,7 @@ void OmToHeader(Header *h, ObjModule *om)
* write into the next field, which we will promptly overwrite
* anyway. (So make sure to write the fields in ascending order.)
*/

len = sprintf(h->file_time, "%lu", om->file_time);
len = sprintf(h->file_time, "%llu", (longlong)om->file_time);
assert(len <= 12);
memset(h->file_time + len, ' ', 12 - len);

Expand Down Expand Up @@ -572,7 +571,9 @@ void LibMSCoff::addObject(const char *module_name, void *buf, size_t buflen)
{ /* Mock things up for the object module file that never was
* actually written out.
*/
time(&om->file_time);
time_t file_time = 0;
time(&file_time);
om->file_time = (long)file_time;
om->user_id = 0; // meaningless on Windows
om->group_id = 0; // meaningless on Windows
om->file_mode = 0100644;
Expand Down Expand Up @@ -677,7 +678,9 @@ void LibMSCoff::WriteLibToBuffer(OutBuffer *libbuf)
om.length = 4 + objsymbols.dim * 4 + slength;
om.offset = 8;
om.name = (char*)"";
::time(&om.file_time);
time_t file_time = 0;
::time(&file_time);
om.file_time = (long)file_time;
om.user_id = 0;
om.group_id = 0;
om.file_mode = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/mars.h
Expand Up @@ -445,7 +445,7 @@ void util_progress();
#endif

struct Dsymbol;
struct Library;
class Library;
struct File;
void obj_start(char *srcfile);
void obj_end(Library *library, File *objfile);
Expand Down
2 changes: 1 addition & 1 deletion src/module.h
Expand Up @@ -24,7 +24,7 @@ struct ModuleDeclaration;
struct Macro;
struct Escape;
struct VarDeclaration;
struct Library;
class Library;

// Back end
#ifdef IN_GCC
Expand Down
18 changes: 9 additions & 9 deletions src/root/longdouble.h
Expand Up @@ -91,19 +91,19 @@ struct longdouble
void set(unsigned long long d) { ld_setull(this, d); }
void set(bool d) { ld_set(this, d); }

operator float () { return ld_read(this); }
operator float () { return (float)ld_read(this); }
operator double () { return ld_read(this); }

operator signed char () { return ld_read(this); }
operator short () { return ld_read(this); }
operator int () { return ld_read(this); }
operator long () { return ld_read(this); }
operator signed char () { return (signed char)ld_read(this); }
operator short () { return (short)ld_read(this); }
operator int () { return (int)ld_read(this); }
operator long () { return (long)ld_read(this); }
operator long long () { return ld_readll(this); }

operator unsigned char () { return ld_read(this); }
operator unsigned short () { return ld_read(this); }
operator unsigned int () { return ld_read(this); }
operator unsigned long () { return ld_read(this); }
operator unsigned char () { return (unsigned char)ld_read(this); }
operator unsigned short () { return (unsigned short)ld_read(this); }
operator unsigned int () { return (unsigned int)ld_read(this); }
operator unsigned long () { return (unsigned long)ld_read(this); }
operator unsigned long long() { return ld_readull(this); }
operator bool () { return mantissa != 0 || exponent != 0; } // correct?
};
Expand Down

0 comments on commit b801f37

Please sign in to comment.