forked from KolibriOS/kolibrios
newlib: add clock_gettime()
git-svn-id: svn://kolibrios.org@6109 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
c64bf3d60e
commit
ac054a24fe
@ -119,6 +119,7 @@ CORE_SRCS:= \
|
||||
search/bsearch.c \
|
||||
signal/signal.c \
|
||||
sys/access.c \
|
||||
sys/clock_gettime.c \
|
||||
sys/close.c \
|
||||
sys/conio.c \
|
||||
sys/create.c \
|
||||
|
@ -47,11 +47,11 @@ CORE_SRCS = {
|
||||
"reent/writer.c",
|
||||
"search/qsort.c", "search/bsearch.c",
|
||||
"signal/signal.c",
|
||||
"sys/access.c", "sys/close.c", "sys/conio.c", "sys/create.c", "sys/errno.c", "sys/finfo.c",
|
||||
"sys/fsize.c", "sys/fstat.c", "sys/gettod.c", "sys/io.c", "sys/ioread.c",
|
||||
"sys/iowrite.c", "sys/isatty.c", "sys/lseek.c", "sys/open.c", "sys/read.c",
|
||||
"sys/_rename.c", "sys/stat.c", "sys/unlink.c", "sys/write.c", "sys/io_alloc.S",
|
||||
"time/asctime.c", "time/asctime_r.c", "time/clock.c", "time/ctime.c",
|
||||
"sys/access.c", "sys/clock_gettime.c", "sys/close.c", "sys/conio.c", "sys/create.c",
|
||||
"sys/errno.c", "sys/finfo.c", "sys/fsize.c", "sys/fstat.c", "sys/gettod.c", "sys/io.c",
|
||||
"sys/ioread.c", "sys/iowrite.c", "sys/isatty.c", "sys/lseek.c", "sys/open.c",
|
||||
"sys/read.c", "sys/_rename.c", "sys/stat.c", "sys/unlink.c", "sys/write.c",
|
||||
"sys/io_alloc.S", "time/asctime.c", "time/asctime_r.c", "time/clock.c", "time/ctime.c",
|
||||
"time/ctime_r.c", "time/difftime.c", "time/gettzinfo.c", "time/gmtime.c",
|
||||
"time/gmtime_r.c", "time/mktime.c", "time/month_lengths.c", "time/lcltime.c",
|
||||
"time/lcltime_r.c", "time/strftime.c", "time/time.c", "time/tzcalc_limits.c",
|
||||
|
@ -23,7 +23,7 @@
|
||||
#define __STRINGIFY(a) #a
|
||||
|
||||
/* 8-bit types */
|
||||
#define __PRI8(x) __INT8 __STRINGIFY(x)
|
||||
#define __PRI8(x) __STRINGIFY(x)
|
||||
#define __PRI8LEAST(x) __LEAST8 __STRINGIFY(x)
|
||||
#define __PRI8FAST(x) __FAST8 __STRINGIFY(x)
|
||||
|
||||
@ -150,8 +150,8 @@
|
||||
#define SCNxFAST16 __SCN16FAST(x)
|
||||
|
||||
/* 32-bit types */
|
||||
#define __PRI32(x) __INT32 __STRINGIFY(x)
|
||||
#define __SCN32(x) __INT32 __STRINGIFY(x)
|
||||
#define __PRI32(x) __STRINGIFY(I32##x)
|
||||
#define __SCN32(x) __STRINGIFY(I32##x)
|
||||
#define __PRI32LEAST(x) __LEAST32 __STRINGIFY(x)
|
||||
#define __SCN32LEAST(x) __LEAST32 __STRINGIFY(x)
|
||||
#define __PRI32FAST(x) __FAST32 __STRINGIFY(x)
|
||||
@ -200,15 +200,14 @@
|
||||
|
||||
|
||||
/* 64-bit types */
|
||||
#define __PRI64(x) __INT64 __STRINGIFY(x)
|
||||
#define __SCN64(x) __INT64 __STRINGIFY(x)
|
||||
#define __PRI64(x) __STRINGIFY(I64##x)
|
||||
#define __SCN64(x) __STRINGIFY(I64##x)
|
||||
|
||||
#define __PRI64LEAST(x) __LEAST64 __STRINGIFY(x)
|
||||
#define __SCN64LEAST(x) __LEAST64 __STRINGIFY(x)
|
||||
#define __PRI64FAST(x) __FAST64 __STRINGIFY(x)
|
||||
#define __SCN64FAST(x) __FAST64 __STRINGIFY(x)
|
||||
|
||||
#if __int64_t_defined
|
||||
#define PRId64 __PRI64(d)
|
||||
#define PRIi64 __PRI64(i)
|
||||
#define PRIo64 __PRI64(o)
|
||||
@ -221,7 +220,6 @@
|
||||
#define SCNo64 __SCN64(o)
|
||||
#define SCNu64 __SCN64(u)
|
||||
#define SCNx64 __SCN64(x)
|
||||
#endif
|
||||
|
||||
#if __int_least64_t_defined
|
||||
#define PRIdLEAST64 __PRI64LEAST(d)
|
||||
@ -254,16 +252,8 @@
|
||||
#endif
|
||||
|
||||
/* max-bit types */
|
||||
#if __have_long64
|
||||
#define __PRIMAX(x) __STRINGIFY(l##x)
|
||||
#define __SCNMAX(x) __STRINGIFY(l##x)
|
||||
#elif __have_longlong64
|
||||
#define __PRIMAX(x) __STRINGIFY(ll##x)
|
||||
#define __SCNMAX(x) __STRINGIFY(ll##x)
|
||||
#else
|
||||
#define __PRIMAX(x) __STRINGIFY(x)
|
||||
#define __SCNMAX(x) __STRINGIFY(x)
|
||||
#endif
|
||||
#define __PRIMAX(x) __STRINGIFY(I64##x)
|
||||
#define __SCNMAX(x) __STRINGIFY(I64##x)
|
||||
|
||||
#define PRIdMAX __PRIMAX(d)
|
||||
#define PRIiMAX __PRIMAX(i)
|
||||
@ -280,11 +270,11 @@
|
||||
|
||||
/* ptr types */
|
||||
#if defined (_INTPTR_EQ_LONGLONG)
|
||||
# define __PRIPTR(x) __STRINGIFY(ll##x)
|
||||
# define __SCNPTR(x) __STRINGIFY(ll##x)
|
||||
# define __PRIPTR(x) __STRINGIFY(I64##x)
|
||||
# define __SCNPTR(x) __STRINGIFY(I64##x)
|
||||
#elif defined (_INTPTR_EQ_LONG)
|
||||
# define __PRIPTR(x) __STRINGIFY(l##x)
|
||||
# define __SCNPTR(x) __STRINGIFY(l##x)
|
||||
# define __PRIPTR(x) __STRINGIFY(I32##x)
|
||||
# define __SCNPTR(x) __STRINGIFY(I32##x)
|
||||
#else
|
||||
# define __PRIPTR(x) __STRINGIFY(x)
|
||||
# define __SCNPTR(x) __STRINGIFY(x)
|
||||
|
@ -25,7 +25,7 @@ static inline int mutex_init(mutex_t *mutex)
|
||||
|
||||
mutex->lock = 0;
|
||||
|
||||
asm volatile(
|
||||
__asm__ volatile(
|
||||
"int $0x40\t"
|
||||
:"=a"(handle)
|
||||
:"a"(77),"b"(FUTEX_INIT),"c"(mutex));
|
||||
@ -38,7 +38,7 @@ static inline int mutex_destroy(mutex_t *mutex)
|
||||
{
|
||||
int retval;
|
||||
|
||||
asm volatile(
|
||||
__asm__ volatile(
|
||||
"int $0x40\t"
|
||||
:"=a"(retval)
|
||||
:"a"(77),"b"(FUTEX_DESTROY),"c"(mutex->handle));
|
||||
@ -55,7 +55,7 @@ static inline void mutex_lock(mutex_t *mutex)
|
||||
|
||||
while (exchange_acquire (&mutex->lock, 2) != 0)
|
||||
{
|
||||
asm volatile(
|
||||
__asm__ volatile(
|
||||
"int $0x40\t\n"
|
||||
:"=a"(tmp)
|
||||
:"a"(77),"b"(FUTEX_WAIT),
|
||||
@ -72,7 +72,7 @@ static inline int mutex_lock_timeout(mutex_t *mutex, int timeout)
|
||||
|
||||
while (exchange_acquire (&mutex->lock, 2) != 0)
|
||||
{
|
||||
asm volatile(
|
||||
__asm__ __volatile__(
|
||||
"int $0x40\t"
|
||||
:"=a"(tmp)
|
||||
:"a"(77),"b"(FUTEX_WAIT),
|
||||
@ -99,7 +99,7 @@ static inline void mutex_unlock(mutex_t *mutex)
|
||||
|
||||
if (prev != 1)
|
||||
{
|
||||
asm volatile(
|
||||
__asm__ volatile(
|
||||
"int $0x40\t"
|
||||
:"=a"(prev)
|
||||
:"a"(77),"b"(FUTEX_WAKE),
|
||||
|
@ -80,37 +80,37 @@ extern "C"
|
||||
|
||||
typedef unsigned int SNDBUF;
|
||||
|
||||
int _stdcall InitSound(int *version);
|
||||
int __stdcall InitSound(int *version);
|
||||
|
||||
int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf);
|
||||
int _stdcall DestroyBuffer(SNDBUF hBuff);
|
||||
int __stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf);
|
||||
int __stdcall DestroyBuffer(SNDBUF hBuff);
|
||||
|
||||
int _stdcall SetFormat(SNDBUF hBuff, unsigned int format);
|
||||
int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format);
|
||||
int __stdcall SetFormat(SNDBUF hBuff, unsigned int format);
|
||||
int __stdcall GetFormat(SNDBUF hBuff, unsigned int *format);
|
||||
|
||||
int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags);
|
||||
int _stdcall SetBufferPos(SNDBUF hBuff, int offset);
|
||||
int _stdcall GetBufferPos(SNDBUF hBuff, int *offset);
|
||||
int _stdcall GetBufferSize(SNDBUF hBuff, int *size);
|
||||
int _stdcall GetBufferFree(SNDBUF hBuff, int *free);
|
||||
int __stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags);
|
||||
int __stdcall SetBufferPos(SNDBUF hBuff, int offset);
|
||||
int __stdcall GetBufferPos(SNDBUF hBuff, int *offset);
|
||||
int __stdcall GetBufferSize(SNDBUF hBuff, int *size);
|
||||
int __stdcall GetBufferFree(SNDBUF hBuff, int *free);
|
||||
|
||||
int _stdcall SetBuffer(SNDBUF hBuff,void* buff,
|
||||
int __stdcall SetBuffer(SNDBUF hBuff,void* buff,
|
||||
int offs, int size);
|
||||
int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size);
|
||||
int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags);
|
||||
int _stdcall StopBuffer(SNDBUF hBuff);
|
||||
int __stdcall WaveOut(SNDBUF hBuff,void *buff, int size);
|
||||
int __stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags);
|
||||
int __stdcall StopBuffer(SNDBUF hBuff);
|
||||
|
||||
int _stdcall SetVolume(SNDBUF hBuff, int left, int right);
|
||||
int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right);
|
||||
int _stdcall SetPan(SNDBUF hBuff, int pan);
|
||||
int _stdcall GetPan(SNDBUF hBuff, int *pan);
|
||||
int __stdcall SetVolume(SNDBUF hBuff, int left, int right);
|
||||
int __stdcall GetVolume(SNDBUF hBuff, int *left, int *right);
|
||||
int __stdcall SetPan(SNDBUF hBuff, int pan);
|
||||
int __stdcall GetPan(SNDBUF hBuff, int *pan);
|
||||
|
||||
int _stdcall GetMasterVol(int* vol);
|
||||
int _stdcall SetMasterVol(int vol);
|
||||
int __stdcall GetMasterVol(int* vol);
|
||||
int __stdcall SetMasterVol(int vol);
|
||||
|
||||
int _stdcall SetTimeBase(SNDBUF hBuff, double base);
|
||||
int _stdcall GetTimeStamp(SNDBUF hBuff, double *stamp);
|
||||
int _stdcall GetDevTime(int *stamp);
|
||||
int __stdcall SetTimeBase(SNDBUF hBuff, double base);
|
||||
int __stdcall GetTimeStamp(SNDBUF hBuff, double *stamp);
|
||||
int __stdcall GetDevTime(int *stamp);
|
||||
|
||||
|
||||
typedef struct
|
||||
@ -133,7 +133,7 @@ typedef struct
|
||||
} WAVEHEADER;
|
||||
|
||||
|
||||
unsigned int _stdcall test_wav(WAVEHEADER *hdr);
|
||||
unsigned int __stdcall test_wav(WAVEHEADER *hdr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
@ -655,6 +655,8 @@
|
||||
#define __GNU_VISIBLE 1
|
||||
#endif
|
||||
|
||||
#define __GNU_VISIBLE 1
|
||||
|
||||
/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
|
||||
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
|
||||
#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
|
||||
|
@ -229,6 +229,8 @@ extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _POSIX_MONOTONIC_CLOCK 200112L
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -144,8 +144,6 @@ struct stat
|
||||
#define UTIME_OMIT -1L
|
||||
#endif
|
||||
|
||||
int _EXFUN(chmod,( const char *__path, mode_t __mode ));
|
||||
int _EXFUN(fchmod,(int __fd, mode_t __mode));
|
||||
int _EXFUN(fstat,( int __fd, struct stat *__sbuf ));
|
||||
int _EXFUN(mkdir,( const char *_path, mode_t __mode ));
|
||||
int _EXFUN(mkfifo,( const char *__path, mode_t __mode ));
|
||||
|
36
contrib/sdk/sources/newlib/libc/sys/clock_gettime.c
Normal file
36
contrib/sdk/sources/newlib/libc/sys/clock_gettime.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <kos32sys.h>
|
||||
|
||||
/* Get current value of CLOCK and store it in TP. */
|
||||
int clock_gettime (clockid_t clock_id, struct timespec *tp)
|
||||
{
|
||||
uint64_t tsc;
|
||||
|
||||
tsc = get_ns_count();
|
||||
|
||||
tp->tv_sec = tsc / 1000000000;
|
||||
tp->tv_nsec = tsc % 1000000000;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user