Changeset 7329e6a in mainline for uspace/lib/c


Ignore:
Timestamp:
2010-11-29T19:22:58Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5581b469
Parents:
3a4b3ba (diff), 41a7f62 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
uspace/lib/c
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/abs32le/include/inttypes.h

    r3a4b3ba r7329e6a  
    3434#define LIBC_abs32le_INTTYPES_H_
    3535
    36 #define PRIdPTR  PRId32
    37 #define PRIoPTR  PRIo32
    38 #define PRIuPTR  PRIu32
    39 #define PRIxPTR  PRIx32
    40 #define PRIXPTR  PRIX32
     36#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
     37#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
     38#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
     39#define PRIua  PRIu32  /**< Format for atomic_count_t. */
    4140
    4241#endif
  • uspace/lib/c/arch/amd64/include/inttypes.h

    r3a4b3ba r7329e6a  
    3030 * @{
    3131 */
    32 /** @file Macros for format specifiers.
    33  *
    34  * Macros for formatting stdint types as specified in section
    35  * 7.8.1 Macros for format specifiers of the C99 draft specification
    36  * (ISO/IEC 9899:201x). Only some macros from the specification are
    37  * implemented.
    38  */
    3932
    4033#ifndef LIBC_amd64_INTTYPES_H_
    4134#define LIBC_amd64_INTTYPES_H_
    4235
    43 #define PRIdPTR  PRId64
    44 #define PRIoPTR  PRIo64
    45 #define PRIuPTR  PRIu64
    46 #define PRIxPTR  PRIx64
    47 #define PRIXPTR  PRIX64
     36#define PRIdn  PRId64  /**< Format for sysarg_t, ipcarg_t, etc. */
     37#define PRIun  PRIu64  /**< Format for sysarg_t, ipcarg_t, etc. */
     38#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
     39#define PRIua  PRIu64  /**< Format for atomic_count_t. */
    4840
    4941#endif
  • uspace/lib/c/arch/arm32/include/inttypes.h

    r3a4b3ba r7329e6a  
    3030 * @{
    3131 */
    32 /** @file Macros for format specifiers.
    33  *
    34  * Macros for formatting stdint types as specified in section
    35  * 7.8.1 Macros for format specifiers of the C99 draft specification
    36  * (ISO/IEC 9899:201x). Only some macros from the specification are
    37  * implemented.
    38  */
    3932
    4033#ifndef LIBC_arm32_INTTYPES_H_
    4134#define LIBC_arm32_INTTYPES_H_
    4235
    43 #define PRIdPTR  PRId32
    44 #define PRIoPTR  PRIo32
    45 #define PRIuPTR  PRIu32
    46 #define PRIxPTR  PRIx32
    47 #define PRIXPTR  PRIX32
     36#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
     37#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
     38#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
     39#define PRIua  PRIu32  /**< Format for atomic_count_t. */
    4840
    4941#endif
  • uspace/lib/c/arch/ia32/include/inttypes.h

    r3a4b3ba r7329e6a  
    3030 * @{
    3131 */
    32 /** @file Macros for format specifiers.
    33  *
    34  * Macros for formatting stdint types as specified in section
    35  * 7.8.1 Macros for format specifiers of the C99 draft specification
    36  * (ISO/IEC 9899:201x). Only some macros from the specification are
    37  * implemented.
    38  */
    3932
    4033#ifndef LIBC_ia32_INTTYPES_H_
    4134#define LIBC_ia32_INTTYPES_H_
    4235
    43 #define PRIdPTR  PRId32
    44 #define PRIoPTR  PRIo32
    45 #define PRIuPTR  PRIu32
    46 #define PRIxPTR  PRIx32
    47 #define PRIXPTR  PRIX32
     36#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
     37#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
     38#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
     39#define PRIua  PRIu32  /**< Format for atomic_count_t. */
    4840
    4941#endif
  • uspace/lib/c/arch/ia64/include/inttypes.h

    r3a4b3ba r7329e6a  
    3030 * @{
    3131 */
    32 /** @file Macros for format specifiers.
    33  *
    34  * Macros for formatting stdint types as specified in section
    35  * 7.8.1 Macros for format specifiers of the C99 draft specification
    36  * (ISO/IEC 9899:201x). Only some macros from the specification are
    37  * implemented.
    38  */
    3932
    4033#ifndef LIBC_ia64_INTTYPES_H_
    4134#define LIBC_ia64_INTTYPES_H_
    4235
    43 #define PRIdPTR  PRId64
    44 #define PRIoPTR  PRIo64
    45 #define PRIuPTR  PRIu64
    46 #define PRIxPTR  PRIx64
    47 #define PRIXPTR  PRIX64
     36#define PRIdn  PRId64  /**< Format for sysarg_t, ipcarg_t, etc. */
     37#define PRIun  PRIu64  /**< Format for sysarg_t, ipcarg_t, etc. */
     38#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
     39#define PRIua  PRIu64  /**< Format for atomic_count_t. */
    4840
    4941#endif
  • uspace/lib/c/arch/mips32/include/inttypes.h

    r3a4b3ba r7329e6a  
    3030 * @{
    3131 */
    32 /** @file Macros for format specifiers.
    33  *
    34  * Macros for formatting stdint types as specified in section
    35  * 7.8.1 Macros for format specifiers of the C99 draft specification
    36  * (ISO/IEC 9899:201x). Only some macros from the specification are
    37  * implemented.
    38  */
    3932
    4033#ifndef LIBC_mips32_INTTYPES_H_
    4134#define LIBC_mips32_INTTYPES_H_
    4235
    43 #define PRIdPTR  PRId32
    44 #define PRIoPTR  PRIo32
    45 #define PRIuPTR  PRIu32
    46 #define PRIxPTR  PRIx32
    47 #define PRIXPTR  PRIX32
     36#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
     37#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
     38#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
     39#define PRIua  PRIu32  /**< Format for atomic_count_t. */
    4840
    4941#endif
  • uspace/lib/c/arch/ppc32/include/inttypes.h

    r3a4b3ba r7329e6a  
    3030 * @{
    3131 */
    32 /** @file Macros for format specifiers.
    33  *
    34  * Macros for formatting stdint types as specified in section
    35  * 7.8.1 Macros for format specifiers of the C99 draft specification
    36  * (ISO/IEC 9899:201x). Only some macros from the specification are
    37  * implemented.
    38  */
    3932
    4033#ifndef LIBC_ppc32_INTTYPES_H_
    4134#define LIBC_ppc32_INTTYPES_H_
    4235
    43 #define PRIdPTR  PRId32
    44 #define PRIoPTR  PRIo32
    45 #define PRIuPTR  PRIu32
    46 #define PRIxPTR  PRIx32
    47 #define PRIXPTR  PRIX32
     36#define PRIdn  PRId32  /**< Format for sysarg_t, ipcarg_t, etc. */
     37#define PRIun  PRIu32  /**< Format for sysarg_t, ipcarg_t, etc. */
     38#define PRIxn  PRIx32  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
     39#define PRIua  PRIu32  /**< Format for atomic_count_t. */
    4840
    4941#endif
  • uspace/lib/c/arch/sparc64/include/inttypes.h

    r3a4b3ba r7329e6a  
    3030 * @{
    3131 */
    32 /** @file Macros for format specifiers.
    33  *
    34  * Macros for formatting stdint types as specified in section
    35  * 7.8.1 Macros for format specifiers of the C99 draft specification
    36  * (ISO/IEC 9899:201x). Only some macros from the specification are
    37  * implemented.
    38  */
    3932
    4033#ifndef LIBC_sparc64_INTTYPES_H_
    4134#define LIBC_sparc64_INTTYPES_H_
    4235
    43 #define PRIdPTR  PRId64
    44 #define PRIoPTR  PRIo64
    45 #define PRIuPTR  PRIu64
    46 #define PRIxPTR  PRIx64
    47 #define PRIXPTR  PRIX64
     36#define PRIdn  PRId64  /**< Format for sysarg_t, ipcarg_t, etc. */
     37#define PRIun  PRIu64  /**< Format for sysarg_t, ipcarg_t, etc. */
     38#define PRIxn  PRIx64  /**< Format for hexadecimal sysarg_t, ipcarg_t, etc. */
     39#define PRIua  PRIu64  /**< Format for atomic_count_t. */
    4840
    4941#endif
  • uspace/lib/c/generic/device/char.c

    r3a4b3ba r7329e6a  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929 /** @addtogroup libc
    3030 * @{
     
    4040#include <stdio.h>
    4141
    42 /** Read to or write from the device using its character interface.
    43  *
    44  * Helper function.
    45  *
    46  * @param dev_phone phone to the device.
    47  * @param buf the buffer for the data read from or written to the device.
    48  * @param len the maximum length of the data to be read or written.
    49  * @param read read from the device if true, write to it otherwise.
    50  *
    51  * @return non-negative number of bytes actually read from or written to the device on success,
    52  * negative error number otherwise.
    53  *
     42/** Read to or write from device.
     43 *
     44 * Helper function to read to or write from a device
     45 * using its character interface.
     46 *
     47 * @param dev_phone Phone to the device.
     48 * @param buf       Buffer for the data read
     49 *                  from or written to the device.
     50 * @param len       Maximum length of the data to be
     51 *                  read or written.
     52 * @param read      Read from the device if true,
     53 *                  write to it otherwise.
     54 *
     55 * @return Non-negative number of bytes actually read
     56 *         from or written to the device on success,
     57 *         negative error number otherwise.
     58 *
    5459 */
    55 static int rw_dev(int dev_phone, void *buf, size_t len, bool read)
     60static ssize_t rw_dev(int dev_phone, void *buf, size_t len, bool read)
    5661{
    57         ipc_call_t answer;
    58        
    5962        async_serialize_start();
    6063       
     64        ipc_call_t answer;
    6165        aid_t req;
    6266        int ret;
    6367       
    6468        if (read) {
    65                 req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE), CHAR_READ_DEV, &answer);
    66                 ret = async_data_read_start(dev_phone, buf, len);               
     69                req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE),
     70                    CHAR_READ_DEV, &answer);
     71                ret = async_data_read_start(dev_phone, buf, len);
    6772        } else {
    68                 req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE), CHAR_WRITE_DEV, &answer);
     73                req = async_send_1(dev_phone, DEV_IFACE_ID(CHAR_DEV_IFACE),
     74                    CHAR_WRITE_DEV, &answer);
    6975                ret = async_data_write_start(dev_phone, buf, len);
    7076        }
    7177       
    7278        ipcarg_t rc;
    73         if (ret != EOK) {               
     79        if (ret != EOK) {
    7480                async_wait_for(req, &rc);
    7581                async_serialize_end();
    76                 if (rc == EOK) {
    77                         return ret;
    78                 }
    79                 else {
    80                         return (int) rc;
    81                 }
     82                if (rc == EOK)
     83                        return (ssize_t) ret;
     84                       
     85                return (ssize_t) rc;
    8286        }
    8387       
     
    8589        async_serialize_end();
    8690       
    87         ret = (int)rc;
    88         if (EOK != ret) {
    89                 return ret;
    90         }
     91        ret = (int) rc;
     92        if (ret != EOK)
     93                return (ssize_t) ret;
    9194       
    92         return IPC_GET_ARG1(answer);   
     95        return (ssize_t) IPC_GET_ARG1(answer);
    9396}
    9497
    95 /** Read from the device using its character interface.
    96  *
    97  * @param dev_phone phone to the device.
    98  * @param buf the output buffer for the data read from the device.
    99  * @param len the maximum length of the data to be read.
    100  *
    101  * @return non-negative number of bytes actually read from the device on success, negative error number otherwise.
     98/** Read from device using its character interface.
     99 *
     100 * @param dev_phone Phone to the device.
     101 * @param buf       Output buffer for the data
     102 *                  read from the device.
     103 * @param len       Maximum length of the data to be read.
     104 *
     105 * @return Non-negative number of bytes actually read
     106 *         from the device on success, negative error
     107 *         number otherwise.
     108 *
    102109 */
    103 int read_dev(int dev_phone, void *buf, size_t len)
    104 {       
     110ssize_t read_dev(int dev_phone, void *buf, size_t len)
     111{
    105112        return rw_dev(dev_phone, buf, len, true);
    106113}
    107114
    108 /** Write to the device using its character interface.
    109  *
    110  * @param dev_phone phone to the device.
    111  * @param buf the input buffer containg the data to be written to the device.
    112  * @param len the maximum length of the data to be written.
    113  *
    114  * @return non-negative number of bytes actually written to the device on success, negative error number otherwise.
     115/** Write to device using its character interface.
     116 *
     117 * @param dev_phone Phone to the device.
     118 * @param buf       Input buffer containg the data
     119 *                  to be written to the device.
     120 * @param len       Maximum length of the data to be written.
     121 *
     122 * @return Non-negative number of bytes actually written
     123 *         to the device on success, negative error number
     124 *         otherwise.
     125 *
    115126 */
    116 int write_dev(int dev_phone, void *buf, size_t len)
     127ssize_t write_dev(int dev_phone, void *buf, size_t len)
    117128{
    118129        return rw_dev(dev_phone, buf, len, false);
    119130}
    120131
    121  
    122  /** @}
     132/** @}
    123133 */
  • uspace/lib/c/generic/io/printf_core.c

    r3a4b3ba r7329e6a  
    8282        PrintfQualifierLong,
    8383        PrintfQualifierLongLong,
    84         PrintfQualifierPointer
     84        PrintfQualifierPointer,
     85        PrintfQualifierSize
    8586} qualifier_t;
    8687
     
    552553 *  - ""   Signed or unsigned int (default value).@n
    553554 *  - "l"  Signed or unsigned long int.@n
    554  *         If conversion is "c", the character is wchar_t (wide character).@n
     555 *         If conversion is "c", the character is wint_t (wide character).@n
    555556 *         If conversion is "s", the string is wchar_t * (wide string).@n
    556557 *  - "ll" Signed or unsigned long long int.@n
     558 *  - "z"  Signed or unsigned ssize_t or site_t.@n
    557559 *
    558560 * CONVERSION:@n
     
    736738                                }
    737739                                break;
     740                        case 'z':
     741                                qualifier = PrintfQualifierSize;
     742                                i = nxt;
     743                                uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
     744                                break;
    738745                        default:
    739746                                /* Default type */
     
    763770                        case 'c':
    764771                                if (qualifier == PrintfQualifierLong)
    765                                         retval = print_wchar(va_arg(ap, wchar_t), width, flags, ps);
     772                                        retval = print_wchar(va_arg(ap, wint_t), width, flags, ps);
    766773                                else
    767774                                        retval = print_char(va_arg(ap, unsigned int), width, flags, ps);
     
    849856                                precision = size << 1;
    850857                                number = (uint64_t) (uintptr_t) va_arg(ap, void *);
     858                                break;
     859                        case PrintfQualifierSize:
     860                                size = sizeof(size_t);
     861                                number = (uint64_t) va_arg(ap, size_t);
    851862                                break;
    852863                        default:
  • uspace/lib/c/generic/stacktrace.c

    r3a4b3ba r7329e6a  
    5050
    5151        while (stacktrace_fp_valid(&st, fp)) {
    52                 printf("%p: %p()\n", fp, pc);
     52                printf("%p: %p()\n", (void *) fp, (void *) pc);
    5353                (void) stacktrace_ra_get(&st, fp, &pc);
    5454                (void) stacktrace_fp_prev(&st, fp, &nfp);
  • uspace/lib/c/generic/str.c

    r3a4b3ba r7329e6a  
    10051005        *end = '\0';
    10061006        return start;
     1007}
     1008
     1009/** Convert string to uint64_t (internal variant).
     1010 *
     1011 * @param nptr   Pointer to string.
     1012 * @param endptr Pointer to the first invalid character is stored here.
     1013 * @param base   Zero or number between 2 and 36 inclusive.
     1014 * @param neg    Indication of unary minus is stored here.
     1015 * @apram result Result of the conversion.
     1016 *
     1017 * @return EOK if conversion was successful.
     1018 *
     1019 */
     1020static int str_uint(const char *nptr, char **endptr, unsigned int base,
     1021    bool *neg, uint64_t *result)
     1022{
     1023        assert(endptr != NULL);
     1024        assert(neg != NULL);
     1025        assert(result != NULL);
     1026       
     1027        *neg = false;
     1028        const char *str = nptr;
     1029       
     1030        /* Ignore leading whitespace */
     1031        while (isspace(*str))
     1032                str++;
     1033       
     1034        if (*str == '-') {
     1035                *neg = true;
     1036                str++;
     1037        } else if (*str == '+')
     1038                str++;
     1039       
     1040        if (base == 0) {
     1041                /* Decode base if not specified */
     1042                base = 10;
     1043               
     1044                if (*str == '0') {
     1045                        base = 8;
     1046                        str++;
     1047                       
     1048                        switch (*str) {
     1049                        case 'b':
     1050                        case 'B':
     1051                                base = 2;
     1052                                str++;
     1053                                break;
     1054                        case 'o':
     1055                        case 'O':
     1056                                base = 8;
     1057                                str++;
     1058                                break;
     1059                        case 'd':
     1060                        case 'D':
     1061                        case 't':
     1062                        case 'T':
     1063                                base = 10;
     1064                                str++;
     1065                                break;
     1066                        case 'x':
     1067                        case 'X':
     1068                                base = 16;
     1069                                str++;
     1070                                break;
     1071                        default:
     1072                                str--;
     1073                        }
     1074                }
     1075        } else {
     1076                /* Check base range */
     1077                if ((base < 2) || (base > 36)) {
     1078                        *endptr = (char *) str;
     1079                        return EINVAL;
     1080                }
     1081        }
     1082       
     1083        *result = 0;
     1084        const char *startstr = str;
     1085       
     1086        while (*str != 0) {
     1087                unsigned int digit;
     1088               
     1089                if ((*str >= 'a') && (*str <= 'z'))
     1090                        digit = *str - 'a' + 10;
     1091                else if ((*str >= 'A') && (*str <= 'Z'))
     1092                        digit = *str - 'A' + 10;
     1093                else if ((*str >= '0') && (*str <= '9'))
     1094                        digit = *str - '0';
     1095                else
     1096                        break;
     1097               
     1098                if (digit >= base)
     1099                        break;
     1100               
     1101                uint64_t prev = *result;
     1102                *result = (*result) * base + digit;
     1103               
     1104                if (*result < prev) {
     1105                        /* Overflow */
     1106                        *endptr = (char *) str;
     1107                        return EOVERFLOW;
     1108                }
     1109               
     1110                str++;
     1111        }
     1112       
     1113        if (str == startstr) {
     1114                /*
     1115                 * No digits were decoded => first invalid character is
     1116                 * the first character of the string.
     1117                 */
     1118                str = nptr;
     1119        }
     1120       
     1121        *endptr = (char *) str;
     1122       
     1123        if (str == nptr)
     1124                return EINVAL;
     1125       
     1126        return EOK;
     1127}
     1128
     1129/** Convert string to uint64_t.
     1130 *
     1131 * @param nptr   Pointer to string.
     1132 * @param endptr If not NULL, pointer to the first invalid character
     1133 *               is stored here.
     1134 * @param base   Zero or number between 2 and 36 inclusive.
     1135 * @param strict Do not allow any trailing characters.
     1136 * @param result Result of the conversion.
     1137 *
     1138 * @return EOK if conversion was successful.
     1139 *
     1140 */
     1141int str_uint64(const char *nptr, char **endptr, unsigned int base,
     1142    bool strict, uint64_t *result)
     1143{
     1144        assert(result != NULL);
     1145       
     1146        bool neg;
     1147        char *lendptr;
     1148        int ret = str_uint(nptr, &lendptr, base, &neg, result);
     1149       
     1150        if (endptr != NULL)
     1151                *endptr = (char *) lendptr;
     1152       
     1153        if (ret != EOK)
     1154                return ret;
     1155       
     1156        /* Do not allow negative values */
     1157        if (neg)
     1158                return EINVAL;
     1159       
     1160        /* Check whether we are at the end of
     1161           the string in strict mode */
     1162        if ((strict) && (*lendptr != 0))
     1163                return EINVAL;
     1164       
     1165        return EOK;
     1166}
     1167
     1168/** Convert string to size_t.
     1169 *
     1170 * @param nptr   Pointer to string.
     1171 * @param endptr If not NULL, pointer to the first invalid character
     1172 *               is stored here.
     1173 * @param base   Zero or number between 2 and 36 inclusive.
     1174 * @param strict Do not allow any trailing characters.
     1175 * @param result Result of the conversion.
     1176 *
     1177 * @return EOK if conversion was successful.
     1178 *
     1179 */
     1180int str_size_t(const char *nptr, char **endptr, unsigned int base,
     1181    bool strict, size_t *result)
     1182{
     1183        assert(result != NULL);
     1184       
     1185        bool neg;
     1186        char *lendptr;
     1187        uint64_t res;
     1188        int ret = str_uint(nptr, &lendptr, base, &neg, &res);
     1189       
     1190        if (endptr != NULL)
     1191                *endptr = (char *) lendptr;
     1192       
     1193        if (ret != EOK)
     1194                return ret;
     1195       
     1196        /* Do not allow negative values */
     1197        if (neg)
     1198                return EINVAL;
     1199       
     1200        /* Check whether we are at the end of
     1201           the string in strict mode */
     1202        if ((strict) && (*lendptr != 0))
     1203                return EINVAL;
     1204       
     1205        /* Check for overflow */
     1206        size_t _res = (size_t) res;
     1207        if (_res != res)
     1208                return EOVERFLOW;
     1209       
     1210        *result = _res;
     1211       
     1212        return EOK;
    10071213}
    10081214
  • uspace/lib/c/include/assert.h

    r3a4b3ba r7329e6a  
    5151
    5252#ifndef NDEBUG
    53 #       define assert(expr) \
    54                 do { \
    55                         if (!(expr)) { \
    56                                 printf("Assertion failed (%s) at file '%s', " \
    57                                     "line %d.\n", #expr, __FILE__, __LINE__); \
    58                                 abort(); \
    59                         } \
    60                 } while (0)
    61 #else
    62 #       define assert(expr)
    63 #endif
     53
     54#define assert(expr) \
     55        do { \
     56                if (!(expr)) { \
     57                        printf("Assertion failed (%s) at file '%s', " \
     58                            "line %d.\n", #expr, __FILE__, __LINE__); \
     59                        abort(); \
     60                } \
     61        } while (0)
     62
     63#else /* NDEBUG */
     64
     65#define assert(expr)
     66
     67#endif /* NDEBUG */
    6468
    6569#endif
  • uspace/lib/c/include/device/char.h

    r3a4b3ba r7329e6a  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28  
     28
    2929 /** @addtogroup libc
    3030 * @{
     
    3232/** @file
    3333 */
    34  
     34
    3535#ifndef LIBC_DEVICE_HW_RES_H_
    3636#define LIBC_DEVICE_HW_RES_H_
     
    3838typedef enum {
    3939        CHAR_READ_DEV = 0,
    40         CHAR_WRITE_DEV 
     40        CHAR_WRITE_DEV
    4141} hw_res_funcs_t;
    4242
    43 int read_dev(int dev_phone, void *buf, size_t len);
    44 int write_dev(int dev_phone, void *buf, size_t len);
     43ssize_t read_dev(int dev_phone, void *buf, size_t len);
     44ssize_t write_dev(int dev_phone, void *buf, size_t len);
    4545
    4646#endif
  • uspace/lib/c/include/err.h

    r3a4b3ba r7329e6a  
    3838#include <stdio.h>
    3939
    40 #define errx(status, fmt, ...) { \
    41         printf((fmt), ##__VA_ARGS__); \
    42         _exit(status); \
    43 }
     40#define errx(status, fmt, ...) \
     41        { \
     42                printf((fmt), ##__VA_ARGS__); \
     43                _exit(status); \
     44        }
    4445
    4546#endif
     
    4748/** @}
    4849 */
    49 
  • uspace/lib/c/include/malloc.h

    r3a4b3ba r7329e6a  
    4141extern uintptr_t get_max_heap_addr(void);
    4242
    43 extern void *malloc(const size_t size);
    44 extern void *calloc(const size_t nmemb, const size_t size);
    45 extern void *memalign(const size_t align, const size_t size);
     43extern void *malloc(const size_t size)
     44    __attribute__((malloc));
     45extern void *calloc(const size_t nmemb, const size_t size)
     46    __attribute__((malloc));
     47extern void *memalign(const size_t align, const size_t size)
     48    __attribute__((malloc));
    4649extern void *realloc(const void *addr, const size_t size);
    4750extern void free(const void *addr);
  • uspace/lib/c/include/stdint.h

    r3a4b3ba r7329e6a  
    3636#define LIBC_STDINT_H_
    3737
    38 #define INT8_MIN  (0x80)
    39 #define INT8_MAX  (0x7F)
     38#define INT8_MIN  INT8_C(0x80)
     39#define INT8_MAX  INT8_C(0x7F)
    4040
    41 #define UINT8_MIN  (0u)
    42 #define UINT8_MAX  (0xFFu)
     41#define UINT8_MIN  UINT8_C(0)
     42#define UINT8_MAX  UINT8_C(0xFF)
    4343
    44 #define INT16_MIN  (0x8000)
    45 #define INT16_MAX  (0x7FFF)
     44#define INT16_MIN  INT16_C(0x8000)
     45#define INT16_MAX  INT16_C(0x7FFF)
    4646
    47 #define UINT16_MIN  (0u)
    48 #define UINT16_MAX  (0xFFFFu)
     47#define UINT16_MIN  UINT16_C(0)
     48#define UINT16_MAX  UINT16_C(0xFFFF)
    4949
    50 #define INT32_MIN  (0x80000000l)
    51 #define INT32_MAX  (0x7FFFFFFFl)
     50#define INT32_MIN  INT32_C(0x80000000)
     51#define INT32_MAX  INT32_C(0x7FFFFFFF)
    5252
    53 #define UINT32_MIN  (0ul)
    54 #define UINT32_MAX  (0xFFFFFFFFul)
     53#define UINT32_MIN  UINT32_C(0)
     54#define UINT32_MAX  UINT32_C(0xFFFFFFFF)
    5555
    56 #define INT64_MIN  (0x8000000000000000ll)
    57 #define INT64_MAX  (0x7FFFFFFFFFFFFFFFll)
     56#define INT64_MIN  INT64_C(0x8000000000000000)
     57#define INT64_MAX  INT64_C(0x7FFFFFFFFFFFFFFF)
    5858
    59 #define UINT64_MIN  (0ull)
    60 #define UINT64_MAX  (0xFFFFFFFFFFFFFFFFull)
     59#define UINT64_MIN  UINT64_C(0)
     60#define UINT64_MAX  UINT64_C(0xFFFFFFFFFFFFFFFF)
    6161
    6262#include <libarch/types.h>
  • uspace/lib/c/include/stdio.h

    r3a4b3ba r7329e6a  
    4141#include <adt/list.h>
    4242
     43#ifndef NVERIFY_PRINTF
     44
     45#define PRINTF_ATTRIBUTE(start, end) \
     46        __attribute__((format(gnu_printf, start, end)))
     47
     48#else /* NVERIFY_PRINTF */
     49
     50#define PRINTF_ATTRIBUTE(start, end)
     51
     52#endif /* NVERIFY_PRINTF */
     53
    4354#define EOF  (-1)
    4455
     
    149160
    150161/* Formatted string output functions */
    151 extern int fprintf(FILE *, const char*, ...);
     162extern int fprintf(FILE *, const char*, ...)
     163    PRINTF_ATTRIBUTE(2, 3);
    152164extern int vfprintf(FILE *, const char *, va_list);
    153165
    154 extern int printf(const char *, ...);
     166extern int printf(const char *, ...)
     167    PRINTF_ATTRIBUTE(1, 2);
    155168extern int vprintf(const char *, va_list);
    156169
    157 extern int snprintf(char *, size_t , const char *, ...);
    158 extern int asprintf(char **, const char *, ...);
     170extern int snprintf(char *, size_t , const char *, ...)
     171    PRINTF_ATTRIBUTE(3, 4);
     172extern int asprintf(char **, const char *, ...)
     173    PRINTF_ATTRIBUTE(2, 3);
    159174extern int vsnprintf(char *, size_t, const char *, va_list);
    160175
  • uspace/lib/c/include/str.h

    r3a4b3ba r7329e6a  
    8686extern char *str_ndup(const char *, size_t max_size);
    8787
     88extern int str_uint64(const char *, char **, unsigned int, bool, uint64_t *);
     89extern int str_size_t(const char *, char **, unsigned int, bool, size_t *);
     90
    8891extern void order_suffix(const uint64_t val, uint64_t *rv, char *suffix);
    8992
  • uspace/lib/c/include/sys/typefmt.h

    r3a4b3ba r7329e6a  
    3939#include <inttypes.h>
    4040
    41 /* off64_t */
     41/* off64_t, aoff64_t */
    4242#define PRIdOFF64 PRId64
    4343#define PRIuOFF64 PRIu64
     
    4545#define PRIXOFF64 PRIX64
    4646
    47 /* (s)size_t */
    48 #define PRIdSIZE PRIdPTR
    49 #define PRIuSIZE PRIuPTR
    50 #define PRIxSIZE PRIxPTR
    51 #define PRIXSIZE PRIXPTR
    52 
    53 /* sysarg_t */
    54 #define PRIdSYSARG PRIdPTR
    55 #define PRIuSYSARG PRIuPTR
    56 #define PRIxSYSARG PRIxPTR
    57 #define PRIXSYSARG PRIxPTR
    58 
    59 /* ipcarg_t */
    60 #define PRIdIPCARG PRIdPTR
    61 #define PRIuIPCARG PRIuPTR
    62 #define PRIxIPCARG PRIxPTR
    63 #define PRIXIPCARG PRIXPTR
    64 
    65 /* taskid_t */
    66 #define PRIdTASKID PRId64
    67 #define PRIuTASKID PRIu64
    68 #define PRIxTASKID PRIx64
    69 #define PRIXTASKID PRIx64
    70 
    7147#endif
    7248
  • uspace/lib/c/include/sys/types.h

    r3a4b3ba r7329e6a  
    4646typedef uint64_t aoff64_t;
    4747
    48 /** Unicode code point */
    49 typedef int32_t wchar_t;
    50 
    5148typedef volatile uint8_t ioport8_t;
    5249typedef volatile uint16_t ioport16_t;
Note: See TracChangeset for help on using the changeset viewer.