Changeset c739102 in mainline for uspace


Ignore:
Timestamp:
2012-11-21T23:26:22Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0f2c80a
Parents:
bebf97d (diff), 1f7753a (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:

Mainline changes.

Location:
uspace
Files:
6 added
16 deleted
30 edited
4 moved

Legend:

Unmodified
Added
Removed
  • uspace/Makefile

    rbebf97d rc739102  
    4040        app/devctl \
    4141        app/edit \
    42         app/ext2info \
    4342        app/getterm \
    4443        app/init \
     
    105104        srv/fs/mfs \
    106105        srv/fs/locfs \
    107         srv/fs/ext2fs \
    108106        srv/fs/ext4fs \
    109107        srv/hid/compositor \
     
    218216        lib/net \
    219217        lib/nic \
    220         lib/ext2 \
    221218        lib/ext4 \
    222219        lib/usb \
  • uspace/Makefile.common

    rbebf97d rc739102  
    118118LIBGUI_PREFIX = $(LIB_PREFIX)/gui
    119119
    120 LIBEXT2_PREFIX = $(LIB_PREFIX)/ext2
    121120LIBEXT4_PREFIX = $(LIB_PREFIX)/ext4
    122121
  • uspace/app/bdsh/config.h

    rbebf97d rc739102  
    5555#define PACKAGE_STRING "The brain dead shell"
    5656#define PACKAGE_TARNAME "bdsh"
    57 #define PACKAGE_VERSION "0.0.1"
    58 
    59 
    60 
     57#define PACKAGE_VERSION "0.1.0"
  • uspace/app/tester/Makefile

    rbebf97d rc739102  
    2929
    3030USPACE_PREFIX = ../..
    31 LIBS = $(LIBEXT2_PREFIX)/libext2.a $(LIBBLOCK_PREFIX)/libblock.a $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
    32 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBEXT2_PREFIX) -I$(LIBSOFTFLOAT_PREFIX)
     31LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a
     32EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBSOFTFLOAT_PREFIX)
    3333BINARY = tester
    3434
     
    4242        print/print4.c \
    4343        print/print5.c \
     44        print/print6.c \
    4445        console/console1.c \
    4546        stdio/stdio1.c \
     
    6263        mm/mapping1.c \
    6364        hw/misc/virtchar1.c \
    64         hw/serial/serial1.c \
    65         ext2/ext2_1.c
     65        hw/serial/serial1.c
    6666
    6767include $(USPACE_PREFIX)/Makefile.common
  • uspace/app/tester/float/softfloat1.c

    rbebf97d rc739102  
    3434#include <mul.h>
    3535#include <div.h>
     36#include <comparison.h>
    3637#include <bool.h>
    3738#include "../tester.h"
     
    4546typedef void (* float_op_t)(float, float, float *, float_t *);
    4647typedef void (* double_op_t)(double, double, double *, double_t *);
     48typedef void (* double_cmp_op_t)(double, double, cmptype_t *, cmptype_t *);
    4749typedef void (* template_t)(void *, unsigned, unsigned, cmptype_t *,
    4850    cmptype_t *);
     
    6668       
    6769        return -a;
     70}
     71
     72static int dcmp(double a, double b)
     73{
     74        if (a < b)
     75                return -1;
     76        else if (a > b)
     77                return 1;
     78
     79        return 0;
    6880}
    6981
     
    96108        *pic = (cmptype_t) (c * PRECISION);
    97109        *pisc = (cmptype_t) (sc.val * PRECISION);
     110}
     111
     112static void
     113double_compare_template(void *f, unsigned i, unsigned j, cmptype_t *pis,
     114    cmptype_t *piss)
     115{
     116        double_cmp_op_t op = (double_cmp_op_t) f;
     117       
     118        op(dop_a[i], dop_b[j], pis, piss);
    98119}
    99120
     
    221242}
    222243
     244static void
     245double_cmp_operator(double a, double b, cmptype_t *pis, cmptype_t *piss)
     246{
     247        *pis = dcmp(a, b);
     248
     249        double_t sa;
     250        double_t sb;
     251
     252        sa.val = a;
     253        sb.val = b;
     254
     255        if (is_double_lt(sa.data, sb.data))
     256                *piss = -1;
     257        else if (is_double_gt(sa.data, sb.data))
     258                *piss = 1;
     259        else if (is_double_eq(sa.data, sb.data))
     260                *piss = 0;
     261        else
     262                *piss = 42;
     263}
     264
    223265const char *test_softfloat1(void)
    224266{
     
    249291                TPRINTF("%s\n", err);
    250292        }
     293        if (!test_template(double_compare_template, double_cmp_operator)) {
     294                err = "Double comparison failed";
     295                TPRINTF("%s\n", err);
     296        }
    251297       
    252298        return err;
  • uspace/app/tester/print/print5.def

    rbebf97d rc739102  
    11{
    2         "print1",
    3         "String printf test",
    4         &test_print1,
     2        "print5",
     3        "Char printf test",
     4        &test_print5,
    55        true
    66},
  • uspace/app/tester/tester.c

    rbebf97d rc739102  
    5353#include "print/print4.def"
    5454#include "print/print5.def"
     55#include "print/print6.def"
    5556#include "console/console1.def"
    5657#include "stdio/stdio1.def"
     
    7374#include "hw/serial/serial1.def"
    7475#include "hw/misc/virtchar1.def"
    75 #include "ext2/ext2_1.def"
    7676        {NULL, NULL, NULL, false}
    7777};
  • uspace/app/tester/tester.h

    rbebf97d rc739102  
    8585extern const char *test_print4(void);
    8686extern const char *test_print5(void);
     87extern const char *test_print6(void);
    8788extern const char *test_console1(void);
    8889extern const char *test_stdio1(void);
     
    105106extern const char *test_serial1(void);
    106107extern const char *test_virtchar1(void);
    107 extern const char *test_ext2_1(void);
    108108extern const char *test_devman1(void);
    109109extern const char *test_devman2(void);
  • uspace/drv/time/cmos-rtc/cmos-rtc.c

    rbebf97d rc739102  
    9999static time_t uptime_get(void);
    100100static bool is_battery_ok(rtc_t *rtc);
     101static int  rtc_fun_online(ddf_fun_t *fun);
     102static int  rtc_fun_offline(ddf_fun_t *fun);
    101103
    102104static ddf_dev_ops_t rtc_dev_ops;
     
    106108        .dev_add = rtc_dev_add,
    107109        .dev_remove = rtc_dev_remove,
     110        .fun_online = rtc_fun_online,
     111        .fun_offline = rtc_fun_offline,
    108112};
    109113
     
    405409        /* Try to normalize the content of the tm structure */
    406410        time_t r = mktime(t);
    407 
    408         rtc->boottime = r - uptime_get();
     411        int result;
     412
     413        if (r < 0)
     414                result = EINVAL;
     415        else {
     416                rtc->boottime = r - uptime_get();
     417                result = EOK;
     418        }
    409419
    410420        fibril_mutex_unlock(&rtc->mutex);
    411421
    412         return r < 0 ? EINVAL : EOK;
     422        return result;
    413423}
    414424
     
    637647        fibril_mutex_unlock(&rtc->mutex);
    638648
     649        rc = rtc_fun_offline(rtc->fun);
     650        if (rc != EOK) {
     651                ddf_msg(LVL_ERROR, "Failed to offline function");
     652                return rc;
     653        }
     654
    639655        rc = ddf_fun_unbind(rtc->fun);
    640656        if (rc != EOK) {
     
    725741}
    726742
     743static int
     744rtc_fun_online(ddf_fun_t *fun)
     745{
     746        int rc;
     747
     748        ddf_msg(LVL_DEBUG, "rtc_fun_online()");
     749
     750        rc = ddf_fun_online(fun);
     751        if (rc == EOK)
     752                ddf_fun_add_to_category(fun, "clock");
     753
     754        return rc;
     755}
     756
     757static int
     758rtc_fun_offline(ddf_fun_t *fun)
     759{
     760        ddf_msg(LVL_DEBUG, "rtc_fun_offline()");
     761        return ddf_fun_offline(fun);
     762}
     763
    727764int
    728765main(int argc, char **argv)
  • uspace/lib/c/Makefile

    rbebf97d rc739102  
    7777        generic/device/pci.c \
    7878        generic/device/ahci.c \
     79        generic/dlfcn.c \
    7980        generic/elf/elf_load.c \
    8081        generic/event.c \
     
    115116        generic/iplink.c \
    116117        generic/iplink_srv.c \
     118        generic/ieee_double.c \
     119        generic/power_of_ten.c \
     120        generic/double_to_str.c \
    117121        generic/malloc.c \
    118122        generic/sysinfo.c \
     
    136140        generic/net/socket_client.c \
    137141        generic/net/socket_parse.c \
     142        generic/stack.c \
    138143        generic/stacktrace.c \
    139144        generic/arg_parse.c \
     
    145150ifeq ($(CONFIG_RTLD),y)
    146151        GENERIC_SOURCES += \
    147                 generic/dlfcn.c \
    148152                generic/rtld/rtld.c \
    149153                generic/rtld/dynamic.c \
  • uspace/lib/c/generic/dlfcn.c

    rbebf97d rc739102  
    3838#include <stdlib.h>
    3939#include <dlfcn.h>
     40
     41#ifdef CONFIG_RTLD
    4042
    4143#include <rtld/module.h>
     
    8789}
    8890
     91#else /* CONFIG_RTLD not defined */
     92
     93void *dlopen(const char *path, int flag)
     94{
     95        return NULL;
     96}
     97
     98void *dlsym(void *mod, const char *sym_name)
     99{
     100        return NULL;
     101}
     102
     103#endif
     104
    89105/** @}
    90106 */
  • uspace/lib/c/generic/fibril.c

    rbebf97d rc739102  
    3737#include <fibril.h>
    3838#include <thread.h>
     39#include <stack.h>
    3940#include <tls.h>
    4041#include <malloc.h>
     42#include <abi/mm/as.h>
     43#include <as.h>
    4144#include <unistd.h>
    4245#include <stdio.h>
     
    4649#include <assert.h>
    4750#include <async.h>
    48 
    49 #ifndef FIBRIL_INITIAL_STACK_PAGES_NO
    50         #define FIBRIL_INITIAL_STACK_PAGES_NO  1
    51 #endif
    5251
    5352/**
     
    195194                                         * stack member filled.
    196195                                         */
    197                                         free(stack);
     196                                        as_area_destroy(stack);
    198197                                }
    199198                                fibril_teardown(srcf->clean_after_me);
     
    269268                return 0;
    270269       
    271         fibril->stack =
    272             (char *) malloc(FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize());
    273         if (!fibril->stack) {
     270        size_t stack_size = stack_size_get();
     271        fibril->stack = as_area_create((void *) -1, stack_size,
     272            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD |
     273            AS_AREA_LATE_RESERVE);
     274        if (fibril->stack == (void *) -1) {
    274275                fibril_teardown(fibril);
    275276                return 0;
     
    281282        context_save(&fibril->ctx);
    282283        context_set(&fibril->ctx, FADDR(fibril_main), fibril->stack,
    283             FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize(), fibril->tcb);
     284            stack_size, fibril->tcb);
    284285
    285286        return (fid_t) fibril;
     
    298299        fibril_t *fibril = (fibril_t *) fid;
    299300       
    300         free(fibril->stack);
     301        as_area_destroy(fibril->stack);
    301302        fibril_teardown(fibril);
    302303}
  • uspace/lib/c/generic/io/log.c

    rbebf97d rc739102  
    239239
    240240        char *message_buffer = malloc(MESSAGE_BUFFER_SIZE);
    241         if (message_buffer == NULL) {
     241        if (message_buffer == NULL)
    242242                return;
    243         }
    244243
    245244        vsnprintf(message_buffer, MESSAGE_BUFFER_SIZE, fmt, args);
    246245        logger_message(logger_session, ctx, level, message_buffer);
     246        free(message_buffer);
    247247}
    248248
  • uspace/lib/c/generic/io/printf_core.c

    rbebf97d rc739102  
    4242#include <ctype.h>
    4343#include <str.h>
     44#include <double_to_str.h>
     45#include <ieee_double.h>
     46#include <assert.h>
     47#include <macros.h>
     48
    4449
    4550/** show prefixes 0x or 0 */
    4651#define __PRINTF_FLAG_PREFIX       0x00000001
    4752
     53/** show the decimal point even if no fractional digits present */
     54#define __PRINTF_FLAG_DECIMALPT    0x00000001
     55
    4856/** signed / unsigned number */
    4957#define __PRINTF_FLAG_SIGNED       0x00000002
     
    6674/** number has - sign */
    6775#define __PRINTF_FLAG_NEGATIVE     0x00000100
     76
     77/** don't print trailing zeros in the fractional part */
     78#define __PRINTF_FLAG_NOFRACZEROS  0x00000200
     79
    6880
    6981/**
     
    110122static const char invalch = U_SPECIAL;
    111123
     124
     125
     126/** Unformatted double number string representation. */
     127typedef struct {
     128        /** Buffer with len digits, no sign or leading zeros. */
     129        char *str;
     130        /** Number of digits in str. */
     131        int len;
     132        /** Decimal exponent, ie number = str * 10^dec_exp */
     133        int dec_exp;
     134        /** True if negative. */
     135        bool neg;
     136} double_str_t;
     137
     138
     139
     140/** Returns the sign character or 0 if no sign should be printed. */
     141static int get_sign_char(bool negative, uint32_t flags)
     142{
     143        if (negative) {
     144                return '-';
     145        } else if (flags & __PRINTF_FLAG_SHOWPLUS) {
     146                return '+';
     147        } else if (flags & __PRINTF_FLAG_SPACESIGN) {
     148                return ' ';
     149        } else {
     150                return 0;
     151        }
     152}
     153
     154/** Prints count times character ch. */
     155static int print_padding(char ch, int count, printf_spec_t *ps)
     156{
     157        for (int i = 0; i < count; ++i) {
     158                if (ps->str_write(&ch, 1, ps->data) < 0) {
     159                        return -1;
     160                }
     161        }
     162
     163        return count;
     164}
     165
     166
    112167/** Print one or more characters without adding newline.
    113168 *
     
    281336                return printf_putstr(nullstr, ps);
    282337       
    283         /* Print leading spaces. */
    284338        size_t strw = str_length(str);
     339
     340        /* Precision unspecified - print everything. */
    285341        if ((precision == 0) || (precision > strw))
    286342                precision = strw;
     
    329385                return printf_putstr(nullstr, ps);
    330386       
    331         /* Print leading spaces. */
    332387        size_t strw = wstr_length(str);
     388
     389        /* Precision not specified - print everything. */
    333390        if ((precision == 0) || (precision > strw))
    334391                precision = strw;
     
    377434    uint32_t flags, printf_spec_t *ps)
    378435{
     436        /* Precision not specified. */
     437        if (precision < 0) {
     438                precision = 0;
     439        }
     440       
    379441        const char *digits;
    380442        if (flags & __PRINTF_FLAG_BIGCHARS)
     
    525587       
    526588        return ((int) counter);
     589}
     590
     591/** Prints a special double (ie NaN, infinity) padded to width characters. */
     592static int print_special(ieee_double_t val, int width, uint32_t flags,
     593        printf_spec_t *ps)
     594{
     595        assert(val.is_special);
     596
     597        char sign = get_sign_char(val.is_negative, flags);
     598
     599        const int str_len = 3;
     600        const char *str;
     601       
     602        if (flags & __PRINTF_FLAG_BIGCHARS) {
     603                str = val.is_infinity ? "INF" : "NAN";
     604        } else {
     605                str = val.is_infinity ? "inf" : "nan";
     606        }
     607
     608        int padding_len = max(0, width - ((sign ? 1 : 0) + str_len));
     609
     610        int counter = 0;
     611        int ret;
     612
     613        /* Leading padding. */
     614        if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
     615                if ((ret = print_padding(' ', padding_len, ps)) < 0)
     616                        return -1;
     617
     618                counter += ret;
     619        }
     620
     621        if (sign) {
     622                if ((ret = ps->str_write(&sign, 1, ps->data)) < 0)
     623                        return -1;
     624               
     625                counter += ret;
     626        }
     627
     628        if ((ret = ps->str_write(str, str_len, ps->data)) < 0)
     629                return -1;
     630       
     631        counter += ret;
     632
     633
     634        /* Trailing padding. */
     635        if (flags & __PRINTF_FLAG_LEFTALIGNED) {
     636                if ((ret = print_padding(' ', padding_len, ps)) < 0)
     637                        return -1;
     638
     639                counter += ret;
     640        }
     641
     642        return counter;
     643}
     644
     645/** Trims trailing zeros but leaves a single "0" intact. */
     646static void fp_trim_trailing_zeros(char *buf, int *len, int *dec_exp)
     647{
     648        /* Cut the zero off by adjusting the exponent. */
     649        while (2 <= *len && '0' == buf[*len - 1]) {
     650                --*len;
     651                ++*dec_exp;
     652        }
     653}
     654
     655/** Textually round up the last digit thereby eliminating it. */
     656static void fp_round_up(char *buf, int *len, int *dec_exp)
     657{
     658        assert(1 <= *len);
     659
     660        char *last_digit = &buf[*len - 1];
     661
     662        int carry = ('5' <= *last_digit);
     663
     664        /* Cut the digit off by adjusting the exponent. */
     665        --*len;
     666        ++*dec_exp;
     667        --last_digit;
     668
     669        if (carry) {
     670                /* Skip all the digits to cut off/round to zero. */
     671                while (buf <= last_digit && '9' == *last_digit) {
     672                        --last_digit;
     673                }
     674
     675                /* last_digit points to the last digit to round but not '9' */
     676                if (buf <= last_digit) {
     677                        *last_digit += 1;
     678                        int new_len = last_digit - buf + 1;
     679                        *dec_exp += *len - new_len;
     680                        *len = new_len;
     681                } else {
     682                        /* All len digits rounded to 0. */
     683                        buf[0] = '1';
     684                        *dec_exp += *len;
     685                        *len = 1;
     686                }
     687        } else {
     688                /* The only digit was rounded to 0. */
     689                if (last_digit < buf) {
     690                        buf[0] = '0';
     691                        *dec_exp = 0;
     692                        *len = 1;
     693                }
     694        }
     695}
     696
     697
     698/** Format and print the double string repressentation according
     699 *  to the %f specifier.
     700 */
     701static int print_double_str_fixed(double_str_t *val_str, int precision, int width,
     702        uint32_t flags, printf_spec_t *ps)
     703{
     704        int len = val_str->len;
     705        char *buf = val_str->str;
     706        int dec_exp = val_str->dec_exp;
     707
     708        assert(0 < len);
     709        assert(0 <= precision);
     710        assert(0 <= dec_exp || -dec_exp <= precision);
     711
     712        /* Number of integral digits to print (at least leading zero). */
     713        int int_len = max(1, len + dec_exp);
     714
     715        char sign = get_sign_char(val_str->neg, flags);
     716
     717        /* Fractional portion lengths. */
     718        int last_frac_signif_pos = max(0, -dec_exp);
     719        int leading_frac_zeros = max(0, last_frac_signif_pos - len);
     720        int signif_frac_figs = min(last_frac_signif_pos, len);
     721        int trailing_frac_zeros = precision - last_frac_signif_pos;
     722        char *buf_frac = buf + len - signif_frac_figs;
     723
     724        if (flags & __PRINTF_FLAG_NOFRACZEROS) {
     725                trailing_frac_zeros = 0;
     726        }
     727
     728        int frac_len = leading_frac_zeros + signif_frac_figs + trailing_frac_zeros;
     729
     730        bool has_decimal_pt = (0 < frac_len) || (flags & __PRINTF_FLAG_DECIMALPT);
     731
     732        /* Number of non-padding chars to print. */
     733        int num_len = (sign ? 1 : 0) + int_len + (has_decimal_pt ? 1 : 0) + frac_len;
     734
     735        int padding_len = max(0, width - num_len);
     736        int ret = 0;
     737        int counter = 0;
     738
     739        /* Leading padding and sign. */
     740
     741        if (!(flags & (__PRINTF_FLAG_LEFTALIGNED | __PRINTF_FLAG_ZEROPADDED))) {
     742                if ((ret = print_padding(' ', padding_len, ps)) < 0)
     743                        return -1;
     744
     745                counter += ret;
     746        }
     747
     748        if (sign) {
     749                if ((ret = ps->str_write(&sign, 1, ps->data)) < 0)
     750                        return -1;
     751               
     752                counter += ret;
     753        }
     754
     755        if (flags & __PRINTF_FLAG_ZEROPADDED) {
     756                if ((ret = print_padding('0', padding_len, ps)) < 0)
     757                        return -1;
     758
     759                counter += ret;
     760        }
     761
     762        /* Print the intergral part of the buffer. */
     763
     764        int buf_int_len = min(len, len + dec_exp);
     765
     766        if (0 < buf_int_len) {
     767                if ((ret = ps->str_write(buf, buf_int_len, ps->data)) < 0)
     768                        return -1;
     769
     770                counter += ret;
     771
     772                /* Print trailing zeros of the integral part of the number. */
     773                if ((ret = print_padding('0', int_len - buf_int_len, ps)) < 0)
     774                        return -1;
     775        } else {
     776                /* Single leading integer 0. */
     777                char ch = '0';
     778                if ((ret = ps->str_write(&ch, 1, ps->data)) < 0)
     779                        return -1;
     780        }
     781
     782        counter += ret;
     783       
     784        /* Print the decimal point and the fractional part. */
     785        if (has_decimal_pt) {
     786                char ch = '.';
     787
     788                if ((ret = ps->str_write(&ch, 1, ps->data)) < 0)
     789                        return -1;
     790               
     791                counter += ret;
     792
     793                /* Print leading zeros of the fractional part of the number. */
     794                if ((ret = print_padding('0', leading_frac_zeros, ps)) < 0)
     795                        return -1;
     796
     797                counter += ret;
     798
     799                /* Print significant digits of the fractional part of the number. */
     800                if (0 < signif_frac_figs) {
     801                        if ((ret = ps->str_write(buf_frac, signif_frac_figs, ps->data)) < 0)
     802                                return -1;
     803
     804                        counter += ret;
     805                }
     806
     807                /* Print trailing zeros of the fractional part of the number. */
     808                if ((ret = print_padding('0', trailing_frac_zeros, ps)) < 0)
     809                        return -1;
     810
     811                counter += ret;
     812        }
     813
     814        /* Trailing padding. */
     815        if (flags & __PRINTF_FLAG_LEFTALIGNED) {
     816                if ((ret = print_padding(' ', padding_len, ps)) < 0)
     817                        return -1;
     818
     819                counter += ret;
     820        }
     821
     822        return counter;
     823}
     824
     825
     826/** Convert, format and print a double according to the %f specifier.
     827 *
     828 * @param g     Double to print.
     829 * @param precision Number of fractional digits to print. If 0 no
     830 *              decimal point will be printed unless the flag
     831 *              __PRINTF_FLAG_DECIMALPT is specified.
     832 * @param width Minimum number of characters to display. Pads
     833 *              with '0' or ' ' depending on the set flags;
     834 * @param flags Printf flags.
     835 * @param ps    Printing functions.
     836 *
     837 * @return The number of characters printed; negative on failure.
     838 */
     839static int print_double_fixed(double g, int precision, int width, uint32_t flags,
     840        printf_spec_t *ps)
     841{
     842        if (flags & __PRINTF_FLAG_LEFTALIGNED) {
     843                flags &= ~__PRINTF_FLAG_ZEROPADDED;
     844        }
     845
     846        if (flags & __PRINTF_FLAG_DECIMALPT) {
     847                flags &= ~__PRINTF_FLAG_NOFRACZEROS;
     848        }
     849
     850        ieee_double_t val = extract_ieee_double(g);
     851
     852        if (val.is_special) {
     853                return print_special(val, width, flags, ps);
     854        }
     855
     856        char buf[MAX_DOUBLE_STR_BUF_SIZE];
     857        const size_t buf_size = MAX_DOUBLE_STR_BUF_SIZE;
     858        double_str_t val_str;
     859
     860        val_str.str = buf;
     861        val_str.neg = val.is_negative;
     862
     863        if (0 <= precision) {
     864                /*
     865                 * Request one more digit so we can round the result. The last
     866                 * digit it returns may have an error of at most +/- 1.
     867                 */
     868                val_str.len = double_to_fixed_str(val, -1, precision + 1, buf, buf_size,
     869                        &val_str.dec_exp);
     870
     871                /*
     872                 * Round using the last digit to produce precision fractional digits.
     873                 * If less than precision+1 fractional digits were output the last
     874                 * digit is definitely inaccurate so also round to get rid of it.
     875                 */
     876                fp_round_up(buf, &val_str.len, &val_str.dec_exp);
     877
     878                /* Rounding could have introduced trailing zeros. */
     879                if (flags & __PRINTF_FLAG_NOFRACZEROS) {
     880                        fp_trim_trailing_zeros(buf, &val_str.len, &val_str.dec_exp);
     881                }
     882        } else {
     883                /* Let the implementation figure out the proper precision. */
     884                val_str.len = double_to_short_str(val, buf, buf_size, &val_str.dec_exp);
     885               
     886                /* Precision needed for the last significant digit. */
     887                precision = max(0, -val_str.dec_exp);
     888        }
     889
     890        return print_double_str_fixed(&val_str, precision, width, flags, ps);
     891}
     892
     893/** Prints the decimal exponent part of a %e specifier formatted number. */
     894static int print_exponent(int exp_val, uint32_t flags, printf_spec_t *ps)
     895{
     896        int counter = 0;
     897        int ret;
     898
     899        char exp_ch = (flags & __PRINTF_FLAG_BIGCHARS) ? 'E' : 'e';
     900
     901        if ((ret = ps->str_write(&exp_ch, 1, ps->data)) < 0)
     902                return -1;
     903       
     904        counter += ret;
     905
     906        char exp_sign = (exp_val < 0) ? '-' : '+';
     907
     908        if ((ret = ps->str_write(&exp_sign, 1, ps->data)) < 0)
     909                return -1;
     910
     911        counter += ret;
     912
     913        /* Print the exponent. */
     914        exp_val = abs(exp_val);
     915       
     916        char exp_str[4] = { 0 };
     917
     918        exp_str[0] = '0' + exp_val / 100;
     919        exp_str[1] = '0' + (exp_val % 100) / 10 ;
     920        exp_str[2] = '0' + (exp_val % 10);
     921       
     922        int exp_len = (exp_str[0] == '0') ? 2 : 3;
     923        const char *exp_str_start = &exp_str[3] - exp_len;
     924
     925        if ((ret = ps->str_write(exp_str_start, exp_len, ps->data)) < 0)
     926                return -1;
     927
     928        counter += ret;
     929
     930        return counter;
     931}
     932
     933
     934/** Format and print the double string repressentation according
     935 *  to the %e specifier.
     936 */
     937static int print_double_str_scient(double_str_t *val_str, int precision,
     938        int width, uint32_t flags, printf_spec_t *ps)
     939{
     940        int len = val_str->len;
     941        int dec_exp = val_str->dec_exp;
     942        char *buf  = val_str->str;
     943
     944        assert(0 < len);
     945
     946        char sign = get_sign_char(val_str->neg, flags);
     947        bool has_decimal_pt = (0 < precision) || (flags & __PRINTF_FLAG_DECIMALPT);
     948        int dec_pt_len = has_decimal_pt ? 1 : 0;
     949
     950        /* Fractional part lengths. */
     951        int signif_frac_figs = len - 1;
     952        int trailing_frac_zeros = precision - signif_frac_figs;
     953
     954        if (flags & __PRINTF_FLAG_NOFRACZEROS) {
     955                trailing_frac_zeros = 0;
     956        }
     957
     958        int frac_len = signif_frac_figs + trailing_frac_zeros;
     959
     960        int exp_val = dec_exp + len - 1;
     961        /* Account for exponent sign and 'e'; minimum 2 digits. */
     962        int exp_len = 2 + (abs(exp_val) >= 100 ? 3 : 2);
     963
     964        /* Number of non-padding chars to print. */
     965        int num_len = (sign ? 1 : 0) + 1 + dec_pt_len + frac_len + exp_len;
     966
     967        int padding_len = max(0, width - num_len);
     968        int ret = 0;
     969        int counter = 0;
     970
     971        if (!(flags & (__PRINTF_FLAG_LEFTALIGNED | __PRINTF_FLAG_ZEROPADDED))) {
     972                if ((ret = print_padding(' ', padding_len, ps)) < 0)
     973                        return -1;
     974
     975                counter += ret;
     976        }
     977
     978        if (sign) {
     979                if ((ret = ps->str_write(&sign, 1, ps->data)) < 0)
     980                        return -1;
     981               
     982                counter += ret;
     983        }
     984
     985        if (flags & __PRINTF_FLAG_ZEROPADDED) {
     986                if ((ret = print_padding('0', padding_len, ps)) < 0)
     987                        return -1;
     988
     989                counter += ret;
     990        }
     991
     992        /* Single leading integer. */
     993        if ((ret = ps->str_write(buf, 1, ps->data)) < 0)
     994                return -1;
     995
     996        counter += ret;
     997
     998        /* Print the decimal point and the fractional part. */
     999        if (has_decimal_pt) {
     1000                char ch = '.';
     1001
     1002                if ((ret = ps->str_write(&ch, 1, ps->data)) < 0)
     1003                        return -1;
     1004               
     1005                counter += ret;
     1006
     1007                /* Print significant digits of the fractional part of the number. */
     1008                if (0 < signif_frac_figs) {
     1009                        if ((ret = ps->str_write(buf + 1, signif_frac_figs, ps->data)) < 0)
     1010                                return -1;
     1011
     1012                        counter += ret;
     1013                }
     1014
     1015                /* Print trailing zeros of the fractional part of the number. */
     1016                if ((ret = print_padding('0', trailing_frac_zeros, ps)) < 0)
     1017                        return -1;
     1018
     1019                counter += ret;
     1020        }
     1021
     1022        /* Print the exponent. */
     1023        if ((ret = print_exponent(exp_val, flags, ps)) < 0)
     1024                return -1;
     1025
     1026        counter += ret;
     1027
     1028        if (flags & __PRINTF_FLAG_LEFTALIGNED) {
     1029                if ((ret = print_padding(' ', padding_len, ps)) < 0)
     1030                        return -1;
     1031
     1032                counter += ret;
     1033        }
     1034
     1035        return counter;
     1036}
     1037
     1038
     1039/** Convert, format and print a double according to the %e specifier.
     1040 *
     1041 * Note that if g is large, the output may be huge (3e100 prints
     1042 * with at least 100 digits).
     1043 *
     1044 * %e style: [-]d.dddde+dd
     1045 *  left-justified:  [-]d.dddde+dd[space_pad]
     1046 *  right-justified: [space_pad][-][zero_pad]d.dddde+dd
     1047 *
     1048 * @param g     Double to print.
     1049 * @param precision Number of fractional digits to print, ie
     1050 *              precision + 1 significant digits to display. If 0 no
     1051 *              decimal point will be printed unless the flag
     1052 *              __PRINTF_FLAG_DECIMALPT is specified. If negative
     1053 *              the shortest accurate number will be printed.
     1054 * @param width Minimum number of characters to display. Pads
     1055 *              with '0' or ' ' depending on the set flags;
     1056 * @param flags Printf flags.
     1057 * @param ps    Printing functions.
     1058 *
     1059 * @return The number of characters printed; negative on failure.
     1060 */
     1061static int print_double_scientific(double g, int precision, int width,
     1062        uint32_t flags, printf_spec_t *ps)
     1063{
     1064        if (flags & __PRINTF_FLAG_LEFTALIGNED) {
     1065                flags &= ~__PRINTF_FLAG_ZEROPADDED;
     1066        }
     1067
     1068        ieee_double_t val = extract_ieee_double(g);
     1069
     1070        if (val.is_special) {
     1071                return print_special(val, width, flags, ps);
     1072        }
     1073
     1074        char buf[MAX_DOUBLE_STR_BUF_SIZE];
     1075        const size_t buf_size = MAX_DOUBLE_STR_BUF_SIZE;
     1076        double_str_t val_str;
     1077
     1078        val_str.str = buf;
     1079        val_str.neg = val.is_negative;
     1080
     1081        if (0 <= precision) {
     1082                /*
     1083                 * Request one more digit (in addition to the leading integer)
     1084                 * so we can round the result. The last digit it returns may
     1085                 * have an error of at most +/- 1.
     1086                 */
     1087                val_str.len = double_to_fixed_str(val, precision + 2, -1, buf, buf_size,
     1088                        &val_str.dec_exp);
     1089
     1090                /*
     1091                 * Round the extra digit to produce precision+1 significant digits.
     1092                 * If less than precision+2 significant digits were returned the last
     1093                 * digit is definitely inaccurate so also round to get rid of it.
     1094                 */
     1095                fp_round_up(buf, &val_str.len, &val_str.dec_exp);
     1096
     1097                /* Rounding could have introduced trailing zeros. */
     1098                if (flags & __PRINTF_FLAG_NOFRACZEROS) {
     1099                        fp_trim_trailing_zeros(buf, &val_str.len, &val_str.dec_exp);
     1100                }
     1101        } else {
     1102                /* Let the implementation figure out the proper precision. */
     1103                val_str.len = double_to_short_str(val, buf, buf_size, &val_str.dec_exp);
     1104               
     1105                /* Use all produced digits. */
     1106                precision = val_str.len - 1;
     1107        }
     1108
     1109        return print_double_str_scient(&val_str, precision, width, flags, ps);
     1110}
     1111
     1112
     1113/** Convert, format and print a double according to the %g specifier.
     1114 *
     1115 * %g style chooses between %f and %e.
     1116 *
     1117 * @param g     Double to print.
     1118 * @param precision Number of significant digits to display; excluding
     1119 *              any leading zeros from this count. If negative
     1120 *              the shortest accurate number will be printed.
     1121 * @param width Minimum number of characters to display. Pads
     1122 *              with '0' or ' ' depending on the set flags;
     1123 * @param flags Printf flags.
     1124 * @param ps    Printing functions.
     1125 *
     1126 * @return The number of characters printed; negative on failure.
     1127 */
     1128static int print_double_generic(double g, int precision, int width,
     1129        uint32_t flags, printf_spec_t *ps)
     1130{
     1131        ieee_double_t val = extract_ieee_double(g);
     1132
     1133        if (val.is_special) {
     1134                return print_special(val, width, flags, ps);
     1135        }
     1136
     1137        char buf[MAX_DOUBLE_STR_BUF_SIZE];
     1138        const size_t buf_size = MAX_DOUBLE_STR_BUF_SIZE;
     1139        int dec_exp;
     1140        int len;
     1141
     1142        /* Honor the user requested number of significant digits. */
     1143        if (0 <= precision) {
     1144                /*
     1145                 * Do a quick and dirty conversion of a single digit to determine
     1146                 * the decimal exponent.
     1147                 */
     1148                len = double_to_fixed_str(val, 1, -1, buf, buf_size, &dec_exp);
     1149                assert(0 < len);
     1150
     1151                precision = max(1, precision);
     1152
     1153                if (-4 <= dec_exp && dec_exp < precision) {
     1154                        precision = precision - (dec_exp + 1);
     1155                        return print_double_fixed(g, precision, width,
     1156                                flags | __PRINTF_FLAG_NOFRACZEROS, ps);
     1157                } else {
     1158                        --precision;
     1159                        return print_double_scientific(g, precision, width,
     1160                                flags | __PRINTF_FLAG_NOFRACZEROS, ps);
     1161                }
     1162        } else {
     1163                /* Convert to get the decimal exponent and digit count.*/
     1164                len = double_to_short_str(val, buf, buf_size, &dec_exp);
     1165                assert(0 < len);
     1166
     1167                if (flags & __PRINTF_FLAG_LEFTALIGNED) {
     1168                        flags &= ~__PRINTF_FLAG_ZEROPADDED;
     1169                }
     1170
     1171                double_str_t val_str;
     1172                val_str.str = buf;
     1173                val_str.len = len;
     1174                val_str.neg = val.is_negative;
     1175                val_str.dec_exp = dec_exp;
     1176
     1177                int first_digit_pos = len + dec_exp;
     1178                int last_digit_pos = dec_exp;
     1179
     1180                /* The whole number (15 digits max) fits between dec places 15 .. -6 */
     1181                if (len <= 15 && -6 <= last_digit_pos && first_digit_pos <= 15) {
     1182                        /* Precision needed for the last significant digit. */
     1183                        precision = max(0, -val_str.dec_exp);
     1184                        return print_double_str_fixed(&val_str, precision, width, flags, ps);
     1185                } else {
     1186                        /* Use all produced digits. */
     1187                        precision = val_str.len - 1;
     1188                        return print_double_str_scient(&val_str, precision, width, flags, ps);
     1189                }
     1190        }
     1191}
     1192
     1193
     1194/** Convert, format and print a double according to the specifier.
     1195 *
     1196 * Depending on the specifier it prints the double using the styles
     1197 * %g, %f or %e by means of print_double_generic(), print_double_fixed(),
     1198 * print_double_scientific().
     1199 *
     1200 * @param g     Double to print.
     1201 * @param spec  Specifier of the style to print in; one of: 'g','G','f','F',
     1202 *              'e','E'.
     1203 * @param precision Number of fractional digits to display. If negative
     1204 *              the shortest accurate number will be printed for style %g;
     1205 *              negative precision defaults to 6 for styles %f, %e.
     1206 * @param width Minimum number of characters to display. Pads
     1207 *              with '0' or ' ' depending on the set flags;
     1208 * @param flags Printf flags.
     1209 * @param ps    Printing functions.
     1210 *
     1211 * @return The number of characters printed; negative on failure.
     1212 */
     1213static int print_double(double g, char spec, int precision, int width,
     1214        uint32_t flags, printf_spec_t *ps)
     1215{
     1216        switch (spec) {
     1217        case 'F':
     1218                flags |= __PRINTF_FLAG_BIGCHARS;
     1219                /* Fall through.*/
     1220        case 'f':
     1221                precision = (precision < 0) ? 6 : precision;
     1222                return print_double_fixed(g, precision, width, flags, ps);
     1223
     1224        case 'E':
     1225                flags |= __PRINTF_FLAG_BIGCHARS;
     1226                /* Fall through.*/
     1227        case 'e':
     1228                precision = (precision < 0) ? 6 : precision;
     1229                return print_double_scientific(g, precision, width, flags, ps);
     1230
     1231        case 'G':
     1232                flags |= __PRINTF_FLAG_BIGCHARS;
     1233                /* Fall through.*/
     1234        case 'g':
     1235                return print_double_generic(g, precision, width, flags, ps);
     1236
     1237        default:
     1238                assert(false);
     1239                return -1;
     1240        }
    5271241}
    5281242
     
    6561370                                case '#':
    6571371                                        flags |= __PRINTF_FLAG_PREFIX;
     1372                                        flags |= __PRINTF_FLAG_DECIMALPT;
    6581373                                        break;
    6591374                                case '-':
     
    7011416                       
    7021417                        /* Precision and '*' operator */
    703                         int precision = 0;
     1418                        int precision = -1;
    7041419                        if (uc == '.') {
    7051420                                i = nxt;
    7061421                                uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
    7071422                                if (isdigit(uc)) {
     1423                                        precision = 0;
    7081424                                        while (true) {
    7091425                                                precision *= 10;
     
    7231439                                        precision = (int) va_arg(ap, int);
    7241440                                        if (precision < 0) {
    725                                                 /* Ignore negative precision */
    726                                                 precision = 0;
     1441                                                /* Ignore negative precision - use default instead */
     1442                                                precision = -1;
    7271443                                        }
    7281444                                }
     
    7741490                         */
    7751491                        case 's':
     1492                                precision = max(0,  precision);
     1493                               
    7761494                                if (qualifier == PrintfQualifierLong)
    7771495                                        retval = print_wstr(va_arg(ap, wchar_t *), width, precision, flags, ps);
     
    7971515                                        goto out;
    7981516                                };
     1517                               
     1518                                counter += retval;
     1519                                j = nxt;
     1520                                goto next_char;
     1521                               
     1522                        /*
     1523                         * Floating point values
     1524                         */
     1525                        case 'G':
     1526                        case 'g':
     1527                        case 'F':
     1528                        case 'f':
     1529                        case 'E':
     1530                        case 'e':
     1531                                retval = print_double(va_arg(ap, double), uc, precision,
     1532                                        width, flags, ps);
     1533                               
     1534                                if (retval < 0) {
     1535                                        counter = -counter;
     1536                                        goto out;
     1537                                }
    7991538                               
    8001539                                counter += retval;
  • uspace/lib/c/generic/stack.c

    rbebf97d rc739102  
    11/*
    2  * Copyright (c) 2011 Martin Sucha
     2 * Copyright (c) 2012 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup fs
     29/** @addtogroup libc
    3030 * @{
    31  */
     31 */
     32/** @file
     33 */
    3234
    33 #ifndef EXT2FS_EXT2FS_H_
    34 #define EXT2FS_EXT2FS_H_
     35#include <stack.h>
     36#include <sysinfo.h>
    3537
    36 #include <libext2.h>
    37 #include <libfs.h>
    38 #include <sys/types.h>
     38size_t stack_size_get(void)
     39{
     40        static sysarg_t stack_size = 0;
    3941
    40 #define min(a, b)               ((a) < (b) ? (a) : (b))
     42        if (!stack_size)
     43                sysinfo_get_value("default.stack_size", &stack_size);
    4144
    42 extern vfs_out_ops_t ext2fs_ops;
    43 extern libfs_ops_t ext2fs_libfs_ops;
     45        return (size_t) stack_size;
     46}
    4447
    45 extern int ext2fs_global_init(void);
    46 extern int ext2fs_global_fini(void);
    47 
    48 #endif
    49 
    50 /**
    51  * @}
     48/** @}
    5249 */
  • uspace/lib/c/generic/thread.c

    rbebf97d rc739102  
    3939#include <abi/proc/uarg.h>
    4040#include <fibril.h>
     41#include <stack.h>
    4142#include <str.h>
    4243#include <async.h>
     
    4445#include <as.h>
    4546#include "private/thread.h"
    46 
    47 #ifndef THREAD_INITIAL_STACK_PAGES
    48         #define THREAD_INITIAL_STACK_PAGES  2
    49 #endif
    5047
    5148/** Main thread function.
     
    10198                return ENOMEM;
    10299       
    103         size_t stack_size = getpagesize() * THREAD_INITIAL_STACK_PAGES;
     100        size_t stack_size = stack_size_get();
    104101        void *stack = as_area_create(AS_AREA_ANY, stack_size,
    105             AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
     102            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD |
     103            AS_AREA_LATE_RESERVE);
    106104        if (stack == AS_MAP_FAILED) {
    107105                free(uarg);
  • uspace/lib/c/include/double_to_str.h

    rbebf97d rc739102  
    11/*
    2  * Copyright (c) 2006 Martin Decky
    3  * Copyright (c) 2011 Martin Sucha
     2 * Copyright (c) 2012 Adam Hraska
    43 * All rights reserved.
    54 *
     
    2827 */
    2928
    30 /** @addtogroup fs
    31  * @{
    32  */
     29#ifndef DOUBLE_TO_STR_H_
     30#define DOUBLE_TO_STR_H_
    3331
    34 /**
    35  * @file        ext2.c
    36  * @brief       EXT2 file system driver for HelenOS.
     32#include <unistd.h>
     33
     34/** Maximum number of digits double_to_*_str conversion functions produce.
     35 *
     36 * Both double_to_short_str and double_to_fixed_str generate digits out
     37 * of a 64bit unsigned int number representation. The max number of
     38 * of digits is therefore 20. Add 1 to help users who forget to reserve
     39 * space for a null terminator.
    3740 */
     41#define MAX_DOUBLE_STR_LEN (20 + 1)
    3842
    39 #include "ext2fs.h"
    40 #include <ipc/services.h>
    41 #include <ns.h>
    42 #include <async.h>
    43 #include <errno.h>
    44 #include <unistd.h>
    45 #include <task.h>
    46 #include <stdio.h>
    47 #include <libfs.h>
    48 #include "../../vfs/vfs.h"
     43/** Maximum buffer size needed to store the output of double_to_*_str
     44 *  functions.
     45 */
     46#define MAX_DOUBLE_STR_BUF_SIZE  21
    4947
    50 #define NAME    "ext2fs"
     48/* Fwd decl.*/
     49struct ieee_double_t_tag;
    5150
    52 vfs_info_t ext2fs_vfs_info = {
    53         .name = NAME,
    54         .instance = 0,
    55 };
     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 *);
    5654
    57 int main(int argc, char **argv)
    58 {
    59         printf(NAME ": HelenOS EXT2 file system server\n");
    60 
    61         if (argc == 3) {
    62                 if (!str_cmp(argv[1], "--instance"))
    63                         ext2fs_vfs_info.instance = strtol(argv[2], NULL, 10);
    64                 else {
    65                         printf(NAME " Unrecognized parameters");
    66                         return -1;
    67                 }
    68         }
    69        
    70         async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
    71             SERVICE_VFS, 0, 0);
    72         if (!vfs_sess) {
    73                 printf(NAME ": failed to connect to VFS\n");
    74                 return -1;
    75         }
    76 
    77         int rc = ext2fs_global_init();
    78         if (rc != EOK) {
    79                 printf(NAME ": Failed global initialization\n");
    80                 return 1;
    81         }       
    82                
    83         rc = fs_register(vfs_sess, &ext2fs_vfs_info, &ext2fs_ops,
    84             &ext2fs_libfs_ops);
    85         if (rc != EOK) {
    86                 fprintf(stdout, NAME ": Failed to register fs (%d)\n", rc);
    87                 return 1;
    88         }
    89        
    90         printf(NAME ": Accepting connections\n");
    91         task_retval(0);
    92         async_manager();
    93         /* not reached */
    94         return 0;
    95 }
    96 
    97 /**
    98  * @}
    99  */
     55#endif
  • uspace/lib/c/include/ieee_double.h

    rbebf97d rc739102  
    11/*
    2  * Copyright (c) 2011 Martin Sucha
     2 * Copyright (c) 2012 Adam Hraska
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libext2
    30  * @{
    31  */
    32 /**
    33  * @file
    34  */
     29#ifndef IEEE_DOUBLE_H_
     30#define IEEE_DOUBLE_H_
    3531
    36 #ifndef LIBEXT2_LIBEXT2_BLOCK_GROUP_H_
    37 #define LIBEXT2_LIBEXT2_BLOCK_GROUP_H_
     32#include <stdint.h>
     33#include <bool.h>
    3834
    39 #include <block.h>
     35/** Represents a non-negative floating point number: significand * 2^exponent */
     36typedef struct fp_num_t_tag {
     37        /** Significand (aka mantissa). */
     38        uint64_t significand;
     39        /** Binary exponent. */
     40        int exponent;
     41} fp_num_t;
    4042
    41 typedef struct ext2_block_group {
    42         uint32_t block_bitmap_block; // Block ID for block bitmap
    43         uint32_t inode_bitmap_block; // Block ID for inode bitmap
    44         uint32_t inode_table_first_block; // Block ID of first block of inode table
    45         uint16_t free_block_count; // Count of free blocks
    46         uint16_t free_inode_count; // Count of free inodes
    47         uint16_t directory_inode_count; // Number of inodes allocated to directories
    48 } ext2_block_group_t;
     43/** Double number description according to IEEE 754. */
     44typedef struct ieee_double_t_tag {
     45        /** The number is a NaN or infinity. */
     46        bool is_special;
     47        /** Not a number. */
     48        bool is_nan;
     49        bool is_negative;
     50        /** The number denoted infinity. */
     51        bool is_infinity;
     52        /** The number could not be represented as a normalized double. */
     53        bool is_denormal;
     54        /**
     55         * The predecessor double is closer than the successor. This happens
     56         * if a normal number is of the form 2^k and it is not the smallest
     57         * normal number.
     58         */
     59        bool is_accuracy_step;
     60        /**
     61         * If !is_special the double's value is:
     62         *   pos_val.significand * 2^pos_val.exponent
     63         */
     64        fp_num_t pos_val;
     65} ieee_double_t;
    4966
    50 typedef struct ext2_block_group_ref {
    51         block_t *block; // Reference to a block containing this block group descr
    52         ext2_block_group_t *block_group;
    53 } ext2_block_group_ref_t;
    54 
    55 #define EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE 32
    56 
    57 extern uint32_t ext2_block_group_get_block_bitmap_block(ext2_block_group_t *);
    58 extern uint32_t ext2_block_group_get_inode_bitmap_block(ext2_block_group_t *);
    59 extern uint32_t ext2_block_group_get_inode_table_first_block(ext2_block_group_t *);
    60 extern uint16_t ext2_block_group_get_free_block_count(ext2_block_group_t *);
    61 extern uint16_t ext2_block_group_get_free_inode_count(ext2_block_group_t *);
    62 extern uint16_t ext2_block_group_get_directory_inode_count(ext2_block_group_t *);
    63 
    64 extern void     ext2_block_group_set_free_block_count(ext2_block_group_t *, uint16_t);
     67extern ieee_double_t extract_ieee_double(double);
    6568
    6669#endif
    67 
    68 /** @}
    69  */
  • uspace/lib/c/include/macros.h

    rbebf97d rc739102  
    3838#define min(a, b)  ((a) < (b) ? (a) : (b))
    3939#define max(a, b)  ((a) > (b) ? (a) : (b))
     40#define abs(a)     ((a) >= 0 ? (a) : (-a))
     41
    4042
    4143#define KiB2SIZE(kb)  ((kb) << 10)
  • uspace/lib/c/include/stack.h

    rbebf97d rc739102  
    11/*
    2  * Copyright (c) 2011 Martin Sucha
     2 * Copyright (c) 2012 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libext2
     29/** @addtogroup libc
    3030 * @{
    3131 */
    32 /**
    33  * @file
     32/** @file
    3433 */
    3534
    36 #ifndef LIBEXT2_LIBEXT2_H_
    37 #define LIBEXT2_LIBEXT2_H_
     35#ifndef LIBC_STACK_H_
     36#define LIBC_STACK_H_
    3837
    39 #include "libext2_superblock.h"
    40 #include "libext2_block_group.h"
    41 #include "libext2_inode.h"
    42 #include "libext2_filesystem.h"
    43 #include "libext2_directory.h"
     38#include <libarch/types.h>
     39
     40extern size_t stack_size_get(void);
    4441
    4542#endif
  • uspace/lib/clui/tinput.c

    rbebf97d rc739102  
    104104static void tinput_display_tail(tinput_t *ti, size_t start, size_t pad)
    105105{
    106         wchar_t dbuf[INPUT_MAX_SIZE + 1];
     106        wchar_t *dbuf = malloc((INPUT_MAX_SIZE + 1) * sizeof(wchar_t));
     107        if (!dbuf)
     108                return;
    107109       
    108110        size_t sa;
     
    146148       
    147149        console_flush(ti->console);
     150
     151        free(dbuf);
    148152}
    149153
  • uspace/lib/ext4/libext4_block_group.c

    rbebf97d rc739102  
    11/*
     2 * Copyright (c) 2011 Martin Sucha
    23 * Copyright (c) 2012 Frantisek Princ
    34 * All rights reserved.
  • uspace/lib/ext4/libext4_block_group.h

    rbebf97d rc739102  
    11/*
     2 * Copyright (c) 2011 Martin Sucha
    23 * Copyright (c) 2012 Frantisek Princ
    34 * All rights reserved.
  • uspace/lib/ext4/libext4_directory.c

    rbebf97d rc739102  
    11/*
     2 * Copyright (c) 2011 Martin Sucha
    23 * Copyright (c) 2012 Frantisek Princ
    34 * All rights reserved.
  • uspace/lib/ext4/libext4_directory.h

    rbebf97d rc739102  
    11/*
     2 * Copyright (c) 2011 Martin Sucha
    23 * Copyright (c) 2012 Frantisek Princ
    34 * All rights reserved.
  • uspace/lib/ext4/libext4_filesystem.c

    rbebf97d rc739102  
    11/*
     2 * Copyright (c) 2011 Martin Sucha
    23 * Copyright (c) 2012 Frantisek Princ
    34 * All rights reserved.
  • uspace/lib/ext4/libext4_filesystem.h

    rbebf97d rc739102  
    11/*
     2 * Copyright (c) 2011 Martin Sucha
    23 * Copyright (c) 2012 Frantisek Princ
    34 * All rights reserved.
  • uspace/lib/ext4/libext4_inode.c

    rbebf97d rc739102  
    11/*
     2 * Copyright (c) 2011 Martin Sucha
    23 * Copyright (c) 2012 Frantisek Princ
    34 * All rights reserved.
  • uspace/lib/ext4/libext4_inode.h

    rbebf97d rc739102  
    11/*
     2 * Copyright (c) 2011 Martin Sucha
    23 * Copyright (c) 2012 Frantisek Princ
    34 * All rights reserved.
  • uspace/lib/ext4/libext4_superblock.c

    rbebf97d rc739102  
    11/*
     2 * Copyright (c) 2011 Martin Sucha
    23 * Copyright (c) 2012 Frantisek Princ
    34 * All rights reserved.
  • uspace/lib/ext4/libext4_superblock.h

    rbebf97d rc739102  
    11/*
     2 * Copyright (c) 2011 Martin Sucha
    23 * Copyright (c) 2012 Frantisek Princ
    34 * All rights reserved.
  • uspace/lib/ext4/libext4_types.h

    rbebf97d rc739102  
    11/*
     2 * Copyright (c) 2011 Martin Sucha
    23 * Copyright (c) 2012 Frantisek Princ
    34 * All rights reserved.
  • uspace/srv/fs/ext4fs/ext4fs_ops.c

    rbebf97d rc739102  
    11/*
     2 * Copyright (c) 2011 Martin Sucha
    23 * Copyright (c) 2012 Frantisek Princ
    34 * All rights reserved.
  • uspace/srv/logger/initlvl.c

    rbebf97d rc739102  
    3838#include <sysinfo.h>
    3939#include <str.h>
     40#include <stdlib.h>
    4041#include "logger.h"
    4142
     
    9192        char level_str[200];
    9293        str_cpy(level_str, 200, (const char *) argument);
     94        free(argument);
    9395
    9496        parse_level_settings(level_str);
Note: See TracChangeset for help on using the changeset viewer.