]> code.delx.au - gnu-emacs/blob - src/w32heap.h
(Text): Replace inforef to emacs-xtra by conditional xref's, depending on
[gnu-emacs] / src / w32heap.h
1 /* Heap management routines (including unexec) for GNU Emacs on Windows NT.
2 Copyright (C) 1994, 2002, 2003, 2004, 2005,
3 2006 Free Software Foundation, Inc.
4
5 This file is part of GNU Emacs.
6
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21
22 Geoff Voelker (voelker@cs.washington.edu) 7-29-94
23 */
24
25 #ifndef NTHEAP_H_
26 #define NTHEAP_H_
27
28 #include <windows.h>
29
30 #define ROUND_UP(p, align) (((DWORD)(p) + (align)-1) & ~((align)-1))
31 #define ROUND_DOWN(p, align) ((DWORD)(p) & ~((align)-1))
32
33 /*
34 * Heap related stuff.
35 */
36 #define get_reserved_heap_size() reserved_heap_size
37 #define get_committed_heap_size() (get_data_end () - get_data_start ())
38 #define get_heap_start() get_data_start ()
39 #define get_heap_end() get_data_end ()
40 #define get_page_size() sysinfo_cache.dwPageSize
41 #define get_allocation_unit() sysinfo_cache.dwAllocationGranularity
42 #define get_processor_type() sysinfo_cache.dwProcessorType
43 #define get_w32_major_version() w32_major_version
44 #define get_w32_minor_version() w32_minor_version
45
46 extern unsigned char *get_data_start();
47 extern unsigned char *get_data_end();
48 extern unsigned long reserved_heap_size;
49 extern SYSTEM_INFO sysinfo_cache;
50 extern OSVERSIONINFO osinfo_cache;
51 extern BOOL using_dynamic_heap;
52 extern int w32_major_version;
53 extern int w32_minor_version;
54 extern int w32_build_number;
55
56 enum {
57 OS_WIN95 = 1,
58 OS_NT
59 };
60
61 extern int os_subtype;
62
63 /* Emulation of Unix sbrk(). */
64 extern void *sbrk (unsigned long size);
65
66 /* Initialize heap structures for sbrk on startup. */
67 extern void init_heap ();
68
69 /* Round the heap to this size. */
70 extern void round_heap (unsigned long size);
71
72 /* Cache system info, e.g., the NT page size. */
73 extern void cache_system_info (void);
74
75 /* ----------------------------------------------------------------- */
76 /* Useful routines for manipulating memory-mapped files. */
77
78 typedef struct file_data {
79 char *name;
80 unsigned long size;
81 HANDLE file;
82 HANDLE file_mapping;
83 unsigned char *file_base;
84 } file_data;
85
86 int open_input_file (file_data *p_file, char *name);
87 int open_output_file (file_data *p_file, char *name, unsigned long size);
88 void close_file_data (file_data *p_file);
89
90 /* Return pointer to section header for named section. */
91 IMAGE_SECTION_HEADER * find_section (char * name, IMAGE_NT_HEADERS * nt_header);
92
93 /* Return pointer to section header for section containing the given
94 relative virtual address. */
95 IMAGE_SECTION_HEADER * rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header);
96
97 #endif /* NTHEAP_H_ */
98
99 /* arch-tag: 3ba4cbe1-8a09-4a41-8f37-fd31f7426b3c
100 (do not change this comment) */