| 1 | /* $Id: kHlpBareThread.c 3599 2007-10-04 19:09:39Z bird $ */
|
|---|
| 2 | /** @file
|
|---|
| 3 | * kHlpBare - Thread Manipulation.
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | /*
|
|---|
| 7 | * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net>
|
|---|
| 8 | *
|
|---|
| 9 | * This file is part of kStuff.
|
|---|
| 10 | *
|
|---|
| 11 | * kStuff is free software; you can redistribute it and/or
|
|---|
| 12 | * modify it under the terms of the GNU Lesser General Public
|
|---|
| 13 | * License as published by the Free Software Foundation; either
|
|---|
| 14 | * version 2.1 of the License, or (at your option) any later version.
|
|---|
| 15 | *
|
|---|
| 16 | * kStuff 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 GNU
|
|---|
| 19 | * Lesser General Public License for more details.
|
|---|
| 20 | *
|
|---|
| 21 | * You should have received a copy of the GNU Lesser General Public
|
|---|
| 22 | * License along with kStuff; if not, write to the Free Software
|
|---|
| 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|---|
| 24 | *
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 | /*******************************************************************************
|
|---|
| 28 | * Header Files *
|
|---|
| 29 | *******************************************************************************/
|
|---|
| 30 | #include <k/kHlpThread.h>
|
|---|
| 31 |
|
|---|
| 32 | #if K_OS == K_OS_DARWIN
|
|---|
| 33 |
|
|---|
| 34 | #elif K_OS == K_OS_LINUX
|
|---|
| 35 | # include <k/kHlpSys.h>
|
|---|
| 36 |
|
|---|
| 37 | #elif K_OS == K_OS_OS2
|
|---|
| 38 | # define INCL_BASE
|
|---|
| 39 | # define INCL_ERRORS
|
|---|
| 40 | # include <os2.h>
|
|---|
| 41 | #elif K_OS == K_OS_WINDOWS
|
|---|
| 42 | # include <Windows.h>
|
|---|
| 43 | #else
|
|---|
| 44 | # error "port me"
|
|---|
| 45 | #endif
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 | /**
|
|---|
| 49 | * Sleep for a number of milliseconds.
|
|---|
| 50 | * @param cMillies Number of milliseconds to sleep.
|
|---|
| 51 | */
|
|---|
| 52 | void kHlpSleep(unsigned cMillies)
|
|---|
| 53 | {
|
|---|
| 54 | #if K_OS == K_OS_DARWIN
|
|---|
| 55 | /** @todo mach_wait_until, see gen/nanosleep.c. */
|
|---|
| 56 | usleep(cMillies * 1000);
|
|---|
| 57 |
|
|---|
| 58 | #elif K_OS == K_OS_LINUX
|
|---|
| 59 | /** @todo find the right syscall... */
|
|---|
| 60 |
|
|---|
| 61 | #elif K_OS == K_OS_OS2
|
|---|
| 62 | DosSleep(cMillies);
|
|---|
| 63 | #elif K_OS == K_OS_WINDOWS
|
|---|
| 64 | Sleep(cMillies);
|
|---|
| 65 | #else
|
|---|
| 66 | usleep(cMillies * 1000);
|
|---|
| 67 | #endif
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|