Changeset 2805
- Timestamp:
- Sep 1, 2006, 2:50:12 AM (19 years ago)
- Location:
- trunk/libc
- Files:
-
- 4 added
- 16 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/libc/Config.kmk
r2741 r2805 74 74 # Templates 75 75 # 76 ## @todo I need recursive inheritance! 76 77 TEMPLATE_libc = 77 78 TEMPLATE_libc_TOOL = GCC3 … … 80 81 TEMPLATE_libc_DEPS = $(LIBC-STD.H) 81 82 TEMPLATE_libc_INST = usr/lib/ 82 TEMPLATE_libc_CFLAGS = $(TEMPLATE_lib_CFLAGS) -std=gnu99 83 TEMPLATE_libc_CFLAGS = $(TEMPLATE_lib_CFLAGS) -std=gnu99 -Wall -Wundef -Wmissing-prototypes 84 TEMPLATE_libc_CFLAGS.os2 = $(TEMPLATE_lib_CFLAGS.os2) -mstack-arg-probe 85 TEMPLATE_libc_CFLAGS.release = $(TEMPLATE_lib_CFLAGS.release) -O3 -mcpu=pentium 83 86 84 87 TEMPLATE_libc.logstrict = -
trunk/libc/include/InnoTekLIBC/fork.h
r2787 r2805 566 566 * management so multiple LIBC versions can share the same module lists. */ 567 567 __LIBC_PFORKMODULE pNext; 568 /** The module handle. */ 569 unsigned hmod; 568 570 /** Reserved space to make it 32 byte aligned - must be zero. */ 569 unsigned auReserved[ 8];571 unsigned auReserved[7]; 570 572 } __LIBC_FORKMODULE; 571 573 … … 588 590 * @returns 0 on normal process startup. 589 591 * 590 * @returns 1 on forked child process startup .592 * @returns 1 on forked child process startup (not executable module). 591 593 * The caller should respond by not calling any _DLL_InitTerm 592 * or similar constructs. If fExecutable the call will not 593 * return in this situation. 594 * or similar constructs. 594 595 * 595 596 * @returns negative on failure. … … 599 600 * @param pModule Pointer to the fork module structure for the 600 601 * module which is to registered. 601 * @param fExecutable Indicator that the call origins from crt0.s and 602 * the final forking should start. The function 603 * will not return if this flag is set and the process 604 * was forked. 605 * 606 */ 607 int __libc_ForkRegisterModule(__LIBC_PFORKMODULE pModule, int fExecutable); 602 */ 603 int __libc_ForkRegisterModule(__LIBC_PFORKMODULE pModule); 608 604 609 605 -
trunk/libc/include/klibc/io.h
r2742 r2805 1 /* $Id: $ */ 2 /** @file 3 * 4 * kLIBC I/O 5 * 6 * Copyright (c) 2006 knut st. osmundsen <bird@innotek.de> 7 * 8 * 9 * This file is part of kLIBC. 10 * 11 * kLIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * kLIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with kLIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 26 1 27 #ifndef __klibc_io_h__ 2 28 #define __klibc_io_h__ -
trunk/libc/include/klibc/logstrict.h
r2745 r2805 282 282 /** Backend IO APIs. */ 283 283 #define __LIBC_LOG_GRP_BACK_IO 26 284 /** Backend OS/2 Files (the file handle class). */ 285 #define __LIBC_LOG_GRP_BACK_OS2FILE 26 284 286 /** Init/Term APIs and Events. */ 285 287 #define __LIBC_LOG_GRP_INITTERM 27 -
trunk/libc/src/kNIX/Makefile.kmk
r2748 r2805 88 88 $(PATH_LIBC_SRC)/kNIX/os2/b_ioFileControl.c \ 89 89 $(PATH_LIBC_SRC)/kNIX/os2/b_ioFileOpen.c \ 90 $(PATH_LIBC_SRC)/kNIX/os2/b_ioFileSizeSet.c \91 $(PATH_LIBC_SRC)/kNIX/os2/b_ioSeek.c \92 90 $(PATH_LIBC_SRC)/kNIX/os2/b_ldrClose.c \ 93 91 $(PATH_LIBC_SRC)/kNIX/os2/b_ldrOpen.c \ … … 106 104 $(PATH_LIBC_SRC)/kNIX/os2/b_signalPending.c \ 107 105 $(PATH_LIBC_SRC)/kNIX/os2/b_signalQueue.c \ 108 $(PATH_LIBC_SRC)/kNIX/os2/b_signalSendPid.c \109 106 $(PATH_LIBC_SRC)/kNIX/os2/b_signalStack.c \ 110 107 $(PATH_LIBC_SRC)/kNIX/os2/b_signalSuspend.c \ … … 139 136 $(PATH_LIBC_SRC)/kNIX/os2/filefind.c \ 140 137 $(PATH_LIBC_SRC)/kNIX/os2/filesys.c \ 138 $(PATH_LIBC_SRC)/kNIX/os2/fhOS2File.c \ 141 139 $(PATH_LIBC_SRC)/kNIX/os2/fs.c \ 142 140 $(PATH_LIBC_SRC)/kNIX/os2/fsync.c \ 143 141 $(PATH_LIBC_SRC)/kNIX/os2/getppid.c \ 144 $(PATH_LIBC_SRC)/kNIX/os2/heap.c \145 $(PATH_LIBC_SRC)/kNIX/os2/heapdump.c \146 142 $(PATH_LIBC_SRC)/kNIX/os2/heaphigh.c \ 147 $(PATH_LIBC_SRC)/kNIX/os2/heapsize.c \148 143 $(PATH_LIBC_SRC)/kNIX/os2/hooks.c \ 149 144 $(PATH_LIBC_SRC)/kNIX/os2/libcfork.c \ … … 182 177 $(PATH_LIBC_SRC)/kNIX/os2/__os_version.c \ 183 178 $(PATH_LIBC_SRC)/kNIX/os2/__pipe.c \ 184 $(PATH_LIBC_SRC)/kNIX/os2/__read.c \185 179 $(PATH_LIBC_SRC)/kNIX/os2/__read_kbd.c \ 186 180 $(PATH_LIBC_SRC)/kNIX/os2/__select.c \ … … 191 185 $(PATH_LIBC_SRC)/kNIX/os2/__wait.c \ 192 186 $(PATH_LIBC_SRC)/kNIX/os2/__waitpid.c \ 193 $(PATH_LIBC_SRC)/kNIX/os2/__write.c \194 187 $(PATH_LIBC_SRC)/kNIX/os2/386/appinit.s \ 195 188 $(PATH_LIBC_SRC)/kNIX/os2/386/thunk0.s \ -
trunk/libc/src/kNIX/b_fs.h
r2733 r2805 217 217 #pragma pack() 218 218 219 220 /** @group Large File Support - API pointers.221 * Test if the function pointer is set before calling it.222 * For APIs which take a structure level parameter, check __pfnDosOpenL.223 * @{ */224 extern ULONG (* _System __libc_gpfnDosOpenL)(PCSZ pszFileName, PHFILE phFile, PULONG pulAction, LONGLONG llFileSize, ULONG ulAttribute, ULONG ulOpenFlags, ULONG ulOpenMode, PEAOP2 pEABuf);225 extern ULONG (* _System __libc_gpfnDosSetFilePtrL)(HFILE hFile, LONGLONG llOffset, ULONG ulOrigin, PLONGLONG pllPos);226 extern ULONG (* _System __libc_gpfnDosSetFileSizeL)(HFILE hFile, LONGLONG cbSize);227 extern ULONG (* _System __libc_gpfnDosSetFileLocksL)(HFILE hFile, __const__ FILELOCKL *pflUnlock, __const__ FILELOCKL *pflLock, ULONG ulTimeout, ULONG flFlags);228 /** @} */229 219 230 220 #endif /* _OS2EMX_H */ -
trunk/libc/src/kNIX/b_processGetResourceLimit.c
r2748 r2805 82 82 { 83 83 #ifdef __OS2__ 84 int rc = __libc_back_sys_processGetResourceLimit(i nt iResId, struct rlimit *pLimit)84 int rc = __libc_back_sys_processGetResourceLimit(iResId, pLimit); 85 85 if (rc) 86 86 LIBCLOG_ERROR_RETURN_INT(rc); -
trunk/libc/src/kNIX/b_signalSendPid.c
r2742 r2805 31 31 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_SIGNAL 32 32 #include "kNIX.h" 33 #include <signal.h>34 #include <errno.h>35 #include <klibc/backend.h>36 #include <klibc/logstrict.h>37 33 #ifdef __OS2__ /* later on NT. */ 38 # include "b_signal.h"34 # include "os2/b_signal.h" 39 35 #endif 40 36 … … 70 66 * Differ between others and our self. 71 67 */ 72 if ( _sys_pid!= pid)68 if (fibGetPid() != pid) 73 69 rc = __libc_back_signalSendPidOther(pid, iSignalNo, NULL); 74 70 else -
trunk/libc/src/kNIX/filehandles.c
r2794 r2805 2 2 /** @file 3 3 * 4 * LIBCFile Handles.5 * 6 * Copyright (c) 200 3-2006 knut st. osmundsen <bird-srcspam@anduin.net>7 * 8 * 9 * This file is part of InnoTekLIBC.10 * 11 * InnoTekLIBC is free software; you can redistribute it and/or modify4 * kNIX File Handles. 5 * 6 * Copyright (c) 2006 knut st. osmundsen <bird@innotek.de> 7 * 8 * 9 * This file is part of kLIBC. 10 * 11 * kLIBC is free software; you can redistribute it and/or modify 12 12 * it under the terms of the GNU Lesser General Public License as published 13 13 * by the Free Software Foundation; either version 2 of the License, or 14 14 * (at your option) any later version. 15 15 * 16 * InnoTekLIBC is distributed in the hope that it will be useful,16 * kLIBC is distributed in the hope that it will be useful, 17 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the … … 20 20 * 21 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with InnoTekLIBC; if not, write to the Free Software22 * along with kLIBC; if not, write to the Free Software 23 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 24 * … … 29 29 * Header Files * 30 30 *******************************************************************************/ 31 #include "libc-alias.h"32 31 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_INITTERM 33 #ifdef __OS2__34 # define INCL_BASE35 # define INCL_ERRORS36 # define INCL_FSMACROS37 # include <os2.h>38 #endif39 #ifdef __NT__40 # include <klibc/nt/nt.h>41 #endif42 32 #include "kNIX.h" 43 #include <malloc.h> 44 #include <string.h> 45 #include <sys/fcntl.h> 46 #include <errno.h> 47 #include <klibc/io.h> 33 48 34 #include <InnoTekLIBC/fork.h> 49 35 #include <InnoTekLIBC/sharedpm.h> 50 36 #include <InnoTekLIBC/tcpip.h> 51 #include <emx/umalloc.h>52 37 #include "b_fs.h" 53 38 #include "b_dir.h" 54 39 55 #include <klibc/backend.h>56 #include <klibc/logstrict.h>57 40 58 41 -
trunk/libc/src/kNIX/kNIX.h
r2748 r2805 28 28 #define __kNIX_h__ 29 29 30 30 31 #include "libc-alias.h" 31 32 #ifdef __OS2__ 33 # include <klibc/os2/os2.h> 32 34 # include "os2/kNIXConfig.h" 33 35 #elif defined(__NT__) 36 # include <klibc/nt/nt.h> 34 37 # include "nt/kNIXConfig.h" 35 38 #else 36 39 # error "Port me! (or get the config right)" 37 40 #endif 41 #include <errno.h> 42 #include <malloc.h> 43 #include <string.h> 44 #include <signal.h> 45 #include <sys/fmutex.h> 46 #include <sys/fcntl.h> 47 #include <sys/resource.h> 48 #include <sys/time.h> 49 #include <sys/types.h> 38 50 #include <klibc/io.h> 51 #include <klibc/umalloc.h> 39 52 #include <klibc/backend.h> 40 #include <sys/fmutex.h> 53 #ifdef __LIBC_LOG_GROUP 54 # include <klibc/logstrict.h> 55 #endif 56 41 57 42 58 __BEGIN_DECLS … … 92 108 /** @} */ 93 109 110 111 /** @group Init Functions 112 * @{ */ 113 extern void __init(int fFlags); 114 extern int __init_dll(int fFlags, unsigned long hmod); 115 extern void /*volatile*/_sys_init_ret(void *stack) __attribute__((__noreturn__)); 116 extern int _sys_init_environ(const char *pszEnv); 117 extern void _sys_init_largefileio(void); 118 extern int __libc_fhInit(void); 119 /** @} */ 120 121 94 122 __END_DECLS 95 123 -
trunk/libc/src/kNIX/os2/fhOS2File.c
r2742 r2805 24 24 * 25 25 */ 26 27 28 /******************************************************************************* 29 * Header Files * 30 *******************************************************************************/ 31 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_OS2FILE 32 #include <klibc/os2/os2.h> 33 #include "../kNIX.h" 26 34 27 35 … … 91 99 if (pvBufSafe) 92 100 { 93 memcpy(pvBufSafe, pvBuf, cb Read); /* paranoia */94 rc = DosRead(pFH->hNative, pvBufSafe, cb Read, &cbActuallyRead);101 memcpy(pvBufSafe, pvBuf, cbToRead); /* paranoia */ 102 rc = DosRead(pFH->hNative, pvBufSafe, cbToRead, &cbActuallyRead); 95 103 memcpy(pvBuf, pvBufSafe, cbToRead); 96 104 free(pvBufSafe); … … 100 108 } 101 109 else 102 rc = DosRead(pFH->hNative, pvBuf Safe, cbRead, &cbActuallyRead);110 rc = DosRead(pFH->hNative, pvBuf, cbToRead, &cbActuallyRead); 103 111 104 112 … … 136 144 */ 137 145 int rc; 138 ULONG cb Written = 0;146 ULONG cbActuallyWritten = 0; 139 147 if ( (pFH->fFlags & __LIBC_FH_TYPEMASK) == F_DEV 140 148 && (uintptr_t)pvBuf >= 512*1024*1024) … … 143 151 if (pvBufSafe) 144 152 { 145 memcpy(pvBufSafe, pvBuf, cb Write);146 rc = DosWrite(pFH->hNative, pvBufSafe, cb Write, &cbWritten);153 memcpy(pvBufSafe, pvBuf, cbToWrite); 154 rc = DosWrite(pFH->hNative, pvBufSafe, cbToWrite, &cbActuallyWritten); 147 155 free(pvBufSafe); 148 156 } … … 151 159 } 152 160 else 153 rc = DosWrite(pFH->hNative, pvBuf Safe, cbRead, &cbWritten);161 rc = DosWrite(pFH->hNative, pvBuf, cbToWrite, &cbActuallyWritten); 154 162 155 163 … … 160 168 LIBCLOG_RETURN_MSG(0, "ret 0 *pcbWritten=%zu\n", *pcbWritten); 161 169 } 162 *pcb Read= 0;170 *pcbWritten = 0; 163 171 if (rc > 0) 164 172 rc = -__libc_native2errno(rc); … … 184 192 LONGLONG ll; 185 193 ULONG ul; 186 } u; 194 } u; 195 int rc; 187 196 #if OFF_MAX > LONG_MAX 188 197 if (__libc_gpfnDosSetFilePtrL) 189 rc = __libc_gpfnDosSetFilePtrL( hFile, off, iMethod, &u.ll);198 rc = __libc_gpfnDosSetFilePtrL(pFH->fh, off, iMethod, &u.ll); 190 199 else 191 200 { … … 196 205 } 197 206 u.off = 0; 198 rc = DosSetFilePtr( hFile, off, iMethod, &u.ul);207 rc = DosSetFilePtr(pFH->fh, off, iMethod, &u.ul); 199 208 } 200 209 #else 201 210 { 202 211 u.off = 0; 203 rc = DosSetFilePtr( hFile, off, iMethod, &u.ul);212 rc = DosSetFilePtr(pFH->fh, off, iMethod, &u.ul); 204 213 } 205 214 #endif … … 207 216 if (__predict_true(!rc)) 208 217 { 209 poffActual = u.off;218 *poffActual = u.off; 210 219 LIBCLOG_RETURN_INT(0); 211 220 } … … 321 330 */ 322 331 off_t cbCur; 323 int rc = getFileSize( fh, &cbCur);332 int rc = getFileSize(pFH->fh, &cbCur); 324 333 if (!rc) 325 334 { … … 329 338 * File size change needed. 330 339 */ 331 rc = setFileSize( fh, cbFile);340 rc = setFileSize(pFH->fh, cbFile); 332 341 if (!rc) 333 342 { … … 356 365 { 357 366 ULONG cb = cbLeft >= sizeof(__libc_gachZeros) ? sizeof(__libc_gachZeros) : cbLeft; 358 rc = DosWrite( fh, &__libc_gachZeros[0], cb, &cb);367 rc = DosWrite(pFH->fh, &__libc_gachZeros[0], cb, &cb); 359 368 cbLeft -= cb; 360 369 } 361 int rc2 = fhOs2FileSeek( fh, offSaved, SEEK_SET, &offIgnored);370 int rc2 = fhOs2FileSeek(pFH, offSaved, SEEK_SET, &offIgnored); 362 371 if (!rc && !rc2) 363 372 { … … 369 378 * Shit, we failed writing zeros. Try undo the expand operation. 370 379 */ 371 setFileSize( fh, cbCur);380 setFileSize(pFH->fh, cbCur); 372 381 if (rc2) 373 382 { 374 fhOs2FileSeek( fh, offSaved, SEEK_SET, &offIgnored);383 fhOs2FileSeek(pFH, offSaved, SEEK_SET, &offIgnored); 375 384 if (!rc) 376 385 rc = rc2; … … 400 409 static int fhOs2FileDuplicate(__LIBC_PFH pFH, int *pfhNew) 401 410 { 411 return -ENOSYS; 402 412 } 403 413 … … 415 425 static int fhOs2FileFileControl(__LIBC_PFH pFH, int iRequest, int iArg, int *prc) 416 426 { 417 427 return -ENOSYS; 418 428 } 419 429 … … 430 440 static int fhOs2FileIOControl(__LIBC_PFH pFH, int iIOControl, int iArg, int *prc) 431 441 { 432 442 return -ENOSYS; 433 443 } 434 444 … … 449 459 static int fhOs2FileSelect(int cFHs, struct fd_set *pRead, struct fd_set *pWrite, struct fd_set *pExcept, struct timeval *tv, int *prc) 450 460 { 451 461 return -ENOSYS; 452 462 } 453 463 -
trunk/libc/src/kNIX/os2/kNIX-os2.h
r2739 r2805 28 28 #define __os2_kNIX_os2_h__ 29 29 30 #include "../backend.h" /** @todo remove backend.h! */ 31 32 33 #ifdef INCL_DOSFILEMGR 34 /** @group Large File Support - API pointers. 35 * Test if the function pointer is set before calling it. 36 * For APIs which take a structure level parameter, check __pfnDosOpenL. 37 * @{ */ 38 extern ULONG (* _System __libc_gpfnDosOpenL)(PCSZ pszFileName, PHFILE phFile, PULONG pulAction, LONGLONG llFileSize, ULONG ulAttribute, ULONG ulOpenFlags, ULONG ulOpenMode, PEAOP2 pEABuf); 39 extern ULONG (* _System __libc_gpfnDosSetFilePtrL)(HFILE hFile, LONGLONG llOffset, ULONG ulOrigin, PLONGLONG pllPos); 40 extern ULONG (* _System __libc_gpfnDosSetFileSizeL)(HFILE hFile, LONGLONG cbSize); 41 extern ULONG (* _System __libc_gpfnDosSetFileLocksL)(HFILE hFile, __const__ FILELOCKL *pflUnlock, __const__ FILELOCKL *pflLock, ULONG ulTimeout, ULONG flFlags); 42 /** @} */ 43 #endif /* INCL_DOSFILEMGR */ 30 44 31 45 -
trunk/libc/src/kNIX/os2/libcfork.c
r2804 r2805 332 332 * @returns 0 on normal process startup. 333 333 * 334 * @returns 1 on forked child process startup .334 * @returns 1 on forked child process startup (not executable module). 335 335 * The caller should respond by not calling any _DLL_InitTerm 336 * or similar constructs. If fExecutable the call will not 337 * return in this situation. 336 * or similar constructs. 338 337 * 339 338 * @returns negative on failure. … … 343 342 * @param pModule Pointer to the fork module structure for the 344 343 * module which is to registered. 345 * @param fExecutable Indicator that the call origins from crt0.s and 346 * the final forking should start. The function 347 * will not return if this flag is set and the process 348 * was forked. 349 */ 350 int __libc_ForkRegisterModule(__LIBC_PFORKMODULE pModule, int fExecutable) 351 { 352 LIBCLOG_ENTER("pModule=%p:{.uVersion=%#x, .pfnAtFork=%p, .papParent1=%p, .papChild1=%p, .pvDataSegBase=%p, .pvDataSegEnd=%p, .fFlags=%#x, .pNext=%p} fExecutable=%d\n", 344 */ 345 int __libc_ForkRegisterModule(__LIBC_PFORKMODULE pModule) 346 { 347 LIBCLOG_ENTER("pModule=%p:{.uVersion=%#x, .pfnAtFork=%p, .papParent1=%p, .papChild1=%p, .pvDataSegBase=%p, .pvDataSegEnd=%p, .fFlags=%#x, .pNext=%p, .hmod=%#x}\n", 353 348 (void *)pModule, pModule->uVersion, (void *)pModule->pfnAtFork, (void *)pModule->papParent1, (void *)pModule->papChild1, 354 (void *)pModule->pvDataSegBase, (void *)pModule->pvDataSegEnd, pModule->fFlags, (void *)pModule->pNext, fExecutable);349 (void *)pModule->pvDataSegBase, (void *)pModule->pvDataSegEnd, pModule->fFlags, (void *)pModule->pNext, pModule->hmod); 355 350 #ifdef DEBUG_LOGGING 356 351 forkLogModuleByAddr(pModule->pvDataSegBase); … … 362 357 PPIB pPib; 363 358 __LIBC_FORKXCPTREGREC2 XcptRegRec; 359 const int fExecutable = !!(pModule->fFlags & __LIBC_FORKMODULE_FLAGS_EXECUTABLE); 364 360 365 361 /* -
trunk/libc/src/kNIX/os2/resource.c
r2748 r2805 30 30 * Header Files * 31 31 *******************************************************************************/ 32 #include <klibc/os2/os2.h> 32 33 #include "../kNIX.h" 33 #define INCL_FSMACROS34 #define INCL_DOSFILEMGR35 #define INCL_DOSPROCESS36 #define INCL_DOSMISC37 #define INCL_DOSERRORS38 #include <os2.h>39 #include <errno.h>40 #include <sys/types.h>41 #include <sys/time.h>42 #include <sys/resource.h>43 44 34 45 35 … … 112 102 } 113 103 114 case RLIMIT_DATA:115 LIBC116 104 117 105 /* -
trunk/libc/src/libc/startup/Makefile.kmk
r2717 r2805 34 34 libc_libc_startup_TEMPLATE = libcsub 35 35 libc_libc_startup_SOURCES = \ 36 $(PATH_LIBC_SRC)/libc/startup/cleanup.c \37 36 $(PATH_LIBC_SRC)/libc/startup/ctor1.c \ 38 37 $(PATH_LIBC_SRC)/libc/startup/dtor1.c \ -
trunk/libc/src/libc/startup/os2/x86/crt0.s
r2289 r2805 2 2 /** @file 3 3 * 4 * Application entry point.4 * OS/2 crt0. 5 5 * 6 * This is the routine that gets control first. It should prepare 7 * argc/argv/envp and call the main function. 6 * Copyright (c) 2006 knut st. osmundsen <bird@innotek.de> 8 7 * 9 8 * 10 * Copyright (c) 1992-1998 by Eberhard Mattes 11 * Copyright (c) 2003 InnoTek Systemberatung GmbH 9 * This file is part of kLIBC. 12 10 * 13 * 14 * This file is part of Innotek LIBC. 15 * 16 * Innotek LIBC is free software; you can redistribute it and/or modify 11 * kLIBC is free software; you can redistribute it and/or modify 17 12 * it under the terms of the GNU Lesser General Public License as published 18 13 * by the Free Software Foundation; either version 2 of the License, or 19 14 * (at your option) any later version. 20 15 * 21 * InnotekLIBC is distributed in the hope that it will be useful,16 * kLIBC is distributed in the hope that it will be useful, 22 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the … … 25 20 * 26 21 * You should have received a copy of the GNU Lesser General Public License 27 * along with InnotekLIBC; if not, write to the Free Software22 * along with kLIBC; if not, write to the Free Software 28 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 29 24 * 30 25 */ 31 26 32 #include <emx/asm386.h>33 27 34 .globl __text 35 .globl __data 36 .globl ___data_start 37 .globl ___bss_start 28 #include <klibc/initterm.h> 38 29 39 .text40 30 41 #if defined(HIGHMEM) 42 #define FLAG_HIGHMEM 1 43 #else 44 #define FLAG_HIGHMEM 0 31 32 /** 33 * The OS/2 executable entry point. 34 * 35 * EAX = EBX = ECX = EDX = ESI = EDI = EBP = GS = 0. 36 * CS = flat code selector. 37 * DS = ES = SS = flat data selector. 38 * FS = TIB selector. 39 * EFLAGS=? 40 * 41 * @returns exit code to pass to DosExit(1, rc); 42 * @param hmod [ebp + 8h] The executable module handle. 43 * @param Reserved [ebp + 0ch] Reserved (probably 0). 44 * @param pszzEnv [ebp + 10h] Pointer to the environment data object. 45 * @param pszzCmdline [ebp + 14h] Pointer to the commandline. 46 * 47 */ 48 .text 49 .global __text 50 __text: 51 /* create stack frame */ 52 mov %esp, %ebp 53 54 #if !defined(NOFORK) && !defined(NOUNIX) 55 /* 56 * Update g_ForkModule.hmod and call __libc_ForkRegisterModule(&g_ForkModule) to 57 * register the fork module. If we're forking, this call will never return. 58 */ 59 mov 8(%ebp), %eax 60 mov %eax, g_ForkModule_hmod 61 62 pushl $g_ForkModule 63 call ___libc_ForkRegisterModule 64 addl $4, %esp 45 65 #endif 46 66 67 /* 68 * Call __libc_InitExe(hmod, &hmod, fFlags, &MainArgs) to initialized 69 * the CRT and get the arguments for main(). 70 */ 71 pushl 0 /* the main argument frame */ 72 pushl 0 73 pushl 0 74 movl %esp, %ecx 75 pushl %ecx /* pMainFrame */ 76 #if defined(HIGHMEM) 77 # define F1 __LIBC_INIT_FLAGS_MEM_HIGH 78 #else 79 # define F1 0 80 #endif 47 81 #if defined(NOUNIX) 48 # define FLAG_NOUNIX 282 # define F2 __LIBC_INIT_FLAGS_NO_UNIX 49 83 #else 50 # define FLAG_NOUNIX084 # define F2 0 51 85 #endif 86 #if defined(ARGS_RESP) 87 # define F3 __LIBC_INIT_FLAGS_EXPAND_RESPONSE_FILE 88 #else 89 # define F3 0 90 #endif 91 #if defined(ARGS_WILD) 92 # define F3 __LIBC_INIT_FLAGS_EXPAND_WILDCARDS 93 #else 94 # define F3 0 95 #endif 96 pushl (F1+F2+F3+F4) 97 lea 8(%ebp), %edx 98 pushl %edx /* pvOS */ 99 movl 8(%ebp), %eax 100 pushl %eax /* hmod */ 101 call ___libc_InitExe 102 addl %esp, $0x0c 52 103 53 __text: 104 /* 105 * We can call main(). Should main return, invoke exit with the return code. 106 * 107 * Should some bright guy override exit() and make it return, we'll loop 108 * eating 4 bytes of stack for each call to exit(). Eventually we'll crash 109 * when we run out of stack. 110 */ 111 call _main 112 addl $0x0c, %esp 54 113 55 #if !defined(NOFORK) && !defined(NOUNIX)56 /* Registering the fork module. If we're forking this call will not return. */57 pushl $158 pushl $ForkModule59 call ___libc_ForkRegisterModule60 addl $8, %esp61 #endif62 pushl $(FLAG_HIGHMEM + FLAG_NOUNIX)63 call ___init_app64 /* esp points to main() call frame. */65 cld66 #ifdef ARGS_RESP67 lea 4(%esp), %eax /* &argv */68 movl %esp, %ecx /* &argc */69 pushl %eax70 pushl %ecx71 call __response72 addl $8, %esp73 #endif74 #ifdef ARGS_WILD75 lea 4(%esp), %eax /* &argv */76 movl %esp, %ecx /* &argc */77 pushl %eax78 pushl %ecx79 call __wildcard80 addl $8, %esp81 #endif82 call __CRT_init83 call _main84 addl $3*4, %esp85 114 do_exit: 86 115 pushl %eax 87 116 call _exit 88 1: jmp 1b /* Just in case exit() returns :-) */ 117 jmp do_exit 89 118 90 119 91 .data 120 121 /** 122 * __data_start (and __data) marks the start of the data segment. 123 * 124 * By convention required by emxbind, the datasegment starts with 125 * a magic number followed by a pointer to the list of OS/2 DLL 126 * references. When linking OMF this is not used by anyone. 127 */ 128 .data 129 .global ___data_start 130 .global __data 92 131 ___data_start: 93 132 __data: 94 .long 0xba0bab // Magic number (error detection) 95 .long __os2dll // list of OS/2 DLL references 96 97 .stabs "__os2dll", 21, 0, 0, 0xffffffff 98 .stabs "___CTOR_LIST__", 21, 0, 0, 0xffffffff 99 .stabs "___DTOR_LIST__", 21, 0, 0, 0xffffffff 100 .stabs "___crtinit1__", 21, 0, 0, 0xffffffff 101 .stabs "___crtexit1__", 21, 0, 0, 0xffffffff 102 .stabs "___eh_frame__", 21, 0, 0, 0xffffffff 103 .stabs "___eh_init__", 21, 0, 0, 0xffffffff 104 .stabs "___eh_term__", 21, 0, 0, 0xffffffff 133 .long 0x00ba0bab /* Magic number (error detection). */ 134 .long __os2dll /* List of OS/2 DLL references. */ 105 135 106 136 #if !defined(NOFORK) && !defined(NOUNIX) 107 .stabs "___fork_parent1__", 21, 0, 0, 0xffffffff 108 .stabs "___fork_child1__", 21, 0, 0, 0xffffffff 137 /** 138 * The fork module structure. 139 */ 140 g_ForkModule: 141 .long 0x00010000 /* uVersion (__LIBC_FORK_MODULE_VERSION) */ 142 .long __atfork_callback /* pfnAtFork */ 143 .long ___fork_parent1__ /* papParent1 */ 144 .long ___fork_child1__ /* papChild1 */ 145 .long ___data_start /* pvDataSegBase */ 146 .long _end /* pvDataSegEnd */ 147 .long 0x00000001 /* fFlags - __LIBC_FORKMODULE_FLAGS_EXECUTABLE */ 148 .long 0 /* pNext */ 149 g_ForkModule_hmod: 150 .long 0 /* hmod */ 151 .long 0 /* uReserved[7] */ 152 .long 0 /* uReserved[7] */ 153 .long 0 /* uReserved[7] */ 154 .long 0 /* uReserved[7] */ 155 .long 0 /* uReserved[7] */ 156 .long 0 /* uReserved[7] */ 157 .long 0 /* uReserved[7] */ 158 #endif 109 159 110 ForkModule:111 .long 0x00010000 // uVersion (__LIBC_FORK_MODULE_VERSION)112 .long __atfork_callback // pfnAtFork113 .long ___fork_parent1__ // papParent1114 .long ___fork_child1__ // papChild1115 .long ___data_start // pvDataSegBase116 .long _end // pvDataSegEnd117 .long 0x00000001 // fFlags - __LIBC_FORKMODULE_FLAGS_EXECUTABLE118 .long 0 // pNext119 .long 0 // uReserved[8]120 .long 0 // uReserved[8]121 .long 0 // uReserved[8]122 .long 0 // uReserved[8]123 .long 0 // uReserved[8]124 .long 0 // uReserved[8]125 .long 0 // uReserved[8]126 .long 0 // uReserved[8]127 #endif128 .stabs "__end",1,0,0,0 /* Force libend inclusion for -Zomf. */129 160 130 .bss 161 /** 162 * __bss_start marks where the BSS segment starts. 163 */ 164 .bss 165 .global ___bss_start 131 166 ___bss_start: 132 167 168 169 /** 170 * Start all the a.out SETs the CRT and GCC are making use of. 171 * 172 * _os2dll is used by emxbind/ld for dll imports. 173 * __CTOR_LIST__ and __DTOR_LIST__ are lists of static constructors and destructors. 174 * __crtinit1__ is the list of static crt init routines. 175 * __crtinit2__ is the list of static crt termination routines. 176 * __eh_frame__, __eh_init__ and __eh_term__ are GCC exception handling info. 177 * __fork_parent1__ and __fork_child1__ are lists with fork time callbacks. 178 */ 179 .stabs "__os2dll", 21, 0, 0, 0xffffffff 180 .stabs "___CTOR_LIST__", 21, 0, 0, 0xffffffff 181 .stabs "___DTOR_LIST__", 21, 0, 0, 0xffffffff 182 .stabs "___crtinit1__", 21, 0, 0, 0xffffffff 183 .stabs "___crtexit1__", 21, 0, 0, 0xffffffff 184 .stabs "___eh_frame__", 21, 0, 0, 0xffffffff 185 .stabs "___eh_init__", 21, 0, 0, 0xffffffff 186 .stabs "___eh_term__", 21, 0, 0, 0xffffffff 187 #if !defined(NOFORK) && !defined(NOUNIX) 188 .stabs "___fork_parent1__", 21, 0, 0, 0xffffffff 189 .stabs "___fork_child1__", 21, 0, 0, 0xffffffff 190 #endif 191 192 193 /** 194 * Add a symbol table entry which drags _end in libend into OMF links. 195 */ 196 .stabs "__end",1,0,0,0 197
Note:
See TracChangeset
for help on using the changeset viewer.