mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-23 10:34:07 +00:00
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.
This commit is contained in:
parent
e7a2937b11
commit
62aba0d497
@ -1,3 +1,8 @@
|
||||
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)
|
||||
{
|
||||
|
37
nt/ChangeLog
37
nt/ChangeLog
@ -1,3 +1,40 @@
|
||||
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);
|
||||
|
21
nt/emacs-x64.manifest
Normal file
21
nt/emacs-x64.manifest
Normal file
@ -0,0 +1,21 @@
|
||||
<?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>
|
@ -1,6 +1,10 @@
|
||||
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
|
||||
|
||||
|
77
nt/preprep.c
77
nt/preprep.c
@ -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);
|
||||
dst_nt_header = (PIMAGE_NT_HEADERS) dst;
|
||||
COPY_CHUNK ("Copying NT header...", nt_header,
|
||||
(DWORD) section - (DWORD) nt_header);
|
||||
(DWORD_PTR) section - (DWORD_PTR) nt_header);
|
||||
dst_section = (PIMAGE_SECTION_HEADER) dst;
|
||||
COPY_CHUNK ("Copying section table...", section,
|
||||
nt_header->FileHeader.NumberOfSections * sizeof (*section));
|
||||
@ -537,7 +538,7 @@ copy_executable_and_move_sections (file_data *p_infile,
|
||||
#define ADJUST_IMPORT_RVA(var) \
|
||||
do { \
|
||||
if ((var) != 0) \
|
||||
*((DWORD *)&(var)) += import_delta_rva; \
|
||||
*((DWORD_PTR *)&(var)) += import_delta_rva; \
|
||||
} while (0)
|
||||
|
||||
dst_nt_header->OptionalHeader.SizeOfInitializedData = 0;
|
||||
@ -627,10 +628,10 @@ copy_executable_and_move_sections (file_data *p_infile,
|
||||
|
||||
{
|
||||
IMAGE_BASE_RELOCATION *relocs, *block, *start_block, *end_block;
|
||||
DWORD import_start = import_section->VirtualAddress + dst_nt_header->OptionalHeader.ImageBase;
|
||||
DWORD import_end = import_start + import_section->Misc.VirtualSize;
|
||||
DWORD len_import_relocs;
|
||||
DWORD len_remaining_relocs;
|
||||
DWORD_PTR import_start = import_section->VirtualAddress + dst_nt_header->OptionalHeader.ImageBase;
|
||||
DWORD_PTR import_end = import_start + import_section->Misc.VirtualSize;
|
||||
DWORD_PTR len_import_relocs;
|
||||
DWORD_PTR len_remaining_relocs;
|
||||
int seen_high = 0;
|
||||
WORD * high_word;
|
||||
void * holder;
|
||||
@ -643,8 +644,8 @@ copy_executable_and_move_sections (file_data *p_infile,
|
||||
any; the profiler needs to be able to patch RVAs in the import
|
||||
section itself. */
|
||||
for (block = relocs, start_block = 0;
|
||||
(DWORD) block - (DWORD) relocs < reloc_dir->Size;
|
||||
block = (void *)((DWORD) block + block->SizeOfBlock))
|
||||
(DWORD_PTR) block - (DWORD_PTR) relocs < reloc_dir->Size;
|
||||
block = (void *)((DWORD_PTR) block + block->SizeOfBlock))
|
||||
{
|
||||
if (block->VirtualAddress >= import_section->VirtualAddress + import_section->Misc.VirtualSize)
|
||||
{
|
||||
@ -660,8 +661,8 @@ copy_executable_and_move_sections (file_data *p_infile,
|
||||
}
|
||||
if (start_block)
|
||||
{
|
||||
len_import_relocs = (DWORD) end_block - (DWORD) start_block;
|
||||
len_remaining_relocs = (DWORD) relocs + reloc_dir->Size - (DWORD) end_block;
|
||||
len_import_relocs = (DWORD_PTR) end_block - (DWORD_PTR) start_block;
|
||||
len_remaining_relocs = (DWORD_PTR) relocs + reloc_dir->Size - (DWORD_PTR) end_block;
|
||||
holder = malloc (len_import_relocs);
|
||||
if (holder == 0)
|
||||
abort ();
|
||||
@ -675,14 +676,14 @@ copy_executable_and_move_sections (file_data *p_infile,
|
||||
to the old import section location, and patching them to
|
||||
reference the new location. */
|
||||
for (block = relocs;
|
||||
(DWORD) block - (DWORD) relocs < reloc_dir->Size;
|
||||
block = (void *)((DWORD) block + block->SizeOfBlock))
|
||||
(DWORD_PTR) block - (DWORD_PTR) relocs < reloc_dir->Size;
|
||||
block = (void *)((DWORD_PTR) block + block->SizeOfBlock))
|
||||
{
|
||||
DWORD page_rva = block->VirtualAddress;
|
||||
DWORD page_offset;
|
||||
DWORD_PTR page_rva = block->VirtualAddress;
|
||||
DWORD_PTR page_offset;
|
||||
union {
|
||||
WORD word;
|
||||
DWORD dword;
|
||||
DWORD_PTR dword;
|
||||
} * ploc;
|
||||
WORD *fixup;
|
||||
|
||||
@ -692,7 +693,7 @@ copy_executable_and_move_sections (file_data *p_infile,
|
||||
continue;
|
||||
|
||||
for (fixup = (WORD *) &block[1];
|
||||
(DWORD) fixup - (DWORD) block < block->SizeOfBlock;
|
||||
(DWORD_PTR) fixup - (DWORD_PTR) block < block->SizeOfBlock;
|
||||
fixup++)
|
||||
{
|
||||
page_offset = (*fixup) & 0xfff;
|
||||
@ -794,8 +795,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);
|
||||
|
@ -1,3 +1,75 @@
|
||||
2012-09-30 Fabrice Popineau <fabrice.popineau@supelec.fr>
|
||||
|
||||
Support x64 build on MS-Windows.
|
||||
* 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.
|
||||
|
||||
* w32term.c (w32_draw_underwave): Don't use GCC extensions for
|
||||
defining an XRectangle structure.
|
||||
|
||||
* w32proc.c (RVA_TO_PTR, w32_executable_type): Fix pointer
|
||||
arithmetics for compatibility with x64.
|
||||
|
||||
* w32menu.c (add_menu_item): Use UINT_PTR instead of UINT, for
|
||||
compatibility with x64.
|
||||
|
||||
* w32heap.h: Adjust prototypes and declarations.
|
||||
|
||||
* 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.
|
||||
|
||||
* w32fns.c (HMONITOR): Condition declaration on _WIN32_WINNT being
|
||||
less than 0x0500.
|
||||
(w32_msg_pump): Use WPARAM type for 'result'.
|
||||
|
||||
* w32.c (init_environment, get_emacs_configuration): Support AMD64
|
||||
architecture.
|
||||
(init_ntproc): Cast arguments of _open_osfhandle to intptr_t, for
|
||||
compatibility with x64.
|
||||
|
||||
* 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.
|
||||
|
||||
* 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.
|
||||
|
||||
* sysdep.c (STDERR_FILENO): Define if not already defined.
|
||||
|
||||
* 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.
|
||||
|
||||
* makefile.w32-in (HEAPSIZE): Get value from EMACS_HEAPSIZE.
|
||||
(bootstrap-temacs-CMD, bootstrap-temacs-SH): Use $(EMACS_PURESIZE)
|
||||
instead of a literal number.
|
||||
|
||||
* gmalloc.c [WINDOWSNT]: Include w32heap.h.
|
||||
(min): Define only if not already defined.
|
||||
|
||||
* 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.
|
||||
|
||||
* image.c (x_bitmap_pixmap): Return ptrdiff_t, not int, since
|
||||
'bitmaps' is a pointer.
|
||||
|
||||
* dispextern.h (x_bitmap_pixmap): Adjust prototype.
|
||||
|
||||
* alloc.c (gdb_make_enums_visible): Now conditional on __GNUC__.
|
||||
|
||||
2012-09-30 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
file-attributes has a new optional arg FOLLOW-SYMLINKS.
|
||||
|
@ -74,6 +74,7 @@ extern void *sbrk ();
|
||||
#endif
|
||||
#ifdef WINDOWSNT
|
||||
#include "w32.h"
|
||||
#include "w32heap.h" /* for sbrk */
|
||||
#endif
|
||||
|
||||
#ifdef DOUG_LEA_MALLOC
|
||||
@ -6607,7 +6608,8 @@ The time is in seconds as a floating point value. */);
|
||||
/* When compiled with GCC, GDB might say "No enum type named
|
||||
pvec_type" if we don't have at least one symbol with that type, and
|
||||
then xbacktrace could fail. Similarly for the other enums and
|
||||
their values. */
|
||||
their values. Some non-GCC compilers don't like these constructs. */
|
||||
#ifdef __GNUC__
|
||||
union
|
||||
{
|
||||
enum CHARTAB_SIZE_BITS CHARTAB_SIZE_BITS;
|
||||
@ -6627,3 +6629,4 @@ union
|
||||
enum lsb_bits lsb_bits;
|
||||
#endif
|
||||
} const EXTERNALLY_VISIBLE gdb_make_enums_visible = {0};
|
||||
#endif /* __GNUC__ */
|
||||
|
@ -3157,7 +3157,7 @@ extern unsigned row_hash (struct glyph_row *);
|
||||
|
||||
extern int x_bitmap_height (struct frame *, ptrdiff_t);
|
||||
extern int x_bitmap_width (struct frame *, ptrdiff_t);
|
||||
extern int x_bitmap_pixmap (struct frame *, ptrdiff_t);
|
||||
extern ptrdiff_t x_bitmap_pixmap (struct frame *, ptrdiff_t);
|
||||
extern void x_reference_bitmap (struct frame *, ptrdiff_t);
|
||||
extern ptrdiff_t x_create_bitmap_from_data (struct frame *, char *,
|
||||
unsigned int, unsigned int);
|
||||
|
10
src/frame.c
10
src/frame.c
@ -3030,7 +3030,7 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr)
|
||||
{
|
||||
char buf[16];
|
||||
Lisp_Object tem;
|
||||
unsigned long w;
|
||||
EMACS_UINT w;
|
||||
|
||||
/* Represent negative positions (off the top or left screen edge)
|
||||
in a way that Fmodify_frame_parameters will understand correctly. */
|
||||
@ -3067,17 +3067,17 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr)
|
||||
MS-Windows it returns a value whose type is HANDLE, which is
|
||||
actually a pointer. Explicit casting avoids compiler
|
||||
warnings. */
|
||||
w = (unsigned long) FRAME_X_WINDOW (f);
|
||||
w = (EMACS_UINT) FRAME_X_WINDOW (f);
|
||||
store_in_alist (alistptr, Qwindow_id,
|
||||
make_formatted_string (buf, "%lu", w));
|
||||
make_formatted_string (buf, "%"pMu, w));
|
||||
#ifdef HAVE_X_WINDOWS
|
||||
#ifdef USE_X_TOOLKIT
|
||||
/* Tooltip frame may not have this widget. */
|
||||
if (FRAME_X_OUTPUT (f)->widget)
|
||||
#endif
|
||||
w = (unsigned long) FRAME_OUTER_WINDOW (f);
|
||||
w = (EMACS_UINT) FRAME_OUTER_WINDOW (f);
|
||||
store_in_alist (alistptr, Qouter_window_id,
|
||||
make_formatted_string (buf, "%lu", w));
|
||||
make_formatted_string (buf, "%"pMu, w));
|
||||
#endif
|
||||
store_in_alist (alistptr, Qicon_name, f->icon_name);
|
||||
FRAME_SAMPLE_VISIBILITY (f);
|
||||
|
@ -36,6 +36,10 @@ Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWSNT
|
||||
#include <w32heap.h> /* for sbrk */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
@ -1289,7 +1293,9 @@ Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
The author may be reached (Email) at the address mike@ai.mit.edu,
|
||||
or (US mail) as Mike Haertel c/o Free Software Foundation. */
|
||||
|
||||
#ifndef min
|
||||
#define min(A, B) ((A) < (B) ? (A) : (B))
|
||||
#endif
|
||||
|
||||
/* On Cygwin the dumped emacs may try to realloc storage allocated in
|
||||
the static heap. We just malloc space in the new heap and copy the
|
||||
|
@ -186,11 +186,11 @@ x_bitmap_width (FRAME_PTR f, ptrdiff_t id)
|
||||
}
|
||||
|
||||
#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
|
||||
int
|
||||
ptrdiff_t
|
||||
x_bitmap_pixmap (FRAME_PTR f, ptrdiff_t id)
|
||||
{
|
||||
/* HAVE_NTGUI needs the explicit cast here. */
|
||||
return (int) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap;
|
||||
return (ptrdiff_t) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -25,7 +25,7 @@ ALL = emacs
|
||||
EMACSLOADPATH=$(CURDIR)/../lisp
|
||||
|
||||
# Size in MBs of the static heap in temacs.exe.
|
||||
HEAPSIZE = 27
|
||||
HEAPSIZE = $(EMACS_HEAPSIZE)
|
||||
|
||||
LOCAL_FLAGS = -Demacs=1 -I../lib -I../nt/inc -DHAVE_NTGUI=1 $(EMACS_EXTRA_C_FLAGS)
|
||||
|
||||
@ -247,10 +247,10 @@ bootstrap: bootstrap-emacs
|
||||
# WARNING: Do NOT split the part inside $(ARGQUOTE)s into multiple lines as
|
||||
# this can break with GNU Make 3.81 and later if sh.exe is used.
|
||||
bootstrap-temacs-CMD:
|
||||
$(MAKE) $(MFLAGS) $(XMFLAGS) temacs CFLAGS=$(ARGQUOTE)$(ESC_CFLAGS) -DPURESIZE=5000000$(ARGQUOTE)
|
||||
$(MAKE) $(MFLAGS) $(XMFLAGS) temacs CFLAGS=$(ARGQUOTE)$(ESC_CFLAGS) -DPURESIZE=$(EMACS_PURESIZE)$(ARGQUOTE)
|
||||
|
||||
bootstrap-temacs-SH:
|
||||
$(MAKE) $(MFLAGS) $(XMFLAGS) temacs CFLAGS=$(ARGQUOTE)$(CFLAGS) -DPURESIZE=5000000$(ARGQUOTE)
|
||||
$(MAKE) $(MFLAGS) $(XMFLAGS) temacs CFLAGS=$(ARGQUOTE)$(CFLAGS) -DPURESIZE=$(EMACS_PURESIZE)$(ARGQUOTE)
|
||||
|
||||
bootstrap-temacs:
|
||||
$(MAKE) $(MFLAGS) bootstrap-temacs-$(SHELLTYPE)
|
||||
|
16
src/ralloc.c
16
src/ralloc.c
@ -72,7 +72,7 @@ static void r_alloc_init (void);
|
||||
/* Declarations for working with the malloc, ralloc, and system breaks. */
|
||||
|
||||
/* Function to set the real break value. */
|
||||
POINTER (*real_morecore) (long int);
|
||||
POINTER (*real_morecore) (ptrdiff_t);
|
||||
|
||||
/* The break value, as seen by malloc. */
|
||||
static POINTER virtual_break_value;
|
||||
@ -91,18 +91,18 @@ static int extra_bytes;
|
||||
/* Macros for rounding. Note that rounding to any value is possible
|
||||
by changing the definition of PAGE. */
|
||||
#define PAGE (getpagesize ())
|
||||
#define ROUNDUP(size) (((unsigned long int) (size) + page_size - 1) \
|
||||
& ~(page_size - 1))
|
||||
#define ROUNDUP(size) (((size_t) (size) + page_size - 1) \
|
||||
& ~((size_t)page_size - 1))
|
||||
|
||||
#define MEM_ALIGN sizeof (double)
|
||||
#define MEM_ROUNDUP(addr) (((unsigned long int)(addr) + MEM_ALIGN - 1) \
|
||||
& ~(MEM_ALIGN - 1))
|
||||
#define MEM_ROUNDUP(addr) (((size_t)(addr) + MEM_ALIGN - 1) \
|
||||
& ~((size_t)MEM_ALIGN - 1))
|
||||
|
||||
/* The hook `malloc' uses for the function which gets more space
|
||||
from the system. */
|
||||
|
||||
#ifndef SYSTEM_MALLOC
|
||||
extern POINTER (*__morecore) (long int);
|
||||
extern POINTER (*__morecore) (ptrdiff_t);
|
||||
#endif
|
||||
|
||||
|
||||
@ -308,7 +308,7 @@ static void
|
||||
relinquish (void)
|
||||
{
|
||||
register heap_ptr h;
|
||||
long excess = 0;
|
||||
ptrdiff_t excess = 0;
|
||||
|
||||
/* Add the amount of space beyond break_value
|
||||
in all heaps which have extend beyond break_value at all. */
|
||||
@ -752,7 +752,7 @@ free_bloc (bloc_ptr bloc)
|
||||
GNU malloc package. */
|
||||
|
||||
static POINTER
|
||||
r_alloc_sbrk (long int size)
|
||||
r_alloc_sbrk (ptrdiff_t size)
|
||||
{
|
||||
register bloc_ptr b;
|
||||
POINTER address;
|
||||
|
@ -54,6 +54,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
#ifdef WINDOWSNT
|
||||
#define read sys_read
|
||||
#define write sys_write
|
||||
#ifndef STDERR_FILENO
|
||||
#define STDERR_FILENO fileno(GetStdHandle(STD_ERROR_HANDLE))
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#endif /* not WINDOWSNT */
|
||||
|
||||
|
@ -67,18 +67,18 @@ void dump_bss_and_heap (file_data *p_infile, file_data *p_outfile);
|
||||
/* Cached info about the .data section in the executable. */
|
||||
PIMAGE_SECTION_HEADER data_section;
|
||||
PCHAR data_start = 0;
|
||||
DWORD data_size = 0;
|
||||
DWORD_PTR data_size = 0;
|
||||
|
||||
/* Cached info about the .bss section in the executable. */
|
||||
PIMAGE_SECTION_HEADER bss_section;
|
||||
PCHAR bss_start = 0;
|
||||
DWORD bss_size = 0;
|
||||
DWORD extra_bss_size = 0;
|
||||
DWORD_PTR bss_size = 0;
|
||||
DWORD_PTR extra_bss_size = 0;
|
||||
/* bss data that is static might be discontiguous from non-static. */
|
||||
PIMAGE_SECTION_HEADER bss_section_static;
|
||||
PCHAR bss_start_static = 0;
|
||||
DWORD bss_size_static = 0;
|
||||
DWORD extra_bss_size_static = 0;
|
||||
DWORD_PTR bss_size_static = 0;
|
||||
DWORD_PTR extra_bss_size_static = 0;
|
||||
|
||||
PIMAGE_SECTION_HEADER heap_section;
|
||||
|
||||
@ -231,7 +231,7 @@ find_section (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;
|
||||
@ -246,7 +246,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)
|
||||
@ -259,7 +259,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;
|
||||
@ -279,8 +279,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). */
|
||||
DWORD
|
||||
relocate_offset (DWORD offset,
|
||||
DWORD_PTR
|
||||
relocate_offset (DWORD_PTR offset,
|
||||
IMAGE_NT_HEADERS * src_nt_header,
|
||||
IMAGE_NT_HEADERS * dst_nt_header)
|
||||
{
|
||||
@ -314,25 +314,25 @@ 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 RVA_TO_PTR(var,section,filedata) \
|
||||
((void *)(RVA_TO_OFFSET (var,section) + (filedata).file_base))
|
||||
((DWORD_PTR)(RVA_TO_OFFSET (var,section) + (filedata).file_base))
|
||||
|
||||
#define PTR_TO_OFFSET(ptr, pfile_data) \
|
||||
((unsigned 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))
|
||||
|
||||
|
||||
/* Flip through the executable and cache the info necessary for dumping. */
|
||||
@ -349,7 +349,7 @@ get_section_info (file_data *p_infile)
|
||||
printf ("Unknown EXE header in %s...bailing.\n", p_infile->name);
|
||||
exit (1);
|
||||
}
|
||||
nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) +
|
||||
nt_header = (PIMAGE_NT_HEADERS) (((DWORD_PTR) dos_header) +
|
||||
dos_header->e_lfanew);
|
||||
if (nt_header == NULL)
|
||||
{
|
||||
@ -488,7 +488,7 @@ copy_executable_and_dump_data (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;
|
||||
|
||||
@ -541,17 +541,17 @@ copy_executable_and_dump_data (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) (((DWORD_PTR) 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),
|
||||
@ -627,8 +627,8 @@ copy_executable_and_dump_data (file_data *p_infile,
|
||||
}
|
||||
if (section == heap_section)
|
||||
{
|
||||
DWORD heap_start = (DWORD) get_heap_start ();
|
||||
DWORD heap_size = get_committed_heap_size ();
|
||||
DWORD_PTR heap_start = (DWORD_PTR) get_heap_start ();
|
||||
DWORD_PTR heap_size = get_committed_heap_size ();
|
||||
|
||||
/* Dump the used portion of the predump heap, adjusting the
|
||||
section's size to the appropriate size. */
|
||||
|
@ -41,7 +41,7 @@ static void (*warn_function) (const char *);
|
||||
static POINTER data_space_start;
|
||||
|
||||
/* Number of bytes of writable memory we can expect to be able to get. */
|
||||
static unsigned long lim_data;
|
||||
static size_t lim_data;
|
||||
|
||||
|
||||
#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_AS)
|
||||
@ -88,7 +88,7 @@ get_lim_data (void)
|
||||
static void
|
||||
get_lim_data (void)
|
||||
{
|
||||
extern unsigned long reserved_heap_size;
|
||||
extern size_t reserved_heap_size;
|
||||
lim_data = reserved_heap_size;
|
||||
}
|
||||
|
||||
@ -166,13 +166,13 @@ static void
|
||||
check_memory_limits (void)
|
||||
{
|
||||
#ifdef REL_ALLOC
|
||||
extern POINTER (*real_morecore) (long);
|
||||
extern POINTER (*real_morecore) (ptrdiff_t);
|
||||
#endif
|
||||
extern POINTER (*__morecore) (long);
|
||||
extern POINTER (*__morecore) (ptrdiff_t);
|
||||
|
||||
register POINTER cp;
|
||||
unsigned long five_percent;
|
||||
unsigned long data_size;
|
||||
size_t five_percent;
|
||||
size_t data_size;
|
||||
enum warnlevel new_warnlevel;
|
||||
|
||||
if (lim_data == 0)
|
||||
|
20
src/w32.c
20
src/w32.c
@ -1738,7 +1738,8 @@ init_environment (char ** argv)
|
||||
/* FIXME: should use substring of get_emacs_configuration ().
|
||||
But I don't think the Windows build supports alpha, mips etc
|
||||
anymore, so have taken the easy option for now. */
|
||||
else if (p && xstrcasecmp (p, "\\i386") == 0)
|
||||
else if (p && (xstrcasecmp (p, "\\i386") == 0
|
||||
|| xstrcasecmp (p, "\\AMD64") == 0))
|
||||
{
|
||||
*p = 0;
|
||||
p = strrchr (modname, '\\');
|
||||
@ -1886,7 +1887,16 @@ get_emacs_configuration (void)
|
||||
case PROCESSOR_INTEL_386:
|
||||
case PROCESSOR_INTEL_486:
|
||||
case PROCESSOR_INTEL_PENTIUM:
|
||||
#ifdef _WIN64
|
||||
arch = "amd64";
|
||||
#else
|
||||
arch = "i386";
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#ifdef PROCESSOR_AMD_X8664
|
||||
case PROCESSOR_AMD_X8664:
|
||||
arch = "amd64";
|
||||
break;
|
||||
#endif
|
||||
|
||||
@ -6646,19 +6656,19 @@ init_ntproc (int dumping)
|
||||
fclose (stderr);
|
||||
|
||||
if (stdin_save != INVALID_HANDLE_VALUE)
|
||||
_open_osfhandle ((long) stdin_save, O_TEXT);
|
||||
_open_osfhandle ((intptr_t) stdin_save, O_TEXT);
|
||||
else
|
||||
_open ("nul", O_TEXT | O_NOINHERIT | O_RDONLY);
|
||||
_fdopen (0, "r");
|
||||
|
||||
if (stdout_save != INVALID_HANDLE_VALUE)
|
||||
_open_osfhandle ((long) stdout_save, O_TEXT);
|
||||
_open_osfhandle ((intptr_t) stdout_save, O_TEXT);
|
||||
else
|
||||
_open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY);
|
||||
_fdopen (1, "w");
|
||||
|
||||
if (stderr_save != INVALID_HANDLE_VALUE)
|
||||
_open_osfhandle ((long) stderr_save, O_TEXT);
|
||||
_open_osfhandle ((intptr_t) stderr_save, O_TEXT);
|
||||
else
|
||||
_open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY);
|
||||
_fdopen (2, "w");
|
||||
@ -6779,7 +6789,7 @@ serial_open (char *port)
|
||||
OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
|
||||
if (hnd == INVALID_HANDLE_VALUE)
|
||||
error ("Could not open %s", port);
|
||||
fd = (int) _open_osfhandle ((int) hnd, 0);
|
||||
fd = (int) _open_osfhandle ((intptr_t) hnd, 0);
|
||||
if (fd == -1)
|
||||
error ("Could not open %s", port);
|
||||
|
||||
|
@ -137,7 +137,7 @@ struct MONITOR_INFO
|
||||
};
|
||||
|
||||
/* Reportedly, MSVC does not have this in its headers. */
|
||||
#ifdef _MSC_VER
|
||||
#if defined (_MSC_VER) && _WIN32_WINNT < 0x0500
|
||||
DECLARE_HANDLE(HMONITOR);
|
||||
#endif
|
||||
|
||||
@ -2252,7 +2252,7 @@ static void
|
||||
w32_msg_pump (deferred_msg * msg_buf)
|
||||
{
|
||||
MSG msg;
|
||||
int result;
|
||||
WPARAM result;
|
||||
HWND focus_window;
|
||||
|
||||
msh_mousewheel = RegisterWindowMessage (MSH_MOUSEWHEEL);
|
||||
@ -2283,7 +2283,7 @@ w32_msg_pump (deferred_msg * msg_buf)
|
||||
/* Reply is not expected. */
|
||||
break;
|
||||
case WM_EMACS_SETKEYBOARDLAYOUT:
|
||||
result = (int) ActivateKeyboardLayout ((HKL) msg.wParam, 0);
|
||||
result = (WPARAM) ActivateKeyboardLayout ((HKL) msg.wParam, 0);
|
||||
if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE,
|
||||
result, 0))
|
||||
emacs_abort ();
|
||||
|
@ -26,7 +26,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
#include "w32heap.h"
|
||||
#include "lisp.h" /* for VALMASK */
|
||||
|
||||
#define RVA_TO_PTR(rva) ((unsigned char *)((DWORD)(rva) + (DWORD)GetModuleHandle (NULL)))
|
||||
#define RVA_TO_PTR(rva) ((unsigned char *)((DWORD_PTR)(rva) + (DWORD_PTR)GetModuleHandle (NULL)))
|
||||
|
||||
/* This gives us the page size and the size of the allocation unit on NT. */
|
||||
SYSTEM_INFO sysinfo_cache;
|
||||
@ -34,7 +34,7 @@ SYSTEM_INFO sysinfo_cache;
|
||||
/* This gives us version, build, and platform identification. */
|
||||
OSVERSIONINFO osinfo_cache;
|
||||
|
||||
unsigned long syspage_mask = 0;
|
||||
size_t syspage_mask = 0;
|
||||
|
||||
/* The major and minor versions of NT. */
|
||||
int w32_major_version;
|
||||
@ -97,7 +97,7 @@ PIMAGE_SECTION_HEADER preload_heap_section;
|
||||
unsigned char *data_region_base = NULL;
|
||||
unsigned char *data_region_end = NULL;
|
||||
unsigned char *real_data_region_end = NULL;
|
||||
unsigned long reserved_heap_size = 0;
|
||||
size_t reserved_heap_size = 0;
|
||||
|
||||
/* The start of the data segment. */
|
||||
unsigned char *
|
||||
@ -121,16 +121,20 @@ allocate_heap (void)
|
||||
the preload heap section up to the usable address limit. Since GNU
|
||||
malloc can handle gaps in the memory it gets from sbrk, we can
|
||||
simply set the sbrk pointer to the base of the new heap region. */
|
||||
unsigned long base =
|
||||
DWORD_PTR base =
|
||||
ROUND_UP ((RVA_TO_PTR (preload_heap_section->VirtualAddress)
|
||||
+ preload_heap_section->Misc.VirtualSize),
|
||||
get_allocation_unit ());
|
||||
unsigned long end = 1 << VALBITS; /* 256MB */
|
||||
DWORD_PTR end = ((unsigned __int64)1) << VALBITS; /* 256MB */
|
||||
void *ptr = NULL;
|
||||
|
||||
while (!ptr && (base < end))
|
||||
{
|
||||
#ifdef _WIN64
|
||||
reserved_heap_size = min(end - base, 0x4000000000i64); /* Limit to 256Gb */
|
||||
#else
|
||||
reserved_heap_size = end - base;
|
||||
#endif
|
||||
ptr = VirtualAlloc ((void *) base,
|
||||
get_reserved_heap_size (),
|
||||
MEM_RESERVE,
|
||||
@ -144,7 +148,11 @@ allocate_heap (void)
|
||||
static char *
|
||||
allocate_heap (void)
|
||||
{
|
||||
unsigned long size = 0x80000000; /* start by asking for 2GB */
|
||||
#ifdef _WIN64
|
||||
size_t size = 0x4000000000i64; /* start by asking for 32GB */
|
||||
#else
|
||||
size_t size = 0x80000000; /* start by asking for 2GB */
|
||||
#endif
|
||||
void *ptr = NULL;
|
||||
|
||||
while (!ptr && size > 0x00100000)
|
||||
@ -166,17 +174,17 @@ allocate_heap (void)
|
||||
be the address of the _start_ (not end) of the new block in case of
|
||||
success, and zero (not -1) in case of failure. */
|
||||
void *
|
||||
sbrk (unsigned long increment)
|
||||
sbrk (ptrdiff_t increment)
|
||||
{
|
||||
void *result;
|
||||
long size = (long) increment;
|
||||
ptrdiff_t size = increment;
|
||||
|
||||
result = data_region_end;
|
||||
|
||||
/* If size is negative, shrink the heap by decommitting pages. */
|
||||
if (size < 0)
|
||||
{
|
||||
int new_size;
|
||||
ptrdiff_t new_size;
|
||||
unsigned char *new_data_region_end;
|
||||
|
||||
size = -size;
|
||||
@ -189,7 +197,7 @@ sbrk (unsigned long increment)
|
||||
partial deallocation [cga]. */
|
||||
new_data_region_end = (data_region_end - size);
|
||||
new_data_region_end = (unsigned char *)
|
||||
((long) (new_data_region_end + syspage_mask) & ~syspage_mask);
|
||||
((DWORD_PTR) (new_data_region_end + syspage_mask) & ~syspage_mask);
|
||||
new_size = real_data_region_end - new_data_region_end;
|
||||
real_data_region_end = new_data_region_end;
|
||||
if (new_size > 0)
|
||||
@ -220,7 +228,7 @@ sbrk (unsigned long increment)
|
||||
/* We really only commit full pages, so record where
|
||||
the real end of committed memory is [cga]. */
|
||||
real_data_region_end = (unsigned char *)
|
||||
((long) (data_region_end + syspage_mask) & ~syspage_mask);
|
||||
((DWORD_PTR) (data_region_end + syspage_mask) & ~syspage_mask);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -245,7 +253,7 @@ init_heap (void)
|
||||
PIMAGE_NT_HEADERS nt_header;
|
||||
|
||||
dos_header = (PIMAGE_DOS_HEADER) RVA_TO_PTR (0);
|
||||
nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) +
|
||||
nt_header = (PIMAGE_NT_HEADERS) (((DWORD_PTR) dos_header) +
|
||||
dos_header->e_lfanew);
|
||||
preload_heap_section = find_section ("EMHEAP", nt_header);
|
||||
|
||||
@ -261,7 +269,7 @@ init_heap (void)
|
||||
#if !USE_LSB_TAG
|
||||
/* Ensure that the addresses don't use the upper tag bits since
|
||||
the Lisp type goes there. */
|
||||
if (((unsigned long) data_region_base & ~VALMASK) != 0)
|
||||
if (((DWORD_PTR) data_region_base & ~VALMASK) != 0)
|
||||
{
|
||||
printf ("Error: The heap was allocated in upper memory.\n");
|
||||
exit (1);
|
||||
@ -284,13 +292,13 @@ init_heap (void)
|
||||
|
||||
/* Round the heap up to the given alignment. */
|
||||
void
|
||||
round_heap (unsigned long align)
|
||||
round_heap (size_t align)
|
||||
{
|
||||
unsigned long needs_to_be;
|
||||
unsigned long need_to_alloc;
|
||||
DWORD_PTR needs_to_be;
|
||||
DWORD_PTR need_to_alloc;
|
||||
|
||||
needs_to_be = (unsigned long) ROUND_UP (get_heap_end (), align);
|
||||
need_to_alloc = needs_to_be - (unsigned long) get_heap_end ();
|
||||
needs_to_be = (DWORD_PTR) ROUND_UP (get_heap_end (), align);
|
||||
need_to_alloc = needs_to_be - (DWORD_PTR) get_heap_end ();
|
||||
|
||||
if (need_to_alloc)
|
||||
sbrk (need_to_alloc);
|
||||
|
@ -24,8 +24,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#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))
|
||||
|
||||
/*
|
||||
* Heap related stuff.
|
||||
@ -42,7 +42,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
extern unsigned char *get_data_start (void);
|
||||
extern unsigned char *get_data_end (void);
|
||||
extern unsigned long reserved_heap_size;
|
||||
extern size_t reserved_heap_size;
|
||||
extern SYSTEM_INFO sysinfo_cache;
|
||||
extern OSVERSIONINFO osinfo_cache;
|
||||
extern BOOL using_dynamic_heap;
|
||||
@ -58,13 +58,13 @@ enum {
|
||||
extern int os_subtype;
|
||||
|
||||
/* Emulation of Unix sbrk(). */
|
||||
extern void *sbrk (unsigned long size);
|
||||
extern void *sbrk (ptrdiff_t size);
|
||||
|
||||
/* Initialize heap structures for sbrk on startup. */
|
||||
extern void init_heap (void);
|
||||
|
||||
/* Round the heap to this size. */
|
||||
extern void round_heap (unsigned long size);
|
||||
extern void round_heap (size_t size);
|
||||
|
||||
/* Cache system info, e.g., the NT page size. */
|
||||
extern void cache_system_info (void);
|
||||
@ -89,6 +89,6 @@ IMAGE_SECTION_HEADER * find_section (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);
|
||||
IMAGE_SECTION_HEADER * rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header);
|
||||
|
||||
#endif /* NTHEAP_H_ */
|
||||
|
@ -1483,8 +1483,8 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
|
||||
|
||||
utf8to16 (out_string, utf8_len, utf16_string);
|
||||
return_value = unicode_append_menu (menu, fuFlags,
|
||||
item != NULL ? (UINT) item
|
||||
: (UINT) wv->call_data,
|
||||
item != NULL ? (UINT_PTR) item
|
||||
: (UINT_PTR) wv->call_data,
|
||||
utf16_string);
|
||||
if (!return_value)
|
||||
{
|
||||
@ -1496,7 +1496,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
|
||||
of minor importance compared with menus not working at all. */
|
||||
return_value =
|
||||
AppendMenu (menu, fuFlags,
|
||||
item != NULL ? (UINT) item: (UINT) wv->call_data,
|
||||
item != NULL ? (UINT_PTR) item: (UINT_PTR) wv->call_data,
|
||||
out_string);
|
||||
/* Don't use Unicode menus in future, unless this is Windows
|
||||
NT or later, where a failure of AppendMenuW does NOT mean
|
||||
@ -1513,7 +1513,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
|
||||
return_value =
|
||||
AppendMenu (menu,
|
||||
fuFlags,
|
||||
item != NULL ? (UINT) item : (UINT) wv->call_data,
|
||||
item != NULL ? (UINT_PTR) item : (UINT_PTR) wv->call_data,
|
||||
out_string );
|
||||
}
|
||||
|
||||
@ -1550,7 +1550,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
|
||||
}
|
||||
|
||||
set_menu_item_info (menu,
|
||||
item != NULL ? (UINT) item : (UINT) wv->call_data,
|
||||
item != NULL ? (UINT_PTR) item : (UINT_PTR) wv->call_data,
|
||||
FALSE, &info);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ extern BOOL WINAPI IsValidLocale (LCID, DWORD);
|
||||
|
||||
#define RVA_TO_PTR(var,section,filedata) \
|
||||
((void *)((section)->PointerToRawData \
|
||||
+ ((DWORD)(var) - (section)->VirtualAddress) \
|
||||
+ ((DWORD_PTR)(var) - (section)->VirtualAddress) \
|
||||
+ (filedata).file_base))
|
||||
|
||||
Lisp_Object Qhigh, Qlow;
|
||||
@ -1190,7 +1190,7 @@ w32_executable_type (char * filename,
|
||||
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
|
||||
goto unwind;
|
||||
|
||||
nt_header = (PIMAGE_NT_HEADERS) ((char *) dos_header + dos_header->e_lfanew);
|
||||
nt_header = (PIMAGE_NT_HEADERS) ((unsigned char *) dos_header + dos_header->e_lfanew);
|
||||
|
||||
if ((char *) nt_header > (char *) dos_header + executable.size)
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ struct w32_display_info *x_display_list;
|
||||
Lisp_Object w32_display_name_list;
|
||||
|
||||
|
||||
#ifndef GLYPHSET
|
||||
#if _WIN32_WINNT < 0x0500
|
||||
/* Pre Windows 2000, this was not available, but define it here so
|
||||
that Emacs compiled on such a platform will run on newer versions. */
|
||||
|
||||
@ -360,7 +360,11 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color)
|
||||
|
||||
/* Find and set clipping rectangle */
|
||||
|
||||
wave_clip = (XRectangle){ x0, y0, width, wave_height };
|
||||
wave_clip.x = x0;
|
||||
wave_clip.y = y0;
|
||||
wave_clip.width = width;
|
||||
wave_clip.height = wave_height;
|
||||
|
||||
get_glyph_string_clip_rect (s, &w32_string_clip);
|
||||
CONVERT_TO_XRECT (string_clip, w32_string_clip);
|
||||
|
||||
|
@ -431,7 +431,15 @@ struct scroll_bar {
|
||||
/* Turning a lisp vector value into a pointer to a struct scroll_bar. */
|
||||
#define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
|
||||
|
||||
#ifdef _WIN64
|
||||
/* Building a 64-bit C integer from two 32-bit lisp integers. */
|
||||
#define SCROLL_BAR_PACK(low, high) (XINT (high) << 32 | XINT (low))
|
||||
|
||||
/* Setting two lisp integers to the low and high words of a 64-bit C int. */
|
||||
#define SCROLL_BAR_UNPACK(low, high, int64) \
|
||||
(XSETINT ((low), ((DWORDLONG)(int64)) & 0xffffffff), \
|
||||
XSETINT ((high), ((DWORDLONG)(int64) >> 32) & 0xffffffff))
|
||||
#else /* not _WIN64 */
|
||||
/* Building a 32-bit C integer from two 16-bit lisp integers. */
|
||||
#define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low))
|
||||
|
||||
@ -439,7 +447,7 @@ struct scroll_bar {
|
||||
#define SCROLL_BAR_UNPACK(low, high, int32) \
|
||||
(XSETINT ((low), (int32) & 0xffff), \
|
||||
XSETINT ((high), ((int32) >> 16) & 0xffff))
|
||||
|
||||
#endif /* not _WIN64 */
|
||||
|
||||
/* Extract the window id of the scroll bar from a struct scroll_bar. */
|
||||
#define SCROLL_BAR_W32_WINDOW(ptr) \
|
||||
@ -447,7 +455,7 @@ struct scroll_bar {
|
||||
|
||||
/* Store a window id in a struct scroll_bar. */
|
||||
#define SET_SCROLL_BAR_W32_WINDOW(ptr, id) \
|
||||
(SCROLL_BAR_UNPACK ((ptr)->w32_window_low, (ptr)->w32_window_high, (int) id))
|
||||
(SCROLL_BAR_UNPACK ((ptr)->w32_window_low, (ptr)->w32_window_high, (intptr_t) id))
|
||||
|
||||
/* Extract the X widget of the scroll bar from a struct scroll_bar. */
|
||||
#define SCROLL_BAR_X_WIDGET(ptr) \
|
||||
|
Loading…
Reference in New Issue
Block a user