From a1dc5e8e6e6f09ce325f1af98e9ed803a4bd070e Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Fri, 28 Jul 2006 13:19:12 +0000 Subject: [PATCH] - Added ftime(), as contributed by Peter Bengtsson. Thank you very much! - Added the missing S_ISSOCKET() macro to . Note that this is not actually a POSIX feature. - Added fmin(), fminf(), fmax() and fmaxf() to the build makefiles. Somehow I must have forgotten about them :-( git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15105 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/GNUmakefile.68k | 7 +++- library/GNUmakefile.os4 | 7 +++- library/changes | 8 ++++ library/include/sys/stat.h | 15 ++++---- library/include/sys/timeb.h | 66 +++++++++++++++++++++++++++++++++ library/timeb_ftime.c | 74 +++++++++++++++++++++++++++++++++++++ 6 files changed, 168 insertions(+), 9 deletions(-) create mode 100644 library/include/sys/timeb.h create mode 100644 library/timeb_ftime.c diff --git a/library/GNUmakefile.68k b/library/GNUmakefile.68k index 520d316..5258971 100644 --- a/library/GNUmakefile.68k +++ b/library/GNUmakefile.68k @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.68k,v 1.85 2006-05-04 08:01:45 obarthel Exp $ +# $Id: GNUmakefile.68k,v 1.86 2006-07-28 13:19:11 obarthel Exp $ # # :ts=8 # @@ -515,6 +515,7 @@ UNIX_LIB = \ termios_tcgetattr.o \ termios_tcsendbreak.o \ termios_tcsetattr.o \ + timeb_ftime.o \ uio_readv.o \ uio_writev.o \ unistd_access.o \ @@ -606,6 +607,10 @@ MATH_LIB = \ math_floorf.o \ math_fma.o \ math_fmaf.o \ + math_fmax.o \ + math_fmaxf.o \ + math_fmin.o \ + math_fminf.o \ math_fmod.o \ math_fmodf.o \ math_fpclassify.o \ diff --git a/library/GNUmakefile.os4 b/library/GNUmakefile.os4 index 967f7d1..e9cff08 100644 --- a/library/GNUmakefile.os4 +++ b/library/GNUmakefile.os4 @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.os4,v 1.98 2006-06-22 09:02:44 obarthel Exp $ +# $Id: GNUmakefile.os4,v 1.99 2006-07-28 13:19:11 obarthel Exp $ # # :ts=8 # @@ -558,6 +558,7 @@ UNIX_LIB = \ termios_tcgetattr.o \ termios_tcsendbreak.o \ termios_tcsetattr.o \ + timeb_ftime.o \ uio_readv.o \ uio_writev.o \ unistd_access.o \ @@ -650,6 +651,10 @@ MATH_LIB = \ math_floorf.o \ math_fma.o \ math_fmaf.o \ + math_fmax.o \ + math_fmaxf.o \ + math_fmin.o \ + math_fminf.o \ math_fmod.o \ math_fmodf.o \ math_fpclassify.o \ diff --git a/library/changes b/library/changes index 8ea4fe9..3250113 100644 --- a/library/changes +++ b/library/changes @@ -1,3 +1,11 @@ +- Added ftime(), as contributed by Peter Bengtsson. Thank you very much! + +- Added the missing S_ISSOCKET() macro to . Note that this + is not actually a POSIX feature. + +- Added fmin(), fminf(), fmax() and fmaxf() to the build makefiles. + Somehow I must have forgotten about them :-( + - select() and waitselect() can now be called without any file descriptor sets to work with, as some software does which uses select() in place of sleep(). diff --git a/library/include/sys/stat.h b/library/include/sys/stat.h index 95dc610..e3225d2 100644 --- a/library/include/sys/stat.h +++ b/library/include/sys/stat.h @@ -1,5 +1,5 @@ /* - * $Id: stat.h,v 1.9 2006-01-08 12:06:14 obarthel Exp $ + * $Id: stat.h,v 1.10 2006-07-28 13:19:12 obarthel Exp $ * * :ts=4 * @@ -106,12 +106,13 @@ extern "C" { /****************************************************************************/ -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) /* directory */ -#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) /* char special */ -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) /* regular file */ -#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) /* symbolic link */ -#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) /* fifo */ -#define S_ISBLK(m) (0) /* block special */ +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) /* directory */ +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) /* char special */ +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) /* regular file */ +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) /* symbolic link */ +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) /* fifo */ +#define S_ISBLK(m) (0) /* block special */ +#define S_ISSOCK(m) (((m) & S_IFSOCK) == S_IFSOCK) /* socket */ /****************************************************************************/ diff --git a/library/include/sys/timeb.h b/library/include/sys/timeb.h new file mode 100644 index 0000000..250ca75 --- /dev/null +++ b/library/include/sys/timeb.h @@ -0,0 +1,66 @@ +/* + * $Id: timeb.h,v 1.1 2006-07-28 13:19:12 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2006 by Olaf Barthel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Neither the name of Olaf Barthel nor the names of contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ***************************************************************************** + * + * Documentation and source code for this library, and the most recent library + * build are available from . + * + ***************************************************************************** + */ + +#ifndef _SYS_TIMEB_H +#define _SYS_TIMEB_H + +/****************************************************************************/ + +#ifndef _TIME_H +#include /* For the definition of time_t */ +#endif /* _TIME_H */ + +/****************************************************************************/ + +struct timeb +{ + time_t time; + unsigned short millitm; + short timezone; + short dstflag; +}; + +/****************************************************************************/ + +extern int ftime(struct timeb *); + +/****************************************************************************/ + +#endif /* _SYS_TIMEB_H */ diff --git a/library/timeb_ftime.c b/library/timeb_ftime.c new file mode 100644 index 0000000..f2faddb --- /dev/null +++ b/library/timeb_ftime.c @@ -0,0 +1,74 @@ +/* + * $Id: timeb_ftime.c,v 1.1 2006-07-28 13:19:11 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2006 by Olaf Barthel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Neither the name of Olaf Barthel nor the names of contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +/****************************************************************************/ + +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +/****************************************************************************/ + +int +ftime(struct timeb *tb) +{ + struct timeval tv; + struct timezone tz; + int retval = -1; + + ENTER(); + + if(tb == NULL) + { + __set_errno(EFAULT); + goto out; + } + + if(gettimeofday(&tv,&tz) != 0) + goto out; + + tb->time = tv.tv_sec; + tb->millitm = tv.tv_usec / 1000; + tb->timezone = tz.tz_minuteswest; + tb->dstflag = tz.tz_dsttime; + + retval = 0; + + out: + + RETURN(retval); + return(retval); +}