Index: embios/trunk/snprintf.c |
— | — | @@ -34,7 +34,8 @@ |
35 | 35 | #include "format.h"
|
36 | 36 |
|
37 | 37 |
|
38 | | -struct for_snprintf {
|
| 38 | +struct for_snprintf
|
| 39 | +{
|
39 | 40 | unsigned char *ptr; /* where to store it */
|
40 | 41 | size_t bytes; /* amount already stored */
|
41 | 42 | size_t max; /* max amount to store */
|
— | — | @@ -43,7 +44,8 @@ |
44 | 45 | static int sprfunc(void *ptr, unsigned char letter)
|
45 | 46 | {
|
46 | 47 | struct for_snprintf *pr = (struct for_snprintf *)ptr;
|
47 | | - if(pr->bytes < pr->max) {
|
| 48 | + if(pr->bytes < pr->max)
|
| 49 | + {
|
48 | 50 | *pr->ptr = letter;
|
49 | 51 | pr->ptr++;
|
50 | 52 | pr->bytes++;
|
Index: embios/trunk/console.h |
— | — | @@ -26,6 +26,7 @@ |
27 | 27 |
|
28 | 28 |
|
29 | 29 | #include "global.h"
|
| 30 | +#include "gcc_extensions.h"
|
30 | 31 | #include <stdarg.h>
|
31 | 32 |
|
32 | 33 |
|
— | — | @@ -33,7 +34,8 @@ |
34 | 35 | void cputc(unsigned int consoles, char string) ICODE_ATTR;
|
35 | 36 | void cputs(unsigned int consoles, const char* string) ICODE_ATTR;
|
36 | 37 | void cwrite(unsigned int consoles, const char* string, size_t length) ICODE_ATTR;
|
37 | | -int cprintf(unsigned int consoles, const char* fmt, ...) ICODE_ATTR;
|
| 38 | +int cprintf(unsigned int consoles, const char* fmt, ...) ICODE_ATTR
|
| 39 | + ATTRIBUTE_PRINTF(2, 3);
|
38 | 40 | int cvprintf(unsigned int consoles, const char* fmt, va_list ap) ICODE_ATTR;
|
39 | 41 | void cflush(unsigned int consoles) ICODE_ATTR;
|
40 | 42 | int cgetc(unsigned int consoles, int timeout) ICODE_ATTR;
|
Index: embios/trunk/snprintf.h |
— | — | @@ -25,15 +25,14 @@ |
26 | 26 | #define __SNPRINTF_H__
|
27 | 27 |
|
28 | 28 |
|
29 | | -#define __need___va_list
|
| 29 | +#include "global.h"
|
| 30 | +#include "gcc_extensions.h"
|
30 | 31 | #include <stdarg.h>
|
31 | | -#include "global.h"
|
32 | 32 |
|
33 | 33 |
|
34 | | -int vsnprintf (char *buf, size_t size, const char *fmt, __VALIST ap);
|
| 34 | +int vsnprintf(char *buf, size_t size, const char *fmt, va_list ap);
|
35 | 35 |
|
36 | | -int snprintf (char *buf, size_t size, const char *fmt, ...)
|
37 | | - ATTRIBUTE_PRINTF(3, 4);
|
| 36 | +int snprintf(char *buf, size_t size, const char *fmt, ...) ATTRIBUTE_PRINTF(3, 4);
|
38 | 37 |
|
39 | 38 |
|
40 | 39 | #endif
|
Index: embios/trunk/panic.h |
— | — | @@ -26,6 +26,8 @@ |
27 | 27 |
|
28 | 28 |
|
29 | 29 | #include "global.h"
|
| 30 | +#include "gcc_extensions.h"
|
| 31 | +#include <stdarg.h>
|
30 | 32 |
|
31 | 33 |
|
32 | 34 | enum panic_severity
|
— | — | @@ -37,7 +39,8 @@ |
38 | 40 |
|
39 | 41 |
|
40 | 42 | void panic(enum panic_severity severity, const char* string) ICODE_ATTR;
|
41 | | -void panicf(enum panic_severity severity, const char* string, ...) ICODE_ATTR;
|
| 43 | +void panicf(enum panic_severity severity, const char* string, ...) ICODE_ATTR
|
| 44 | + ATTRIBUTE_PRINTF(2, 3);
|
42 | 45 |
|
43 | 46 |
|
44 | 47 | #endif
|
Index: embios/trunk/file.c |
— | — | @@ -18,16 +18,15 @@ |
19 | 19 | * KIND, either express or implied. |
20 | 20 | * |
21 | 21 | ****************************************************************************/ |
| 22 | +#include "global.h" |
22 | 23 | #include <string.h> |
23 | 24 | #include <errno.h> |
24 | | -#include <stdbool.h> |
25 | 25 | #include "file.h" |
26 | 26 | #include "fat.h" |
27 | 27 | #include "dir.h" |
28 | 28 | #include "debug.h" |
29 | | -#include "dircache.h" |
30 | 29 | #include "filefuncs.h" |
31 | | -#include "system.h" |
| 30 | +#include "gcc_extensions.h"
|
32 | 31 | |
33 | 32 | /* |
34 | 33 | These functions provide a roughly POSIX-compatible file IO API. |
Index: embios/trunk/gcc_extensions.h |
— | — | @@ -0,0 +1,46 @@ |
| 2 | +/*************************************************************************** |
| 3 | + * __________ __ ___. |
| 4 | + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 5 | + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 6 | + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 7 | + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 8 | + * \/ \/ \/ \/ \/ |
| 9 | + * |
| 10 | + * Copyright © 2010 Rafaël Carré |
| 11 | + * |
| 12 | + * This program is free software; you can redistribute it and/or |
| 13 | + * modify it under the terms of the GNU General Public License |
| 14 | + * as published by the Free Software Foundation; either version 2 |
| 15 | + * of the License, or (at your option) any later version. |
| 16 | + * |
| 17 | + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | + * KIND, either express or implied. |
| 19 | + * |
| 20 | + ****************************************************************************/ |
| 21 | + |
| 22 | +#ifndef __GCC_EXTENSIONS_H__ |
| 23 | +#define __GCC_EXTENSIONS_H__ |
| 24 | + |
| 25 | +/* Support for some GCC extensions */ |
| 26 | + |
| 27 | +/* Compile time check of format for printf/scanf like functions */ |
| 28 | +#ifdef __GNUC__ |
| 29 | +#define ATTRIBUTE_PRINTF(fmt, arg1) __attribute__( ( format( printf, fmt, arg1 ) ) ) |
| 30 | +#define ATTRIBUTE_SCANF(fmt, arg1) __attribute__( ( format( scanf, fmt, arg1 ) ) ) |
| 31 | +#else |
| 32 | +#define ATTRIBUTE_PRINTF(fmt, arg1) |
| 33 | +#define ATTRIBUTE_SCANF(fmt, arg1) |
| 34 | +#endif |
| 35 | + |
| 36 | + |
| 37 | +/* Use to give gcc hints on which branch is most likely taken */ |
| 38 | +#if defined(__GNUC__) && __GNUC__ >= 3 |
| 39 | +#define LIKELY(x) __builtin_expect(!!(x), 1) |
| 40 | +#define UNLIKELY(x) __builtin_expect(!!(x), 0) |
| 41 | +#else |
| 42 | +#define LIKELY(x) (x) |
| 43 | +#define UNLIKELY(x) (x) |
| 44 | +#endif |
| 45 | + |
| 46 | + |
| 47 | +#endif /* _GCC_EXTENSIONS_H_ */ |
Property changes on: embios/trunk/gcc_extensions.h |
___________________________________________________________________ |
Added: svn:mergeinfo |
## -0,0 +0,1 ## |
1 | 48 | Merged /embios/trunk/gcc_extensions.h:r18-19 |