Changeset 810


Ignore:
Timestamp:
Oct 6, 2003, 2:55:10 AM (22 years ago)
Author:
bird
Message:

#608: High memory support.

Location:
trunk
Files:
42 added
45 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile

    • Property cvs2svn:cvs-rev changed from 1.53 to 1.54
    r809 r810  
    681681ifeq "$(BUILD_PLATFORM)" "OS2"         
    682682        unset GCCLOAD ; $(MAKE) $(MAKEOPT) -C $(PATH_OBJ)/gcc \
    683             LIBGCC2_DEBUG_CFLAGS="$(BUILD_DEBUGINFO)" \
    684                       CFLAGS="$(SPEC_HACK) $(BUILD_DEBUGINFO) -O2" \
    685                     CXXFLAGS="$(SPEC_HACK) $(BUILD_DEBUGINFO) -O2" \
    686                  BOOT_CFLAGS="$(SPEC_HACK) $(BUILD_DEBUGINFO) -O2 -mcpu=pentium -mpreferred-stack-boundary=2 -malign-strings=0 -falign-loops=2 -falign-jumps=2 -falign-functions=2" \
    687                      LDFLAGS="$(SPEC_HACK) $(BUILD_DEBUGINFO) -Zexe -Zcrtdll -Zstack 1024" \
    688                 BOOT_LDFLAGS="$(SPEC_HACK) $(BUILD_DEBUGINFO) -Zexe -Zcrtdll -Zstack 1024" \
     683            LIBGCC2_DEBUG_CFLAGS="$(BUILD_DEBUGINFO) -Zhigh-mem " \
     684                      CFLAGS="$(SPEC_HACK) $(BUILD_DEBUGINFO) -Zhigh-mem -O2" \
     685                    CXXFLAGS="$(SPEC_HACK) $(BUILD_DEBUGINFO) -Zhigh-mem -O2" \
     686                 BOOT_CFLAGS="$(SPEC_HACK) $(BUILD_DEBUGINFO) -Zhigh-mem -O2 -mcpu=pentium -mpreferred-stack-boundary=2 -malign-strings=0 -falign-loops=2 -falign-jumps=2 -falign-functions=2" \
     687                     LDFLAGS="$(SPEC_HACK) $(BUILD_DEBUGINFO) -Zhigh-mem -Zexe -Zcrtdll -Zstack 1024" \
     688                BOOT_LDFLAGS="$(SPEC_HACK) $(BUILD_DEBUGINFO) -Zhigh-mem -Zexe -Zcrtdll -Zstack 1024" \
    689689                bootstrap
    690690else
     
    794794                unset GCCLOAD; \
    795795                export GCC_OMF="real"; \
    796             export LIBGCC2_DEBUG_CFLAGS="-g -Zaout"; \
    797                 export       CFLAGS="$(OMFSPEC_HACK) -Zomf -g "; \
    798                 export     CXXFLAGS="$(OMFSPEC_HACK) -Zomf -g "; \
    799                 export  BOOT_CFLAGS="$(OMFSPEC_HACK) -Zomf -g "; \
    800                 export      LDFLAGS="$(OMFSPEC_HACK) -Zomf -g -Zexe -Zcrtdll -Zstack 1024"; \
    801                 export BOOT_LDFLAGS="$(OMFSPEC_HACK) -Zomf -g -Zexe -Zcrtdll -Zstack 1024"; \
     796            export LIBGCC2_DEBUG_CFLAGS="-g -Zhigh-mem -Zaout"; \
     797                export       CFLAGS="$(OMFSPEC_HACK) -Zhigh-mem -Zomf -g "; \
     798                export     CXXFLAGS="$(OMFSPEC_HACK) -Zhigh-mem -Zomf -g "; \
     799                export  BOOT_CFLAGS="$(OMFSPEC_HACK) -Zhigh-mem -Zomf -g "; \
     800                export      LDFLAGS="$(OMFSPEC_HACK) -Zhigh-mem -Zomf -g -Zexe -Zcrtdll -Zstack 1024"; \
     801                export BOOT_LDFLAGS="$(OMFSPEC_HACK) -Zhigh-mem -Zomf -g -Zexe -Zcrtdll -Zstack 1024"; \
    802802                $(subst \,/,$(COMSPEC)) ; \
    803803                mv -f $(PATH_BUILTTOOLS)/omfhackbin $(PATH_BUILTTOOLS)/omfhack
     
    818818        if test ! -d $(PATH_BUILTTOOLS)/omfhackbin; then echo "no omfhackbin"; exit 1; fi ; \
    819819        unset GCCLOAD ; export GCC_OMF="real" ; echo GCC_OMF=$$GCC_OMF; $(MAKE) $(MAKEOPT) -C $(PATH_OBJ)/gccomf \
    820             LIBGCC2_DEBUG_CFLAGS="-g -Zaout" \
    821                       CFLAGS="$(OMFSPEC_HACK) -Zomf -g " \
    822                     CXXFLAGS="$(OMFSPEC_HACK) -Zomf -g " \
    823                  BOOT_CFLAGS="$(OMFSPEC_HACK) -Zomf -g " \
    824                      LDFLAGS="$(OMFSPEC_HACK) -Zomf -g -Zexe -Zcrtdll -Zstack 1024" \
    825                 BOOT_LDFLAGS="$(OMFSPEC_HACK) -Zomf -g -Zexe -Zcrtdll -Zstack 1024" \
     820            LIBGCC2_DEBUG_CFLAGS="-g -Zhigh-mem -Zaout" \
     821                      CFLAGS="$(OMFSPEC_HACK) -Zhigh-mem -Zomf -g " \
     822                    CXXFLAGS="$(OMFSPEC_HACK) -Zhigh-mem -Zomf -g " \
     823                 BOOT_CFLAGS="$(OMFSPEC_HACK) -Zhigh-mem -Zomf -g " \
     824                     LDFLAGS="$(OMFSPEC_HACK) -Zhigh-mem -Zomf -g -Zexe -Zcrtdll -Zstack 1024" \
     825                BOOT_LDFLAGS="$(OMFSPEC_HACK) -Zhigh-mem -Zomf -g -Zexe -Zcrtdll -Zstack 1024" \
    826826                -e all
    827827        mv -f $(PATH_BUILTTOOLS)/omfhackbin $(PATH_BUILTTOOLS)/omfhack
  • trunk/src/emx/Makefile

    • Property cvs2svn:cvs-rev changed from 1.37 to 1.38
    r809 r810  
    103103LD = gcc
    104104# Linker flags
    105 LDFLAGS     = $(LDFLAGS.$(MODE)) $(LDFLAGS.KIND) -Zmap -Zstack 1024 $(LIBS)
     105LDFLAGS     = $(LDFLAGS.$(MODE)) $(LDFLAGS.KIND) -Zmap -Zstack 1024 -Zhigh-mem $(LIBS)
    106106LDFLAGS.DLL = $(LDFLAGS) -Zdll
    107107# Linker flags for different build modes
  • trunk/src/emx/include/emx/umalloc.h

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r809 r810  
    77extern "C" {
    88#endif
     9
     10/* include all we need here to make life easier. */
     11#include <stddef.h>
     12#include <umalloc.h>
     13#include <sys/builtin.h>
     14#include <sys/fmutex.h>
     15#include <sys/rmutex.h>
     16#include <sys/uflags.h>
    917
    1018/* =========================== Introduction =========================== */
     
    221229
    222230#define _UM_TILE_OK(p,s)      (_UM_TILE_ALIGNED ((p), (s)) \
    223                                && _UM_TILE_TILED ((p), (s))) 
     231                               && _UM_TILE_TILED ((p), (s)))
    224232
    225233/* Compute the smallest number X such that P will be aligned on a A
     
    603611
    604612/* Note that _um_regular_heap is declared in <umalloc.h>.
    605    _um_tiled_heap isn't, so we declare it here. */
     613   the others aren't, so we declare them here. */
    606614
    607615extern Heap_t _um_tiled_heap;
     616extern Heap_t _um_high_heap;
     617extern Heap_t _um_low_heap;
    608618
    609619
     
    710720int _um_find_bucket (size_t);
    711721void _um_free_maybe_lock (void *, int);
    712 void _um_init_default_regular_heap (void);
    713 void _um_init_default_tiled_heap (void);
     722Heap_t _um_init_default_regular_heap (void);
     723Heap_t _um_init_default_tiled_heap (void);
    714724void *_um_lump_alloc (Heap_t, size_t, size_t, unsigned);
    715725void _um_lump_coalesce_free (Heap_t, struct _um_lump *, struct _um_seg *,
     
    725735int _um_walk_no_lock (Heap_t, _um_callback2 *, void *);
    726736
     737
     738/** @group Low Memory Heap Routines.
     739 * Intended for internal LIBC use. First call to any of these routines
     740 * will initialize the heap.
     741 * @{ */
     742void *  _lmalloc(size_t);
     743void *  _lcalloc(size_t, size_t);
     744void *  _lrealloc(void *, size_t);
     745Heap_t  _linitheap(void);
     746/** @} */
     747
     748/** @group High Memory Heap Routines.
     749 * Intended for internal LIBC use. First call to any of these routines
     750 * will initialize the heap.
     751 * @{ */
     752void *  _hmalloc(size_t);
     753void *  _hcalloc(size_t, size_t);
     754void *  _hrealloc(void *, size_t);
     755Heap_t  _hinitheap(void);
     756void *  __libc_HimemDefaultAlloc(Heap_t Heap, size_t *pcb, int *pfClean);
     757void    __libc_HimemDefaultRelease(Heap_t Heap, void *pv, size_t cb);
     758int     __libc_HasHighMem(void);
     759/** @} */
     760
     761
     762/** @group Default Heap Voting.
     763 * @{ */
     764void    __libc_HeapVote(int fDefaultHeapInHighMem);
     765void    __libc_HeapEndVoting(void);
     766int     __libc_HeapGetResult(void);
     767/** @} */
     768
     769
     770
    727771/* Inline functions. */
    728772
     
    763807{
    764808  /* Use the 'syscall' write for safest possible path. */
    765   extern int __write (int handle, const void *buf, size_t nbytes); 
     809  extern int __write (int handle, const void *buf, size_t nbytes);
    766810  __write (2, "\r\n!_um_abort!", 13);
    767811  if (pszmsg)
    768812    {
    769813      const char *psz = pszmsg;
    770       while (*psz) 
     814      while (*psz)
    771815        psz++;
    772816      __write (2, " ", 1);
  • trunk/src/emx/include/stdlib.h

    • Property cvs2svn:cvs-rev changed from 1.15 to 1.16
    r809 r810  
    180180 */
    181181#if __POSIX_VISIBLE /* >= ??? */
    182 /* int   posix_memalign(void **, size_t, size_t); (ADV) */
     182int      posix_memalign(void **, size_t, size_t); /* bird: we implement this. */
    183183/** @todo int    rand_r(unsigned *);    */              /* (TSF) */
    184184int      setenv(const char *, const char *, int);
  • trunk/src/emx/include/umalloc.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r809 r810  
    4747#define _HEAP_TILED     0x02
    4848#define _HEAP_SHARED    0x04
     49#define _HEAP_HIGHMEM   0x08 /* advisory flag */
    4950
    5051#define _BLOCK_CLEAN    1
     
    9596void *_utmalloc (Heap_t, size_t);
    9697
    97 
    9898#if defined (__cplusplus)
    9999}
  • trunk/src/emx/src/lib/alias/alias.smak

    • Property cvs2svn:cvs-rev changed from 1.11 to 1.12
    r809 r810  
    1010.TKIND  := aout
    1111.INSDIR := lib/
    12 .TARGET := c_alias.a
     12.TARGET := libc_alias.a
    1313include common.smak
    1414
     
    2222# For every aliased function create a .o file containing the alias
    2323# and add it to the target library.
    24 $.$(.TARG): $.stmp-libc-std
     24##$.$(.TARG): $.stmp-libc-std
     25## Depending on the timestamp kind of sucks, now we depend on the
     26## header, which is better but will require libc to be build first.
     27$.$(.TARG): $.libc-std.h
    2528        $(call RM,$@)
    26         @$(call DO.STDALIAS,_strcasecmp,__std_stricmp,$.strcasecmp.o)
    27         @$(call DO.STDALIAS,_strncasecmp,__std_strnicmp,$.strncasecmp.o)
    28         @$(call DO.STDALIAS,_itoa,__std_ltoa,$.itoa.o)
    29         @$(call DO.STDALIAS,__itoa,__std_ltoa,$._itoa.o)
    30         @$(call DO.STDALIAS,__Exit,__exit,$.__Exit.o)
    31         @$(foreach x,$(ALIAS.FUNCS),\
    32           $(call DO.STDALIAS,_$x,__std_$x,$.$x.o)$(NL))
    33         @$(foreach x,$(ALIAS._FUNCS),\
    34           $(call DO.STDALIAS,__$x,__std_$x,$._$x.o)$(NL))
    35         $(AR) $(ARFLAGS) $@ $(addprefix $.,\
    36           strcasecmp.o strncasecmp.o itoa.o _itoa.o __Exit.o \
    37           $(addsuffix .o,$(ALIAS.FUNCS) $(addprefix _,$(ALIAS._FUNCS))))
    38         @$(call RM,$(addprefix $., \
    39           strcasecmp.o strncasecmp.o itoa.o _itoa.o __Exit.o \
    40           $(addsuffix .o,$(ALIAS.FUNCS) $(addprefix _,$(ALIAS._FUNCS)))))
     29        $(call MKDIR,$.aliases)
     30        $(call RM,$.aliases/*.o)
     31        $(call RM,$.aliases/*.s)
     32        @$(call DO.STDALIAS,_strcasecmp,__std_stricmp,$.aliases/strcasecmp.o)
     33        @$(call DO.STDALIAS,_strncasecmp,__std_strnicmp,$.aliases/strncasecmp.o)
     34        @$(call DO.STDALIAS,_itoa,__std_ltoa,$.aliases/itoa.o)
     35        @$(call DO.STDALIAS,__itoa,__std_ltoa,$.aliases/_itoa.o)
     36        @$(call DO.STDALIAS,__Exit,__exit,$.aliases/__Exit.o)
     37        for i in $(ALIAS.FUNCS); do \
     38                echo "Aliasing _$$i to __std_$$i ..."; \
     39        echo ".stabs \"_$$i\",11,0,0,0;.stabs \"__std_$$i\",1,0,0,0;" > $.aliases/_$$i.s; \
     40        if as -o $.aliases/_$$i.o $.aliases/_$$i.s; then \
     41                else false; \
     42                fi \
     43        done
     44        for i in $(ALIAS._FUNCS); do \
     45                echo "Aliasing __$$i to __std_$$i ..."; \
     46                echo ".stabs \"__$$i\",11,0,0,0;.stabs \"__std_$$i\",1,0,0,0;" > $.aliases/__$$i.s; \
     47                if as -o $.aliases/__$$i.o $.aliases/__$$i.s; then \
     48                else false; \
     49                fi \
     50        done
     51        $(AR) $(ARFLAGS) $@ $.aliases/*.o
    4152
    4253include mkomflib.smak
  • trunk/src/emx/src/lib/app/app.smak

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r809 r810  
    77
    88.TKIND  := aout
    9 .TARGET := c_app.a
     9.TARGET := libc_app.a
    1010.TSRC   := $(wildcard src/lib/app/*.c)
    1111.TCF    := -I$.
     
    2020
    2121.TKIND  := aout prof
    22 .TARGET := c_app_p.a
     22.TARGET := libc_app_p.a
    2323include mklib.smak
  • trunk/src/emx/src/lib/io/eadread.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r809 r810  
    1111#include <errno.h>
    1212#include <sys/ead.h>
     13#include <emx/umalloc.h>
    1314#include "ea.h"
    1415
     
    147148    {
    148149      reftype = ENUMEA_REFTYPE_PATH;
    149       fileref = path;
     150      i = strlen(path) + 1;
     151      fileref = alloca(i);
     152      memcpy(fileref, path, i);
    150153    }
    151154  else
     
    162165        {
    163166          dena_buf_size += 0x20000; /* DosEnumAttribute is broken */
    164           dena_buf = realloc (dena_buf, dena_buf_size);
     167          dena_buf = _lrealloc (dena_buf, dena_buf_size);
    165168          if (dena_buf == NULL)
    166169            {
  • trunk/src/emx/src/lib/libc.def

    • Property cvs2svn:cvs-rev changed from 1.21 to 1.22
    r809 r810  
    4343    "__sys_pid" @23
    4444    "__sys_ppid" @24
    45     "__sys_private_heap" @25
     45    "__um_high_heap" @25
    4646    "__sys_thread_table" @26
    4747    "__sys_top_heap_obj" @27
     
    7272    "___locale_lconv" @52
    7373    "___locale_time" @53
    74     "__sys_virtual_address_limit" @54
    75     "___pfnDosOpenL" @55
    76     "___pfnDosSetFileLocksL" @56
    77     "___pfnDosSetFilePtrL" @57
    78     "___pfnDosSetFileSizeL" @58
     74    "__um_low_heap" @54
     75    "__rand48_add" @55
     76    "__rand48_mult" @56
     77    "__rand48_seed" @57
    7978
    8079; code
     
    8988    "__init1_fdinit" @108
    9089    "__init1_tmp" @109
    91     "___init_environ" @110
    92     "___init_ret" @111
     90    "__std_posix_memalign" @110
     91    "__lrealloc" @111
    9392    "__init_streams" @112
    9493    "___initthread" @113
     
    812811    "__std_unsetenv" @831
    813812    "__std_lockf" @832
    814     "___init_largefileio" @833
     813    "__lmalloc" @833
    815814    "__std_fseeko" @834
    816815    "__std_ftello" @835
     
    835834    "__dorand48" @854
    836835    "__std_srand48" @855
    837     "__rand48_add" @856
    838     "__rand48_mult" @857
    839     "__rand48_seed" @858
    840     "__std_drand48" @859
    841     "__std_erand48" @860
    842     "__std_jrand48" @861
    843     "__std_lcong48" @862
    844     "__std_lrand48" @863
    845     "__std_mrand48" @864
    846     "__std_nrand48" @865
    847     "__std_seed48" @866
    848     "__std_qsort_r" @867
     836    "__std_drand48" @856
     837    "__std_erand48" @857
     838    "__std_jrand48" @858
     839    "__std_lcong48" @859
     840    "__std_lrand48" @860
     841    "__std_mrand48" @861
     842    "__std_nrand48" @862
     843    "__std_seed48" @863
     844    "__std_qsort_r" @864
     845    "__hcalloc" @865
     846    "__hinitheap" @866
     847    "__hmalloc" @867
     848    "__hrealloc" @868
     849    "__lcalloc" @869
     850    "__linitheap" @870
  • trunk/src/emx/src/lib/libc.smak

    • Property cvs2svn:cvs-rev changed from 1.26 to 1.27
    r809 r810  
    2525.MDESC  := The C library
    2626
    27 .TARGET := c_p.a
     27.TARGET := libc_p.a
    2828.TKIND  := aout prof
    2929.TSRC   := $(libc.TSRC.$(CPU)) $(libc.TSRC)
     
    3434include mklib.smak
    3535
    36 # Build c.a last since LIBC.DLL needs .OBJS from c.a
    37 .TARGET := c.a
     36# Build libc.a last since LIBC.DLL needs .OBJS from libc.a
     37.TARGET := libc.a
    3838.TKIND  := aout
    3939.TKEEP  := 1
     
    4949LIBC.STUBARG    := $(if $(LIBC.STUB),-Zlinker -STUB:$(LIBC.STUB))
    5050LIBC.DLL        := $.omf/libc$(VH)$(VM).dll
    51 LIBC.IMPLIB     := $.omf/c_dll.lib $.aout/c_dll.a
     51LIBC.IMPLIB     := $.omf/libc_dll.lib $.aout/libc_dll.a
    5252LIBC.DEF        := $.omf/libc.def
    53 LIBC.OBJS       := $.omf/src/lib/startup/386/dll0.obj $.omf/src/lib/startup/dllinit.obj
    54 LIBC.LIBS       := $.omf/c.lib $.omf/c_app.lib
    55 LIBC.DEPS       := $(LIBC.STUB) $.omf/c_alias.lib
     53LIBC.OBJS       := $.omf/src/lib/startup/dll0hi.obj $.omf/src/lib/startup/dllinit.obj
     54LIBC.LIBS       := $.omf/libc.lib $.omf/libc_app.lib
     55LIBC.DEPS       := $(LIBC.STUB) $.omf/libc_alias.lib
    5656LIBC.DLL.OBJS   :=
    5757LIBC.DIRS       := $(sort $(dir $(LIBC.OBJS) $(LIBC.DEPS) $(LIBC.DLL.OBJS)))
     
    5959LIBC.PRF.DLL    := $(LIBC.DLL:.dll=.prf)
    6060LIBC.PRF.DEF    := $.omf/libc.prf.def
    61 LIBC.PRF.OBJS   := $.omf/src/lib/startup/386/dll0.obj $.omf-prof/src/lib/startup/dllinit.obj
    62 LIBC.PRF.LIBS   := $.omf-prof/c_p.lib $.omf-prof/c_app_p.lib
     61LIBC.PRF.OBJS   := $.omf/src/lib/startup/dll0hi.obj $.omf-prof/src/lib/startup/dllinit.obj
     62LIBC.PRF.LIBS   := $.omf-prof/libc_p.lib $.omf-prof/libc_app_p.lib
    6363LIBC.PRF.DEPS   := $(LIBC.DEPS)
    6464LIBC.PRF.DIRS   := $(sort $(dir $(LIBC.PRF.OBJS) $(LIBC.PRF.DEPS)))
     
    9595        @$(call FECHO,$@,EXPORTS)
    9696        $(call DO.EMXEXP,$(filter %.lib,$^),$@)
     97        sed -e "/\"___pfn/d" -e "/\"__sys_/d" -e "/\"___libc_/d" $@ > $@.tmp
     98        mv -f $@.tmp $@
    9799        krx.exe src/lib/dlllegacy.cmd -e "_DLL_InitTerm" $@ src/lib/libc.def
    98100
     
    114116        echo $@         
    115117
    116 # LIBC .def file (two steps).
     118# LIBC.PREF .def file
    117119$(LIBC.PRF.DEF): $(LIBC.DEF)
    118120        $(call RM,$@)
     
    134136        echo $@         
    135137
    136 # LIBC .def file (two steps)
     138# LIBC.ELH .def file
    137139# Man! This sucks! Isn't there support for inline files (<<\nfile\n<<) in GNU MAKE?
    138 # Even M$/IBM nmake     have that.
     140# Even M$/IBM nmake     have that. ;-)
    139141# And no, I couldn't care less about performance with this type of DLL.
    140142$(LIBC.ELH.DEF): $(LIBC.DEF) src/lib/libc.smak
     
    213215.PHONY: libc-dll
    214216all: libc-dll
    215 libc-dll: emxbind emxexp app alias libc os2 \
     217libc-dll: emxbind emxexp app alias libc os2 os2@omf \
    216218                        $(LIBC.DIRS) $(LIBC.DLL) $(LIBC.IMPLIB) \
    217219                        $(LIBC.PRF.DIRS) $(LIBC.PRF.DLL) \
     
    244246
    245247# How libc-std.h can be auto-generated.
    246 # Unfortunately, we cannot use c.a to find out all _std_ names since
    247 # c.a itself depends on this header file. Thus we have to scan all source
     248# Unfortunately, we cannot use libc.a to find out all _std_ names since
     249# libc.a itself depends on this header file. Thus we have to scan all source
    248250# files for _STD() macros invocations. Fortunately, gawk rulez forever thus
    249251# this happens in just a fraction of second.
  • trunk/src/emx/src/lib/malloc/heapchk.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r809 r810  
    1515  _UM_MT_DECL
    1616  int rc1, rc2;
     17  Heap_t    heap_reg = _UM_DEFAULT_REGULAR_HEAP;
     18  Heap_t    heap_tiled = _UM_DEFAULT_TILED_HEAP;
    1719
    1820  /* Initialize the heap pointers, in case _heapchk() is called by a
    1921     new thread before malloc(). */
    2022
    21   if (_UM_DEFAULT_REGULAR_HEAP == NULL)
    22     _um_init_default_regular_heap ();
    23   if (_UM_DEFAULT_TILED_HEAP == NULL)
    24     _um_init_default_tiled_heap ();
     23  if (heap_reg == NULL)
     24    heap_reg = _um_init_default_regular_heap ();
     25  if (heap_tiled == NULL)
     26    heap_tiled = _um_init_default_tiled_heap ();
    2527
    2628  /* First check the regular heap. */
    2729
    28   rc1 = _uheapchk (_UM_DEFAULT_REGULAR_HEAP);
     30  rc1 = _uheapchk (heap_reg);
    2931  if (rc1 != _HEAPOK && rc1 != _HEAPEMPTY)
    3032    return rc1;
     
    4042     heaps is non-empty. */
    4143
    42   rc2 = _uheapchk (_UM_DEFAULT_TILED_HEAP);
     44  rc2 = _uheapchk (heap_tiled);
    4345  if (rc2 == _HEAPEMPTY)
    4446    return rc1;
  • trunk/src/emx/src/lib/malloc/heapmin.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r809 r810  
    1414{
    1515  _UM_MT_DECL
     16  Heap_t    heap_reg = _UM_DEFAULT_REGULAR_HEAP;
    1617
    17   if (_UM_DEFAULT_REGULAR_HEAP == NULL)
    18     _um_init_default_regular_heap ();
    19   return _uheapmin (_UM_DEFAULT_REGULAR_HEAP);
     18  if (heap_reg == NULL)
     19    heap_reg = _um_init_default_regular_heap ();
     20  return _uheapmin (heap_reg);
    2021}
  • trunk/src/emx/src/lib/malloc/heapwalk.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r809 r810  
    22
    33#include "libc-alias.h"
    4 #include <stdlib.h>
    5 #include <stddef.h>
    64#include <umalloc.h>
    7 #include <sys/builtin.h>        /* For <sys/fmutex.h> */
    8 #include <sys/fmutex.h>         /* For <sys/rmutex.h> */
    9 #include <sys/rmutex.h>
    105#include <emx/umalloc.h>
    116#include <emx/thread.h>
     
    149{
    1510  _UM_MT_DECL
    16   int rc;
     11  Heap_t    heap_reg = _UM_DEFAULT_REGULAR_HEAP;
     12  Heap_t    heap_tiled = _UM_DEFAULT_TILED_HEAP;
     13  int       rc;
    1714
    1815  /* Initialize the heap pointers, in case _heap_walk() is called by a
    1916     new thread before malloc(). */
    2017
    21   if (_UM_DEFAULT_REGULAR_HEAP == NULL)
    22     _um_init_default_regular_heap ();
    23   if (_UM_DEFAULT_TILED_HEAP == NULL)
    24     _um_init_default_tiled_heap ();
     18  if (heap_reg == NULL)
     19    heap_reg = _um_init_default_regular_heap ();
     20  if (heap_tiled == NULL)
     21    heap_tiled = _um_init_default_tiled_heap ();
    2522
    2623  /* First walk through the regular heap. */
    2724
    28   rc = _uheap_walk (_UM_DEFAULT_REGULAR_HEAP, callback);
     25  rc = _uheap_walk (heap_reg, callback);
    2926  if (rc != 0)
    3027    return rc;
     
    3330     heap, return the regular heap's status. */
    3431
    35   if (_UM_DEFAULT_REGULAR_HEAP == _UM_DEFAULT_TILED_HEAP
    36       || _UM_DEFAULT_TILED_HEAP == NULL)
     32  if (heap_reg == heap_tiled || heap_tiled == NULL)
    3733    return rc;
    3834
    3935  /* Walk through the tiled heap. */
    4036
    41   return _uheap_walk (_UM_DEFAULT_TILED_HEAP, callback);
     37  return _uheap_walk (heap_tiled, callback);
    4238}
  • trunk/src/emx/src/lib/malloc/initr.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r809 r810  
    22
    33#include "libc-alias.h"
    4 #include <stdlib.h>
    5 #include <stddef.h>
    64#include <umalloc.h>
    7 #include <sys/builtin.h>        /* For <sys/fmutex.h> */
    8 #include <sys/fmutex.h>         /* For <sys/rmutex.h> */
    9 #include <sys/rmutex.h>
     5#include <emx/umalloc.h>
    106#include <sys/smutex.h>
    11 #include <sys/uflags.h>
    12 #include <emx/umalloc.h>
    137#include <emx/thread.h>
    148
    15 /* This is the default regular heap. */
    16 
     9/** This is the default regular heap. */
    1710Heap_t _um_regular_heap;
    1811
     12/**
     13 * Sets the default regular heap for the current thread and perhaps
     14 * even the system.
     15 *
     16 * Now because of the voting procedure we do not set the _um_regular_heap nor
     17 * the per thread variable until the voting is completed. There for make sure
     18 * to use the returned value not the one in the per thread or system variables!
     19 *
     20 * @returns Default heap for the thread.
     21 */
     22Heap_t _um_init_default_regular_heap(void)
     23{
     24    _UM_MT_DECL
     25    static _smutex  lock;
     26    Heap_t          heap_reg = _UM_DEFAULT_REGULAR_HEAP;
    1927
    20 void _um_init_default_regular_heap (void)
    21 {
    22   _UM_MT_DECL
    23   void *memory;
    24   Heap_t h;
    25   static _smutex lock;
     28    /*
     29     * Is there actually anything left to be done?
     30     */
     31    if (!heap_reg)
     32    {
     33        int     vote = __libc_HeapGetResult();
     34        if (vote >= 0)
     35        {
     36            /*
     37             * Is system wide default heap initiated?
     38             */
     39            _smutex_request(&lock);
     40            heap_reg = _um_regular_heap;
     41            if (!heap_reg)
     42            {
     43                if (vote)
     44                {
     45                    /*
     46                     * Use high memory heap.
     47                     */
     48                    _um_regular_heap = heap_reg = _hinitheap();
     49                }
     50                else
     51                {
     52                    /*
     53                     * Use low memory heap.
     54                     */
     55                    _um_regular_heap = heap_reg = _linitheap();
     56                }
     57            }
     58            _smutex_release(&lock);
    2659
    27   _smutex_request (&lock);
    28 
    29   /* Create the regular heap if it hasn't been created by another
    30      thread between the check of _UM_DEFAULT_REGULAR_HEAP by our
    31      caller and obtaining the semaphore. */
    32 
    33   if (_UM_DEFAULT_REGULAR_HEAP == NULL)
    34     {
    35       if (_um_regular_heap == NULL)
     60            /*
     61             * Set the per thread default.
     62             */
     63            _UM_DEFAULT_REGULAR_HEAP = heap_reg;
     64        }
     65        else
    3666        {
    37           _uflags (_UF_SBRK_MODEL, _UF_SBRK_ARBITRARY);
    38           memory = sbrk (_INITIAL_DEFAULT_HEAP_SIZE);
    39           if (memory == (void *)-1)
    40             abort ();
    41           h = _ucreate2 (memory, _INITIAL_DEFAULT_HEAP_SIZE,
    42                          !_BLOCK_CLEAN, _HEAP_REGULAR,
    43                          _um_default_alloc, _um_default_release,
    44                          _um_default_expand, _um_default_shrink);
    45           if (h == NULL)
    46             abort ();
    47           if (_uopen (h) != 0)
    48             abort ();
    49           _um_regular_heap = h;
     67            /*
     68             * The voting is not yet over, so we must return the low heap.
     69             * We do not set either the per thread or system defaults!
     70             */
     71            heap_reg = _um_low_heap;
     72            if (!heap_reg)
     73                heap_reg = _linitheap();
    5074        }
    51 
    52       _UM_DEFAULT_REGULAR_HEAP = _um_regular_heap;
    5375    }
    5476
    55   _smutex_release (&lock);
     77    return heap_reg;
    5678}
     79
  • trunk/src/emx/src/lib/malloc/initt.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r809 r810  
    22
    33#include "libc-alias.h"
    4 #include <stdlib.h>
    5 #include <stddef.h>
    6 #include <umalloc.h>
    7 #include <sys/builtin.h>        /* For <sys/fmutex.h> */
    8 #include <sys/fmutex.h>         /* For <sys/rmutex.h> */
    9 #include <sys/rmutex.h>
     4#include <emx/umalloc.h>
    105#include <sys/smutex.h>
    11 #include <sys/uflags.h>
    12 #include <emx/umalloc.h>
    136#include <emx/thread.h>
    147
    15 /* This is the default tiled heap. */
    16 
     8/** This is the default tiled heap. */
    179Heap_t _um_tiled_heap = NULL;
    1810
     11/**
     12 * Initialize the default tiled heap for the current thread.
     13 *
     14 * Sets _um_tiled_heap to _um_low_heap if zero. The per thread
     15 * default tiled heap is set to _um_tiled_heap.
     16 *
     17 * @returns Heap handle on success.
     18 */
     19Heap_t _um_init_default_tiled_heap(void)
     20{
     21    _UM_MT_DECL
     22    Heap_t          heap_tiled;
     23    static _smutex  lock;
    1924
    20 void _um_init_default_tiled_heap (void)
    21 {
    22   _UM_MT_DECL
    23   static _smutex lock;
    24 
    25   _smutex_request (&lock);
    26 
    27   /* Create the tiled heap if it hasn't been created by another thread
    28      between the check of _UM_DEFAULT_TILED_HEAP by our caller and
    29      obtaining the semaphore. */
    30 
    31   if (_UM_DEFAULT_TILED_HEAP == NULL)
     25    /*
     26     * Create the tiled heap if it hasn't been created by another thread
     27     * between the check of _UM_DEFAULT_TILED_HEAP by our caller and
     28     * obtaining the semaphore.
     29     */
     30    heap_tiled = _UM_DEFAULT_TILED_HEAP;
     31    if (heap_tiled == NULL)
    3232    {
    33       if (_um_tiled_heap == NULL)
     33        _smutex_request(&lock);
     34        if (_um_tiled_heap == NULL)
    3435        {
    35           /* Use the regular heap also as tiled heap. */
    36           _um_init_default_regular_heap ();
    37           _um_tiled_heap = _um_regular_heap;
     36            /* Use the low heap also as tiled heap. */
     37            _linitheap();
     38            _um_tiled_heap = _um_low_heap;
    3839        }
    3940
    40 
    41       _UM_DEFAULT_TILED_HEAP = _um_tiled_heap;
     41        _UM_DEFAULT_TILED_HEAP = heap_tiled = _um_tiled_heap;
     42        _smutex_release(&lock);
    4243    }
    4344
    44   _smutex_release (&lock);
     45    return heap_tiled;
    4546}
     47
  • trunk/src/emx/src/lib/malloc/malloc.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r809 r810  
    1414{
    1515  _UM_MT_DECL
     16  Heap_t    heap_reg = _UM_DEFAULT_REGULAR_HEAP;
    1617
    17   if (_UM_DEFAULT_REGULAR_HEAP == NULL)
    18     _um_init_default_regular_heap ();
    19   return _umalloc (_UM_DEFAULT_REGULAR_HEAP, size);
     18  if (heap_reg == NULL)
     19    heap_reg = _um_init_default_regular_heap ();
     20  return _umalloc (heap_reg, size);
    2021}
  • trunk/src/emx/src/lib/malloc/realloc.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r809 r810  
    1515    return malloc (new_size);
    1616  else
    17     return _um_realloc (block, new_size, 4, 0);
     17    return _um_realloc (block, new_size, new_size < 32 ? 4 : 16, 0);
    1818}
  • trunk/src/emx/src/lib/malloc/ucalloc.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r809 r810  
    1818  void *block;
    1919  unsigned flags;
     20  unsigned align;
    2021
    2122  assert (h->magic == _UM_MAGIC_HEAP);
     
    2728    return NULL;
    2829
     30  align = (size < 32 ? 4 : 16);
     31
    2932  _um_heap_lock (h);
    3033  flags = _UMFI_ZERO;
    3134  if (h->type & _HEAP_TILED)
    3235    flags |= _UMFI_TILED;
    33   block = _um_alloc_no_lock (h, bytes, 4, flags);
     36  block = _um_alloc_no_lock (h, bytes, align, flags);
    3437  _um_heap_unlock (h);
    3538  return block;
  • trunk/src/emx/src/lib/malloc/ucreate2.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r809 r810  
    2222
    2323  /* Check the TYPE argument.  It must not contain any bits but
    24      _HEAP_REGULAR, _HEAP_TILED, and _HEAP_SHARED.  Exactly one of
    25      _HEAP_REGULAR and _HEAP_TILED must be set. */
     24     _HEAP_REGULAR, _HEAP_TILED, _HEAP_SHARED, and _HEAP_HIGHMEM.
     25     Exactly one of _HEAP_REGULAR and _HEAP_TILED must be set.
     26     _HEAP_HIGHMEM and _HEAP_TILED are mutaly exclusive. */
    2627
    27   if (type & ~(_HEAP_REGULAR|_HEAP_TILED|_HEAP_SHARED))
     28  if (type & ~(_HEAP_REGULAR|_HEAP_TILED|_HEAP_SHARED|_HEAP_HIGHMEM))
    2829    return NULL;
    2930  t = type & (_HEAP_REGULAR|_HEAP_TILED);
    3031  if (t != _HEAP_REGULAR && t != _HEAP_TILED)
    3132      return NULL;
     33  if ((type & (_HEAP_HIGHMEM|_HEAP_TILED)) == (_HEAP_HIGHMEM|_HEAP_TILED))
     34      return NULL;
     35
    3236
    3337  /* Check the SIZE argument. */
  • trunk/src/emx/src/lib/malloc/umalloc.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r809 r810  
    1515  void *block;
    1616  unsigned flags;
     17  unsigned align = (size < 32 ? 4 : 16);
    1718
    1819  assert (h->magic == _UM_MAGIC_HEAP);
    1920  if (h->magic != _UM_MAGIC_HEAP)
    2021    return NULL;
     22
    2123  _um_heap_lock (h);
    2224  flags = 0;
    2325  if (h->type & _HEAP_TILED)
    2426    flags |= _UMFI_TILED;
    25   block = _um_alloc_no_lock (h, size, 4, flags);
     27  block = _um_alloc_no_lock (h, size, align, flags);
    2628  _um_heap_unlock (h);
    2729  return block;
  • trunk/src/emx/src/lib/malloc/utcalloc.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r809 r810  
    1919  if (h->magic != _UM_MAGIC_HEAP)
    2020    return NULL;
     21  if (h->type & _HEAP_HIGHMEM)
     22    return NULL;
    2123
    2224  bytes = count * size;
  • trunk/src/emx/src/lib/malloc/utmalloc.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r809 r810  
    1818  if (h->magic != _UM_MAGIC_HEAP)
    1919    return NULL;
     20  if (h->type & _HEAP_HIGHMEM)
     21    return NULL;
    2022  _um_heap_lock (h);
    2123  block = _um_alloc_no_lock (h, size, 4, _UMFI_TILED);
  • trunk/src/emx/src/lib/misc/dirent.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r809 r810  
    1111#include <emx/io.h>
    1212#include <emx/syscalls.h>
     13#include <emx/umalloc.h>
    1314
    1415
     
    115116         */
    116117        cch = strlen(psz) + 1;
    117         dp = malloc(sizeof(struct _dircontents) + cch);
     118        dp = _hmalloc(sizeof(struct _dircontents) + cch);
    118119        if (dp == NULL)
    119120        {
  • trunk/src/emx/src/lib/misc/getopt.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r809 r810  
    66#include <string.h>
    77#include <emx/getopt.h>
     8#include <emx/umalloc.h>
    89
    910char *optarg          = NULL;
     
    4748      if (optmode == GETOPT_ANY)
    4849        {
    49           options = (char **)malloc (argc * sizeof (char *));
    50           non_options = (char **)malloc (argc * sizeof (char *));
     50          options = (char **)_hmalloc (argc * sizeof (char *));
     51          non_options = (char **)_hmalloc (argc * sizeof (char *));
    5152          if (options == NULL || non_options == NULL)
    5253            {
  • trunk/src/emx/src/lib/os2_386/os2.smak

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r809 r810  
    66.INSDIR := lib/
    77
    8 .TARGET := os2.a
     8.TARGET := libos2.a
    99.TKIND  := aout
    1010.TSRC.386 := $(wildcard src/lib/os2_386/*.s)
    11 .TSRC   := $(.TSRC.$(CPU)) $(wildcard src/lib/os2_386/*.c)
     11.TSRC   := $(.TSRC.$(CPU)) $(wildcard src/lib/os2_386/*.c) $(wildcard src/lib/os2_386/safe/*.c)
    1212.TCF    := -Wno-unused -s
    1313.IMPS   := $(wildcard src/lib/os2_386/*.imp)
     
    1515include mkimplib.smak
    1616
    17 .TARGET := os2_p.a
     17.TARGET := libos2_p.a
    1818.TKIND  := aout prof
    1919.TCF    := -Wno-unused
    2020include mkimplib.smak
     21
  • trunk/src/emx/src/lib/startup/386/crt0.s

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r809 r810  
    3838
    3939__text:
     40#if defined (HIGHMEM)
     41    pushl    $1     /* vote for high mem for default stack */
     42#else
     43    pushl    $0     /* veto agains high mem for default stack */
     44#endif
    4045        call    ___init_app
    4146    /* esp points to main() call frame. */
  • trunk/src/emx/src/lib/startup/386/dll0.s

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r809 r810  
    3636
    3737__text:
    38 /** @todo ___init_dll shouldn't be called, only _DLL_InitTerm. */
     38    cmpl    $0, 8(%esp)
     39    jz      do_common_init
     40    jmp     do_initterm
     41
     42    /*
     43     * Nonstandard: we're doing some early initializations.
     44     */
     45do_common_init:
     46#if defined (HIGHMEM)
     47    pushl    $1     /* vote for high mem for default stack */
     48#else
     49    pushl    $0     /* veto against high mem for default stack */
     50#endif
    3951        call    ___init_dll
     52    add     $4, %esp
     53    orl     %eax, %eax
     54    jz      do_initterm
     55    /*
     56     * __init_dll() failed - fail the dll loading.
     57     */
     58    xorl    %eax, %eax
     59    ret
     60
     61    /*
     62     * Standard initialization.
     63     */
     64do_initterm:
    4065        cld
    4166    jmp     _DLL_InitTerm
    4267
     68
    4369        .data
    44 
    4570__data:
    4671        .long   0xba0bab        // Magic number (error detection)
  • trunk/src/emx/src/lib/startup/startup.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r809 r810  
    111111 * LIBCxy.DLL:
    112112 *      - dll0.s gets control and calls __init_dll in sys/__initdll.c
     113 *          - __init_dll calls __libc_HeapVote() to do the heap voting.
    113114 *          - __init_dll calls __init_os_version() to set _osminor,_osmajor globals.
    114115 *          - __init_dll initiates _sys_pid and _sys_ppid globals.
    115  *          - __init_dll creates _sys_heap_fmutex.
    116  *          - __init_dll allocates and initialized the _sys_private_heap heap, which is
    117  *            operated by DosSubSetMem() and it's friends.
     116 *          - __init_dll creates _sys_heap_fmutex and _sys_gmtxHimem.
    118117 *          - __init_dll then initializes _sys_thread_table and calls __newthread() in
    119118 *            sys/__newthread.c to create the thread 1 entry.
     119 *              - __newthread() will call __sys_newthread() which inits the high memory
     120 *                heap (or low if no high mem) when calling _hmalloc().
    120121 *          - __init_dll calls __init_environ() which initializes environ and _org_environ.
    121122 *          - __init_dll then intializes _sys_clock0_ms with the current MS count.
     
    130131 * Your.DLL:
    131132 *      - dll0.s gets control and calls __init_dll() in sys/__initdll.c
    132  *          - __init_dll returns at once since already done during LIBCxy.DLL init.
     133 *          - __init_dll calls __libc_HeapVote() to do the heap voting.
     134 *          - __init_dll then returns since already done during LIBCxy.DLL init.
    133135 *      - dll0.s calls _DLL_InitTerm in startup/dllinit.c.
    134136 *          - _DLL_InitTerm calls _CRT_init() in startup/startup.c to initialize the CRT.
     
    141143 *      - crt0.s gets control and calls ___init_app in sys/386/appinit.s which forwards
    142144 *        the call to __init() in sys/__init.c.
    143  *          - __init() calls __init_dll() which returns at once because of LIBCxy.DLL init.
     145 *          - __init() calls __init_dll() to do common initiation.
     146 *              - __init_dll calls __libc_HeapVote() to do the heap voting.
     147 *              - __init_dll then returns since already done during LIBCxy.DLL init.
    144148 *          - __init() parse the commandline to figure out how much stack to use for array
    145149 *            and the argument copy.
  • trunk/src/emx/src/lib/startup/startup.smak

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r809 r810  
    99include common.smak
    1010
    11 .OBJS += $(addprefix $.$(.TKIND.DIR)src/lib/startup/,mcrt0.o gcrt0.o) \
     11.OBJS += $(addprefix $.$(.TKIND.DIR)src/lib/startup/,mcrt0.o gcrt0.o crt0hi.o dll0hi.o) \
    1212  $(addprefix $.omf/src/lib/startup/,mcrt0.obj gcrt0.obj \
    13   $(CPU)/crt0.obj $(CPU)/dll0.obj)
     13  $(CPU)/crt0.obj $(CPU)/dll0.obj crt0hi.obj dll0hi.obj)
    1414.DIRS := $(sort $(dir $(.OBJS)))
    1515TARGDIRS += $(.DIRS)
     
    2121        $(call CP,$^,$(dir $@))
    2222
     23$.aout/src/lib/startup/crt0hi.o: src/lib/startup/386/crt0.s
     24        $(call DO.COMPILE.s, -DHIGHMEM)
     25       
     26$.aout/src/lib/startup/dll0hi.o: src/lib/startup/386/dll0.s
     27        $(call DO.COMPILE.s, -DHIGHMEM)
     28                               
    2329$.aout/src/lib/startup/mcrt0.o: src/lib/startup/386/crt0.s
    2430        $(call DO.COMPILE.s, -DMCRT0)
     
    3036        $(call RM,tmp1.o tmp2.o)
    3137
    32 # This rule doesnt work if the aout/src/lib/startup/ directory does not
     38# This rule doesn't work if the aout/src/lib/startup/ directory does not
    3339# exist when make is started, and is ignored because of this (shit!)
    3440#$.omf/src/lib/startup/%.obj: $.aout/src/lib/startup/%.o
     
    4046$.omf/src/lib/startup/gcrt0.obj: $.aout/src/lib/startup/gcrt0.o
    4147        $(call DO.EMXOMF,-m__text)
     48$.omf/src/lib/startup/dll0hi.obj: $.aout/src/lib/startup/dll0hi.o
     49        $(call DO.EMXOMF,-m__text)
     50$.omf/src/lib/startup/crt0hi.obj: $.aout/src/lib/startup/crt0hi.o
     51        $(call DO.EMXOMF,-m__text)
    4252$.omf/src/lib/startup/386/dll0.obj: $.aout/src/lib/startup/386/dll0.o
    4353        $(call DO.EMXOMF,-m__text)
  • trunk/src/emx/src/lib/sys/386/__init_environ.s

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r809 r810  
    3636 *
    3737 */
    38     .globl ___init_environ
    39 ___init_environ:
     38    .globl __sys_init_environ
     39__sys_init_environ:
    4040    pushl   %ebp
    4141    movl    %esp, %ebp
     
    6868    movl    %esi, %ecx
    6969    subl    %esp, %ecx
    70     / DosSubAllocMem(_sys_private_heap, &_org_environ, size);
     70    / _org_environ = _hmalloc(size);
    7171    pushl   %ecx
    72     pushl   $__org_environ
    73     pushl   __sys_private_heap
    74     call    DosSubAllocMem
    75     addl    $12, %esp
     72    call    __hmalloc
     73    addl    $4, %esp
    7674    orl     %eax, %eax
    77     jnz     env_ret
     75    jz      env_ret
     76    mov     %eax, __org_environ
    7877
    7978    /*
  • trunk/src/emx/src/lib/sys/386/appinit.s

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r809 r810  
    22
    33        .globl  ___init_app
    4         .globl  ___init_ret
     4        .globl  __sys_init_ret
    55
    66        .data
     
    1616        hlt
    1717
    18 ___init_ret:
     18__sys_init_ret:
    1919        movl    4(%esp), %esp
    2020        jmp     *L_ret
  • trunk/src/emx/src/lib/sys/386/systhrea.s

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r809 r810  
    88
    99__sys_thread:
     10        /** @todo change this to use a TLS variable */
     11        movl    %fs, %ecx
     12        movl    $DosTIB, %eax
     13        movl    %eax, %fs
    1014        fs
    1115        movl    12, %eax                /* ptib2 */
    1216        movl    0(%eax), %edx           /* TID */
    1317        movl    __sys_thread_table(,%edx,4), %eax
     18        movl    %ecx, %fs
    1419        testl   %eax, %eax
    1520        jz      1f
     
    2126        pushl   %edx                    /* tid */
    2227        call    ___sys_newthread
    23         addl    $4, %esp
     28        addl    $8, %esp
    2429        popl    %edx
    2530        movl    __sys_thread_table(,%edx,4), %eax
  • trunk/src/emx/src/lib/sys/__endthread.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r809 r810  
    22
    33#include "libc-alias.h"
     4#include <stdlib.h>
    45#define INCL_DOS
    56#define INCL_FSMACROS
     
    1112{
    1213  thread_data *tp;
    13   FS_VAR();
    1414
    1515  if (tid < MAX_THREADS && _sys_thread_table[tid] != NULL)
    1616    {
    1717      tp = _sys_thread_table[tid];
    18       FS_SAVE_LOAD();
    1918      if (tp->fd.hdir != HDIR_CREATE)
    2019        {
     20          FS_VAR();
     21          FS_SAVE_LOAD();
    2122          DosFindClose (tp->fd.hdir);
     23          FS_RESTORE();
    2224          tp->fd.hdir = HDIR_CREATE;
    2325        }
    24       DosSubFreeMem (_sys_private_heap, tp, sizeof (thread_data));
    25       FS_RESTORE();
     26      free (tp);
    2627      _sys_thread_table[tid] = NULL;
    2728    }
  • trunk/src/emx/src/lib/sys/__init.c

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r809 r810  
    1010*/
    1111
     12
     13/*******************************************************************************
     14*   Header Files                                                               *
     15*******************************************************************************/
    1216#include "libc-alias.h"
    1317#define INCL_DOS
     
    2125#include <alloca.h>
    2226
     27
     28/* All globals is to be defined in this object file. */
    2329#define EXTERN
    2430#define INIT(x) = x
    25 
    2631#include "syscalls.h"
    2732
    2833
    29 extern int __init_dll(void);
    30 extern void volatile __init_ret(void *stack);
     34/*******************************************************************************
     35*   Internal Functions                                                         *
     36*******************************************************************************/
    3137static int parse_args(const char *src, char **argv, char *pool);
    3238
     39
     40/*******************************************************************************
     41*   Global Variables                                                           *
     42*******************************************************************************/
    3343/** argument count found by parse_args(). */
    3444static int argc;
    3545
     46
     47/*******************************************************************************
     48*   Defined Constants And Macros                                               *
     49*******************************************************************************/
    3650/** Helper macros for parse args
    3751 * @{ */
     
    128142 * magic done in sys/386/appinit.s. The top of the returned stack have a layout
    129143 * as seen in struct stackframe below - start of struct is main() callframe.
     144 * @param   fDefaultHeapInHighMem   If set the application is open to put the default
     145 *                                  heap in high memory.
     146 *                                  If clear the application veto against putting the
     147 *                                  default heap in high memory.
     148 *                                  Passed on to __init_dll().
    130149 * @ingroup startup
    131150 */
    132 void __init(void)
     151void __init(int fDefaultHeapInHighMem)
    133152{
    134153    /** top of stack unpon 'return' from this function. */
     
    155174    /*
    156175     * Do the common initialization in case we're linked statically.
     176     * Then end the heap voting.
    157177     */
    158     if (__init_dll())
     178    if (__init_dll(fDefaultHeapInHighMem))
    159179        goto failure;
     180
     181    __libc_HeapEndVoting();
     182
    160183
    161184    /*
     
    200223
    201224    /* Return to the program. */
    202     __init_ret(pStackFrame);
     225    _sys_init_ret(pStackFrame);
    203226
    204227failure:
  • trunk/src/emx/src/lib/sys/__initdll.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r809 r810  
    3232#include "syscalls.h"
    3333
     34/* Make this function an weak external. */
     35#pragma weak __init_largefileio
     36
     37
    3438/*******************************************************************************
    3539*   Global Variables                                                           *
     
    3943
    4044
    41 /*******************************************************************************
    42 *   External Functions                                                         *
    43 *******************************************************************************/
    44 extern int __init_environ(const char *pszEnv);
    45 extern void __init_largefileio(void) __attribute__((weak));
    46 
    47 
    4845/**
    4946 * Common init code for crt0 and dll0.
    5047 * This should perhaps be a part of _CRT_init.
    5148 */
    52 int __init_dll(void)
     49int __init_dll(int fDefaultHeapInHighMem)
    5350{
    5451    ULONG   aul[2];
     
    6057
    6158    /*
    62      * Only called once.
     59     * Heap voting.
     60     */
     61    __libc_HeapVote(fDefaultHeapInHighMem);
     62
     63    /*
     64     * The rest must only be executed once.
    6365     */
    6466    if (initialized)
     
    7678     * Check for high memory (>512MB) support.
    7779     */
    78     _sys_virtual_address_limit = 0;
     80    _sys_gcbVirtualAddressLimit = 0;
    7981    if (    !DosQuerySysInfo(QSV_VIRTUALADDRESSLIMIT, QSV_VIRTUALADDRESSLIMIT, &aul[0], sizeof(aul[0]))
    8082        &&  aul[0] > 512)
    81         _sys_virtual_address_limit = aul[0] * 1024*1024;
     83        _sys_gcbVirtualAddressLimit = aul[0] * 1024*1024;
    8284
    8385    /*
     
    9496
    9597    /*
    96      * Initialize the heap.  Here, we only create the semaphore
    97      * (while having only one thread).  The heap will be created by __sbrk().
     98     * Initialize the heap semaphores.
    9899     */
    99100    if (_fmutex_create(&_sys_heap_fmutex, 0) != 0)
    100101        return -1;
    101 
    102     /*
    103      * LIBC Private heap, used for org_environ and per thread data.
    104      * Let's try put it in high memory...
    105      */
    106     /** @todo Redo this private heap stuff. */
    107     rc = DosAllocMem(&_sys_private_heap, SYS_PRIVATE_HEAP_SIZE,
    108                      _sys_virtual_address_limit
    109                         ? PAG_READ | PAG_WRITE | OBJ_ANY
    110                         : PAG_READ | PAG_WRITE);
    111     if (rc != 0)
    112         return -1;
    113     rc = DosSubSetMem(_sys_private_heap,
    114                       DOSSUB_INIT | DOSSUB_SPARSE_OBJ | DOSSUB_SERIALIZE,
    115                       SYS_PRIVATE_HEAP_SIZE);
    116     if (rc != 0)
     102    if (_fmutex_create(&_sys_gmtxHimem, 0) != 0)
    117103        return -1;
    118104
     
    128114     * Setup environment (org_environ and _STD(environ))
    129115     */
    130     rc = __init_environ(ppib->pib_pchenv);
     116    rc = _sys_init_environ(ppib->pib_pchenv);
    131117    if (rc)
    132118        return -1;
     
    137123     * large file suppoort enabled.
    138124     */
    139     if (__init_largefileio)
    140         __init_largefileio();
     125    if (_sys_init_largefileio)
     126        _sys_init_largefileio();
    141127
    142128    /*
  • trunk/src/emx/src/lib/sys/__newthread.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r809 r810  
    22
    33#include "libc-alias.h"
     4#include <os2emx.h>
    45#include <errno.h>
    5 #define INCL_DOS
    6 #define INCL_FSMACROS
    7 #include <os2emx.h>
    86#include <emx/syscalls.h>
     7#include <emx/umalloc.h>
    98#include "syscalls.h"
    109
     
    1312int __sys_newthread (int tid, int *errnop)
    1413{
    15   ULONG rc;
    1614  void *data;
    17   FS_VAR();
    1815
    1916  if (tid >= MAX_THREADS)
     
    2320      return -1;
    2421    }
    25   FS_SAVE_LOAD();
    26   rc = DosSubAllocMem (_sys_private_heap, &data, sizeof (thread_data));
    27   FS_RESTORE();
    28   if (rc != 0)
     22  data = _hmalloc (sizeof (thread_data));
     23  if (!data)
    2924    {
    30       _sys_set_errno (rc);
     25      errno = ENOMEM;
    3126      return -1;
    3227    }
  • trunk/src/emx/src/lib/sys/__open.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r809 r810  
    9191    {
    9292        LONGLONG cbInitialTmp = cbInitial;
    93         rc = __pfnDosOpenL(pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
     93        int     cch = strlen(pszFile);
     94        char *  pszFile_safe = alloca(cch + 1);
     95        if (pszFile_safe)
     96        {
     97            strcpy(pszFile_safe, pszFile);
     98            rc = __pfnDosOpenL(pszFile_safe, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
     99        }
     100        else
     101            rc = ERROR_NOT_ENOUGH_MEMORY;
    94102    }
    95103    else
  • trunk/src/emx/src/lib/sys/__pipe.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r809 r810  
    44#define INCL_DOSQUEUES
    55#define INCL_FSMACROS
     6#include <os2safe.h>
    67#include <os2emx.h>
    78#include <emx/syscalls.h>
  • trunk/src/emx/src/lib/sys/__read.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r809 r810  
    33#include "libc-alias.h"
    44#define INCL_FSMACROS
     5#define INCL_ERRORS
    56#include <os2emx.h>
     7#include <stdlib.h>
     8#include <memory.h>
     9#include <emx/umalloc.h>
    610#include <emx/syscalls.h>
    711#include "syscalls.h"
     
    1115  ULONG rc;
    1216  ULONG n;
     17  void *pvBuf_safe = NULL;
    1318  FS_VAR();
    1419
     20  /*
     21   * Devices doesn't like getting high addresses.
     22   */
     23  if ((unsigned)buf >= 512*1024*1024)
     24  {
     25    ULONG   ulType = 0;
     26    ULONG   ulAttr = 0;
     27    FS_SAVE_LOAD();
     28    rc = DosQueryHType(handle, &ulType, &ulAttr);
     29    FS_RESTORE();
     30
     31    if (!rc && (ulType & 0xf) == HANDTYPE_DEVICE)
     32      {
     33        pvBuf_safe = _lmalloc(nbyte);
     34        if (!pvBuf_safe)
     35            return ERROR_NOT_ENOUGH_MEMORY;
     36        memcpy(pvBuf_safe, buf, nbyte);
     37      }
     38  }
     39
    1540  FS_SAVE_LOAD();
    16   rc = DosRead (handle, buf, nbyte, &n);
     41  rc = DosRead (handle, pvBuf_safe ? pvBuf_safe : buf, nbyte, &n);
    1742  FS_RESTORE();
     43  if (pvBuf_safe)
     44    {
     45      memcpy(buf, pvBuf_safe, nbyte);
     46      free(pvBuf_safe);
     47    }
    1848  if (rc == 0)
    1949    return n;
  • trunk/src/emx/src/lib/sys/__write.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r809 r810  
    33#include "libc-alias.h"
    44#define INCL_FSMACROS
     5#define INCL_ERRORS
    56#include <os2emx.h>
     7#include <memory.h>
     8#include <stdlib.h>
    69#include <emx/syscalls.h>
     10#include <emx/umalloc.h>
    711#include "syscalls.h"
    812
     
    1115  ULONG rc;
    1216  ULONG n;
     17  void *pvBuf_safe = NULL;
    1318  FS_VAR();
     19
     20  /*
     21   * Devices doesn't like getting high addresses.
     22   */
     23  if ((unsigned)buf >= 512*1024*1024)
     24  {
     25    ULONG   ulType = 0;
     26    ULONG   ulAttr = 0;
     27    FS_SAVE_LOAD();
     28    rc = DosQueryHType(handle, &ulType, &ulAttr);
     29    FS_RESTORE();
     30
     31    if (!rc && (ulType & 0xf) == HANDTYPE_DEVICE)
     32      {
     33        if (nbyte > 256)
     34          { /* use heap for large buffers */
     35            pvBuf_safe = _lmalloc(nbyte);
     36            if (!pvBuf_safe)
     37                return ERROR_NOT_ENOUGH_MEMORY;
     38            memcpy(pvBuf_safe, buf, nbyte);
     39            buf = pvBuf_safe;
     40          }
     41        else
     42          { /* use stack for small buffers */
     43            pvBuf_safe = alloca(nbyte);
     44            memcpy(pvBuf_safe, buf, nbyte);
     45            buf = pvBuf_safe;
     46            pvBuf_safe = NULL;
     47          }
     48      }
     49  }
    1450
    1551  FS_SAVE_LOAD();
    1652  rc = DosWrite (handle, buf, nbyte, &n);
    1753  FS_RESTORE();
     54
     55  if (pvBuf_safe)
     56      free(pvBuf_safe);
    1857  if (rc == 0)
    1958    return n;
  • trunk/src/emx/src/lib/sys/largefileio.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r809 r810  
    3737#define INCL_BASE
    3838#include <os2.h>
     39#include "syscalls.h"
    3940
    4041
     
    6263 * @author  knut st. osmundsen <bird-srcspam@anduin.net>
    6364 */
    64 void __init_largefileio(void)
     65void _sys_init_largefileio(void)
    6566{
    6667    HMODULE     hmod = NULLHANDLE;
  • trunk/src/emx/src/lib/sys/remove.c

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r809 r810  
    55#define INCL_FSMACROS
    66#define INCL_DOSMISC
     7#include <os2safe.h>
    78#include <os2emx.h>
    89#include <emx/syscalls.h>
  • trunk/src/emx/src/lib/sys/syscalls.h

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r809 r810  
    5454 * address space size in bytes.
    5555 *
    56  * Initiated by __init_dll(). */
    57 EXTERN unsigned long _sys_virtual_address_limit;
     56 * Initiated by __init_dll().
     57 */
     58EXTERN unsigned long    _sys_gcbVirtualAddressLimit;
     59
    5860
    5961/* The top heap object.  This points into _sys_heap_objs[] or is NULL.
     
    6567   objects are managed in LIFO fashion. */
    6668
    67 EXTERN struct heap_obj _sys_heap_objs[MAX_HEAP_OBJS];
     69EXTERN struct heap_obj  _sys_heap_objs[MAX_HEAP_OBJS];
    6870
    6971/* This is the number of heap objects. */
    7072
    71 EXTERN unsigned _sys_heap_obj_count;
     73EXTERN unsigned         _sys_heap_obj_count;
    7274
    7375/* This variable can be initialized by the application to control the
    7476   size of the heap object(s). */
    7577
    76 extern unsigned _sys_heap_size;
     78extern unsigned         _sys_heap_size;
    7779
    7880
     
    158160#define MAX_THREADS 1024
    159161
    160 /* This mutex semaphore protects the heap. */
    161 #ifdef _FMC_SHARED
    162 EXTERN _fmutex _sys_heap_fmutex;
    163 #endif
    164 EXTERN void *_sys_private_heap INIT (NULL);
    165162EXTERN thread_data *_sys_thread_table[MAX_THREADS];
    166163
     
    172169void _sys_set_errno (unsigned long rc);
    173170void _sys_get_clock (unsigned long *ms);
     171
     172/** @group Heap stuff.
     173 * @{ */
    174174ULONG _sys_expand_heap_obj_by (ULONG incr);
    175175ULONG _sys_expand_heap_by (ULONG incr, ULONG sbrk_model);
     
    177177ULONG _sys_shrink_heap_by (ULONG decr, ULONG sbrk_model);
    178178ULONG _sys_shrink_heap_obj_by (ULONG decr);
     179#ifdef _FMC_SHARED
     180/** This mutex semaphore protects the heap. */
     181EXTERN _fmutex          _sys_heap_fmutex;
     182/** Mutex semaphore protecting the list of high memory big blocks. */
     183EXTERN _fmutex          _sys_gmtxHimem;
     184#endif
     185/** @} */
    179186
     187
     188/** @group Init functions
     189 * @{ */
     190extern int              __init_dll(int fDefaultHeapInHighMem);
     191extern void volatile    _sys_init_ret(void *stack);
     192extern int              _sys_init_environ(const char *pszEnv);
     193extern void             _sys_init_largefileio(void);
     194/** @} */
  • trunk/src/emx/src/libos2/os2.smak

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r809 r810  
    66.INSDIR := lib/
    77
    8 .TARGET := os2.a
     8.TARGET := libos2.a
    99.TKIND  := aout
    1010.TSRC.386 := $(wildcard src/lib/os2_386/*.s)
    11 .TSRC   := $(.TSRC.$(CPU)) $(wildcard src/lib/os2_386/*.c)
     11.TSRC   := $(.TSRC.$(CPU)) $(wildcard src/lib/os2_386/*.c) $(wildcard src/lib/os2_386/safe/*.c)
    1212.TCF    := -Wno-unused -s
    1313.IMPS   := $(wildcard src/lib/os2_386/*.imp)
     
    1515include mkimplib.smak
    1616
    17 .TARGET := os2_p.a
     17.TARGET := libos2_p.a
    1818.TKIND  := aout prof
    1919.TCF    := -Wno-unused
    2020include mkimplib.smak
     21
  • trunk/src/gcc/gcc/config/i386/emx.h

    • Property cvs2svn:cvs-rev changed from 1.21 to 1.22
    r809 r810  
    267267  "%(cpp_cpu) "                                                                \
    268268  "%{posix:-D_POSIX_SOURCE} "                                                  \
    269   "%{Zmt*:} "                                                                  \
     269  "%{Zmt*:} %{Zlow-mem:} "                                                     \
    270270  "%{pg:-D__GPROF__} "                                                         \
    271271  "%{mepilogue:-D__EPILOGUE__} "                                               \
     
    315315/* Override the default crt0 files.  */
    316316#define STARTFILE_SPEC                                                         \
    317   "%{Zdll:dll0%O%{Zomf:bj}%s}"                                                 \
     317  "%{Zdll:dll0%{Zhigh-mem:hi}%O%{Zomf:bj}%s}"                                  \
    318318  "%{!Zdll:%{pg:gcrt0%O%{Zomf:bj}%s}"                                          \
    319           "%{!pg:%{pn:gcrt0%O%{Zomf:bj}%s}%{!pn:%{p:mcrt0%O%{Zomf:bj}%s}%{!p:crt0%O%{Zomf:bj}%s}}}"\
     319          "%{!pg:%{pn:gcrt0%O%{Zomf:bj}%s}%{!pn:%{p:mcrt0%O%{Zomf:bj}%s}%{!p:crt0%{Zhigh-mem:hi}%O%{Zomf:bj}%s}}}"\
    320320         " %{Zbin-files:binmode%O%{Zomf:bj}%s} %{Zsmall-conv:smallcnv%O%{Zomf:bj}%s}}"
    321321
     
    348348  "%(cpp_cpu) "                                                                \
    349349  "%{posix:-D_POSIX_SOURCE} "                                                  \
    350   "%{Zmt*:} "                                                                  \
     350  "%{Zmt*:} %{Zlow-mem:} "                                                     \
    351351  "%{pg:-D__GPROF__} "                                                         \
    352352  "%{mepilogue:-D__EPILOGUE__} "                                               \
     
    396396/* Override the default crt0 files.  */
    397397#define STARTFILE_SPEC                                                         \
    398   "%{Zdll:dll0%O%{!Zaout:bj}%s}"                                               \
     398  "%{Zdll:dll0%{Zhigh-mem:hi}%O%{!Zaout:bj}%s}"                                        \
    399399  "%{!Zdll:%{pg:gcrt0%O%{!Zaout:bj}%s}"                                        \
    400           "%{!pg:%{pn:gcrt0%O%{!Zaout:bj}%s}%{!pn:%{p:mcrt0%O%{!Zaout:bj}%s}%{!p:crt0%O%{!Zaout:bj}%s}}}"\
     400          "%{!pg:%{pn:gcrt0%O%{!Zaout:bj}%s}%{!pn:%{p:mcrt0%O%{!Zaout:bj}%s}%{!p:crt0%{Zhigh-mem:hi}%O%{!Zaout:bj}%s}}}"\
    401401         " %{Zbin-files:binmode%O%{!Zaout:bj}%s} %{Zsmall-conv:smallcnv%O%{!Zaout:bj}%s}}"
    402402
Note: See TracChangeset for help on using the changeset viewer.