Commit 62aba0d4 authored by Fabrice Popineau's avatar Fabrice Popineau Committed by Eli Zaretskii

Support x64 build on MS-Windows with MSVC.

 src/w32term.h (SCROLL_BAR_PACK, SCROLL_BAR_UNPACK): Define for x64.
 (SET_SCROLL_BAR_W32_WINDOW): Cast ID to intptr_t, for
 compatibility with x64.
 src/w32term.c (w32_draw_underwave): Don't use GCC extensions for
 defining an XRectangle structure.
 src/w32proc.c (RVA_TO_PTR, w32_executable_type): Fix pointer
 arithmetics for compatibility with x64.
 src/w32menu.c (add_menu_item): Use UINT_PTR instead of UINT, for
 compatibility with x64.
 src/w32heap.h: Adjust prototypes and declarations.
 src/w32heap.c (RVA_TO_PTR, allocate_heap, sbrk, init_heap)
 (round_heap): Use DWORD_PTR, ptrdiff_t and size_t instead of
 DWORD, long, and unsigned long, for compatibility with x64.
 (allocate_heap) [_WIN64]: Reserve 32GB of memory.
 (sbrk): Argument is now of type ptrdiff_t.
 src/w32fns.c (HMONITOR): Condition declaration on _WIN32_WINNT being
 less than 0x0500.
 (w32_msg_pump): Use WPARAM type for 'result'.
 src/w32.c (init_environment, get_emacs_configuration): Support AMD64
 architecture.
 (init_ntproc): Cast arguments of _open_osfhandle to intptr_t, for
 compatibility with x64.
 src/vm-limit.c (lim_data): Now size_t.
 (check_memory_limits): Adjust prototypes of real_morecore and
 __morecore to receive argument of type ptrdiff_t.  Use size_t for
 five_percent and data_size.
 src/unexw32.c: Use DWORD_PTR instead of DWORD for file-scope
 variables, for compatibility with x64.
 (rva_to_section, offset_to_section, relocate_offset)
 (OFFSET_TO_RVA, RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET)
 (PTR_TO_RVA, RVA_TO_PTR, OFFSET_TO_PTR, get_section_info)
 (copy_executable_and_dump_data): Use DWORD_PTR instead of DWORD
 for compatibility with x64.
 src/sysdep.c (STDERR_FILENO): Define if not already defined.
 src/ralloc.c (real_morecore): Argument type is now ptrdiff_t.
 (__morecore): Argument type is now ptrdiff_t.
 (ROUNDUP, MEM_ROUNDUP): Use size_t instead of 'unsigned long'.
 (relinquish): Use ptrdiff_t type for 'excess'.
 (r_alloc_sbrk): Argument type is now ptrdiff_t.
 src/makefile.w32-in (HEAPSIZE): Get value from EMACS_HEAPSIZE.
 (bootstrap-temacs-CMD, bootstrap-temacs-SH): Use $(EMACS_PURESIZE)
 instead of a literal number.
 src/gmalloc.c [WINDOWSNT]: Include w32heap.h.
 (min): Define only if not already defined.
 src/frame.c (x_report_frame_params): Use EMACS_UINT for the return
 value of FRAME_X_WINDOW, to fit a 64-bit pointer on 64-bit Windows
 hosts.
 src/image.c (x_bitmap_pixmap): Return ptrdiff_t, not int, since
 'bitmaps' is a pointer.
 src/dispextern.h (x_bitmap_pixmap): Adjust prototype.
 src/alloc.c (gdb_make_enums_visible): Now conditional on __GNUC__.

 nt/makefile.w32-in ($(TRES)): Use $(EMACS_MANIFEST).
 nt/inc/sys/socket.h: Don't map Winsock error codes to standard ones
 that are already defined.
 nt/inc/ms-w32.h (EMACS_INT, EMACS_UINT, EMACS_INT_MAX, PRIuMAX)
 (pI, _INTPTR) [_MSC_VER]: Fix definitions for MSVC.
 [_MSC_VER]: Add pragmas to suppress some MSVC warnings.
 nt/preprep.c (pfnCheckSumMappedFile, rva_to_section)
 (offset_to_section, relocate_offset, OFFSET_TO_RVA)
 (RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET, PTR_TO_RVA)
 (OFFSET_TO_PTR, ROUND_UP, ROUND_DOWN)
 (copy_executable_and_move_sections, ADJUST_IMPORT_RVA, main): Use
 DWORD_PTR instead of DWORD for compatibility with x64.
 nt/nmake.defs: Support AMD64.
 (EMACS_HEAPSIZE, EMACS_PURESIZE, EMACS_MANIFEST): New macros.
 nt/gmake.defs: (EMACS_HEAPSIZE, EMACS_PURESIZE, EMACS_MANIFEST):
 New macros.
 nt/addsection.c (pfnCheckSumMappedFile, rva_to_section)
 (offset_to_section, relocate_offset, OFFSET_TO_RVA)
 (RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET, PTR_TO_RVA)
 (OFFSET_TO_PTR, ROUND_UP, ROUND_DOWN)
 (copy_executable_and_add_section, main): Use DWORD_PTR instead of
 DWORD, for compatibility with x64.
 nt/emacs-x64.manifest: New file.
 nt/emacs-x86.manifest: Renamed from emacs.manifest.

 lib-src/ntlib.c (gettimeofday): Copy from src/w32.c.  lib/gettime. 
 needs this function.
