Mercurial > emacs
view src/w32heap.c @ 87828:41248ae03f06
(org-entry-properties): Include the CLOCKSUM special
property.
(org-columns-edit-value): Do not allow to edit the special
CLOCKSUM property.
(org-flag-drawer): Use the original value of `outline-regexp'.
(org-remember-handler): Add invisible-ok flag to call to
`org-end-of-subtree'
(org-agenda-highlight-todo): Respect
`org-agenda-todo-keyword-format'.
(org-agenda-todo-keyword-format): New option.
(org-infile-export-plist): No restriction while searching for
options.
(org-remember-handler): Remove comments at the end of the buffer.
(org-remember-use-refile-when-interactive): New option.
(org-table-sort-lines): Make sure sorting works on link
descritions only, and ignores the link.
(org-sort-entries-or-items): Make sure the end of the subtree is
included.
(org-refile-use-outline-path): New allowed values `file' and
`full-file-path'.
(org-get-refile-targets): Respect new values for
`org-refile-use-outline-path'.
(org-agenda-get-restriction-and-command): DEL goes back to initial
list.
(org-export-as-xoxo): Restore point when done.
(org-open-file): Allow multiple %s in command.
(org-clock-in-switch-to-state): New option.
(org-first-list-item-p): New function.
(org-last-remember-storage-locations): New variable.
(org-get-refile-targets): Interpret the new maxlevel setting.
(org-refile-targets): New option `:maxlevel'.
(org-copy-subtree): Include empty lines before but not after
subtree.
(org-back-over-empty-lines, org-skip-whitespace): New functions.
(org-move-item-down, org-move-item-up): Include empty lines before
but not after item.
(org-first-sibling-p): New function.
(org-remember-apply-template): Defaults, completions and history
for template prompts. Also, interpret new `%!' escape.
(org-context-choices): New constant.
(org-bound-and-true-p): New macro.
(org-imenu-depth): New option.
(org-imenu-markers): New variable.
(org-imenu-new-marker, org-imenu-get-tree)
(org-speedbar-set-agenda-restriction): New functions.
(org-agenda-set-restriction-lock)
(org-agenda-remove-restriction-lock, org-agenda-maybe-redo): New
functions.
(org-agenda-restriction-lock): New face.
(org-agenda-restriction-lock-overlay)
(org-speedbar-restriction-lock-overlay): New variables.
(org-open-at-point): Removed obsolete way to do redirection in
shell links.
(org-imenu-and-speedbar): New customization group.
(org-entry-properties): Return keyword-less time strings.
(org-clock-heading-function): New option.
(org-clock-in): Use `org-clock-heading-function'.
(org-calendar-holiday): Try to use `calendar-check-holidays'
instead of the obsolete `check-calendar-holidays'.
(org-export-html-special-string-regexps): New constant.
(org-massive-special-regexp): New variable.
(org-compute-latex-and-specials-regexp)
(org-do-latex-and-special-faces): New functions.
(org-latex-and-export-specials): New face.
(org-highlight-latex-fragments-and-specials): New option.
(org-link-escape-chars): Use characters instead of strings.
(org-link-escape-chars-browser, org-link-escape)
(org-link-unescape): Use characters instead of strings.
(org-export-html-convert-sub-super, org-html-do-expand): Check for
protected text.
(org-emphasis-alist): Additional `verbatim' flag.
(org-set-emph-re): Handle the verbatim flag and compute
`org-verbatim-re'.
(org-cleaned-string-for-export): Protect verbatim elements.
(org-verbatim-re): New variable.
(org-hide-emphasis-markers): New option.
(org-additional-option-like-keywords): Add new keywords.
(org-get-entry): Renamed from `org-get-cleaned-entry'.
(org-icalendar-cleanup-string): New function for quoting icalendar
text.
(org-agenda-skip-scheduled-if-done): New option.
(org-agenda-get-scheduled, org-agenda-get-blocks): Use
`org-agenda-skip-scheduled-if-done'.
(org-prepare-agenda-buffers): Allow buffers as arguments.
(org-entry-properties): Add CATEGORY as a special property.
(org-use-property-inheritance): Allow a list of properties as a
value.
(org-eval-in-calendar): No longer update the prompt.
(org-read-date-popup-calendar): Renamed from
`org-popup-calendar-for-date-prompt'.
(org-read-date-display-live): New variable.
(org-read-date-display): New function.
(org-read-date-analyze): New function.
(org-remember-apply-template): Define `remember-finalize' if it is
not yet defined.
(org-remember-insinuate): New function.
(org-read-date-prefer-future): New option.
(org-read-date): Respect the setting of
`org-read-date-prefer-future'. Use `org-read-date-analyze'.
(org-set-font-lock-defaults): Use `org-archive-tag' instead of a
hardcoded string.
(org-remember-apply-template): Use `remember-finalize' instead of
`remember-buffer'.
(org-columns-compute, org-column-number-to-string)
(org-columns-uncompile-format, org-columns-compile-format)
(org-columns-compile-format): Handle printf format specifier.
(org-columns-new, org-column-number-to-string)
(org-columns-uncompile-format, org-columns-compile-format):
Support for new currency summary type.
(org-tree-to-indirect-buffer): Do not kill old buffer when
`org-indirect-buffer-display' is `new-frame'.
(org-indirect-buffer-display): Document that `new-frame' leads to
indiret buffer proliferation.
(org-agenda-list): Use `org-extend-today-until'.
(org-extend-today-until): New option.
(org-format-org-table-html): Use lower-case for <col> tag.
(org-agenda-execute): New command.
(org-agenda-mode-map): Keybindings of "g" "G", "e" modified.
(org-select-remember-template): New function.
(org-remember-apply-template): Use `org-select-remember-template'.
(org-go-to-remember-target): New function.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Fri, 18 Jan 2008 15:07:17 +0000 |
parents | fc2bcd2a8aad |
children | 606f2d163a64 8971ddf55736 |
line wrap: on
line source
/* Heap management routines for GNU Emacs on the Microsoft W32 API. Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of GNU Emacs. GNU Emacs is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Geoff Voelker (voelker@cs.washington.edu) 7-29-94 */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdlib.h> #include <stdio.h> #include "w32heap.h" #include "lisp.h" /* for VALMASK */ #define RVA_TO_PTR(rva) ((unsigned char *)((DWORD)(rva) + (DWORD)GetModuleHandle (NULL))) /* This gives us the page size and the size of the allocation unit on NT. */ SYSTEM_INFO sysinfo_cache; /* This gives us version, build, and platform identification. */ OSVERSIONINFO osinfo_cache; unsigned long syspage_mask = 0; /* The major and minor versions of NT. */ int w32_major_version; int w32_minor_version; int w32_build_number; /* Distinguish between Windows NT and Windows 95. */ int os_subtype; /* Cache information describing the NT system for later use. */ void cache_system_info (void) { union { struct info { char major; char minor; short platform; } info; DWORD data; } version; /* Cache the version of the operating system. */ version.data = GetVersion (); w32_major_version = version.info.major; w32_minor_version = version.info.minor; if (version.info.platform & 0x8000) os_subtype = OS_WIN95; else os_subtype = OS_NT; /* Cache page size, allocation unit, processor type, etc. */ GetSystemInfo (&sysinfo_cache); syspage_mask = sysinfo_cache.dwPageSize - 1; /* Cache os info. */ osinfo_cache.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); GetVersionEx (&osinfo_cache); w32_build_number = osinfo_cache.dwBuildNumber; if (os_subtype == OS_WIN95) w32_build_number &= 0xffff; } /* Emulate getpagesize. */ int getpagesize (void) { return sysinfo_cache.dwPageSize; } /* Info for managing our preload heap, which is essentially a fixed size data area in the executable. */ PIMAGE_SECTION_HEADER preload_heap_section; /* Info for keeping track of our heap. */ 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; /* The start of the data segment. */ unsigned char * get_data_start (void) { return data_region_base; } /* The end of the data segment. */ unsigned char * get_data_end (void) { return data_region_end; } static char * allocate_heap (void) { /* Try to get as much as possible of the address range from the end of 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 = ROUND_UP ((RVA_TO_PTR (preload_heap_section->VirtualAddress) + preload_heap_section->Misc.VirtualSize), get_allocation_unit ()); unsigned long end = 1 << VALBITS; /* 256MB */ void *ptr = NULL; while (!ptr && (base < end)) { reserved_heap_size = end - base; ptr = VirtualAlloc ((void *) base, get_reserved_heap_size (), MEM_RESERVE, PAGE_NOACCESS); base += 0x00100000; /* 1MB increment */ } return ptr; } /* Emulate Unix sbrk. */ void * sbrk (unsigned long increment) { void *result; long size = (long) increment; result = data_region_end; /* If size is negative, shrink the heap by decommitting pages. */ if (size < 0) { int new_size; unsigned char *new_data_region_end; size = -size; /* Sanity checks. */ if ((data_region_end - size) < data_region_base) return NULL; /* We can only decommit full pages, so allow for 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); new_size = real_data_region_end - new_data_region_end; real_data_region_end = new_data_region_end; if (new_size > 0) { /* Decommit size bytes from the end of the heap. */ if (using_dynamic_heap && !VirtualFree (real_data_region_end, new_size, MEM_DECOMMIT)) return NULL; } data_region_end -= size; } /* If size is positive, grow the heap by committing reserved pages. */ else if (size > 0) { /* Sanity checks. */ if ((data_region_end + size) > (data_region_base + get_reserved_heap_size ())) return NULL; /* Commit more of our heap. */ if (using_dynamic_heap && VirtualAlloc (data_region_end, size, MEM_COMMIT, PAGE_READWRITE) == NULL) return NULL; data_region_end += size; /* 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); } return result; } /* Initialize the internal heap variables used by sbrk. When running in preload phase (ie. in the undumped executable), we rely entirely on a fixed size heap section included in the .exe itself; this is preserved during dumping, and truncated to the size actually used. When running in the dumped executable, we reserve as much as possible of the address range that is addressable by Lisp object pointers, to supplement what is left of the preload heap. Although we cannot rely on the dynamically allocated arena being contiguous with the static heap area, it is not a problem because sbrk can pretend that the gap was allocated by something else; GNU malloc detects when there is a jump in the sbrk values, and starts a new heap block. */ void init_heap () { PIMAGE_DOS_HEADER dos_header; PIMAGE_NT_HEADERS nt_header; dos_header = (PIMAGE_DOS_HEADER) RVA_TO_PTR (0); nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) + dos_header->e_lfanew); preload_heap_section = find_section ("EMHEAP", nt_header); if (using_dynamic_heap) { data_region_base = allocate_heap (); if (!data_region_base) { printf ("Error: Could not reserve dynamic heap area.\n"); exit (1); } #if defined (NO_UNION_TYPE) && !defined (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) { printf ("Error: The heap was allocated in upper memory.\n"); exit (1); } #endif data_region_end = data_region_base; real_data_region_end = data_region_end; } else { data_region_base = RVA_TO_PTR (preload_heap_section->VirtualAddress); data_region_end = data_region_base; real_data_region_end = data_region_end; reserved_heap_size = preload_heap_section->Misc.VirtualSize; } /* Update system version information to match current system. */ cache_system_info (); } /* Round the heap up to the given alignment. */ void round_heap (unsigned long align) { unsigned long needs_to_be; unsigned long 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 (); if (need_to_alloc) sbrk (need_to_alloc); } #if (_MSC_VER >= 1000 && _MSC_VER < 1300 && !defined(USE_CRT_DLL)) /* MSVC 4.2 invokes these functions from mainCRTStartup to initialize a heap via HeapCreate. They are normally defined by the runtime, but we override them here so that the unnecessary HeapCreate call is not performed. */ int __cdecl _heap_init (void) { /* Stepping through the assembly indicates that mainCRTStartup is expecting a nonzero success return value. */ return 1; } void __cdecl _heap_term (void) { return; } #endif /* arch-tag: 9a6a9860-040d-422d-8905-450dd535cd9c (do not change this comment) */