You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

85 lines
2.7 KiB

/* Heap management routines for NetRunner on Windows NT.
This file was taken from GNU Emacs.
Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008, 2009 Free Software Foundation, Inc.
*/
#ifndef NTHEAP_H_
#define NTHEAP_H_
#include <windows.h>
#define ROUND_UP(p, align) (((DWORD)(p) + (align)-1) & ~((align)-1))
#define ROUND_DOWN(p, align) ((DWORD)(p) & ~((align)-1))
/*
* Heap related stuff.
*/
#define get_reserved_heap_size() reserved_heap_size
#define get_committed_heap_size() (get_data_end () - get_data_start ())
#define get_heap_start() get_data_start ()
#define get_heap_end() get_data_end ()
#define get_page_size() nt_sysinfo.dwPageSize
#define get_allocation_unit() nt_sysinfo.dwAllocationGranularity
#define get_processor_type() nt_sysinfo.dwProcessorType
#define get_w32_major_version() nt_major_version
#define get_w32_minor_version() nt_minor_version
extern unsigned char *get_data_start();
extern unsigned char *get_data_end();
extern unsigned long reserved_heap_size;
extern SYSTEM_INFO nt_sysinfo;
extern OSVERSIONINFO nt_apilevel;
extern BOOL using_dynamic_heap;
extern int nt_major_version;
extern int nt_minor_version;
extern int nt_build_number;
enum {
OS_WIN95 = 1, // cus someone demanded Win32s support, arrrgh (yes, this is a C99 compliant comment)
OS_NT
};
extern int os_subtype;
/* Emulation of Unix sbrk(). */
extern void *sbrk (unsigned long size);
/* Initialize heap structures for sbrk on startup. */
extern void init_heap ();
/* Round the heap to this size. */
extern void round_heap (unsigned long size);
/* Cache system info, e.g., the NT page size. */
extern void cache_system_info (void);
/* ----------------------------------------------------------------- */
/* Useful routines for manipulating memory-mapped files. */
typedef struct file_data {
char *name;
unsigned long size;
HANDLE file;
HANDLE file_mapping;
unsigned char *file_base;
} file_data;
int open_input_file (file_data *p_file, char *name);
int open_output_file (file_data *p_file, char *name, unsigned long size);
void close_file_data (file_data *p_file);
/* Return pointer to section header for named section. */
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);
#define RVA_TO_PTR(rva) ((unsigned char *)((DWORD)(rva) + (DWORD)GetModuleHandle(NULL)))
#ifndef VALBITS
#define VALBITS (32 - 3)
#endif
#define VALMASK ((((int) 1) << VALBITS) - 1)
#endif /* NTHEAP_H_ */