Changeset 82d062d8 in mainline


Ignore:
Timestamp:
2012-10-31T21:03:03Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f220e25
Parents:
34b9299
Message:

Add a missing copyright message and cstyle.

Location:
uspace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/print/print6.c

    r34b9299 r82d062d8  
     1/*
     2 * Copyright (c) 2012 Adam Hraska
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
    129#include <stdio.h>
    230#include <unistd.h>
     
    432
    533#include <str.h>
    6 
    7 
    8 
    934
    1035const char *test_print6(void)
     
    2853                { 0.099999999999999999, "%g",  "0.1", 0 },   
    2954
    30                 /* gcc and msvc convert "3.4567e-317" to different binary doubles. */
     55                /*
     56                 * gcc and msvc convert "3.4567e-317" to different binary
     57                 * doubles.
     58                 */
    3159                { 3.4567e-317, "%g",  "3.4567e-317", "3.456998e-317" },   
    3260                { 3.4567e-318, "%g",  "3.4567e-318", 0 },   
     
    5684
    5785                /* full padding */
    58                 { 1e-1, "%+010.3e",  "+1.000e-01", 0 },  /* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_ZEROPADDED */
     86
     87                /* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_ZEROPADDED */
     88                { 1e-1, "%+010.3e",  "+1.000e-01", 0 },
    5989                { 1e-1, "%+10.3e",  "+1.000e-01", 0 },   
    60                 { 1e-1, "%+-10.3e",  "+1.000e-01", 0 },  /* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_LEFTALIGNED */
     90                /* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_LEFTALIGNED */
     91                { 1e-1, "%+-10.3e",  "+1.000e-01", 0 },
    6192
    6293                /* padding */
    63                 { 1e-1, "%+010.2e",  "+01.00e-01", 0 },  /* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_ZEROPADDED */
     94
     95                /* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_ZEROPADDED */
     96                { 1e-1, "%+010.2e",  "+01.00e-01", 0 },
    6497                { 1e-1, "%+10.2e",  " +1.00e-01", 0 },   
    65                 { 1e-1, "%+-10.2e",  "+1.00e-01 ", 0 },  /* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_LEFTALIGNED */
    66 
    67                 { 1e-1, "% 010.2e",  " 01.00e-01", 0 },  /* __PRINTF_FLAG_SPACESIGN | __PRINTF_FLAG_ZEROPADDED */
    68                 { 1e-1, "%010.2e",  "001.00e-01", 0 },   /* __PRINTF_FLAG_ZEROPADDED */
    69                 { 1e-1, "% 10.2e",  "  1.00e-01", 0 },   /* __PRINTF_FLAG_SPACESIGN */
     98                /* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_LEFTALIGNED */
     99                { 1e-1, "%+-10.2e",  "+1.00e-01 ", 0 },
     100                /* __PRINTF_FLAG_SPACESIGN | __PRINTF_FLAG_ZEROPADDED */
     101                { 1e-1, "% 010.2e",  " 01.00e-01", 0 },
     102                /* __PRINTF_FLAG_ZEROPADDED */
     103                { 1e-1, "%010.2e",  "001.00e-01", 0 },
     104                /* __PRINTF_FLAG_SPACESIGN */
     105                { 1e-1, "% 10.2e",  "  1.00e-01", 0 },
    70106                { 1e-1, "%10.2e",  "  1.00e-01", 0 },   
    71107
    72108                /* padding fractionals */
    73                 { 1.08e29, "%+010.3e",  "+1.080e+29", 0 },  /* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_ZEROPADDED */
     109
     110                /* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_ZEROPADDED */
     111                { 1.08e29, "%+010.3e",  "+1.080e+29", 0 },
    74112                { 1.08e29, "%+10.3e",  "+1.080e+29", 0 }, 
    75                 { 1.08e29, "%+011.2e",  "+001.08e+29", 0 }, /* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_ZEROPADDED */
     113                /* __PRINTF_FLAG_SHOWPLUS | __PRINTF_FLAG_ZEROPADDED */
     114                { 1.08e29, "%+011.2e",  "+001.08e+29", 0 },
    76115                { 1.085e29, "%11.2e", "   1.09e+29", 0 },   
    77116
    78117                /* rounding */
     118
    79119                { 1.345e2, "%+10.2e",  " +1.35e+02", 0 },
    80120                { 9.995e2, "%+10.2e",  " +1.00e+03", 0 },
    81121                { -9.99499999e2, "%10.2e",  " -9.99e+02", 0 },   
    82122                { -9.99499999e2, "%10.0e",  "    -1e+03", 0 },   
    83                 { -9.99499999e2, "%#10.0e",  "   -1.e+03", 0 }, /* __PRINTF_FLAG_DECIMALPT */
    84                 { -1.2345006789e+231, "%#10.10e",   "-1.2345006789e+231", 0 },  /* __PRINTF_FLAG_DECIMALPT */
    85                 { -1.23450067995e+231, "%#10.10e",  "-1.2345006800e+231", 0 },  /* __PRINTF_FLAG_DECIMALPT */
     123                /* __PRINTF_FLAG_DECIMALPT */
     124                { -9.99499999e2, "%#10.0e",  "   -1.e+03", 0 },
     125                /* __PRINTF_FLAG_DECIMALPT */
     126                { -1.2345006789e+231, "%#10.10e",   "-1.2345006789e+231", 0 },
     127                /* __PRINTF_FLAG_DECIMALPT */
     128                { -1.23450067995e+231, "%#10.10e",  "-1.2345006800e+231", 0 },
    86129                       
    87130                /* special */
     131
    88132                { 1e300 * 1e300, "%10.5e",  "       inf", 0 },   
    89133                { -1.0 /(1e300 * 1e300), "%10.2e",  " -0.00e+00", 0 },   
    90                 { 1e300 * 1e300, "%10.5E",  "       INF", 0 },          /* __PRINTF_FLAG_BIGCHARS */
    91                 { -1.0 /(1e300 * 1e300), "%10.2E",  " -0.00E+00", 0 },  /* __PRINTF_FLAG_BIGCHARS */
     134                /* __PRINTF_FLAG_BIGCHARS */
     135                { 1e300 * 1e300, "%10.5E",  "       INF", 0 },
     136                /* __PRINTF_FLAG_BIGCHARS */
     137                { -1.0 /(1e300 * 1e300), "%10.2E",  " -0.00E+00", 0 },
    92138
    93139                /*
     
    96142                 
    97143                /* padding */
    98                 { 1e-1, "% 010.3f",  " 00000.100", 0 },  /* __PRINTF_FLAG_SPACESIGN | __PRINTF_FLAG_ZEROPADDED */
    99                 { 1e-1, "% 0-10.3f",  " 0.100    ", 0 }, /* __PRINTF_FLAG_SPACESIGN | __PRINTF_FLAG_ZEROPADDED | __PRINTF_FLAG_LEFTALIGNED */
    100                 { 1e-1, "% 010.3f",  " 00000.100", 0 },  /* __PRINTF_FLAG_SPACESIGN | __PRINTF_FLAG_ZEROPADDED */
     144
     145                /* __PRINTF_FLAG_SPACESIGN | __PRINTF_FLAG_ZEROPADDED */
     146                { 1e-1, "% 010.3f",  " 00000.100", 0 },
     147                /*
     148                 * __PRINTF_FLAG_SPACESIGN | __PRINTF_FLAG_ZEROPADDED |
     149                 * __PRINTF_FLAG_LEFTALIGNED
     150                 */
     151                { 1e-1, "% 0-10.3f",  " 0.100    ", 0 },
     152                /* __PRINTF_FLAG_SPACESIGN | __PRINTF_FLAG_ZEROPADDED */
     153                { 1e-1, "% 010.3f",  " 00000.100", 0 },
    101154                { 1e-1, "%10.3f",  "     0.100", 0 },   
    102155
    103156                /* rounding */
     157
    104158                { -0.0, "%10.0f",     "        -0", 0 },   
    105159                { -0.099, "%+10.3f",   "    -0.099", 0 },
     
    111165                { 0.1, "%+10.6f",      " +0.100000", 0 },
    112166
    113                 /* The compiler will go for closer 0.10..055 instead of 0.09..917 */
     167                /*
     168                 * The compiler will go for closer 0.10..055 instead of
     169                 * 0.09..917
     170                 */
    114171                { 0.1, "%+10.20f",  "+0.10000000000000000550", 0 }, 
    115172                /* Next closest to 0.1 */
    116                 { 0.0999999999999999917, "%+10.20f",  "+0.09999999999999999170", 0 },
    117                 { 0.0999999999999999917, "%+10f",  " +0.100000", 0 },
    118                 { 0.0999999999999998945, "%10.20f",  "0.09999999999999989450", 0 },   
    119                
     173                { 0.0999999999999999917, "%+10.20f", "+0.09999999999999999170",
     174                    0 },
     175                { 0.0999999999999999917, "%+10f",    " +0.100000", 0 },
     176                { 0.0999999999999998945, "%10.20f",  "0.09999999999999989450",
     177                    0 },   
    120178        };
    121179
     
    125183        char buf[256 + 1] = { 0 };
    126184       
    127         TPRINTF("Test printing of floating point numbers via printf(\"%%f\"):\n");
     185        TPRINTF("Test printing of floating point numbers via "
     186            "printf(\"%%f\"):\n");
    128187       
    129188        for (int i = 0; i < patterns_len; ++i) {
     
    131190                snprintf(buf, buf_size, pat[i].fmt, pat[i].val);
    132191               
    133                 if (0 == str_cmp(buf, pat[i].exp_str)) {
    134                         TPRINTF("ok:  %s |%s| == |%s|\n", pat[i].fmt, buf, pat[i].exp_str);
     192                if (!str_cmp(buf, pat[i].exp_str)) {
     193                        TPRINTF("ok:  %s |%s| == |%s|\n",
     194                            pat[i].fmt, buf, pat[i].exp_str);
    135195                } else {
    136                         if (pat[i].warn_str && 0 == str_cmp(buf, pat[i].warn_str)) {
    137                                 TPRINTF("warn: %s |%s| != |%s|\n", pat[i].fmt, buf, pat[i].exp_str);
     196                        if (pat[i].warn_str && !str_cmp(buf, pat[i].warn_str)) {
     197                                TPRINTF("warn: %s |%s| != |%s|\n",
     198                                    pat[i].fmt, buf, pat[i].exp_str);
    138199                        } else {
    139200                                ++failed;
    140                                 TPRINTF("ERR: %s |%s| != |%s|\n", pat[i].fmt, buf, pat[i].exp_str);
     201                                TPRINTF("ERR: %s |%s| != |%s|\n",
     202                                    pat[i].fmt, buf, pat[i].exp_str);
    141203                        }
    142204                }
  • uspace/lib/c/generic/double_to_str.c

    r34b9299 r82d062d8  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829#include <double_to_str.h>
    2930
  • uspace/lib/c/generic/ieee_double.c

    r34b9299 r82d062d8  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829#include <ieee_double.h>
    2930
  • uspace/lib/c/generic/power_of_ten.c

    r34b9299 r82d062d8  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829#include "private/power_of_ten.h"
    2930
  • uspace/lib/c/generic/private/power_of_ten.h

    r34b9299 r82d062d8  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829#ifndef POWER_OF_TEN_H_
    2930#define POWER_OF_TEN_H_
     
    3233struct fp_num_t_tag;
    3334
    34 
    35 void get_power_of_ten(int binary_exp, struct fp_num_t_tag *power_of_10,
    36         int *decimal_exp);
    37 
     35extern void get_power_of_ten(int, struct fp_num_t_tag *, int *);
    3836
    3937#endif
  • uspace/lib/c/include/double_to_str.h

    r34b9299 r82d062d8  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829#ifndef DOUBLE_TO_STR_H_
    2930#define DOUBLE_TO_STR_H_
     
    4546#define MAX_DOUBLE_STR_BUF_SIZE  21
    4647
    47 
    4848/* Fwd decl.*/
    4949struct ieee_double_t_tag;
    5050
    51 
    52 int double_to_short_str(struct ieee_double_t_tag val, char *buf, size_t buf_size,
    53         int *dec_exponent);
    54 
    55 int double_to_fixed_str(struct ieee_double_t_tag ieee_val, int signif_d_cnt,
    56         int frac_d_cnt, char *buf, size_t buf_size, int *dec_exponent);
    57 
     51extern int double_to_short_str(struct ieee_double_t_tag, char *, size_t, int *);
     52extern int double_to_fixed_str(struct ieee_double_t_tag, int, int, char *,
     53    size_t, int *);
    5854
    5955#endif
  • uspace/lib/c/include/ieee_double.h

    r34b9299 r82d062d8  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829#ifndef IEEE_DOUBLE_H_
    2930#define IEEE_DOUBLE_H_
     
    3132#include <stdint.h>
    3233#include <bool.h>
    33 
    3434
    3535/** Represents a non-negative floating point number: significand * 2^exponent */
     
    4040        int exponent;
    4141} fp_num_t;
    42 
    4342
    4443/** Double number description according to IEEE 754. */
     
    6665} ieee_double_t;
    6766
    68 
    69 ieee_double_t extract_ieee_double(double val);
     67extern ieee_double_t extract_ieee_double(double);
    7068
    7169#endif
Note: See TracChangeset for help on using the changeset viewer.