From f2f500d61c071f14ad4eb0605482e62b8aec2b31 Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Tue, 12 Mar 2002 19:17:50 +0000 Subject: Fix another O_LARGEFILE bug. Also, I forget to make floating point optional in the new printf code. --- libc/stdio/printf.c | 41 ++++++++++++++++++++++++++++++++--------- libc/stdio/stdio.c | 12 ++++++++++-- 2 files changed, 42 insertions(+), 11 deletions(-) (limited to 'libc/stdio') diff --git a/libc/stdio/printf.c b/libc/stdio/printf.c index ad4da445b..ea066bb87 100644 --- a/libc/stdio/printf.c +++ b/libc/stdio/printf.c @@ -54,6 +54,22 @@ /**********************************************************************/ +#define __STDIO_PRINTF_FLOAT + +#if defined(__UCLIBC__) && !defined(__UCLIBC_HAS_FLOATS__) +#undef __STDIO_PRINTF_FLOAT +#endif + +#ifdef __BCC__ +#undef __STDIO_PRINTF_FLOAT +#endif + +#ifndef __STDIO_PRINTF_FLOAT +#undef L__dtostr +#endif + +/**********************************************************************/ + #define __STDIO_GLIBC_CUSTOM_PRINTF /* TODO -- move these to a configuration section? */ @@ -197,10 +213,10 @@ typedef union { #ifdef ULLONG_MAX unsigned long long ull; #endif -#ifndef __BCC__ +#ifdef __STDIO_PRINTF_FLOAT double d; long double ld; -#endif +#endif /* __STDIO_PRINTF_FLOAT */ void *p; } argvalue_t; @@ -234,7 +250,9 @@ typedef struct { /* TODO -- __isdigit() macro */ #define __isdigit(c) (((unsigned int)(c - '0')) < 10) +#ifdef __STDIO_PRINTF_FLOAT extern size_t _dtostr(FILE * fp, long double x, struct printf_info *info); +#endif #define _outnstr(stream, string, len) _stdio_fwrite(s, len, stream) /* TODO */ @@ -511,7 +529,7 @@ void _ppfs_setargs(register ppfs_t *ppfs) /* we're assuming wchar_t is at least an int */ GET_VA_ARG(p,wc,wchar_t,ppfs->arg); break; -#ifndef __BCC__ +#ifdef __STDIO_PRINTF_FLOAT /* PA_FLOAT */ case PA_DOUBLE: GET_VA_ARG(p,d,double,ppfs->arg); @@ -519,11 +537,12 @@ void _ppfs_setargs(register ppfs_t *ppfs) case (PA_DOUBLE|PA_FLAG_LONG_DOUBLE): GET_VA_ARG(p,ld,long double,ppfs->arg); break; -#else +#else /* __STDIO_PRINTF_FLOAT */ case PA_DOUBLE: case (PA_DOUBLE|PA_FLAG_LONG_DOUBLE): assert(0); -#endif + continue; +#endif /* __STDIO_PRINTF_FLOAT */ default: /* TODO -- really need to ensure this can't happen */ assert(ppfs->argtype[i-1] & PA_FLAG_PTR); @@ -598,11 +617,11 @@ static const short int type_codes[] = { PA_INT|PA_FLAG_LONG, PA_INT|PA_FLAG_LONG_LONG, PA_WCHAR, -#ifndef __BCC__ +#ifdef __STDIO_PRINTF_FLOAT /* PA_FLOAT, */ PA_DOUBLE, PA_DOUBLE|PA_FLAG_LONG_DOUBLE, -#endif +#endif /* __STDIO_PRINTF_FLOAT */ }; static const unsigned char type_sizes[] = { @@ -621,11 +640,11 @@ static const unsigned char type_sizes[] = { PROMOTED_SIZE_OF(long), /* TODO -- is this correct? (above too) */ #endif PROMOTED_SIZE_OF(wchar_t), -#ifndef __BCC__ +#ifdef __STDIO_PRINTF_FLOAT /* PROMOTED_SIZE_OF(float), */ PROMOTED_SIZE_OF(double), PROMOTED_SIZE_OF(long double), -#endif +#endif /* __STDIO_PRINTF_FLOAT */ }; static int _promoted_size(int argtype) @@ -1099,12 +1118,16 @@ int _do_one_spec(FILE * __restrict stream, register ppfs_t *ppfs, int *count) } numfill = ((numfill > slen) ? numfill - slen : 0); } else if (ppfs->conv_num <= CONV_A) { /* floating point */ +#ifdef __STDIO_PRINTF_FLOAT *count += _dtostr(stream, (PRINT_INFO_FLAG_VAL(&(ppfs->info),is_long_double) ? *(long double *) *argptr : (long double) (* (double *) *argptr)), &ppfs->info); return 0; +#else /* __STDIO_PRINTF_FLOAT */ + return -1; /* TODO -- try ton continue? */ +#endif /* __STDIO_PRINTF_FLOAT */ } else if (ppfs->conv_num <= CONV_S) { /* wide char or string */ #if 1 return -1; /* TODO -- wide */ diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c index 6d4bf40ec..e54274112 100644 --- a/libc/stdio/stdio.c +++ b/libc/stdio/stdio.c @@ -41,6 +41,13 @@ #include #include +#ifndef O_LARGEFILE /* uClibc undefines this if no large file support. */ +#ifdef __STDIO_LARGE_FILES +#error missing define for O_LARGEFILE! +#endif +#define O_LARGEFILE 0 +#endif + /**********************************************************************/ /* First deal with some build issues... */ @@ -2170,7 +2177,7 @@ FILE *_stdio_fopen(const char * __restrict filename, } else { #ifdef __STDIO_LARGE_FILES if (filedes < -1) { - open_mode |= __FLAG_LARGEFILE; + open_mode |= O_LARGEFILE; } #endif /* __STDIO_LARGE_FILES */ stream->filedes = open(filename, open_mode, 0666); @@ -2193,7 +2200,8 @@ FILE *_stdio_fopen(const char * __restrict filename, #ifdef __STDIO_BUFFERS (isatty(stream->filedes) * __FLAG_LBF) | #endif /* __STDIO_BUFFERS */ -#if (O_APPEND == __FLAG_APPEND) && (O_LARGEFILE == __FLAG_LARGEFILE) +#if (O_APPEND == __FLAG_APPEND) \ +&& ((O_LARGEFILE == __FLAG_LARGEFILE) || (O_LARGEFILE == 0)) (open_mode & (O_APPEND|O_LARGEFILE)) | /* i386 linux and elks */ #else /* (O_APPEND == __FLAG_APPEND) && (O_LARGEFILE == __FLAG_LARGEFILE) */ ((open_mode & O_APPEND) ? __FLAG_APPEND : 0) | -- cgit v1.2.3