Changeset 2918
- Timestamp:
- Dec 29, 2006, 1:43:05 AM (19 years ago)
- Location:
- trunk/libc
- Files:
-
- 9 added
- 6 deleted
- 11 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/libc/include/klibc/backend.h
r2917 r2918 144 144 * 145 145 * @returns 0 on success. 146 * @returns -EINVAL if the pReqTS is invalid.147 146 * @returns -EINTR if the interrupted by signal. 148 147 * 149 148 * @param u64NanoReq Time to sleep, in nano seconds. 150 149 * @param pu64NanoRem Where to store remaining time (also nano seconds). 151 150 * 152 151 * @remark For relativly small sleeps this api temporarily changes the thread 153 152 * priority to timecritical (that is, if it's in the normal or idle priority … … 635 634 */ 636 635 int __libc_Back_ldrOpen(const char *pszLibrary, int fFlags, void **ppvModule, char *pszError, size_t cchError); 636 637 /** 638 * Get the name of the executable. 639 * 640 * @returns 0 on success. 641 * @returns Negated error code (errno.h) on failure. 642 * @param pszNameBuf Where to store the name. 643 * @param cchNameBuf The size of the buffer. 644 */ 645 int __libc_Back_ldrExeName(char *pszNameBuf, size_t cchNameBuf); 637 646 638 647 /** … … 1137 1146 */ 1138 1147 int __libc_Back_processSetPriority(int iWhich, id_t idWho, int iPrio); 1148 1149 /** 1150 * Get the resource usage of the process or the child processes. 1151 * 1152 * @returns 0 on success. 1153 * @returns Neagted error code (errno.h) on failure. 1154 * @param iWho Who to get the resource usage of, RUSAGE_SELF or RUSAGE_CHILDREN. 1155 * @param pUsage Where to store the resource usage. 1156 */ 1157 int __libc_Back_processGetResourceUsage(int iWho, struct rusage *pUsage); 1139 1158 1140 1159 /** -
trunk/libc/include/klibc/logstrict.h
r2909 r2918 237 237 /** Other I/O APIs. */ 238 238 #define __LIBC_LOG_GRP_IO 4 239 /** Other Filesystem APIs. */ 240 #define __LIBC_LOG_GRP_FS 4 /** @todo fixme */ 239 241 /** String APIs. */ 240 242 #define __LIBC_LOG_GRP_STRING 5 -
trunk/libc/src/kNIX/Makefile.kmk
r2917 r2918 65 65 $(PATH_LIBC_SRC)/kNIX/heap.c \ 66 66 $(PATH_LIBC_SRC)/kNIX/heapdata.c \ 67 $(PATH_LIBC_SRC)/kNIX/_os_version.c \ 67 68 68 69 # $(PATH_LIBC_SRC)/kNIX/b_ioDuplicate.c \ … … 92 93 $(PATH_LIBC_SRC)/kNIX/os2/b_ioFileOpen.c \ 93 94 $(PATH_LIBC_SRC)/kNIX/os2/b_ldrClose.c \ 95 $(PATH_LIBC_SRC)/kNIX/os2/b_ldrExeName.c \ 94 96 $(PATH_LIBC_SRC)/kNIX/os2/b_ldrOpen.c \ 95 97 $(PATH_LIBC_SRC)/kNIX/os2/b_ldrSymbol.c \ … … 102 104 $(PATH_LIBC_SRC)/kNIX/os2/b_processExit.c \ 103 105 $(PATH_LIBC_SRC)/kNIX/os2/b_processGetPriority.c \ 106 $(PATH_LIBC_SRC)/kNIX/os2/b_processGetResourceUsage.c \ 104 107 $(PATH_LIBC_SRC)/kNIX/os2/b_processSetPriority.c \ 105 108 $(PATH_LIBC_SRC)/kNIX/os2/b_processWait.c \ … … 122 125 $(PATH_LIBC_SRC)/kNIX/os2/b_timeHighResNano.c \ 123 126 $(PATH_LIBC_SRC)/kNIX/os2/b_timeSet.c \ 124 $(PATH_LIBC_SRC)/kNIX/os2/clock.c \125 $(PATH_LIBC_SRC)/kNIX/os2/core.c \126 127 $(PATH_LIBC_SRC)/kNIX/os2/DosAllocMemEx.c \ 127 128 $(PATH_LIBC_SRC)/kNIX/os2/DosAllocSharedMemEx.c \ … … 139 140 $(PATH_LIBC_SRC)/kNIX/os2/DosOpenMutexSemEx.c \ 140 141 $(PATH_LIBC_SRC)/kNIX/os2/exceptions.c \ 141 $(PATH_LIBC_SRC)/kNIX/os2/execname.c \142 142 $(PATH_LIBC_SRC)/kNIX/os2/FastInfoBlocks.c \ 143 143 $(PATH_LIBC_SRC)/kNIX/os2/filefind.c \ 144 $(PATH_LIBC_SRC)/kNIX/os2/filesys.c \145 144 $(PATH_LIBC_SRC)/kNIX/os2/fhOS2File.c \ 146 145 $(PATH_LIBC_SRC)/kNIX/os2/fs-os2.c \ 147 146 $(PATH_LIBC_SRC)/kNIX/os2/fsync.c \ 148 $(PATH_LIBC_SRC)/kNIX/os2/getppid.c \149 147 $(PATH_LIBC_SRC)/kNIX/os2/heaphigh.c \ 150 148 $(PATH_LIBC_SRC)/kNIX/os2/hooks.c \ … … 159 157 $(PATH_LIBC_SRC)/kNIX/os2/sharedpm.c \ 160 158 $(PATH_LIBC_SRC)/kNIX/os2/signals.c \ 161 $(PATH_LIBC_SRC)/kNIX/os2/sleep2.c \162 159 $(PATH_LIBC_SRC)/kNIX/os2/sysv_sem.c \ 163 160 $(PATH_LIBC_SRC)/kNIX/os2/sysv_shm.c \ … … 166 163 $(PATH_LIBC_SRC)/kNIX/os2/tcpipver43.c \ 167 164 $(PATH_LIBC_SRC)/kNIX/os2/timebomb.c \ 168 $(PATH_LIBC_SRC)/kNIX/os2/uflags.c \169 $(PATH_LIBC_SRC)/kNIX/os2/umask.c \170 $(PATH_LIBC_SRC)/kNIX/os2/__chmod.c \171 $(PATH_LIBC_SRC)/kNIX/os2/__dup.c \172 $(PATH_LIBC_SRC)/kNIX/os2/__dup2.c \173 $(PATH_LIBC_SRC)/kNIX/os2/__init.c \174 $(PATH_LIBC_SRC)/kNIX/os2/__initdll.c \175 $(PATH_LIBC_SRC)/kNIX/os2/__ioctl1.c \176 $(PATH_LIBC_SRC)/kNIX/os2/__ioctl2.c \177 $(PATH_LIBC_SRC)/kNIX/os2/__os_version.c \178 $(PATH_LIBC_SRC)/kNIX/os2/__pipe.c \179 $(PATH_LIBC_SRC)/kNIX/os2/__read_kbd.c \180 $(PATH_LIBC_SRC)/kNIX/os2/__select.c \181 $(PATH_LIBC_SRC)/kNIX/os2/__spawnve.c \182 165 $(PATH_LIBC_SRC)/kNIX/os2/386/appinit.s \ 183 166 $(PATH_LIBC_SRC)/kNIX/os2/386/thunk0.s \ … … 185 168 $(PATH_LIBC_SRC)/kNIX/os2/386/unwind.s \ 186 169 $(PATH_LIBC_SRC)/kNIX/os2/386/__init_environ.s \ 170 $(PATH_LIBC_SRC)/kNIX/os2/umask.c \ 171 $(PATH_LIBC_SRC)/kNIX/os2/__chmod.c \ 172 $(PATH_LIBC_SRC)/kNIX/os2/__spawnve.c \ 173 $(PATH_LIBC_SRC)/kNIX/os2/__read_kbd.c 174 TODO= \ 175 $(PATH_LIBC_SRC)/kNIX/os2/__init.c \ 176 $(PATH_LIBC_SRC)/kNIX/os2/__initdll.c \ 177 $(PATH_LIBC_SRC)/kNIX/os2/__dup.c \ 178 $(PATH_LIBC_SRC)/kNIX/os2/__dup2.c \ 179 $(PATH_LIBC_SRC)/kNIX/os2/__ioctl1.c \ 180 $(PATH_LIBC_SRC)/kNIX/os2/__ioctl2.c \ 181 $(PATH_LIBC_SRC)/kNIX/os2/__pipe.c \ 182 $(PATH_LIBC_SRC)/kNIX/os2/__select.c \ 187 183 188 184 -
trunk/libc/src/kNIX/os2/__spawnve.c
r2909 r2918 31 31 #include "kNIX.h" 32 32 /** @todo Cleanup __spawnve.c properly! */ 33 #include "b_signal.h"34 #include "b_process.h"35 33 #include <emx/syscalls.h> 36 #include <InnoTekLIBC/sharedpm.h>37 34 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_PROCESS 38 35 #include <klibc/logstrict.h> -
trunk/libc/src/kNIX/os2/b_fsStat.c
r2913 r2918 200 200 */ 201 201 bzero(pStatFs, sizeof(*pStatFs)); 202 strnc py(pStatFs->f_fstypename, (char *)&pfsq->szName[pfsq->cbName + 1] /* FSDName */, sizeof(pStatFs->f_fstypename) - 1);202 strncat(pStatFs->f_fstypename, (char *)&pfsq->szName[pfsq->cbName + 1] /* FSDName */, sizeof(pStatFs->f_fstypename) - 1); 203 203 int fDefDevName = 0; 204 204 if (/*!strcmp(pStatFs->f_fstypename, "LAN") && */pfsq->cbFSAData) -
trunk/libc/src/kNIX/os2/b_threadSleep.c
r2916 r2918 34 34 * 35 35 * @returns 0 on success. 36 * @returns -EINVAL if the pReqTS is invalid.37 36 * @returns -EINTR if the interrupted by signal. 38 37 * 39 38 * @param u64NanoReq Time to sleep, in nano seconds. 40 39 * @param pu64NanoRem Where to store remaining time (also nano seconds). 41 40 * 42 41 * @remark For relativly small sleeps this api temporarily changes the thread 43 42 * priority to timecritical (that is, if it's in the normal or idle priority -
trunk/libc/src/libc/io/Makefile.kmk
r2917 r2918 142 142 $(PATH_LIBC_SRC)/libc/io/_crlf.c \ 143 143 $(PATH_LIBC_SRC)/libc/io/_fbuf.c \ 144 $(PATH_LIBC_SRC)/libc/io/_filesys.c \ 144 145 $(PATH_LIBC_SRC)/libc/io/_fill.c \ 145 146 $(PATH_LIBC_SRC)/libc/io/_flush.c \ -
trunk/libc/src/libc/process/Makefile.kmk
r2748 r2918 35 35 libc_libc_process_SOURCES = \ 36 36 $(PATH_LIBC_SRC)/libc/process/bsd_signal.c \ 37 $(PATH_LIBC_SRC)/libc/process/clock.c \ 37 38 $(PATH_LIBC_SRC)/libc/process/execl.c \ 38 39 $(PATH_LIBC_SRC)/libc/process/execle.c \ … … 47 48 $(PATH_LIBC_SRC)/libc/process/getitimer.c \ 48 49 $(PATH_LIBC_SRC)/libc/process/getrlimit.c \ 50 $(PATH_LIBC_SRC)/libc/process/getrusage.c \ 49 51 $(PATH_LIBC_SRC)/libc/process/getpid.c \ 52 $(PATH_LIBC_SRC)/libc/process/getppid.c \ 50 53 $(PATH_LIBC_SRC)/libc/process/getpriority.c \ 51 54 $(PATH_LIBC_SRC)/libc/process/kill.c \ … … 92 95 $(PATH_LIBC_SRC)/libc/process/sigwait.c \ 93 96 $(PATH_LIBC_SRC)/libc/process/sigwaitinfo.c \ 97 $(PATH_LIBC_SRC)/libc/process/sleep.c \ 94 98 $(PATH_LIBC_SRC)/libc/process/spawnl.c \ 95 99 $(PATH_LIBC_SRC)/libc/process/spawnle.c \ … … 112 116 $(PATH_LIBC_SRC)/libc/process/waitpid.c \ 113 117 $(PATH_LIBC_SRC)/libc/process/_atfork_callback.c \ 118 $(PATH_LIBC_SRC)/libc/process/_execname.c \ 114 119 $(PATH_LIBC_SRC)/libc/process/_gettid.c \ 115 120 $(PATH_LIBC_SRC)/libc/process/_signal_os2.c \ 116 121 $(PATH_LIBC_SRC)/libc/process/_signal_sysv.c \ 122 $(PATH_LIBC_SRC)/libc/process/_sleep2.c \ 117 123 118 124 libc_libc_process_SOURCES.os2 = \ -
trunk/libc/src/libc/process/clock.c
r2899 r2918 1 /* sys/clock.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 2 1 /* $Id: $ */ 2 /** @file 3 * 4 * kLIBC - clock(). 5 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-srcspam@anduin.net> 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 */ 3 26 #include "libc-alias.h" 4 #include <os2emx.h>5 27 #include <time.h> 6 #include <emx/syscalls.h> 7 #include "syscalls.h" 8 9 /* This function no longer tries to use QSV_TIME_LOW and QSV_TIME_HIGH 10 to increase the time before the return value wraps around. Now, it 11 will wrap around after 49 days. */ 28 #include <klibc/backend.h> 29 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_TIME 30 #include <klibc/logstrict.h> 12 31 13 32 clock_t _STD(clock)(void) 14 33 { 15 ULONG val_ms; 16 clock_t result; 34 LIBCLOG_ENTER("\n"); 17 35 18 _sys_get_clock(&val_ms); 19 result = (val_ms - _sys_clock0_ms) / 10; 20 return result; 36 /* Get the times. */ 37 struct rusage Usage; 38 int rc = __libc_Back_processGetResourceUsage(RUSAGE_SELF, &Usage); 39 if (__predict_false(rc != 0)) 40 { 41 LIBC_ASSERTM_FAILED("rc=%d\n", rc); 42 LIBCLOG_ERROR_RETURN_INT(-1); 43 } 44 45 /* Sum and convert to clock ticks. */ 46 uint64_t cMicroSeconds = ((uint64_t)Usage.ru_stime.tv_sec + (uint64_t)Usage.ru_utime.tv_sec) * 1000000 47 + Usage.ru_stime.tv_usec + Usage.ru_utime.tv_usec; 48 clock_t cTicks = cMicroSeconds / (1000000 / CLOCKS_PER_SEC); 49 LIBCLOG_RETURN_MSG(cTicks, "ret %llu (%#llx)\n", (long long)cTicks, (long long)cTicks); 21 50 } 51 -
trunk/libc/src/libc/process/getpid.c
r2730 r2918 2 2 /** @file 3 3 * 4 * LIBC - getpid().4 * kLIBC - getpid(). 5 5 * 6 6 * Copyright (c) 2006 knut st. osmundsen <bird@innotek.de> … … 25 25 */ 26 26 27 28 /*******************************************************************************29 * Header Files *30 *******************************************************************************/31 27 #include "libc-alias.h" 32 28 #include <unistd.h> 33 29 #include <process.h> 34 30 #include <klibc/fib.h> 35 36 31 37 32 /** … … 40 35 * @returns process id. 41 36 */ 42 int _STD(getpid)(void)37 pid_t _STD(getpid)(void) 43 38 { 44 39 return fibGetPid(); -
trunk/libc/src/libc/process/siginterrupt_data.c
r1618 r2918 29 29 *******************************************************************************/ 30 30 #include "libc-alias.h" 31 #include < InnoTekLIBC/libc.h>31 #include <sys/signal.h> 32 32 33 33 -
trunk/libc/src/libc/time/times.c
r2909 r2918 4 4 * kLIBC - times(). 5 5 * 6 * Copyright (c) 1990-1996 by Eberhard Mattes7 6 * Copyright (c) 2004-2006 knut st. osmundsen <bird-srcspam@anduin.net> 8 7 * … … 27 26 28 27 #include "libc-alias.h" 28 #include <sys/times.h> 29 #include <sys/time.h> 29 30 #include <time.h> 30 #include < sys/time.h>31 #include < sys/times.h>31 #include <errno.h> 32 #include <klibc/backend.h> 32 33 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_TIME 33 34 #include <klibc/logstrict.h> 34 35 36 /** Converts a time value to clock ticks. */ 37 static clock_t tv2ticks(struct timeval const *ptv) 38 { 39 return ptv->tv_sec * (uint64_t)CLOCKS_PER_SEC 40 + ptv->tv_usec * (uint64_t)(1000000 / CLOCKS_PER_SEC); 41 } 35 42 36 43 /** … … 38 45 * @remark return value overflows 39 46 */ 40 clock_t _STD(times)(struct tms * buffer)47 clock_t _STD(times)(struct tms *pBuf) 41 48 { 42 LIBCLOG_ENTER("buffer=%p\n", (void *)buffer); 49 LIBCLOG_ENTER("pBuf=%p\n", (void *)pBuf); 50 51 /* 52 * Get sys/user times if requested. 53 */ 54 if (pBuf) 55 { 56 struct rusage Usage; 57 int rc = __libc_Back_processGetResourceUsage(RUSAGE_SELF, &Usage); 58 if (!rc) 59 { 60 pBuf->tms_utime = tv2ticks(&Usage.ru_utime); 61 pBuf->tms_stime = tv2ticks(&Usage.ru_stime); 62 rc = __libc_Back_processGetResourceUsage(RUSAGE_CHILDREN, &Usage); 63 if (!rc) 64 { 65 pBuf->tms_cutime = tv2ticks(&Usage.ru_utime); 66 pBuf->tms_cstime = tv2ticks(&Usage.ru_stime); 67 } 68 } 69 if (rc) 70 { 71 errno = -rc; 72 LIBCLOG_ERROR_RETURN_INT(-1); 73 } 74 } 75 76 /* 77 * Get monotone time and recalc it to ticks. 78 */ 79 /** @todo this should be a monotone time source. gettimeofday() isn't monotone. */ 43 80 struct timeval tv; 44 if (buffer)45 {46 buffer->tms_utime = clock(); /* clock () * HZ / CLOCKS_PER_SEC */47 buffer->tms_stime = 0;48 buffer->tms_cutime = 0;49 buffer->tms_cstime = 0;50 }51 81 if (gettimeofday(&tv, NULL) != 0) 52 82 LIBCLOG_ERROR_RETURN_INT(-1); 53 clock_t rc = CLK_TCK * tv.tv_sec + (CLK_TCK * tv.tv_usec) / 1000000; 54 if (buffer) 55 LIBCLOG_RETURN_MSG(rc, "ret %d (%#x) - buffer={.tms_utime=%d, .tms_stime=%d, .tms_cutime=%d, .tms_cstime=%d}\n", 56 (int)rc, (int)rc, (int)buffer->tms_utime, (int)buffer->tms_stime, (int)buffer->tms_cutime, 57 (int)buffer->tms_cstime); 58 LIBCLOG_RETURN_MSG(rc, "ret %d (%#x)\n", (int)rc, (int)rc); 83 clock_t cTicks = tv2ticks(&tv); 84 85 if (pBuf) 86 LIBCLOG_RETURN_MSG(cTicks, "ret %lld (%#llx) - pBuf={.tms_utime=%lld, .tms_stime=%lld, .tms_cutime=%lld, .tms_cstime=%lld}\n", 87 (long long)cTicks, (long long)cTicks, 88 (long long)pBuf->tms_utime, (long long)pBuf->tms_stime, 89 (long long)pBuf->tms_cutime, (long long)pBuf->tms_cstime); 90 LIBCLOG_RETURN_MSG(cTicks, "ret %lld (%#llx)\n", (long long)cTicks, (long long)cTicks); 59 91 } 92
Note:
See TracChangeset
for help on using the changeset viewer.