parent e7a2937b
2012-09-30 Eli Zaretskii <eliz@gnu.org>
* ntlib.c (gettimeofday): Copy from src/w32.c. lib/gettime.c
needs this function.
2012-09-26 Juanma Barranquero <lekktu@gmail.com>
* makefile.w32-in (obj): Add profiler.o.
......
......@@ -29,9 +29,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <sys/stat.h>
#include <errno.h>
#include <ctype.h>
#include <sys/timeb.h>
#include "ntlib.h"
struct timezone
{
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of dst correction */
};
#define MAXPATHLEN _MAX_PATH
/* Emulate sleep...we could have done this with a define, but that
......@@ -202,6 +209,29 @@ getpass (const char * prompt)
return NULL;
}
/* This is needed because lib/gettime.c calls gettimeofday, which MSVC
doesn't have. Copied from w32.c. */
void
gettimeofday (struct timeval *tv, struct timezone *tz)
{
struct _timeb tb;
_ftime (&tb);
tv->tv_sec = tb.time;
tv->tv_usec = tb.millitm * 1000L;
/* Implementation note: _ftime sometimes doesn't update the dstflag
according to the new timezone when the system timezone is
changed. We could fix that by using GetSystemTime and
GetTimeZoneInformation, but that doesn't seem necessary, since
Emacs always calls gettimeofday with the 2nd argument NULL (see
current_emacs_time). */
if (tz)
{
tz->tz_minuteswest = tb.timezone; /* minutes west of Greenwich */
tz->tz_dsttime = tb.dstflag; /* type of dst correction */
}
}
int
fchown (int fd, unsigned uid, unsigned gid)
{
......
2012-09-30 Eli Zaretskii <eliz@gnu.org>
* makefile.w32-in ($(TRES)): Use $(EMACS_MANIFEST).
2012-09-30 Fabrice Popineau <fabrice.popineau@supelec.fr>
* inc/sys/socket.h: Don't map Winsock error codes to standard ones
that are already defined.
* inc/ms-w32.h (EMACS_INT, EMACS_UINT, EMACS_INT_MAX, PRIuMAX)
(pI, _INTPTR) [_MSC_VER]: Fix definitions for MSVC.
[_MSC_VER]: Add pragmas to suppress some MSVC warnings.
* preprep.c (pfnCheckSumMappedFile, rva_to_section)
(offset_to_section, relocate_offset, OFFSET_TO_RVA)
(RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET, PTR_TO_RVA)
(OFFSET_TO_PTR, ROUND_UP, ROUND_DOWN)
(copy_executable_and_move_sections, ADJUST_IMPORT_RVA, main): Use
DWORD_PTR instead of DWORD for compatibility with x64.
* nmake.defs: Support AMD64.
(EMACS_HEAPSIZE, EMACS_PURESIZE, EMACS_MANIFEST): New macros.
* gmake.defs: (EMACS_HEAPSIZE, EMACS_PURESIZE, EMACS_MANIFEST):
New macros.
* addsection.c (pfnCheckSumMappedFile, rva_to_section)
(offset_to_section, relocate_offset, OFFSET_TO_RVA)
(RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET, PTR_TO_RVA)
(OFFSET_TO_PTR, ROUND_UP, ROUND_DOWN)
(copy_executable_and_add_section, main): Use DWORD_PTR instead of
DWORD, for compatibility with x64.
* emacs-x64.manifest: New file.
* emacs-x86.manifest: Renamed from emacs.manifest.
2012-09-30 Eli Zaretskii <eliz@gnu.org>
* inc/sys/time.h (ITIMER_REAL, ITIMER_PROF): Define.
......
......@@ -35,10 +35,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
in \\win32sdk\mstools\samples\image\include\imagehlp.h. */
PIMAGE_NT_HEADERS
(__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress,
DWORD FileLength,
LPDWORD HeaderSum,
LPDWORD CheckSum);
(__stdcall * pfnCheckSumMappedFile) (PVOID BaseAddress,
DWORD_PTR FileLength,
PDWORD_PTR HeaderSum,
PDWORD_PTR CheckSum);
#undef min
#undef max
......@@ -164,7 +164,7 @@ find_section (const char *name, IMAGE_NT_HEADERS *nt_header)
/* Return pointer to section header for section containing the given
relative virtual address. */
IMAGE_SECTION_HEADER *
rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header)
{
PIMAGE_SECTION_HEADER section;
int i;
......@@ -179,7 +179,7 @@ rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
some very old exes (eg. gzip dated Dec 1993). Since
w32_executable_type relies on this function to work reliably,
we need to cope with this. */
DWORD real_size = max (section->SizeOfRawData,
DWORD_PTR real_size = max (section->SizeOfRawData,
section->Misc.VirtualSize);
if (rva >= section->VirtualAddress
&& rva < section->VirtualAddress + real_size)
......@@ -192,7 +192,7 @@ rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
/* Return pointer to section header for section containing the given
offset in its raw data area. */
IMAGE_SECTION_HEADER *
offset_to_section (DWORD offset, IMAGE_NT_HEADERS * nt_header)
offset_to_section (DWORD_PTR offset, IMAGE_NT_HEADERS * nt_header)
{
PIMAGE_SECTION_HEADER section;
int i;
......@@ -212,8 +212,8 @@ offset_to_section (DWORD offset, IMAGE_NT_HEADERS * nt_header)
/* Return offset to an object in dst, given offset in src. We assume
there is at least one section in both src and dst images, and that
the some sections may have been added to dst (after sections in src). */
static DWORD
relocate_offset (DWORD offset,
static DWORD_PTR
relocate_offset (DWORD_PTR offset,
IMAGE_NT_HEADERS * src_nt_header,
IMAGE_NT_HEADERS * dst_nt_header)
{
......@@ -247,32 +247,33 @@ relocate_offset (DWORD offset,
}
#define OFFSET_TO_RVA(offset, section) \
(section->VirtualAddress + ((DWORD)(offset) - section->PointerToRawData))
(section->VirtualAddress + ((DWORD_PTR)(offset) - section->PointerToRawData))
#define RVA_TO_OFFSET(rva, section) \
(section->PointerToRawData + ((DWORD)(rva) - section->VirtualAddress))
(section->PointerToRawData + ((DWORD_PTR)(rva) - section->VirtualAddress))
#define RVA_TO_SECTION_OFFSET(rva, section) \
((DWORD)(rva) - section->VirtualAddress)
((DWORD_PTR)(rva) - section->VirtualAddress)
/* Convert address in executing image to RVA. */
#define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL))
#define PTR_TO_RVA(ptr) ((DWORD_PTR)(ptr) - (DWORD_PTR) GetModuleHandle (NULL))
#define PTR_TO_OFFSET(ptr, pfile_data) \
((unsigned const char *)(ptr) - (pfile_data)->file_base)
#define OFFSET_TO_PTR(offset, pfile_data) \
((pfile_data)->file_base + (DWORD)(offset))
((pfile_data)->file_base + (DWORD_PTR)(offset))
#define ROUND_UP(p, align) (((DWORD)(p) + (align)-1) & ~((align)-1))
#define ROUND_DOWN(p, align) ((DWORD)(p) & ~((align)-1))
#define ROUND_UP(p, align) \
(((DWORD_PTR)(p) + (align)-1) & ~((DWORD_PTR)(align)-1))
#define ROUND_DOWN(p, align) ((DWORD_PTR)(p) & ~((DWORD_PTR)(align)-1))
static void
copy_executable_and_add_section (file_data *p_infile,
file_data *p_outfile,
const char *new_section_name,
DWORD new_section_size)
DWORD_PTR new_section_size)
{
unsigned char *dst;
PIMAGE_DOS_HEADER dos_header;
......@@ -280,7 +281,7 @@ copy_executable_and_add_section (file_data *p_infile,
PIMAGE_NT_HEADERS dst_nt_header;
PIMAGE_SECTION_HEADER section;
PIMAGE_SECTION_HEADER dst_section;
DWORD offset;
DWORD_PTR offset;
int i;
int be_verbose = GetEnvironmentVariable ("DEBUG_DUMP", NULL, 0) > 0;
......@@ -317,17 +318,17 @@ copy_executable_and_add_section (file_data *p_infile,
Note that dst is updated implicitly by each COPY_CHUNK. */
dos_header = (PIMAGE_DOS_HEADER) p_infile->file_base;
nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) +
nt_header = (PIMAGE_NT_HEADERS) (((unsigned char *) dos_header) +
dos_header->e_lfanew);
section = IMAGE_FIRST_SECTION (nt_header);
dst = (unsigned char *) p_outfile->file_base;
COPY_CHUNK ("Copying DOS header...", dos_header,
(DWORD) nt_header - (DWORD) dos_header, be_verbose);
(DWORD_PTR) nt_header - (DWORD_PTR) dos_header, be_verbose);
dst_nt_header = (PIMAGE_NT_HEADERS) dst;
COPY_CHUNK ("Copying NT header...", nt_header,
(DWORD) section - (DWORD) nt_header, be_verbose);
(DWORD_PTR) section - (DWORD_PTR) nt_header, be_verbose);
dst_section = (PIMAGE_SECTION_HEADER) dst;
COPY_CHUNK ("Copying section table...", section,
nt_header->FileHeader.NumberOfSections * sizeof (*section),
......@@ -509,8 +510,8 @@ main (int argc, char **argv)
/* Patch up header fields; profiler is picky about this. */
{
HANDLE hImagehelp = LoadLibrary ("imagehlp.dll");
DWORD headersum;
DWORD checksum;
DWORD_PTR headersum;
DWORD_PTR checksum;
dos_header = (PIMAGE_DOS_HEADER) out_file.file_base;
nt_header = (PIMAGE_NT_HEADERS) ((char *) dos_header + dos_header->e_lfanew);
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls"
version="6.0.0.0" processorArchitecture="AMD64"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
<assemblyIdentity version="1.0.0.0" processorArchitecture="AMD64"
name="emacs" type="win32"/>
<description>GNU Emacs</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
Emacs ICON icons\emacs.ico
32649 CURSOR icons\hand.cur
1 24 "emacs.manifest"
#ifdef WIN64
1 24 "emacs-x64.manifest"
#else
1 24 "emacs-x86.manifest"
#endif
#ifndef VS_VERSION_INFO
#define VS_VERSION_INFO 1
......
......@@ -139,15 +139,27 @@ OS_TYPE = windowsnt
ifeq "$(PROCESSOR_ARCHITECTURE)" "x86"
ARCH = i386
CPU = i386
EMACS_HEAPSIZE = 27
EMACS_PURESIZE = 5000000
EMACS_MANIFEST = emacs-x86.manifest
else
ifeq "$(PROCESSOR_ARCHITECTURE)" "MIPS"
ARCH = mips
EMACS_HEAPSIZE = 27
EMACS_PURESIZE = 5000000
EMACS_MANIFEST = emacs-mips.manifest
else
ifeq "$(PROCESSOR_ARCHITECTURE)" "ALPHA"
ARCH = alpha
EMACS_HEAPSIZE = 27
EMACS_PURESIZE = 5000000
EMACS_MANIFEST = emacs-alpha.manifest
else
ifeq "$(PROCESSOR_ARCHITECTURE)" "PPC"
ARCH = ppc
EMACS_HEAPSIZE = 27
EMACS_PURESIZE = 5000000
EMACS_MANIFEST = emacs-ppc.manifest
else
$(error Unknown architecture type "$(PROCESSOR_ARCHITECTURE)")
endif
......
......@@ -358,7 +358,7 @@ extern char *get_emacs_configuration_options (void);
extern int getloadavg (double *, int);
#if defined (__MINGW32__) || _MSC_VER >= 1400
#if defined (__MINGW32__)
/* Define to 1 if the system has the type `long long int'. */
# define HAVE_LONG_LONG_INT 1
......@@ -366,21 +366,37 @@ extern int getloadavg (double *, int);
/* Define to 1 if the system has the type `unsigned long long int'. */
# define HAVE_UNSIGNED_LONG_LONG_INT 1
#elif _MSC_VER >= 1200
#endif
#ifdef _MSC_VER
# if defined(_WIN64)
typedef __int64 EMACS_INT;
typedef unsigned __int64 EMACS_UINT;
# define EMACS_INT_MAX LLONG_MAX
# define PRIuMAX "llu"
# define pI "ll"
/* Fix a bug in MSVC headers : stdint.h */
# define _INTPTR 2
# elif defined(_WIN32)
/* Temporarily disable wider-than-pointer integers until they're tested more.
Build with CFLAGS='-DWIDE_EMACS_INT' to try them out. */
# ifdef WIDE_EMACS_INT
# ifdef WIDE_EMACS_INT
/* Use pre-C99-style 64-bit integers. */
typedef __int64 EMACS_INT;
typedef unsigned __int64 EMACS_UINT;
# define EMACS_INT_MAX _I64_MAX
# define pI "I64"
# define EMACS_INT_MAX LLONG_MAX
# define PRIuMAX "llu"
# define pI "I64"
# else
typedef int EMACS_INT;
typedef unsigned int EMACS_UINT;
# define EMACS_INT_MAX LONG_MAX
# define PRIuMAX "lu"
# define pI "l"
# endif
# endif
#endif
/* We need a little extra space, see ../../lisp/loadup.el. */
......@@ -420,6 +436,22 @@ extern void _DebPrint (const char *fmt, ...);
#define DebPrint(stuff)
#endif
#ifdef _MSC_VER
#if _MSC_VER >= 800 && !defined(__cplusplus)
/* Unnamed type definition in parentheses.
A structure, union, or enumerated type with no name is defined in a
parenthetical expression. The type definition is meaningless. */
#pragma warning(disable:4116)
/* 'argument' : conversion from 'type1' to 'type2', possible loss of
data A floating point type was converted to an integer type. A
possible loss of data may have occurred. */
#pragma warning(disable:4244)
/* Negative integral constant converted to unsigned type.
An expression converts a negative integer constant to an unsigned type.
The result of the expression is probably meaningless. */
#pragma warning(disable:4308)
#endif
#endif
#define TERM_HEADER "w32term.h"
......
......@@ -126,42 +126,147 @@ int fcntl (int s, int cmd, int options);
extern int h_errno;
/* map winsock error codes to standard names */
#if defined(EWOULDBLOCK)
#undef EWOULDBLOCK
#endif
#define EWOULDBLOCK WSAEWOULDBLOCK
#if defined(EINPROGRESS)
#undef EINPROGRESS
#endif
#define EINPROGRESS WSAEINPROGRESS
#if defined(EALREADY)
#undef EALREADY
#endif
#define EALREADY WSAEALREADY
#if defined(ENOTSOCK)
#undef ENOTSOCK
#endif
#define ENOTSOCK WSAENOTSOCK
#if defined(EDESTADDRREQ)
#undef EDESTADDRREQ
#endif
#define EDESTADDRREQ WSAEDESTADDRREQ
#if defined(EMSGSIZE)
#undef EMSGSIZE
#endif
#define EMSGSIZE WSAEMSGSIZE
#if defined(EPROTOTYPE)
#undef EPROTOTYPE
#endif
#define EPROTOTYPE WSAEPROTOTYPE
#if defined(ENOPROTOOPT)
#undef ENOPROTOOPT
#endif
#define ENOPROTOOPT WSAENOPROTOOPT
#if defined(EPROTONOSUPPORT)
#undef EPROTONOSUPPORT
#endif
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
#if defined(ESOCKTNOSUPPORT)
#undef ESOCKTNOSUPPORT
#endif
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
#if defined(EOPNOTSUPP)
#undef EOPNOTSUPP
#endif
#define EOPNOTSUPP WSAEOPNOTSUPP
#if defined(EPFNOSUPPORT)
#undef EPFNOSUPPORT
#endif
#define EPFNOSUPPORT WSAEPFNOSUPPORT
#if defined(EAFNOSUPPORT)
#undef EAFNOSUPPORT
#endif
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#if defined(EADDRINUSE)
#undef EADDRINUSE
#endif
#define EADDRINUSE WSAEADDRINUSE
#if defined(EADDRNOTAVAIL)
#undef EADDRNOTAVAIL
#endif
#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
#if defined(ENETDOWN)
#undef ENETDOWN
#endif
#define ENETDOWN WSAENETDOWN
#if defined(ENETUNREACH)
#undef ENETUNREACH
#endif
#define ENETUNREACH WSAENETUNREACH
#if defined(ENETRESET)
#undef ENETRESET
#endif
#define ENETRESET WSAENETRESET
#if defined(ECONNABORTED)
#undef ECONNABORTED
#endif
#define ECONNABORTED WSAECONNABORTED
#if defined(ECONNRESET)
#undef ECONNRESET
#endif
#define ECONNRESET WSAECONNRESET
#if defined(ENOBUFS)
#undef ENOBUFS
#endif
#define ENOBUFS WSAENOBUFS
#if defined(EISCONN)
#undef EISCONN
#endif
#define EISCONN WSAEISCONN
#if defined(ENOTCONN)
#undef ENOTCONN
#endif
#define ENOTCONN WSAENOTCONN
#if defined(ESHUTDOWN)
#undef ESHUTDOWN
#endif
#define ESHUTDOWN WSAESHUTDOWN
#if defined(ETOOMANYREFS)
#undef ETOOMANYREFS
#endif
#define ETOOMANYREFS WSAETOOMANYREFS
#if defined(ETIMEDOUT)
#undef ETIMEDOUT
#endif
#define ETIMEDOUT WSAETIMEDOUT
#if defined(ECONNREFUSED)
#undef ECONNREFUSED
#endif
#define ECONNREFUSED WSAECONNREFUSED
#if defined(ELOOP)
#undef ELOOP
#endif
#define ELOOP WSAELOOP
/* #define ENAMETOOLONG WSAENAMETOOLONG */
#if defined(EHOSTDOWN)
#undef EHOSTDOWN
#endif
#define EHOSTDOWN WSAEHOSTDOWN
#if defined(EHOSTUNREACH)
#undef EHOSTUNREACH
#endif
#define EHOSTUNREACH WSAEHOSTUNREACH
/* #define ENOTEMPTY WSAENOTEMPTY */
#if defined(EPROCLIM)
#undef EPROCLIM
#endif
#define EPROCLIM WSAEPROCLIM
#if defined(EUSERS)
#undef EUSERS
#endif
#define EUSERS WSAEUSERS
#if defined(EDQUOT)
#undef EDQUOT
#endif
#define EDQUOT WSAEDQUOT
#if defined(ESTALE)
#undef ESTALE
#endif
#define ESTALE WSAESTALE
#if defined(EREMOTE)
#undef EREMOTE
#endif
#define EREMOTE WSAEREMOTE
#endif /* _SOCKET_H_ */
......
......@@ -66,7 +66,7 @@ $(BLD)/preprep.exe: $(BLD)/preprep.$(O)
# The resource file. NT 3.10 requires the use of cvtres; even though
# it is not necessary on later versions, it is still ok to use it.
#
$(TRES): emacs.rc icons/emacs.ico emacs.manifest stamp_BLD
$(TRES): emacs.rc icons/emacs.ico $(EMACS_MANIFEST) stamp_BLD
$(RC) $(RC_OUT)$(TRES) emacs.rc
$(CLIENTRES): emacsclient.rc stamp_BLD
......
......@@ -87,7 +87,11 @@ ARCH = alpha
! if "$(PROCESSOR_ARCHITECTURE)" == "PPC"
ARCH = ppc
! else
! error Unknown architecture type "$(PROCESSOR_ARCHITECTURE)"
! if "$(PROCESSOR_ARCHITECTURE)" == "AMD64"
ARCH = AMD64
! else
! error Unknown architecture type "$(PROCESSOR_ARCHITECTURE)"
! endif
! endif
! endif
! endif
......@@ -106,7 +110,7 @@ CC = cl
CC_OUT = -Fo
LINK = link
LINK_OUT = -out:
RC = rc
RC = rc $(ARCH_RCFLAGS)
RC_OUT = -Fo
RC_INCLUDE = -i
......@@ -147,21 +151,21 @@ DEBUG_CFLAGS =
MWINDOWS = -subsystem:windows -entry:mainCRTStartup
CFLAGS = -I. $(ARCH_CFLAGS) \
CFLAGS = -I. $(ARCH_CFLAGS) -D_CRT_SECURE_NO_WARNINGS \
$(DEBUG_CFLAGS) $(USER_CFLAGS) $(LOCAL_FLAGS)
ESC_CFLAGS = -I. $(ARCH_CFLAGS) \
ESC_CFLAGS = -I. $(ARCH_CFLAGS) -D_CRT_SECURE_NO_WARNINGS \
$(DEBUG_CFLAGS) $(ESC_USER_CFLAGS) $(LOCAL_FLAGS)
#SYS_LDFLAGS = -nologo -release -incremental:no -version:3.10 -swaprun:cd -swaprun:net setargv.obj
!ifdef NOOPT
SYS_LDFLAGS = -nologo -manifest -dynamicbase:no -debug -incremental:no -version:3.10 -swaprun:cd -swaprun:net setargv.obj
!else
SYS_LDFLAGS = -nologo -manifest -dynamicbase:no -release -incremental:no -version:3.10 -swaprun:cd -swaprun:net setargv.obj
!endif
SYS_LDFLAGS = -nologo -manifest -dynamicbase:no -incremental:no -version:3.10 -swaprun:cd -swaprun:net setargv.obj
# see comments in allocate_heap in w32heap.c before changing any of the
# -stack, -heap, or -base settings.
TEMACS_EXTRA_LINK = -stack:0x00800000 -heap:0x00100000 -base:0x01000000 -pdb:$(BLD)\temacs.pdb -machine:$(ARCH) $(SUBSYSTEM_CONSOLE) -entry:_start -map:$(BLD)\temacs.map $(EXTRA_LINK)
!if "$(ARCH)" == "i386"
TEMACS_EXTRA_LINK = -stack:0x00800000 -heap:0x00100000 -base:0x01000000 -pdb:$(BLD)\temacs.pdb -machine:x86 $(SUBSYSTEM_CONSOLE) -entry:_start -map:$(BLD)\temacs.map $(EXTRA_LINK)
!elseif "$(ARCH)" == "AMD64"
TEMACS_EXTRA_LINK = -stack:0x00800000 -heap:0x00100000 -base:0x400000000 -pdb:$(BLD)\temacs.pdb -machine:x64 $(SUBSYSTEM_CONSOLE) -entry:_start -map:$(BLD)\temacs.map $(EXTRA_LINK)
!endif
!ifdef NOOPT
OBJDIR = obj
......@@ -212,11 +216,17 @@ ARCH_CFLAGS = -nologo -D_X86_=1 -c -Zl -Zp8 -W2 -Od -Gd $(DEBUG_FLAG)
ARCH_CFLAGS = -nologo -D_X86_=1 -c -Zl -Zp8 -W2 -Oi -Ot -Oy- -Ob2 -GF -Gy -Gd $(DEBUG_FLAG)
!endif
ARCH_LDFLAGS = $(SYS_LDFLAGS)
EMACS_HEAPSIZE = 27
EMACS_PURESIZE = 5000000
EMACS_MANIFEST = emacs-x86.manifest
!else
!if "$(ARCH)" == "mips"
ARCH_CFLAGS = -D_MIPS_=1 -c -W2 -Zi -Od -Gt0
ARCH_LDFLAGS = $(SYS_LDFLAGS)
EMACS_HEAPSIZE = 27
EMACS_PURESIZE = 5000000
EMACS_MANIFEST = emacs-mips.manifest
!else
!if "$(ARCH)" == "alpha"
......@@ -226,12 +236,30 @@ ARCH_CFLAGS = -D_ALPHA_=1 -c -Ze -Zi -W2 -Od -D__stdcall= -D__cdecl=
ARCH_CFLAGS = -D_ALPHA_=1 -c -Ze -Zi -W2 -O1 -D__stdcall= -D__cdecl=
!endif
ARCH_LDFLAGS = $(SYS_LDFLAGS)
EMACS_HEAPSIZE = 27
EMACS_PURESIZE = 5000000
EMACS_MANIFEST = emacs-alpha.manifest
!else
!if "$(ARCH)" == "ppc"
# These flags are a guess...if they don't work, please send me mail.
ARCH_CFLAGS = -D_PPC_=1 -c -Ze -Zi -W2 -Od
ARCH_LDFLAGS = $(SYS_LDFLAGS)
EMACS_HEAPSIZE = 27
EMACS_PURESIZE = 5000000
EMACS_MANIFEST = emacs-ppc.manifest
!else
!if "$(ARCH)" == "AMD64"
!ifdef NOOPT
ARCH_CFLAGS = -nologo -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -c -Zl -Zp8 -W2 -Od -Gd -Wp64 $(DEBUG_FLAG)
!else
ARCH_CFLAGS = -nologo -D_AMD64_=1 -DWIN64 -D_WIN64 -DWIN32 -D_WIN32 -c -Zl -Zp8 -W2 -O2x -GF -Gy -Gd $(DEBUG_FLAG)
!endif
ARCH_LDFLAGS = $(SYS_LDFLAGS) -machine:x64
ARCH_RCFLAGS = -DWIN64
EMACS_HEAPSIZE = 42
EMACS_PURESIZE = 10000000
EMACS_MANIFEST = emacs-x64.manifest
!else
!ERROR Unknown architecture type "$(ARCH)".
......@@ -239,6 +267,7 @@ ARCH_LDFLAGS = $(SYS_LDFLAGS)
!endif
!endif
!endif
!endif
LINK_FLAGS = $(ARCH_LDFLAGS) $(DEBUG_LINK) $(USER_LDFLAGS)
......@@ -262,4 +291,3 @@ EXTRA_LINK = -profile
.c{$(BLD)}.obj::
$(CC) $(CFLAGS) -Fo$(BLD)\ $<
!ENDIF
......@@ -36,9 +36,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
PIMAGE_NT_HEADERS
(__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress,
DWORD FileLength,
LPDWORD HeaderSum,
LPDWORD CheckSum);
DWORD_PTR FileLength,
PDWORD_PTR HeaderSum,
PDWORD_PTR CheckSum);
#undef min
#undef max
......@@ -196,7 +196,7 @@ find_section (const char *name, IMAGE_NT_HEADERS *nt_header)
/* Return pointer to section header for section containing the given
relative virtual address. */
IMAGE_SECTION_HEADER *
rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header)
{
PIMAGE_SECTION_HEADER section;
int i;
......@@ -211,7 +211,7 @@ rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
some very old exes (eg. gzip dated Dec 1993). Since
w32_executable_type relies on this function to work reliably,
we need to cope with this. */
DWORD real_size = max (section->SizeOfRawData,
DWORD_PTR real_size = max (section->SizeOfRawData,
section->Misc.VirtualSize);
if (rva >= section->VirtualAddress
&& rva < section->VirtualAddress + real_size)
......@@ -224,7 +224,7 @@ rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
/* Return pointer to section header for section containing the given
offset in its raw data area. */
IMAGE_SECTION_HEADER *
offset_to_section (DWORD offset, IMAGE_NT_HEADERS * nt_header)
offset_to_section (DWORD_PTR offset, IMAGE_NT_HEADERS * nt_header)
{
PIMAGE_SECTION_HEADER section;
int i;
......@@ -244,8 +244,8 @@ offset_to_section (DWORD offset, IMAGE_NT_HEADERS * nt_header)
/* Return offset to an object in dst, given offset in src. We assume
there is at least one section in both src and dst images, and that
the some sections may have been added to dst (after sections in src). */
static DWORD
relocate_offset (DWORD offset,
static DWORD_PTR
relocate_offset (DWORD_PTR offset,
IMAGE_NT_HEADERS * src_nt_header,
IMAGE_NT_HEADERS * dst_nt_header)
{
......@@ -279,28 +279,29 @@ relocate_offset (DWORD offset,
}
#define OFFSET_TO_RVA(offset, section) \
(section->VirtualAddress + ((DWORD)(offset) - section->PointerToRawData))
(section->VirtualAddress + ((DWORD_PTR)(offset) - section->PointerToRawData))
#define RVA_TO_OFFSET(rva, section) \
(section->PointerToRawData + ((DWORD)(rva) - section->VirtualAddress))
(section->PointerToRawData + ((DWORD_PTR)(rva) - section->VirtualAddress))
#define RVA_TO_SECTION_OFFSET(rva, section) \
((DWORD)(rva) - section->VirtualAddress)
((DWORD_PTR)(rva) - section->VirtualAddress)
#define RVA_TO_PTR(var,section,filedata) \
((void *)(RVA_TO_OFFSET(var,section) + (filedata)->file_base))
/* Convert address in executing image to RVA. */
#define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL))
#define PTR_TO_RVA(ptr) ((DWORD_PTR)(ptr) - (DWORD_PTR) GetModuleHandle (NULL))
#define PTR_TO_OFFSET(ptr, pfile_data) \
((unsigned const char *)(ptr) - (pfile_data)->file_base)
#define OFFSET_TO_PTR(offset, pfile_data) \
((pfile_data)->file_base + (DWORD)(offset))
((pfile_data)->file_base + (DWORD_PTR)(offset))
#define ROUND_UP(p, align) (((DWORD)(p) + (align)-1) & ~((align)-1))
#define ROUND_DOWN(p, align) ((DWORD)(p) & ~((align)-1))
#define ROUND_UP(p, align) \
(((DWORD_PTR)(p) + (align)-1) & ~((DWORD_PTR)(align)-1))
#define ROUND_DOWN(p, align) ((DWORD_PTR)(p) & ~((DWORD_PTR)(align)-1))
/* The MSVC prep program generates a ._xe file from .exe, where relevant
......@@ -353,9 +354,9 @@ copy_executable_and_move_sections (file_data *p_infile,
PIMAGE_SECTION_HEADER reloc_section;
PIMAGE_DATA_DIRECTORY import_dir;
PIMAGE_DATA_DIRECTORY reloc_dir;
DWORD import_delta_rva;
DWORD reloc_delta_rva;
DWORD offset;
DWORD_PTR import_delta_rva;
DWORD_PTR reloc_delta_rva;
DWORD_PTR offset;
int i;
#define COPY_CHUNK(message, src, size) \
......@@ -388,7 +389,7 @@ copy_executable_and_move_sections (file_data *p_infile,
Note that dst is updated implicitly by each COPY_CHUNK. */
dos_header = (PIMAGE_DOS_HEADER) p_infile->file_base;
nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) +
nt_header = (PIMAGE_NT_HEADERS) (((unsigned char *) dos_header) +
dos_header->e_lfanew);
section = IMAGE_FIRST_SECTION (nt_header);
......@@ -406,10 +407,10 @@ copy_executable_and_move_sections (file_data *p_infile,
dst = (unsigned char *) p_outfile->file_base;
COPY_CHUNK ("Copying DOS header...", dos_header,
(DWORD) nt_header - (DWORD) dos_header);
(DWORD_PTR) nt_header - (DWORD_PTR) dos_header);