mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Added the fsync() and fdatasync() functions and the <stdint.h> and
<inttypes.h> header files contributed by Peter Bengtsson. Thank you very much! git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14827 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: GNUmakefile.68k,v 1.24 2005-02-03 16:56:15 obarthel Exp $
|
||||
# $Id: GNUmakefile.68k,v 1.25 2005-02-04 15:03:09 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@ -389,8 +389,10 @@ C_LIB = \
|
||||
unistd_dup.o \
|
||||
unistd_dup2.o \
|
||||
unistd_fchown.o \
|
||||
unistd_fdatasync.o \
|
||||
unistd_fdopen.o \
|
||||
unistd_fileno.o \
|
||||
unistd_fsync.o \
|
||||
unistd_ftruncate.o \
|
||||
unistd_getcwd.o \
|
||||
unistd_getopt.o \
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: GNUmakefile.os4,v 1.24 2005-02-03 16:56:15 obarthel Exp $
|
||||
# $Id: GNUmakefile.os4,v 1.25 2005-02-04 15:03:09 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@ -391,8 +391,10 @@ C_LIB = \
|
||||
unistd_dup.o \
|
||||
unistd_dup2.o \
|
||||
unistd_fchown.o \
|
||||
unistd_fdatasync.o \
|
||||
unistd_fdopen.o \
|
||||
unistd_fileno.o \
|
||||
unistd_fsync.o \
|
||||
unistd_ftruncate.o \
|
||||
unistd_getcwd.o \
|
||||
unistd_getopt.o \
|
||||
|
||||
@ -36,6 +36,10 @@
|
||||
- The library no longer sends ACTION_DISK_INFO packets to the console
|
||||
handler. The side-effects were too varied and irritating after all.
|
||||
|
||||
- Added the fsync() and fdatasync() functions and the <stdint.h> and
|
||||
<inttypes.h> header files contributed by Peter Bengtsson. Thank
|
||||
you very much!
|
||||
|
||||
|
||||
c.lib 1.187 (29.1.2005)
|
||||
|
||||
|
||||
296
library/include/inttypes.h
Normal file
296
library/include/inttypes.h
Normal file
@ -0,0 +1,296 @@
|
||||
/*
|
||||
* $Id: inttypes.h,v 1.1 2005-02-04 15:03:13 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||
* Copyright (c) 2002-2005 by Olaf Barthel <olsen@sourcery.han.de>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _INTTYPES_H
|
||||
#define _INTTYPES_H
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* Integral types with specified size; contributed by Peter Bengtsson */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef _STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif /* _STDINT_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* printf() format specifications for different types. */
|
||||
|
||||
/* "Decimal" */
|
||||
#define PRId8 "d"
|
||||
#define PRId16 "d"
|
||||
#define PRId32 "d"
|
||||
#define PRId64 "lld"
|
||||
|
||||
#define PRIdLEAST8 "d"
|
||||
#define PRIdLEAST16 "d"
|
||||
#define PRIdLEAST32 "d"
|
||||
#define PRIdLEAST64 "lld"
|
||||
|
||||
#define PRIdFAST8 "d"
|
||||
#define PRIdFAST16 "d"
|
||||
#define PRIdFAST32 "d"
|
||||
#define PRIdFAST64 "lld"
|
||||
|
||||
#define PRIdPTR "ld"
|
||||
|
||||
/* "Integer" */
|
||||
#define PRIi8 "i"
|
||||
#define PRIi16 "i"
|
||||
#define PRIi32 "i"
|
||||
#define PRIi64 "lli"
|
||||
|
||||
#define PRIiLEAST8 "i"
|
||||
#define PRIiLEAST16 "i"
|
||||
#define PRIiLEAST32 "i"
|
||||
#define PRIiLEAST64 "lli"
|
||||
|
||||
#define PRIiFAST8 "i"
|
||||
#define PRIiFAST16 "i"
|
||||
#define PRIiFAST32 "i"
|
||||
#define PRIiFAST64 "lli"
|
||||
|
||||
#define PRIiPTR "li"
|
||||
|
||||
/* "Unsigned" */
|
||||
#define PRIu8 "u"
|
||||
#define PRIu16 "u"
|
||||
#define PRIu32 "u"
|
||||
#define PRIu64 "llu"
|
||||
|
||||
#define PRIuLEAST8 "u"
|
||||
#define PRIuLEAST16 "u"
|
||||
#define PRIuLEAST32 "u"
|
||||
#define PRIuLEAST64 "llu"
|
||||
|
||||
#define PRIuFAST8 "u"
|
||||
#define PRIuFAST16 "u"
|
||||
#define PRIuFAST32 "u"
|
||||
#define PRIuFAST64 "llu"
|
||||
|
||||
#define PRIuPTR "lu"
|
||||
|
||||
/* "Hexadecimal - lowercase " */
|
||||
#define PRIx8 "x"
|
||||
#define PRIx16 "x"
|
||||
#define PRIx32 "x"
|
||||
#define PRIx64 "llx"
|
||||
|
||||
#define PRIxLEAST8 "x"
|
||||
#define PRIxLEAST16 "x"
|
||||
#define PRIxLEAST32 "x"
|
||||
#define PRIxLEAST64 "llx"
|
||||
|
||||
#define PRIxFAST8 "x"
|
||||
#define PRIxFAST16 "x"
|
||||
#define PRIxFAST32 "x"
|
||||
#define PRIxFAST64 "llx"
|
||||
|
||||
#define PRIxPTR "lx"
|
||||
|
||||
/* "Hexadecimal - Uppercase" */
|
||||
#define PRIX8 "X"
|
||||
#define PRIX16 "X"
|
||||
#define PRIX32 "X"
|
||||
#define PRIX64 "llX"
|
||||
|
||||
#define PRIXLEAST8 "X"
|
||||
#define PRIXLEAST16 "X"
|
||||
#define PRIXLEAST32 "X"
|
||||
#define PRIXLEAST64 "llX"
|
||||
|
||||
#define PRIXFAST8 "X"
|
||||
#define PRIXFAST16 "X"
|
||||
#define PRIXFAST32 "X"
|
||||
#define PRIXFAST64 "llX"
|
||||
|
||||
#define PRIXPTR "lX"
|
||||
|
||||
/* "Octal" */
|
||||
#define PRIo8 "o"
|
||||
#define PRIo16 "o"
|
||||
#define PRIo32 "o"
|
||||
#define PRIo64 "llo"
|
||||
|
||||
#define PRIoLEAST8 "o"
|
||||
#define PRIoLEAST16 "o"
|
||||
#define PRIoLEAST32 "o"
|
||||
#define PRIoLEAST64 "llo"
|
||||
|
||||
#define PRIoFAST8 "o"
|
||||
#define PRIoFAST16 "o"
|
||||
#define PRIoFAST32 "o"
|
||||
#define PRIoFAST64 "llo"
|
||||
|
||||
#define PRIoPTR "lo"
|
||||
|
||||
/* intmax_t is 32 bits for SAS/C, 64-bits for GCC or if using a conforming C99 compiler. */
|
||||
|
||||
#if defined(__GNUC__) || ((__STDC_VERSION__ +0) >= 199901L)
|
||||
#define PRIdMAX "lld"
|
||||
#define PRIiMAX "lli"
|
||||
#define PRIuMAX "llu"
|
||||
#define PRIxMAX "llx"
|
||||
#define PRIXMAX "llX"
|
||||
#define PRIoMAX "llo"
|
||||
#else
|
||||
#define PRIdMAX "ld"
|
||||
#define PRIiMAX "li"
|
||||
#define PRIuMAX "lu"
|
||||
#define PRIxMAX "lx"
|
||||
#define PRIXMAX "lX"
|
||||
#define PRIoMAX "lo"
|
||||
#endif
|
||||
|
||||
/* scanf() format specifiers. */
|
||||
|
||||
/* "Decimal" */
|
||||
/* #define SCNd8 "hhd" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNd16 "hd"
|
||||
#define SCNd32 "d"
|
||||
#define SCNd64 "lld"
|
||||
|
||||
/* #define SCNdLEAST8 "hhd" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNdLEAST16 "hd"
|
||||
#define SCNdLEAST32 "d"
|
||||
#define SCNdLEAST64 "lld"
|
||||
|
||||
/* #define SCNdFAST8 "hhd" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNdFAST16 "d"
|
||||
#define SCNdFAST32 "d"
|
||||
#define SCNdFAST64 "lld"
|
||||
|
||||
#define SCNdPTR "d"
|
||||
|
||||
/* "Integer" */
|
||||
/* #define SCNi8 "hhi" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNi16 "hi"
|
||||
#define SCNi32 "i"
|
||||
#define SCNi64 "lli"
|
||||
|
||||
/* #define SCNiLEAST8 "hhi" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNiLEAST16 "hi"
|
||||
#define SCNiLEAST32 "i"
|
||||
#define SCNiLEAST64 "lli"
|
||||
|
||||
/* #define SCNiFAST8 "hhi" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNiFAST16 "i"
|
||||
#define SCNiFAST32 "i"
|
||||
#define SCNiFAST64 "lli"
|
||||
|
||||
#define SCNiPTR "i"
|
||||
|
||||
/* "Unsigned" */
|
||||
/* #define SCNu8 "hhu" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNu16 "hu"
|
||||
#define SCNu32 "u"
|
||||
#define SCNu64 "llu"
|
||||
|
||||
/* #define SCNuLEAST8 "hhu" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNuLEAST16 "hu"
|
||||
#define SCNuLEAST32 "u"
|
||||
#define SCNuLEAST64 "llu"
|
||||
|
||||
/* #define SCNuFAST8 "hhu" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNuFAST16 "u"
|
||||
#define SCNuFAST32 "u"
|
||||
#define SCNuFAST64 "llu"
|
||||
|
||||
#define SCNuPTR "u"
|
||||
|
||||
/* "Hexadecimal" */
|
||||
/* #define SCNx8 "hhx" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNx16 "hx"
|
||||
#define SCNx32 "x"
|
||||
#define SCNx64 "llx"
|
||||
|
||||
/* #define SCNxLEAST8 "hhx" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNxLEAST16 "hx"
|
||||
#define SCNxLEAST32 "x"
|
||||
#define SCNxLEAST64 "llx"
|
||||
|
||||
/* #define SCNxFAST8 "hhx" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNxFAST16 "x"
|
||||
#define SCNxFAST32 "x"
|
||||
#define SCNxFAST64 "llx"
|
||||
|
||||
#define SCNxPTR "x"
|
||||
|
||||
/* "Octal" */
|
||||
/* #define SCNo8 "hho" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNo16 "ho"
|
||||
#define SCNo32 "o"
|
||||
#define SCNo64 "llo"
|
||||
|
||||
/* #define SCNoLEAST8 "hho" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNoLEAST16 "ho"
|
||||
#define SCNoLEAST32 "o"
|
||||
#define SCNoLEAST64 "llo"
|
||||
|
||||
/* #define SCNoFAST8 "hho" */ /* Missing. TODO: Add support for char conversions in scanf() */
|
||||
#define SCNoFAST16 "o"
|
||||
#define SCNoFAST32 "o"
|
||||
#define SCNoFAST64 "llo"
|
||||
|
||||
#define SCNoPTR "o"
|
||||
|
||||
#if defined(__GNUC__) || ((__STDC_VERSION__ +0) >= 199901L)
|
||||
#define SCNdMAX "lld"
|
||||
#define SCNiMAX "lli"
|
||||
#define SCNuMAX "llu"
|
||||
#define SCNxMAX "llx"
|
||||
#define SCNoMAX "llo"
|
||||
#else
|
||||
#define SCNdMAX "ld"
|
||||
#define SCNiMAX "li"
|
||||
#define SCNuMAX "lu"
|
||||
#define SCNxMAX "lx"
|
||||
#define SCNoMAX "lo"
|
||||
#endif
|
||||
|
||||
/* TODO: Add the rest of inttypes.h here + in the library. */
|
||||
|
||||
/*
|
||||
* Missing stuff is among other things atoll(), strtoll(), ...
|
||||
* Then there is the matter of wchar support - Zzzz.
|
||||
*/
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#endif /* _INTTYPES_H */
|
||||
186
library/include/stdint.h
Normal file
186
library/include/stdint.h
Normal file
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* $Id: stdint.h,v 1.1 2005-02-04 15:03:14 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||
* Copyright (c) 2002-2005 by Olaf Barthel <olsen@sourcery.han.de>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _STDINT_H
|
||||
#define _STDINT_H
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* C99 integer type definitions; contributed by Peter Bengtsson */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef _LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif /* _LIMITS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* Common for all supported compilers. */
|
||||
|
||||
typedef signed char int8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
|
||||
typedef signed char int_least8_t;
|
||||
typedef signed short int_least16_t;
|
||||
typedef signed int int_least32_t;
|
||||
typedef unsigned char uint_least8_t;
|
||||
typedef unsigned short uint_least16_t;
|
||||
typedef unsigned int uint_least32_t;
|
||||
|
||||
/* This is mostly guesswork. */
|
||||
typedef signed char int_fast8_t;
|
||||
typedef signed int int_fast16_t;
|
||||
typedef signed int int_fast32_t;
|
||||
typedef unsigned char uint_fast8_t;
|
||||
typedef unsigned int uint_fast16_t;
|
||||
typedef unsigned int uint_fast32_t;
|
||||
|
||||
typedef signed long intptr_t;
|
||||
typedef unsigned long uintptr_t;
|
||||
|
||||
|
||||
#if defined(__GNUC__) || ((__STDC_VERSION__ +0) >= 199901L)
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef signed long long int_least64_t;
|
||||
typedef unsigned long long uint_least64_t;
|
||||
typedef signed long long int_fast64_t;
|
||||
typedef unsigned long long uint_fast64_t;
|
||||
typedef signed long long intmax_t;
|
||||
typedef unsigned long long uintmax_t;
|
||||
#else /* No 64-bit types for SAS/C */
|
||||
typedef signed long intmax_t;
|
||||
typedef unsigned long uintmax_t;
|
||||
#endif
|
||||
|
||||
#define INT8_MIN SCHAR_MIN
|
||||
#define INT8_MAX SCHAR_MAX
|
||||
#define UINT8_MAX UCHAR_MAX
|
||||
#define INT16_MIN SHRT_MIN
|
||||
#define INT16_MAX SHRT_MAX
|
||||
#define UINT16_MAX USHRT_MAX
|
||||
#define INT32_MIN INT_MIN
|
||||
#define INT32_MAX INT_MAX
|
||||
#define UINT32_MAX UINT_MAX
|
||||
#if defined(__GNUC__) || ((__STDC_VERSION__ +0) >= 199901L)
|
||||
#define INT64_MIN LLONG_MIN
|
||||
#define INT64_MAX LLONG_MAX
|
||||
#define UINT64_MAX ULLONG_MAX
|
||||
#endif
|
||||
|
||||
#define INT_LEAST8_MIN SCHAR_MIN
|
||||
#define INT_LEAST8_MAX SCHAR_MAX
|
||||
#define UINT_LEAST8_MAX UCHAR_MAX
|
||||
#define INT_LEAST16_MIN SHRT_MIN
|
||||
#define INT_LEAST16_MAX SHRT_MAX
|
||||
#define UINT_LEAST16_MAX USHRT_MAX
|
||||
#define INT_LEAST32_MIN INT_MIN
|
||||
#define INT_LEAST32_MAX INT_MAX
|
||||
#define UINT_LEAST32_MAX UINT_MAX
|
||||
#if defined(__GNUC__) || ((__STDC_VERSION__ +0) >= 199901L)
|
||||
#define INT_LEAST64_MIN LLONG_MIN
|
||||
#define INT_LEAST64_MAX LLONG_MAX
|
||||
#define UINT_LEAST64_MAX ULLONG_MAX
|
||||
#endif
|
||||
|
||||
#define INT_FAST8_MIN SCHAR_MIN
|
||||
#define INT_FAST8_MAX SCHAR_MAX
|
||||
#define UINT_FAST8_MAX UCHAR_MAX
|
||||
#define INT_FAST16_MIN INT_MIN
|
||||
#define INT_FAST16_MAX INT_MAX
|
||||
#define UINT_FAST16_MAX UINT_MAX
|
||||
#define INT_FAST32_MIN INT_MIN
|
||||
#define INT_FAST32_MAX INT_MAX
|
||||
#define UINT_FAST32_MAX UINT_MAX
|
||||
#if defined(__GNUC__) || ((__STDC_VERSION__ +0) >= 199901L)
|
||||
#define INT_FAST64_MIN LLONG_MIN
|
||||
#define INT_FAST64_MAX LLONG_MAX
|
||||
#define UINT_FAST64_MAX ULLONG_MAX
|
||||
#endif
|
||||
|
||||
#define INTPTR_MIN LONG_MIN
|
||||
#define INTPTR_MAX LONG_MAX
|
||||
#define UINTPTR_MAX ULONG_MAX
|
||||
|
||||
#if defined(__GNUC__) || ((__STDC_VERSION__ +0) >= 199901L)
|
||||
#define INTMAX_MIN LLONG_MIN
|
||||
#define INTMAX_MAX LLONG_MAX
|
||||
#define UINTMAX_MAX ULLONG_MAX
|
||||
#else
|
||||
#define INTMAX_MIN LONG_MIN
|
||||
#define INTMAX_MAX LONG_MAX
|
||||
#define UINTMAX_MAX ULONG_MAX
|
||||
#endif
|
||||
|
||||
#if !defined(__cpluspluis) || defined(__STDC_LIMIT_MACROS)
|
||||
/* sigatomic_t is an int. */
|
||||
#define SIG_ATOMIC_MIN INT_MIN
|
||||
#define SIG_ATOMIC_MAX INT_MAX
|
||||
|
||||
/* Maximum value of size_t */
|
||||
#define SIZE_MAX UINT_MAX
|
||||
#endif /* not C++ or LIMIT_MACROS */
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
|
||||
#define INT8_C(x) x
|
||||
#define INT16_C(x) x
|
||||
#define INT32_C(x) x
|
||||
#define INT64_C(x) x ## LL
|
||||
|
||||
#define UINT8_C(x) x ## U
|
||||
#define UINT16_C(x) x ## U
|
||||
#define UINT32_C(x) x ## U
|
||||
#define UINT64_C(x) x ## ULL
|
||||
|
||||
#if defined(__GNUC__) || ((__STDC_VERSION__ +0) >= 199901L)
|
||||
#define INTMAX_C(x) x ## LL
|
||||
#define UINTMAX_C(x) x ## ULL
|
||||
#else
|
||||
#define INTMAX_C(x) x ## L
|
||||
#define UINTMAX_C(x) x ## UL
|
||||
#endif
|
||||
|
||||
#endif /* not C++ or CONSTANT_MACROS */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#endif /* _STDINT_H */
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: unistd.h,v 1.8 2005-01-02 09:07:21 obarthel Exp $
|
||||
* $Id: unistd.h,v 1.9 2005-02-04 15:03:14 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -98,6 +98,8 @@ extern void usleep(unsigned long microseconds);
|
||||
extern int getopt(int argc, char * argv[], char *opts);
|
||||
extern pid_t getpid(void);
|
||||
extern char *realpath(const char *file_name, char *resolved_name);
|
||||
extern int fsync(int file_descriptor);
|
||||
extern int fdatasync(int file_descriptor);
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# $Id: smakefile,v 1.19 2005-02-03 16:56:15 obarthel Exp $
|
||||
_#
|
||||
# $Id: smakefile,v 1.20 2005-02-04 15:03:10 obarthel Exp $
|
||||
#
|
||||
# :ts=8
|
||||
#
|
||||
@ -501,8 +501,10 @@ UNISTD_OBJ = \
|
||||
unistd_dup.o \
|
||||
unistd_dup2.o \
|
||||
unistd_fchown.o \
|
||||
unistd_fdatasync.o \
|
||||
unistd_fdopen.o \
|
||||
unistd_fileno.o \
|
||||
unistd_fsync.o \
|
||||
unistd_ftruncate.o \
|
||||
unistd_getcwd.o \
|
||||
unistd_getopt.o \
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: socket_hook_entry.c,v 1.5 2005-02-03 16:56:15 obarthel Exp $
|
||||
* $Id: socket_hook_entry.c,v 1.6 2005-02-04 15:03:10 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -174,6 +174,15 @@ __socket_hook_entry(
|
||||
|
||||
break;
|
||||
|
||||
case file_hook_action_flush:
|
||||
|
||||
SHOWMSG("file_hook_action_flush attempted on socket");
|
||||
|
||||
result = -1;
|
||||
error = EINVAL;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
SHOWVALUE(message->action);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_fdhookentry.c,v 1.8 2005-02-03 16:56:15 obarthel Exp $
|
||||
* $Id: stdio_fdhookentry.c,v 1.9 2005-02-04 15:03:11 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -1395,6 +1395,30 @@ grow_file_size(struct fd * fd,int num_bytes,int * error_ptr)
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
static void
|
||||
sync_fd(struct fd * fd,int mode)
|
||||
{
|
||||
assert( fd != NULL );
|
||||
|
||||
if(fd->fd_DefaultFile != ZERO)
|
||||
{
|
||||
/* The mode tells us what to flush. 0 means "flush just the data", and
|
||||
everything else means "flush everything. */
|
||||
Flush(fd->fd_DefaultFile);
|
||||
|
||||
if(mode != 0)
|
||||
{
|
||||
struct FileHandle * fh = BADDR(fd->fd_DefaultFile);
|
||||
|
||||
/* Verify that this file is not bound to "NIL:". */
|
||||
if(fh->fh_Type != NULL)
|
||||
DoPkt(fh->fh_Type,ACTION_FLUSH, 0,0,0,0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
void
|
||||
__fd_hook_entry(
|
||||
struct Hook * UNUSED unused_hook,
|
||||
@ -2205,6 +2229,15 @@ __fd_hook_entry(
|
||||
result = 0;
|
||||
break;
|
||||
|
||||
case file_hook_action_flush:
|
||||
|
||||
SHOWMSG("file_hook_action_flush");
|
||||
|
||||
sync_fd(fd,message->arg);
|
||||
|
||||
result = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
SHOWVALUE(message->action);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: stdio_headers.h,v 1.11 2005-02-04 08:49:10 obarthel Exp $
|
||||
* $Id: stdio_headers.h,v 1.12 2005-02-04 15:03:11 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
@ -323,7 +323,8 @@ enum file_hook_action_t
|
||||
file_hook_action_duplicate_fd,
|
||||
file_hook_action_seek_and_extend,
|
||||
file_hook_action_is_interactive,
|
||||
file_hook_action_set_async
|
||||
file_hook_action_set_async,
|
||||
file_hook_action_flush
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
97
library/unistd_fdatasync.c
Normal file
97
library/unistd_fdatasync.c
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* $Id: unistd_fdatasync.c,v 1.1 2005-02-04 15:03:11 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||
* Copyright (c) 2002-2005 by Olaf Barthel <olsen@sourcery.han.de>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _UNISTD_HEADERS_H
|
||||
#include "unistd_headers.h"
|
||||
#endif /* _UNISTD_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* fdatasync() performs as fsync() except that metadata (atime, ctime etc.)
|
||||
is not necessarily flushed. The original source code was contributed by
|
||||
Peter Bengtsson. */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
int
|
||||
fdatasync(int file_descriptor)
|
||||
{
|
||||
DECLARE_UTILITYBASE();
|
||||
|
||||
struct file_hook_message message;
|
||||
struct fd * fd;
|
||||
int result = -1;
|
||||
|
||||
ENTER();
|
||||
|
||||
SHOWVALUE(file_descriptor);
|
||||
|
||||
assert( UtilityBase != NULL );
|
||||
|
||||
if(__check_abort_enabled)
|
||||
__check_abort();
|
||||
|
||||
assert( file_descriptor >= 0 && file_descriptor < __num_fd );
|
||||
assert( __fd[file_descriptor] != NULL );
|
||||
assert( FLAG_IS_SET(__fd[file_descriptor]->fd_Flags,FDF_IN_USE) );
|
||||
|
||||
fd = __get_file_descriptor(file_descriptor);
|
||||
if(fd == NULL)
|
||||
{
|
||||
__set_errno(EBADF);
|
||||
goto out;
|
||||
}
|
||||
|
||||
message.action = file_hook_action_flush;
|
||||
message.arg = 0; /* flush just the data */
|
||||
|
||||
assert( fd->fd_Hook != NULL );
|
||||
|
||||
CallHookPkt(fd->fd_Hook,fd,&message);
|
||||
|
||||
result = message.result;
|
||||
if(result != 0)
|
||||
{
|
||||
__set_errno(message.error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
RETURN(result);
|
||||
return(result);
|
||||
}
|
||||
96
library/unistd_fsync.c
Normal file
96
library/unistd_fsync.c
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* $Id: unistd_fsync.c,v 1.1 2005-02-04 15:03:11 obarthel Exp $
|
||||
*
|
||||
* :ts=4
|
||||
*
|
||||
* Portable ISO 'C' (1994) runtime library for the Amiga computer
|
||||
* Copyright (c) 2002-2005 by Olaf Barthel <olsen@sourcery.han.de>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _UNISTD_HEADERS_H
|
||||
#include "unistd_headers.h"
|
||||
#endif /* _UNISTD_HEADERS_H */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* The following is not part of the ISO 'C' (1994) standard. */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
/* fsync() flushes all pending data and metadata on a file descriptor.
|
||||
The original source code was contributed by Peter Bengtsson. */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
int
|
||||
fsync(int file_descriptor)
|
||||
{
|
||||
DECLARE_UTILITYBASE();
|
||||
|
||||
struct file_hook_message message;
|
||||
struct fd * fd;
|
||||
int result = -1;
|
||||
|
||||
ENTER();
|
||||
|
||||
SHOWVALUE(file_descriptor);
|
||||
|
||||
assert( UtilityBase != NULL );
|
||||
|
||||
if(__check_abort_enabled)
|
||||
__check_abort();
|
||||
|
||||
assert( file_descriptor >= 0 && file_descriptor < __num_fd );
|
||||
assert( __fd[file_descriptor] != NULL );
|
||||
assert( FLAG_IS_SET(__fd[file_descriptor]->fd_Flags,FDF_IN_USE) );
|
||||
|
||||
fd = __get_file_descriptor(file_descriptor);
|
||||
if(fd == NULL)
|
||||
{
|
||||
__set_errno(EBADF);
|
||||
goto out;
|
||||
}
|
||||
|
||||
message.action = file_hook_action_flush;
|
||||
message.arg = 1; /* flush everything */
|
||||
|
||||
assert( fd->fd_Hook != NULL );
|
||||
|
||||
CallHookPkt(fd->fd_Hook,fd,&message);
|
||||
|
||||
result = message.result;
|
||||
if(result != 0)
|
||||
{
|
||||
__set_errno(message.error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
RETURN(result);
|
||||
return(result);
|
||||
}
|
||||
Reference in New Issue
Block a user