Changeset 544a2e4 in mainline for uspace/lib


Ignore:
Timestamp:
2011-05-30T21:37:43Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7b712b60
Parents:
18ba2e4f (diff), 0743493a (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
Files:
18 added
76 edited
12 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/block/libblock.c

    r18ba2e4f r544a2e4  
    5151#include <macros.h>
    5252#include <mem.h>
     53#include <malloc.h>
     54#include <stdio.h>
    5355#include <sys/typefmt.h>
    5456#include <stacktrace.h>
  • uspace/lib/c/Makefile

    r18ba2e4f r544a2e4  
    4141CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config
    4242
     43LINKER_SCRIPTS = \
     44        $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld \
     45        $(LIBC_PREFIX)/arch/$(UARCH)/_link-loader.ld \
     46        $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld \
     47        $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld
     48
    4349PRE_DEPEND = $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(COMMON_HEADER_ARCH)
    44 EXTRA_OUTPUT = $(LINKER_SCRIPT)
    45 EXTRA_CLEAN = $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(COMMON_HEADER_ARCH) $(LINKER_SCRIPT)
     50EXTRA_OUTPUT = $(LINKER_SCRIPTS)
     51EXTRA_CLEAN = $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(COMMON_HEADER_ARCH) $(LINKER_SCRIPTS)
    4652LIBRARY = libc
     53SLIBRARY = libc.so.0.0
     54LSONAME = libc.so0
     55
    4756
    4857-include $(COMMON_MAKEFILE)
    4958-include $(CONFIG_MAKEFILE)
    5059-include arch/$(UARCH)/Makefile.inc
     60
     61EXTRA_CFLAGS += -I../../srv/loader/include
    5162
    5263GENERIC_SOURCES = \
     
    97108        generic/adt/measured_strings.c \
    98109        generic/adt/char_map.c \
     110        generic/adt/prodcons.c \
    99111        generic/time.c \
    100112        generic/stdlib.c \
     
    113125        generic/arg_parse.c \
    114126        generic/sort.c \
    115         generic/stats.c
     127        generic/stats.c \
     128        generic/assert.c
     129
     130ifeq ($(CONFIG_RTLD), y)
     131        GENERIC_SOURCES += \
     132                generic/dlfcn.c \
     133                generic/rtld/rtld.c \
     134                generic/rtld/elf_load.c \
     135                generic/rtld/dynamic.c \
     136                generic/rtld/module.c \
     137                generic/rtld/symbol.c
     138endif
    116139
    117140SOURCES = \
     
    132155        ln -sfn ../$< $@
    133156
    134 $(LINKER_SCRIPT): $(LINKER_SCRIPT).in
     157$(LIBC_PREFIX)/arch/$(UARCH)/_link.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
    135158        $(GCC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -E -x c $< | grep -v "^\#" > $@
     159
     160$(LIBC_PREFIX)/arch/$(UARCH)/_link-loader.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
     161        $(GCC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -DLOADER -E -x c $< | grep -v "^\#" > $@
     162
     163$(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
     164        $(GCC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -DSHLIB -E -x c $< | grep -v "^\#" > $@
     165
     166$(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
     167        $(GCC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -DDLEXE -E -x c $< | grep -v "^\#" > $@
    136168
    137169$(COMMON_HEADER_ARCH): $(COMMON_HEADER)
  • uspace/lib/c/arch/abs32le/Makefile.inc

    r18ba2e4f r544a2e4  
    2929ARCH_SOURCES = \
    3030        arch/$(UARCH)/src/entry.c \
     31        arch/$(UARCH)/src/entryjmp.c \
    3132        arch/$(UARCH)/src/thread_entry.c \
    3233        arch/$(UARCH)/src/fibril.c \
  • uspace/lib/c/arch/abs32le/_link.ld.in

    r18ba2e4f r544a2e4  
    33
    44PHDRS {
     5#ifdef LOADER
     6        interp PT_INTERP;
     7        text PT_LOAD FILEHDR PHDRS FLAGS(5);
     8#else
    59        text PT_LOAD FLAGS(5);
     10#endif
    611        data PT_LOAD FLAGS(6);
    712}
    813
    914SECTIONS {
     15#ifdef LOADER
     16        .interp : {
     17                *(.interp);
     18        } :interp
     19       
     20        . = 0x70001000 + SIZEOF_HEADERS;
     21#else
    1022        . = 0x1000 + SIZEOF_HEADERS;
    11        
     23#endif
    1224        .text : {
    1325                *(.text .text.*);
  • uspace/lib/c/arch/abs32le/src/entryjmp.c

    r18ba2e4f r544a2e4  
    3131
    3232#include <bool.h>
    33 #include "arch.h"
     33#include <entry_point.h>
    3434
    35 void program_run(void *entry_point, void *pcb)
     35/** Jump to program entry point. */
     36void entry_point_jmp(void *entry_point, void *pcb)
    3637{
    3738        while (true);
  • uspace/lib/c/arch/amd64/Makefile.inc

    r18ba2e4f r544a2e4  
    2929ARCH_SOURCES = \
    3030        arch/$(UARCH)/src/entry.s \
     31        arch/$(UARCH)/src/entryjmp.s \
    3132        arch/$(UARCH)/src/thread_entry.s \
    3233        arch/$(UARCH)/src/syscall.S \
  • uspace/lib/c/arch/amd64/_link.ld.in

    r18ba2e4f r544a2e4  
    33
    44PHDRS {
     5#ifdef LOADER
     6        interp PT_INTERP;
     7        text PT_LOAD FILEHDR PHDRS FLAGS(5);
     8#else
    59        text PT_LOAD FLAGS(5);
     10#endif
    611        data PT_LOAD FLAGS(6);
    712        debug PT_NOTE;
     
    914
    1015SECTIONS {
     16#ifdef LOADER
     17        .interp : {
     18                *(.interp);
     19        } :interp
     20       
     21        . = 0x70001000 + SIZEOF_HEADERS;
     22#else
    1123        . = 0x1000 + SIZEOF_HEADERS;
    12        
     24#endif
    1325        .init : {
    1426                *(.init);
  • uspace/lib/c/arch/amd64/src/entryjmp.s

    r18ba2e4f r544a2e4  
    2727#
    2828
    29 .globl program_run
     29.globl entry_point_jmp
    3030
    31 ## void program_run(void *entry_point, void *pcb);
     31## void entry_point_jmp(void *entry_point, void *pcb);
    3232#
    3333# %rdi  contains entry_point
    3434# %rsi  contains pcb
    3535#
    36 # Jump to a program entry point
    37 program_run:
     36# Jump to program entry point
     37entry_point_jmp:
    3838        # pcb must be passed in %rdi, use %rdx as a scratch register
    3939        mov %rdi, %rdx
  • uspace/lib/c/arch/arm32/Makefile.inc

    r18ba2e4f r544a2e4  
    3030ARCH_SOURCES = \
    3131        arch/$(UARCH)/src/entry.s \
     32        arch/$(UARCH)/src/entryjmp.s \
    3233        arch/$(UARCH)/src/thread_entry.s \
    3334        arch/$(UARCH)/src/syscall.c \
  • uspace/lib/c/arch/arm32/_link.ld.in

    r18ba2e4f r544a2e4  
    33
    44PHDRS {
     5#ifdef LOADER
     6        interp PT_INTERP;
     7        text PT_LOAD FILEHDR PHDRS FLAGS(5);
     8#else
    59        text PT_LOAD FLAGS(5);
     10#endif
    611        data PT_LOAD FLAGS(6);
    712}
    813
    914SECTIONS {
     15#ifdef LOADER
     16        .interp : {
     17                *(.interp);
     18        } :interp
     19       
     20        . = 0x70001000 + SIZEOF_HEADERS;
     21#else
    1022        . = 0x1000 + SIZEOF_HEADERS;
    11        
     23#endif
    1224        .init : {
    1325                *(.init);
  • uspace/lib/c/arch/arm32/src/entryjmp.s

    r18ba2e4f r544a2e4  
    2727#
    2828
    29 .globl program_run
     29.globl entry_point_jmp
    3030
    31 ## void program_run(void *entry_point, void *pcb);
     31## void entry_point_jmp(void *entry_point, void *pcb);
    3232#
    3333# r0    contains entry_point
    3434# r1    contains pcb
    3535#
    36 # Jump to a program entry point
    37 program_run:
     36# Jump to program entry point
     37entry_point_jmp:
    3838        # load ras_page address to r2
    3939        ldr r2, =ras_page
  • uspace/lib/c/arch/ia32/Makefile.common

    r18ba2e4f r544a2e4  
    2828
    2929CLANG_ARCH = i386
    30 GCC_CFLAGS += -march=pentium
     30GCC_CFLAGS += -march=pentium -fno-omit-frame-pointer
    3131
    3232ENDIANESS = LE
  • uspace/lib/c/arch/ia32/Makefile.inc

    r18ba2e4f r544a2e4  
    2929ARCH_SOURCES = \
    3030        arch/$(UARCH)/src/entry.s \
     31        arch/$(UARCH)/src/entryjmp.s \
    3132        arch/$(UARCH)/src/thread_entry.s \
    3233        arch/$(UARCH)/src/syscall.S \
     
    3536        arch/$(UARCH)/src/setjmp.S \
    3637        arch/$(UARCH)/src/stacktrace.c \
    37         arch/$(UARCH)/src/stacktrace_asm.S
     38        arch/$(UARCH)/src/stacktrace_asm.S \
     39        arch/$(UARCH)/src/rtld/dynamic.c \
     40        arch/$(UARCH)/src/rtld/reloc.c
    3841
    3942.PRECIOUS: arch/$(UARCH)/src/entry.o
  • uspace/lib/c/arch/ia32/_link.ld.in

    r18ba2e4f r544a2e4  
     1#ifndef SHLIB
    12STARTUP(LIBC_PATH/arch/UARCH/src/entry.o)
    23ENTRY(__entry)
     4#endif
    35
    46PHDRS {
     7#if defined(LOADER) || defined(DLEXE)
     8        interp PT_INTERP;
     9        text PT_LOAD FILEHDR PHDRS FLAGS(5);
     10#else
    511        text PT_LOAD FLAGS(5);
     12#endif
    613        data PT_LOAD FLAGS(6);
     14#if defined(SHLIB) || defined(DLEXE)
     15        dynamic PT_DYNAMIC;
     16#endif
    717        debug PT_NOTE;
    818}
    919
    1020SECTIONS {
     21#if defined(LOADER) || defined(DLEXE)
     22        .interp : {
     23                *(.interp);
     24        } :interp
     25#endif
     26#ifdef LOADER
     27        . = 0x70001000 + SIZEOF_HEADERS;
     28#else
    1129        . = 0x1000 + SIZEOF_HEADERS;
    12        
     30#endif
    1331        .init : {
    1432                *(.init);
     
    1937                *(.rodata .rodata.*);
    2038        } :text
     39
     40#if defined(SHLIB) || defined(DLEXE)
     41        .rel.plt : {
     42                *(.rel.plt);
     43        }
     44        /*
     45         *.rel.dyn MUST FOLLOW IMMEDIATELY after .rel.plt
     46         * without alignment gap or DT_REL will be broken
     47         */
     48        .rel.dyn : {
     49                *(.rel.*);
     50        } :text
    2151       
     52        .plt : {
     53                *(.plt);
     54        } :text
     55       
     56        .dynsym : {
     57                *(.dynsym);
     58        } :text
     59       
     60        .dynstr : {
     61                *(.dynstr);
     62        } :text
     63       
     64        .hash : {
     65                *(.hash);
     66        } :text
     67#endif
    2268        . = . + 0x1000;
     69       
     70#if defined(SHLIB) || defined(DLEXE)
     71        .dynamic : {
     72                *(.dynamic);
     73        } :data :dynamic
     74#endif
    2375       
    2476        .data : {
     
    2678        } :data
    2779       
     80#if defined(SHLIB) || defined(DLEXE)
     81        .data.rel : {
     82                *(.data.rel .data.rel.*);
     83        } :data
     84
     85        .got : {
     86                *(.got);
     87        } :data
     88        .got.plt : {
     89                *(.got.plt);
     90        } :data
     91#endif
     92       
     93#ifndef DLEXE
    2894        .tdata : {
    2995                _tdata_start = .;
     
    37103       
    38104        _tls_alignment = ALIGNOF(.tdata);
     105#endif
    39106       
    40107        .bss : {
     108                *(.dynbss);
    41109                *(COMMON);
    42110                *(.bss);
  • uspace/lib/c/arch/ia32/include/config.h

    r18ba2e4f r544a2e4  
    3636#define LIBC_ia32_CONFIG_H_
    3737
    38 #define PAGE_WIDTH      12
    39 #define PAGE_SIZE       (1 << PAGE_WIDTH)
     38#define PAGE_WIDTH  12
     39#define PAGE_SIZE   (1 << PAGE_WIDTH)
     40
     41#define USER_ADDRESS_SPACE_START_ARCH  UINT32_C(0x00000000)
     42#define USER_ADDRESS_SPACE_END_ARCH    UINT32_C(0x7fffffff)
    4043
    4144#endif
  • uspace/lib/c/arch/ia32/include/ddi.h

    r18ba2e4f r544a2e4  
    3737#include <libarch/types.h>
    3838
    39 #define IO_SPACE_BOUNDARY       ((void *) (64 * 1024))
     39#define IO_SPACE_BOUNDARY  ((void *) (64 * 1024))
    4040
    4141static inline uint8_t pio_read_8(ioport8_t *port)
  • uspace/lib/c/arch/ia32/include/faddr.h

    r18ba2e4f r544a2e4  
    3838#include <libarch/types.h>
    3939
    40 #define FADDR(fptr)             ((uintptr_t) (fptr))
     40#define FADDR(fptr)  ((uintptr_t) (fptr))
    4141
    4242#endif
  • uspace/lib/c/arch/ia32/include/fibril.h

    r18ba2e4f r544a2e4  
    4242 * panic sooner or later
    4343 */
    44 #define SP_DELTA     (12)
     44#define SP_DELTA  12
    4545
    4646#define context_set(c, _pc, stack, size, ptls) \
     
    5151                (c)->ebp = 0; \
    5252        } while (0)
    53        
    54 /* We include only registers that must be preserved
     53
     54/*
     55 * We include only registers that must be preserved
    5556 * during function call
    5657 */
  • uspace/lib/c/arch/ia32/include/rtld/dynamic.h

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29 /** @addtogroup fs
     29/** @addtogroup generic
    3030 * @{
    3131 */
    3232/** @file
    33  * @brief
    3433 */
    3534
    36 #ifndef LOADER_ARCH_H_
    37 #define LOADER_ARCH_H_
     35#ifndef LIBC_ia32_RTLD_DYNAMIC_H_
     36#define LIBC_ia32_RTLD_DYNAMIC_H_
    3837
    39 extern void program_run(void *entry_point, void *pcb);
     38#include <sys/types.h>
     39
     40typedef struct {
     41        /* Empty. */
     42} dyn_info_arch_t;
    4043
    4144#endif
    4245
    43 /**
    44  * @}
     46/** @}
    4547 */
  • uspace/lib/c/arch/ia32/src/entryjmp.s

    r18ba2e4f r544a2e4  
    2727#
    2828
    29 .globl program_run
     29.globl entry_point_jmp
    3030
    31 ## void program_run(void *entry_point, void *pcb);
     31## void entry_point_jmp(void *entry_point, void *pcb);
    3232#
    33 # Jump to a program entry point
    34 program_run:
     33# Jump to program entry point
     34entry_point_jmp:
    3535        # Use standard ia32 prologue not to confuse anybody
    3636        push %ebp
  • uspace/lib/c/arch/ia32/src/stacktrace.c

    r18ba2e4f r544a2e4  
    3535 */
    3636
     37#include <libarch/config.h>
    3738#include <sys/types.h>
    3839#include <bool.h>
    39 
    4040#include <stacktrace.h>
    4141
    42 #define FRAME_OFFSET_FP_PREV    0
    43 #define FRAME_OFFSET_RA         4
     42#define FRAME_OFFSET_FP_PREV  0
     43#define FRAME_OFFSET_RA       4
    4444
    4545bool stacktrace_fp_valid(stacktrace_t *st, uintptr_t fp)
    4646{
    4747        (void) st;
    48         return fp != 0;
     48        return (fp != 0) && (fp <= USER_ADDRESS_SPACE_END_ARCH);
    4949}
    5050
  • uspace/lib/c/arch/ia32/src/syscall.S

    r18ba2e4f r544a2e4  
    3232__syscall_fast_func:
    3333        .long __syscall_slow
     34        .size __syscall_fast_func, . - __syscall_fast_func
    3435
    3536.text
     
    7172 */
    7273.global __syscall_fast
     74        .type __syscall_fast, @function
     75
    7376__syscall_fast:
    7477        pushl %ebx
     
    9598        popl %ebx
    9699        ret
     100
     101        .size __syscall_fast, . - __syscall_fast
  • uspace/lib/c/arch/ia32/src/tls.c

    r18ba2e4f r544a2e4  
    3737#include <tls.h>
    3838#include <sys/types.h>
     39#include <align.h>
    3940
    4041tcb_t * __alloc_tls(void **data, size_t size)
     
    4849}
    4950
     51/*
     52 * Rtld TLS support
     53 */
     54
     55typedef struct {
     56        unsigned long int ti_module;
     57        unsigned long int ti_offset;
     58} tls_index;
     59
     60void __attribute__ ((__regparm__ (1)))
     61    *___tls_get_addr(tls_index *ti);
     62
     63void __attribute__ ((__regparm__ (1)))
     64    *___tls_get_addr(tls_index *ti)
     65{
     66        size_t tls_size;
     67        uint8_t *tls;
     68
     69        /* Calculate size of TLS block */
     70        tls_size = ALIGN_UP(&_tbss_end - &_tdata_start, &_tls_alignment);
     71
     72        /* The TLS block is just before TCB */
     73        tls = (uint8_t *)__tcb_get() - tls_size;
     74
     75        return tls + ti->ti_offset;
     76}
     77
    5078/** @}
    5179 */
  • uspace/lib/c/arch/ia64/Makefile.inc

    r18ba2e4f r544a2e4  
    2929ARCH_SOURCES = \
    3030        arch/$(UARCH)/src/entry.s \
     31        arch/$(UARCH)/src/entryjmp.s \
    3132        arch/$(UARCH)/src/thread_entry.s \
    3233        arch/$(UARCH)/src/syscall.S \
  • uspace/lib/c/arch/ia64/_link.ld.in

    r18ba2e4f r544a2e4  
    33
    44PHDRS {
     5#ifdef LOADER
     6        interp PT_INTERP;
    57        text PT_LOAD FLAGS(5);
     8#else
     9        text PT_LOAD FLAGS(5);
     10#endif
    611        data PT_LOAD FLAGS(6);
    712}
    813
    914SECTIONS {
     15#ifdef LOADER
     16        .interp : {
     17                *(.interp);
     18        } :interp
     19       
     20        . = 0x800000000 + SIZEOF_HEADERS;
     21#else
    1022        . = 0x4000 + SIZEOF_HEADERS;
    11        
     23#endif
     24        /*
     25         * XXX This is just a work around. Problem: .init section does not
     26         * have the proper alignment.
     27         */
     28        . = ALIGN(., 16);
     29
    1230        .init : {
    1331                *(.init);
  • uspace/lib/c/arch/ia64/src/entryjmp.s

    r18ba2e4f r544a2e4  
    2828
    2929.text
    30 .globl program_run
     30.globl entry_point_jmp
    3131
    32 ## void program_run(void *entry_point, void *pcb);
     32## void entry_point_jmp(void *entry_point, void *pcb);
    3333#
    3434# in0 (r32)     contains entry_point
    3535# in1 (r33)     contains pcb
    3636#
    37 # Jump to a program entry point
    38 program_run:
     37# Jump to program entry point
     38entry_point_jmp:
    3939        # Pass pcb to the entry point in r2
    4040
  • uspace/lib/c/arch/mips32/Makefile.inc

    r18ba2e4f r544a2e4  
    2929ARCH_SOURCES = \
    3030        arch/$(UARCH)/src/entry.s \
     31        arch/$(UARCH)/src/entryjmp.s \
    3132        arch/$(UARCH)/src/thread_entry.s \
    3233        arch/$(UARCH)/src/syscall.c \
  • uspace/lib/c/arch/mips32/_link.ld.in

    r18ba2e4f r544a2e4  
    33
    44PHDRS {
     5#ifdef LOADER
     6        interp PT_INTERP;
     7        text PT_LOAD FILEHDR PHDRS FLAGS(5);
     8#else
    59        text PT_LOAD FLAGS(5);
     10#endif
    611        data PT_LOAD FLAGS(6);
    712}
    813
    914SECTIONS {
     15#ifdef LOADER
     16        .interp : {
     17                *(.interp);
     18        } :interp
     19       
     20        . = 0x70004000 + SIZEOF_HEADERS;
     21#else
    1022        . = 0x4000 + SIZEOF_HEADERS;
    11        
     23#endif
    1224        .init : {
    1325                *(.init);
  • uspace/lib/c/arch/mips32/src/entryjmp.s

    r18ba2e4f r544a2e4  
    2929.text
    3030.section .text
    31 .global program_run
     31.global entry_point_jmp
    3232.set noreorder
    3333
    34 ## void program_run(void *entry_point, void *pcb);
     34## void entry_point_jmp(void *entry_point, void *pcb);
    3535#
    3636# $a0 (=$4)     contains entry_point
    3737# $a1 (=$5)     contains pcb
    3838#
    39 # Jump to a program entry point
    40 .ent program_run
    41 program_run:
     39# Jump to program entry point
     40.ent entry_point_jmp
     41entry_point_jmp:
    4242        # tmp := entry_point
    4343        move $25, $a0
  • uspace/lib/c/arch/mips32eb/Makefile.inc

    r18ba2e4f r544a2e4  
    2929ARCH_SOURCES = \
    3030        arch/$(UARCH)/src/entry.s \
     31        arch/$(UARCH)/src/entryjmp.s \
    3132        arch/$(UARCH)/src/thread_entry.s \
    3233        arch/$(UARCH)/src/syscall.c \
  • uspace/lib/c/arch/ppc32/Makefile.inc

    r18ba2e4f r544a2e4  
    2929ARCH_SOURCES = \
    3030        arch/$(UARCH)/src/entry.s \
     31        arch/$(UARCH)/src/entryjmp.s \
    3132        arch/$(UARCH)/src/thread_entry.s \
    3233        arch/$(UARCH)/src/syscall.c \
  • uspace/lib/c/arch/ppc32/_link.ld.in

    r18ba2e4f r544a2e4  
    33
    44PHDRS {
     5#ifdef LOADER
     6        interp PT_INTERP;
     7        text PT_LOAD FILEHDR PHDRS FLAGS(5);
     8#else
    59        text PT_LOAD FLAGS(5);
     10#endif
    611        data PT_LOAD FLAGS(6);
     12        debug PT_NOTE;
    713}
    814
    915SECTIONS {
     16#ifdef LOADER
     17        .interp : {
     18                *(.interp);
     19        } :interp
     20       
     21        . = 0x70001000 + SIZEOF_HEADERS;
     22#else
    1023        . = 0x1000 + SIZEOF_HEADERS;
    11        
     24#endif
    1225        .init : {
    1326                *(.init);
     
    4356        } :data
    4457       
     58#ifdef CONFIG_LINE_DEBUG
     59        .comment 0 : { *(.comment); } :debug
     60        .debug_abbrev 0 : { *(.debug_abbrev); } :debug
     61        .debug_aranges 0 : { *(.debug_aranges); } :debug
     62        .debug_info 0 : { *(.debug_info); } :debug
     63        .debug_line 0 : { *(.debug_line); } :debug
     64        .debug_loc 0 : { *(.debug_loc); } :debug
     65        .debug_pubnames 0 : { *(.debug_pubnames); } :debug
     66        .debug_pubtypes 0 : { *(.debug_pubtypes); } :debug
     67        .debug_ranges 0 : { *(.debug_ranges); } :debug
     68        .debug_str 0 : { *(.debug_str); } :debug
     69#endif
     70       
    4571        /DISCARD/ : {
    4672                *(*);
  • uspace/lib/c/arch/ppc32/src/entryjmp.s

    r18ba2e4f r544a2e4  
    2727#
    2828
    29 .globl program_run
     29.globl entry_point_jmp
    3030
    31 ## void program_run(void *entry_point, void *pcb);
     31## void entry_point_jmp(void *entry_point, void *pcb);
    3232#
    3333# %r3   contains entry_point
    3434# %r4   contains pcb
    3535#
    36 # Jump to a program entry point
    37 program_run:
     36# Jump to program entry point
     37entry_point_jmp:
    3838        mtctr %r3
    3939        mr %r6, %r4     # Pass pcb to the entry point in %r6
  • uspace/lib/c/arch/sparc64/Makefile.inc

    r18ba2e4f r544a2e4  
    2929ARCH_SOURCES = \
    3030        arch/$(UARCH)/src/entry.s \
     31        arch/$(UARCH)/src/entryjmp.s \
    3132        arch/$(UARCH)/src/thread_entry.s \
    3233        arch/$(UARCH)/src/fibril.S \
  • uspace/lib/c/arch/sparc64/_link.ld.in

    r18ba2e4f r544a2e4  
    33
    44PHDRS {
     5#ifdef LOADER
     6        interp PT_INTERP;
     7        text PT_LOAD FILEHDR PHDRS FLAGS(5);
     8#else
    59        text PT_LOAD FLAGS(5);
     10#endif
    611        data PT_LOAD FLAGS(6);
    712}
    813
    914SECTIONS {
     15#ifdef LOADER
     16        .interp : {
     17                *(.interp);
     18        } :interp
     19       
     20        . = 0x70004000 + SIZEOF_HEADERS;
     21#else
    1022        . = 0x4000 + SIZEOF_HEADERS;
    11        
     23#endif
    1224        .init : {
    1325                *(.init);
  • uspace/lib/c/arch/sparc64/src/entryjmp.s

    r18ba2e4f r544a2e4  
    2727#
    2828
    29 .globl program_run
     29.globl entry_point_jmp
    3030
    31 ## void program_run(void *entry_point, void *pcb);
     31## void entry_point_jmp(void *entry_point, void *pcb);
    3232#
    3333# %o0   contains entry_point
    3434# %o1   contains pcb
    3535#
    36 # Jump to a program entry point
    37 program_run:
     36# Jump to program entry point
     37entry_point_jmp:
    3838        # Pass pcb pointer to entry point in %o1. As it is already
    3939        # there, no action is needed.
  • uspace/lib/c/generic/as.c

    r18ba2e4f r544a2e4  
    5151 *
    5252 */
    53 void *as_area_create(void *address, size_t size, int flags)
     53void *as_area_create(void *address, size_t size, unsigned int flags)
    5454{
    5555        return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t) address,
     
    6767 *
    6868 */
    69 int as_area_resize(void *address, size_t size, int flags)
     69int as_area_resize(void *address, size_t size, unsigned int flags)
    7070{
    7171        return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t) address,
     
    9595 *
    9696 */
    97 int as_area_change_flags(void *address, int flags)
     97int as_area_change_flags(void *address, unsigned int flags)
    9898{
    9999        return __SYSCALL2(SYS_AS_AREA_CHANGE_FLAGS, (sysarg_t) address,
  • uspace/lib/c/generic/async.c

    r18ba2e4f r544a2e4  
    102102#include <arch/barrier.h>
    103103#include <bool.h>
     104#include <stdlib.h>
     105#include <malloc.h>
    104106#include "private/async.h"
    105107
  • uspace/lib/c/generic/async_sess.c

    r18ba2e4f r544a2e4  
    105105#include <errno.h>
    106106#include <assert.h>
     107#include <async.h>
    107108#include "private/async_sess.h"
    108109
  • uspace/lib/c/generic/errno.c

    r18ba2e4f r544a2e4  
    3636#include <fibril.h>
    3737
    38 int _errno;
     38static fibril_local int fibril_errno;
     39
     40int *__errno(void)
     41{
     42        return &fibril_errno;
     43}
    3944
    4045/** @}
  • uspace/lib/c/generic/event.c

    r18ba2e4f r544a2e4  
    4141#include <kernel/ipc/event_types.h>
    4242
    43 /** Subscribe for event notifications.
     43/** Subscribe event notifications.
    4444 *
    45  * @param evno   Event number.
    46  * @param method Use this method for notifying me.
     45 * @param evno    Event type to subscribe.
     46 * @param imethod Use this interface and method for notifying me.
    4747 *
    4848 * @return Value returned by the kernel.
     49 *
    4950 */
    50 int event_subscribe(event_type_t e, sysarg_t method)
     51int event_subscribe(event_type_t evno, sysarg_t imethod)
    5152{
    52         return __SYSCALL2(SYS_EVENT_SUBSCRIBE, (sysarg_t) e, (sysarg_t) method);
     53        return __SYSCALL2(SYS_EVENT_SUBSCRIBE, (sysarg_t) evno,
     54            (sysarg_t) imethod);
     55}
     56
     57/** Unmask event notifications.
     58 *
     59 * @param evno Event type to unmask.
     60 *
     61 * @return Value returned by the kernel.
     62 *
     63 */
     64int event_unmask(event_type_t evno)
     65{
     66        return __SYSCALL1(SYS_EVENT_UNMASK, (sysarg_t) evno);
    5367}
    5468
  • uspace/lib/c/generic/fibril_synch.c

    r18ba2e4f r544a2e4  
    4343#include <stacktrace.h>
    4444#include <stdlib.h>
     45#include <stdio.h>
    4546#include "private/async.h"
    4647
  • uspace/lib/c/generic/io/io.c

    r18ba2e4f r544a2e4  
    173173                }
    174174                *flags = (O_APPEND | O_CREAT) | (plus ? O_RDWR : O_WRONLY);
     175                break;
    175176        default:
    176177                errno = EINVAL;
  • uspace/lib/c/generic/io/klog.c

    r18ba2e4f r544a2e4  
    3838#include <sys/types.h>
    3939#include <unistd.h>
     40#include <errno.h>
    4041#include <io/klog.h>
     42#include <io/printf_core.h>
    4143
    4244size_t klog_write(const void *buf, size_t size)
     
    5557}
    5658
     59/** Print formatted text to klog.
     60 *
     61 * @param fmt Format string
     62 *
     63 * \see For more details about format string see printf_core.
     64 *
     65 */
     66int klog_printf(const char *fmt, ...)
     67{
     68        va_list args;
     69        va_start(args, fmt);
     70       
     71        int ret = klog_vprintf(fmt, args);
     72       
     73        va_end(args);
     74       
     75        return ret;
     76}
     77
     78static int klog_vprintf_str_write(const char *str, size_t size, void *data)
     79{
     80        size_t wr = klog_write(str, size);
     81        return str_nlength(str, wr);
     82}
     83
     84static int klog_vprintf_wstr_write(const wchar_t *str, size_t size, void *data)
     85{
     86        size_t offset = 0;
     87        size_t chars = 0;
     88       
     89        while (offset < size) {
     90                char buf[STR_BOUNDS(1)];
     91                size_t sz = 0;
     92               
     93                if (chr_encode(str[chars], buf, &sz, STR_BOUNDS(1)) == EOK)
     94                        klog_write(buf, sz);
     95               
     96                chars++;
     97                offset += sizeof(wchar_t);
     98        }
     99       
     100        return chars;
     101}
     102
     103/** Print formatted text to klog.
     104 *
     105 * @param fmt Format string
     106 * @param ap  Format parameters
     107 *
     108 * \see For more details about format string see printf_core.
     109 *
     110 */
     111int klog_vprintf(const char *fmt, va_list ap)
     112{
     113        printf_spec_t ps = {
     114                klog_vprintf_str_write,
     115                klog_vprintf_wstr_write,
     116                NULL
     117        };
     118       
     119        return printf_core(fmt, &ps, ap);
     120}
     121
    57122/** @}
    58123 */
  • uspace/lib/c/generic/io/vprintf.c

    r18ba2e4f r544a2e4  
    9696/** Print formatted text to stdout.
    9797 *
    98  * @param file Output stream
    99  * @param fmt  Format string
    100  * @param ap   Format parameters
     98 * @param fmt Format string
     99 * @param ap  Format parameters
    101100 *
    102101 * \see For more details about format string see printf_core.
  • uspace/lib/c/generic/libc.c

    r18ba2e4f r544a2e4  
    5353#include "private/io.h"
    5454
     55#ifdef CONFIG_RTLD
     56#include <rtld/rtld.h>
     57#endif
     58
    5559static bool env_setup = false;
    5660
     
    7781        char **argv;
    7882       
     83#ifdef __IN_SHARED_LIBC__
     84        if (__pcb != NULL && __pcb->rtld_runtime != NULL) {
     85                runtime_env = (runtime_env_t *) __pcb->rtld_runtime;
     86        }
     87#endif
    7988        /*
    8089         * Get command line arguments and initialize
  • uspace/lib/c/generic/malloc.c

    r18ba2e4f r544a2e4  
    4444#include <mem.h>
    4545#include <futex.h>
     46#include <stdlib.h>
    4647#include <adt/gcdlcm.h>
    4748#include "private/malloc.h"
     
    6364 */
    6465#define BASE_ALIGN  16
     66
     67/** Heap shrink granularity
     68 *
     69 * Try not to pump and stress the heap to much
     70 * by shrinking and enlarging it too often.
     71 * A heap area won't shrunk if it the released
     72 * free block is smaller than this constant.
     73 *
     74 */
     75#define SHRINK_GRANULARITY  (64 * PAGE_SIZE)
    6576
    6677/** Overhead of each heap block. */
     
    6879        (sizeof(heap_block_head_t) + sizeof(heap_block_foot_t))
    6980
     81/** Overhead of each area. */
     82#define AREA_OVERHEAD(size) \
     83        (ALIGN_UP(size + sizeof(heap_area_t), BASE_ALIGN))
     84
    7085/** Calculate real size of a heap block.
    7186 *
     
    85100 *
    86101 */
    87 #define AREA_FIRST_BLOCK(area) \
     102#define AREA_FIRST_BLOCK_HEAD(area) \
    88103        (ALIGN_UP(((uintptr_t) (area)) + sizeof(heap_area_t), BASE_ALIGN))
     104
     105/** Get last block in heap area.
     106 *
     107 */
     108#define AREA_LAST_BLOCK_FOOT(area) \
     109        (((uintptr_t) (area)->end) - sizeof(heap_block_foot_t))
     110
     111/** Get header in heap block.
     112 *
     113 */
     114#define BLOCK_HEAD(foot) \
     115        ((heap_block_head_t *) \
     116            (((uintptr_t) (foot)) + sizeof(heap_block_foot_t) - (foot)->size))
    89117
    90118/** Get footer in heap block.
     
    93121#define BLOCK_FOOT(head) \
    94122        ((heap_block_foot_t *) \
    95             (((uintptr_t) head) + head->size - sizeof(heap_block_foot_t)))
     123            (((uintptr_t) (head)) + (head)->size - sizeof(heap_block_foot_t)))
    96124
    97125/** Heap area.
     
    114142        void *end;
    115143       
     144        /** Previous heap area */
     145        struct heap_area *prev;
     146       
    116147        /** Next heap area */
    117148        struct heap_area *next;
     
    156187
    157188/** Next heap block to examine (next fit algorithm) */
    158 static heap_block_head_t *next = NULL;
     189static heap_block_head_t *next_fit = NULL;
    159190
    160191/** Futex for thread-safe heap manipulation */
    161192static futex_t malloc_futex = FUTEX_INITIALIZER;
     193
     194#ifndef NDEBUG
     195
     196#define malloc_assert(expr) \
     197        do { \
     198                if (!(expr)) {\
     199                        futex_up(&malloc_futex); \
     200                        assert_abort(#expr, __FILE__, __LINE__); \
     201                } \
     202        } while (0)
     203
     204#else /* NDEBUG */
     205
     206#define malloc_assert(expr)
     207
     208#endif /* NDEBUG */
    162209
    163210/** Initialize a heap block
     
    201248        heap_block_head_t *head = (heap_block_head_t *) addr;
    202249       
    203         assert(head->magic == HEAP_BLOCK_HEAD_MAGIC);
     250        malloc_assert(head->magic == HEAP_BLOCK_HEAD_MAGIC);
    204251       
    205252        heap_block_foot_t *foot = BLOCK_FOOT(head);
    206253       
    207         assert(foot->magic == HEAP_BLOCK_FOOT_MAGIC);
    208         assert(head->size == foot->size);
     254        malloc_assert(foot->magic == HEAP_BLOCK_FOOT_MAGIC);
     255        malloc_assert(head->size == foot->size);
    209256}
    210257
    211258/** Check a heap area structure
    212259 *
     260 * Should be called only inside the critical section.
     261 *
    213262 * @param addr Address of the heap area.
    214263 *
     
    218267        heap_area_t *area = (heap_area_t *) addr;
    219268       
    220         assert(area->magic == HEAP_AREA_MAGIC);
    221         assert(area->start < area->end);
    222         assert(((uintptr_t) area->start % PAGE_SIZE) == 0);
    223         assert(((uintptr_t) area->end % PAGE_SIZE) == 0);
     269        malloc_assert(area->magic == HEAP_AREA_MAGIC);
     270        malloc_assert(addr == area->start);
     271        malloc_assert(area->start < area->end);
     272        malloc_assert(((uintptr_t) area->start % PAGE_SIZE) == 0);
     273        malloc_assert(((uintptr_t) area->end % PAGE_SIZE) == 0);
    224274}
    225275
    226276/** Create new heap area
    227277 *
    228  * @param start Preffered starting address of the new area.
    229  * @param size  Size of the area.
     278 * Should be called only inside the critical section.
     279 *
     280 * @param size Size of the area.
    230281 *
    231282 */
     
    247298       
    248299        area->start = astart;
    249         area->end = (void *)
    250             ALIGN_DOWN((uintptr_t) astart + asize, BASE_ALIGN);
     300        area->end = (void *) ((uintptr_t) astart + asize);
     301        area->prev = NULL;
    251302        area->next = NULL;
    252303        area->magic = HEAP_AREA_MAGIC;
    253304       
    254         void *block = (void *) AREA_FIRST_BLOCK(area);
     305        void *block = (void *) AREA_FIRST_BLOCK_HEAD(area);
    255306        size_t bsize = (size_t) (area->end - block);
    256307       
     
    261312                last_heap_area = area;
    262313        } else {
     314                area->prev = last_heap_area;
    263315                last_heap_area->next = area;
    264316                last_heap_area = area;
     
    270322/** Try to enlarge a heap area
    271323 *
     324 * Should be called only inside the critical section.
     325 *
    272326 * @param area Heap area to grow.
    273  * @param size Gross size of item to allocate (bytes).
     327 * @param size Gross size to grow (bytes).
     328 *
     329 * @return True if successful.
    274330 *
    275331 */
     
    281337        area_check(area);
    282338       
    283         size_t asize = ALIGN_UP((size_t) (area->end - area->start) + size,
    284             PAGE_SIZE);
    285        
    286339        /* New heap area size */
    287         void *end = (void *)
    288             ALIGN_DOWN((uintptr_t) area->start + asize, BASE_ALIGN);
     340        size_t gross_size = (size_t) (area->end - area->start) + size;
     341        size_t asize = ALIGN_UP(gross_size, PAGE_SIZE);
     342        void *end = (void *) ((uintptr_t) area->start + asize);
    289343       
    290344        /* Check for overflow */
     
    298352       
    299353        /* Add new free block */
    300         block_init(area->end, (size_t) (end - area->end), true, area);
     354        size_t net_size = (size_t) (end - area->end);
     355        if (net_size > 0)
     356                block_init(area->end, net_size, true, area);
    301357       
    302358        /* Update heap area parameters */
     
    308364/** Try to enlarge any of the heap areas
    309365 *
     366 * Should be called only inside the critical section.
     367 *
    310368 * @param size Gross size of item to allocate (bytes).
    311369 *
     
    317375       
    318376        /* First try to enlarge some existing area */
    319         heap_area_t *area;
    320         for (area = first_heap_area; area != NULL; area = area->next) {
     377        for (heap_area_t *area = first_heap_area; area != NULL;
     378            area = area->next) {
    321379                if (area_grow(area, size))
    322380                        return true;
     
    324382       
    325383        /* Eventually try to create a new area */
    326         return area_create(AREA_FIRST_BLOCK(size));
    327 }
    328 
    329 /** Try to shrink heap space
    330  *
     384        return area_create(AREA_OVERHEAD(size));
     385}
     386
     387/** Try to shrink heap
     388 *
     389 * Should be called only inside the critical section.
    331390 * In all cases the next pointer is reset.
    332391 *
    333  */
    334 static void heap_shrink(void)
    335 {
    336         next = NULL;
     392 * @param area Last modified heap area.
     393 *
     394 */
     395static void heap_shrink(heap_area_t *area)
     396{
     397        area_check(area);
     398       
     399        heap_block_foot_t *last_foot =
     400            (heap_block_foot_t *) AREA_LAST_BLOCK_FOOT(area);
     401        heap_block_head_t *last_head = BLOCK_HEAD(last_foot);
     402       
     403        block_check((void *) last_head);
     404        malloc_assert(last_head->area == area);
     405       
     406        if (last_head->free) {
     407                /*
     408                 * The last block of the heap area is
     409                 * unused. The area might be potentially
     410                 * shrunk.
     411                 */
     412               
     413                heap_block_head_t *first_head =
     414                    (heap_block_head_t *) AREA_FIRST_BLOCK_HEAD(area);
     415               
     416                block_check((void *) first_head);
     417                malloc_assert(first_head->area == area);
     418               
     419                size_t shrink_size = ALIGN_DOWN(last_head->size, PAGE_SIZE);
     420               
     421                if (first_head == last_head) {
     422                        /*
     423                         * The entire heap area consists of a single
     424                         * free heap block. This means we can get rid
     425                         * of it entirely.
     426                         */
     427                       
     428                        heap_area_t *prev = area->prev;
     429                        heap_area_t *next = area->next;
     430                       
     431                        if (prev != NULL) {
     432                                area_check(prev);
     433                                prev->next = next;
     434                        } else
     435                                first_heap_area = next;
     436                       
     437                        if (next != NULL) {
     438                                area_check(next);
     439                                next->prev = prev;
     440                        } else
     441                                last_heap_area = prev;
     442                       
     443                        as_area_destroy(area->start);
     444                } else if (shrink_size >= SHRINK_GRANULARITY) {
     445                        /*
     446                         * Make sure that we always shrink the area
     447                         * by a multiple of page size and update
     448                         * the block layout accordingly.
     449                         */
     450                       
     451                        size_t asize = (size_t) (area->end - area->start) - shrink_size;
     452                        void *end = (void *) ((uintptr_t) area->start + asize);
     453                       
     454                        /* Resize the address space area */
     455                        int ret = as_area_resize(area->start, asize, 0);
     456                        if (ret != EOK)
     457                                abort();
     458                       
     459                        /* Update heap area parameters */
     460                        area->end = end;
     461                        size_t excess = ((size_t) area->end) - ((size_t) last_head);
     462                       
     463                        if (excess > 0) {
     464                                if (excess >= STRUCT_OVERHEAD) {
     465                                        /*
     466                                         * The previous block cannot be free and there
     467                                         * is enough free space left in the area to
     468                                         * create a new free block.
     469                                         */
     470                                        block_init((void *) last_head, excess, true, area);
     471                                } else {
     472                                        /*
     473                                         * The excess is small. Therefore just enlarge
     474                                         * the previous block.
     475                                         */
     476                                        heap_block_foot_t *prev_foot = (heap_block_foot_t *)
     477                                            (((uintptr_t) last_head) - sizeof(heap_block_foot_t));
     478                                        heap_block_head_t *prev_head = BLOCK_HEAD(prev_foot);
     479                                       
     480                                        block_check((void *) prev_head);
     481                                       
     482                                        block_init(prev_head, prev_head->size + excess,
     483                                            prev_head->free, area);
     484                                }
     485                        }
     486                }
     487        }
     488       
     489        next_fit = NULL;
    337490}
    338491
     
    361514static void split_mark(heap_block_head_t *cur, const size_t size)
    362515{
    363         assert(cur->size >= size);
     516        malloc_assert(cur->size >= size);
    364517       
    365518        /* See if we should split the block. */
     
    397550{
    398551        area_check((void *) area);
    399         assert((void *) first_block >= (void *) AREA_FIRST_BLOCK(area));
    400         assert((void *) first_block < area->end);
    401        
    402         heap_block_head_t *cur;
    403         for (cur = first_block; (void *) cur < area->end;
     552        malloc_assert((void *) first_block >= (void *) AREA_FIRST_BLOCK_HEAD(area));
     553        malloc_assert((void *) first_block < area->end);
     554       
     555        for (heap_block_head_t *cur = first_block; (void *) cur < area->end;
    404556            cur = (heap_block_head_t *) (((void *) cur) + cur->size)) {
    405557                block_check(cur);
     
    424576                                split_mark(cur, real_size);
    425577                               
    426                                 next = cur;
     578                                next_fit = cur;
    427579                                return addr;
    428580                        } else {
     
    435587                                         * data in (including alignment).
    436588                                         */
    437                                         if ((void *) cur > (void *) AREA_FIRST_BLOCK(area)) {
     589                                        if ((void *) cur > (void *) AREA_FIRST_BLOCK_HEAD(area)) {
    438590                                                /*
    439591                                                 * There is a block before the current block.
     
    476628                                                split_mark(next_head, real_size);
    477629                                               
    478                                                 next = next_head;
     630                                                next_fit = next_head;
    479631                                                return aligned;
    480632                                        } else {
     
    495647                                                        size_t reduced_size = cur->size - excess;
    496648                                                        cur = (heap_block_head_t *)
    497                                                             (AREA_FIRST_BLOCK(area) + excess);
     649                                                            (AREA_FIRST_BLOCK_HEAD(area) + excess);
    498650                                                       
    499                                                         block_init((void *) AREA_FIRST_BLOCK(area), excess,
    500                                                             true, area);
     651                                                        block_init((void *) AREA_FIRST_BLOCK_HEAD(area),
     652                                                            excess, true, area);
    501653                                                        block_init(cur, reduced_size, true, area);
    502654                                                        split_mark(cur, real_size);
    503655                                                       
    504                                                         next = cur;
     656                                                        next_fit = cur;
    505657                                                        return aligned;
    506658                                                }
     
    526678static void *malloc_internal(const size_t size, const size_t align)
    527679{
    528         assert(first_heap_area != NULL);
     680        malloc_assert(first_heap_area != NULL);
    529681       
    530682        if (align == 0)
     
    540692       
    541693        /* Try the next fit approach */
    542         split = next;
     694        split = next_fit;
    543695       
    544696        if (split != NULL) {
     
    551703       
    552704        /* Search the entire heap */
    553         heap_area_t *area;
    554         for (area = first_heap_area; area != NULL; area = area->next) {
     705        for (heap_area_t *area = first_heap_area; area != NULL;
     706            area = area->next) {
    555707                heap_block_head_t *first = (heap_block_head_t *)
    556                     AREA_FIRST_BLOCK(area);
     708                    AREA_FIRST_BLOCK_HEAD(area);
    557709               
    558710                void *addr = malloc_area(area, first, split, real_size,
     
    651803       
    652804        block_check(head);
    653         assert(!head->free);
     805        malloc_assert(!head->free);
    654806       
    655807        heap_area_t *area = head->area;
    656808       
    657809        area_check(area);
    658         assert((void *) head >= (void *) AREA_FIRST_BLOCK(area));
    659         assert((void *) head < area->end);
     810        malloc_assert((void *) head >= (void *) AREA_FIRST_BLOCK_HEAD(area));
     811        malloc_assert((void *) head < area->end);
    660812       
    661813        void *ptr = NULL;
     
    674826                        block_init((void *) head + real_size,
    675827                            orig_size - real_size, true, area);
    676                         heap_shrink();
     828                        heap_shrink(area);
    677829                }
    678830               
     
    696848                       
    697849                        ptr = ((void *) head) + sizeof(heap_block_head_t);
    698                         next = NULL;
     850                        next_fit = NULL;
    699851                } else
    700852                        reloc = true;
     
    728880       
    729881        block_check(head);
    730         assert(!head->free);
     882        malloc_assert(!head->free);
    731883       
    732884        heap_area_t *area = head->area;
    733885       
    734886        area_check(area);
    735         assert((void *) head >= (void *) AREA_FIRST_BLOCK(area));
    736         assert((void *) head < area->end);
     887        malloc_assert((void *) head >= (void *) AREA_FIRST_BLOCK_HEAD(area));
     888        malloc_assert((void *) head < area->end);
    737889       
    738890        /* Mark the block itself as free. */
     
    750902       
    751903        /* Look at the previous block. If it is free, merge the two. */
    752         if ((void *) head > (void *) AREA_FIRST_BLOCK(area)) {
     904        if ((void *) head > (void *) AREA_FIRST_BLOCK_HEAD(area)) {
    753905                heap_block_foot_t *prev_foot =
    754906                    (heap_block_foot_t *) (((void *) head) - sizeof(heap_block_foot_t));
     
    764916        }
    765917       
    766         heap_shrink();
     918        heap_shrink(area);
    767919       
    768920        futex_up(&malloc_futex);
    769921}
    770922
     923void *heap_check(void)
     924{
     925        futex_down(&malloc_futex);
     926       
     927        if (first_heap_area == NULL) {
     928                futex_up(&malloc_futex);
     929                return (void *) -1;
     930        }
     931       
     932        /* Walk all heap areas */
     933        for (heap_area_t *area = first_heap_area; area != NULL;
     934            area = area->next) {
     935               
     936                /* Check heap area consistency */
     937                if ((area->magic != HEAP_AREA_MAGIC) ||
     938                    ((void *) area != area->start) ||
     939                    (area->start >= area->end) ||
     940                    (((uintptr_t) area->start % PAGE_SIZE) != 0) ||
     941                    (((uintptr_t) area->end % PAGE_SIZE) != 0)) {
     942                        futex_up(&malloc_futex);
     943                        return (void *) area;
     944                }
     945               
     946                /* Walk all heap blocks */
     947                for (heap_block_head_t *head = (heap_block_head_t *)
     948                    AREA_FIRST_BLOCK_HEAD(area); (void *) head < area->end;
     949                    head = (heap_block_head_t *) (((void *) head) + head->size)) {
     950                       
     951                        /* Check heap block consistency */
     952                        if (head->magic != HEAP_BLOCK_HEAD_MAGIC) {
     953                                futex_up(&malloc_futex);
     954                                return (void *) head;
     955                        }
     956                       
     957                        heap_block_foot_t *foot = BLOCK_FOOT(head);
     958                       
     959                        if ((foot->magic != HEAP_BLOCK_FOOT_MAGIC) ||
     960                            (head->size != foot->size)) {
     961                                futex_up(&malloc_futex);
     962                                return (void *) foot;
     963                        }
     964                }
     965        }
     966       
     967        futex_up(&malloc_futex);
     968       
     969        return NULL;
     970}
     971
    771972/** @}
    772973 */
  • uspace/lib/c/generic/stacktrace.c

    r18ba2e4f r544a2e4  
    6161        stacktrace_prepare();
    6262        stacktrace_print_fp_pc(stacktrace_fp_get(), stacktrace_pc_get());
     63       
    6364        /*
    6465         * Prevent the tail call optimization of the previous call by
    6566         * making it a non-tail call.
    6667         */
    67         (void) stacktrace_fp_get();
     68       
     69        printf("-- end of stack trace --\n");
    6870}
    6971
  • uspace/lib/c/generic/str.c

    r18ba2e4f r544a2e4  
    12151215void order_suffix(const uint64_t val, uint64_t *rv, char *suffix)
    12161216{
    1217         if (val > 10000000000000000000ULL) {
    1218                 *rv = val / 1000000000000000000ULL;
     1217        if (val > UINT64_C(10000000000000000000)) {
     1218                *rv = val / UINT64_C(1000000000000000000);
    12191219                *suffix = 'Z';
    1220         } else if (val > 1000000000000000000ULL) {
    1221                 *rv = val / 1000000000000000ULL;
     1220        } else if (val > UINT64_C(1000000000000000000)) {
     1221                *rv = val / UINT64_C(1000000000000000);
    12221222                *suffix = 'E';
    1223         } else if (val > 1000000000000000ULL) {
    1224                 *rv = val / 1000000000000ULL;
     1223        } else if (val > UINT64_C(1000000000000000)) {
     1224                *rv = val / UINT64_C(1000000000000);
    12251225                *suffix = 'T';
    1226         } else if (val > 1000000000000ULL) {
    1227                 *rv = val / 1000000000ULL;
     1226        } else if (val > UINT64_C(1000000000000)) {
     1227                *rv = val / UINT64_C(1000000000);
    12281228                *suffix = 'G';
    1229         } else if (val > 1000000000ULL) {
    1230                 *rv = val / 1000000ULL;
     1229        } else if (val > UINT64_C(1000000000)) {
     1230                *rv = val / UINT64_C(1000000);
    12311231                *suffix = 'M';
    1232         } else if (val > 1000000ULL) {
    1233                 *rv = val / 1000ULL;
     1232        } else if (val > UINT64_C(1000000)) {
     1233                *rv = val / UINT64_C(1000);
    12341234                *suffix = 'k';
    12351235        } else {
     
    12391239}
    12401240
     1241void bin_order_suffix(const uint64_t val, uint64_t *rv, const char **suffix,
     1242    bool fixed)
     1243{
     1244        if (val > UINT64_C(1152921504606846976)) {
     1245                *rv = val / UINT64_C(1125899906842624);
     1246                *suffix = "EiB";
     1247        } else if (val > UINT64_C(1125899906842624)) {
     1248                *rv = val / UINT64_C(1099511627776);
     1249                *suffix = "TiB";
     1250        } else if (val > UINT64_C(1099511627776)) {
     1251                *rv = val / UINT64_C(1073741824);
     1252                *suffix = "GiB";
     1253        } else if (val > UINT64_C(1073741824)) {
     1254                *rv = val / UINT64_C(1048576);
     1255                *suffix = "MiB";
     1256        } else if (val > UINT64_C(1048576)) {
     1257                *rv = val / UINT64_C(1024);
     1258                *suffix = "KiB";
     1259        } else {
     1260                *rv = val;
     1261                if (fixed)
     1262                        *suffix = "B  ";
     1263                else
     1264                        *suffix = "B";
     1265        }
     1266}
     1267
    12411268/** @}
    12421269 */
  • uspace/lib/c/generic/thread.c

    r18ba2e4f r544a2e4  
    4444
    4545#ifndef THREAD_INITIAL_STACK_PAGES_NO
    46 #define THREAD_INITIAL_STACK_PAGES_NO 1
     46#define THREAD_INITIAL_STACK_PAGES_NO   2
    4747#endif
    4848
  • uspace/lib/c/include/adt/fifo.h

    r18ba2e4f r544a2e4  
    5151typedef unsigned long fifo_index_t;
    5252
    53 #define FIFO_CREATE_STATIC(name, t, itms)               \
    54         struct {                                        \
    55                 t fifo[(itms)];                         \
    56                 fifo_count_t items;                     \
    57                 fifo_index_t head;                      \
    58                 fifo_index_t tail;                      \
     53#define FIFO_CREATE_STATIC(name, t, itms) \
     54        struct { \
     55                t fifo[(itms)]; \
     56                fifo_count_t items; \
     57                fifo_index_t head; \
     58                fifo_index_t tail; \
    5959        } name
    6060
  • uspace/lib/c/include/adt/list.h

    r18ba2e4f r544a2e4  
    4747 *
    4848 * @param name Name of the new statically allocated list.
    49  */
    50 #define LIST_INITIALIZE(name)  link_t name = { \
    51         .prev = &name, \
    52         .next = &name \
    53 }
     49 *
     50 */
     51#define LIST_INITIALIZE(name) \
     52        link_t name = { \
     53                .prev = &name, \
     54                .next = &name \
     55        }
     56
     57#define list_get_instance(link, type, member) \
     58        ((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member))))
     59
     60#define list_foreach(list, iterator) \
     61        for (link_t *iterator = (list).next; \
     62            iterator != &(list); iterator = iterator->next)
    5463
    5564/** Initialize doubly-linked circular list link
     
    5867 *
    5968 * @param link Pointer to link_t structure to be initialized.
     69 *
    6070 */
    6171static inline void link_initialize(link_t *link)
     
    6979 * Initialize doubly-linked circular list.
    7080 *
    71  * @param head Pointer to link_t structure representing head of the list.
    72  */
    73 static inline void list_initialize(link_t *head)
    74 {
    75         head->prev = head;
    76         head->next = head;
     81 * @param list Pointer to link_t structure representing the list.
     82 *
     83 */
     84static inline void list_initialize(link_t *list)
     85{
     86        list->prev = list;
     87        list->next = list;
    7788}
    7889
     
    8293 *
    8394 * @param link Pointer to link_t structure to be added.
    84  * @param head Pointer to link_t structure representing head of the list.
    85  */
    86 static inline void list_prepend(link_t *link, link_t *head)
    87 {
    88         link->next = head->next;
    89         link->prev = head;
    90         head->next->prev = link;
    91         head->next = link;
     95 * @param list Pointer to link_t structure representing the list.
     96 *
     97 */
     98static inline void list_prepend(link_t *link, link_t *list)
     99{
     100        link->next = list->next;
     101        link->prev = list;
     102        list->next->prev = link;
     103        list->next = link;
    92104}
    93105
     
    97109 *
    98110 * @param link Pointer to link_t structure to be added.
    99  * @param head Pointer to link_t structure representing head of the list.
    100  */
    101 static inline void list_append(link_t *link, link_t *head)
    102 {
    103         link->prev = head->prev;
    104         link->next = head;
    105         head->prev->next = link;
    106         head->prev = link;
    107 }
    108 
    109 /** Insert item before another item in doubly-linked circular list. */
    110 static inline void list_insert_before(link_t *l, link_t *r)
    111 {
    112         list_append(l, r);
    113 }
    114 
    115 /** Insert item after another item in doubly-linked circular list. */
    116 static inline void list_insert_after(link_t *r, link_t *l)
    117 {
    118         list_prepend(l, r);
     111 * @param list Pointer to link_t structure representing the list.
     112 *
     113 */
     114static inline void list_append(link_t *link, link_t *list)
     115{
     116        link->prev = list->prev;
     117        link->next = list;
     118        list->prev->next = link;
     119        list->prev = link;
     120}
     121
     122/** Insert item before another item in doubly-linked circular list.
     123 *
     124 */
     125static inline void list_insert_before(link_t *link, link_t *list)
     126{
     127        list_append(link, list);
     128}
     129
     130/** Insert item after another item in doubly-linked circular list.
     131 *
     132 */
     133static inline void list_insert_after(link_t *link, link_t *list)
     134{
     135        list_prepend(list, link);
    119136}
    120137
     
    123140 * Remove item from doubly-linked circular list.
    124141 *
    125  * @param link Pointer to link_t structure to be removed from the list it is contained in.
     142 * @param link Pointer to link_t structure to be removed from the list
     143 *             it is contained in.
     144 *
    126145 */
    127146static inline void list_remove(link_t *link)
     
    136155 * Query emptiness of doubly-linked circular list.
    137156 *
    138  * @param head Pointer to link_t structure representing head of the list.
    139  */
    140 static inline int list_empty(link_t *head)
    141 {
    142         return ((head->next == head) ? 1 : 0);
    143 }
    144 
     157 * @param list Pointer to link_t structure representing the list.
     158 *
     159 */
     160static inline int list_empty(link_t *list)
     161{
     162        return (list->next == list);
     163}
     164
     165/** Get head item of a list.
     166 *
     167 * @param list Pointer to link_t structure representing the list.
     168 *
     169 * @return Head item of the list.
     170 * @return NULL if the list is empty.
     171 *
     172 */
     173static inline link_t *list_head(link_t *list)
     174{
     175        return ((list->next == list) ? NULL : list->next);
     176}
    145177
    146178/** Split or concatenate headless doubly-linked circular list
     
    151183 * concatenates splitted lists and splits concatenated lists.
    152184 *
    153  * @param part1 Pointer to link_t structure leading the first (half of the headless) list.
    154  * @param part2 Pointer to link_t structure leading the second (half of the headless) list.
     185 * @param part1 Pointer to link_t structure leading the first
     186 *              (half of the headless) list.
     187 * @param part2 Pointer to link_t structure leading the second
     188 *              (half of the headless) list.
     189 *
    155190 */
    156191static inline void headless_list_split_or_concat(link_t *part1, link_t *part2)
     
    165200}
    166201
    167 
    168202/** Split headless doubly-linked circular list
    169203 *
    170204 * Split headless doubly-linked circular list.
    171205 *
    172  * @param part1 Pointer to link_t structure leading the first half of the headless list.
    173  * @param part2 Pointer to link_t structure leading the second half of the headless list.
     206 * @param part1 Pointer to link_t structure leading
     207 *              the first half of the headless list.
     208 * @param part2 Pointer to link_t structure leading
     209 *              the second half of the headless list.
     210 *
    174211 */
    175212static inline void headless_list_split(link_t *part1, link_t *part2)
     
    182219 * Concatenate two headless doubly-linked circular lists.
    183220 *
    184  * @param part1 Pointer to link_t structure leading the first headless list.
    185  * @param part2 Pointer to link_t structure leading the second headless list.
     221 * @param part1 Pointer to link_t structure leading
     222 *              the first headless list.
     223 * @param part2 Pointer to link_t structure leading
     224 *              the second headless list.
     225 *
    186226 */
    187227static inline void headless_list_concat(link_t *part1, link_t *part2)
     
    190230}
    191231
    192 #define list_get_instance(link, type, member)  ((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member))))
    193 
    194 extern int list_member(const link_t *link, const link_t *head);
    195 extern void list_concat(link_t *head1, link_t *head2);
    196 extern unsigned int list_count(const link_t *link);
     232/** Get n-th item of a list.
     233 *
     234 * @param list Pointer to link_t structure representing the list.
     235 * @param n    Item number (indexed from zero).
     236 *
     237 * @return n-th item of the list.
     238 * @return NULL if no n-th item found.
     239 *
     240 */
     241static inline link_t *list_nth(link_t *list, unsigned int n)
     242{
     243        unsigned int cnt = 0;
     244       
     245        list_foreach(*list, link) {
     246                if (cnt == n)
     247                        return link;
     248               
     249                cnt++;
     250        }
     251       
     252        return NULL;
     253}
     254
     255extern int list_member(const link_t *, const link_t *);
     256extern void list_concat(link_t *, link_t *);
     257extern unsigned int list_count(const link_t *);
    197258
    198259#endif
  • uspace/lib/c/include/adt/measured_strings.h

    r18ba2e4f r544a2e4  
    6161extern measured_string_t *measured_string_create_bulk(const uint8_t *, size_t);
    6262extern measured_string_t *measured_string_copy(measured_string_t *);
     63
    6364extern int measured_strings_receive(measured_string_t **, uint8_t **, size_t);
    6465extern int measured_strings_reply(const measured_string_t *, size_t);
  • uspace/lib/c/include/as.h

    r18ba2e4f r544a2e4  
    5454}
    5555
    56 extern void *as_area_create(void *address, size_t size, int flags);
    57 extern int as_area_resize(void *address, size_t size, int flags);
    58 extern int as_area_change_flags(void *address, int flags);
    59 extern int as_area_destroy(void *address);
    60 extern void *set_maxheapsize(size_t mhs);
    61 extern void * as_get_mappable_page(size_t sz);
     56extern void *as_area_create(void *, size_t, unsigned int);
     57extern int as_area_resize(void *, size_t, unsigned int);
     58extern int as_area_change_flags(void *, unsigned int);
     59extern int as_area_destroy(void *);
     60extern void *set_maxheapsize(size_t);
     61extern void *as_get_mappable_page(size_t);
    6262
    6363#endif
  • uspace/lib/c/include/assert.h

    r18ba2e4f r544a2e4  
    4040 *
    4141 * If NDEBUG is not set, the assert() macro
    42  * evaluates expr and if it is false prints 
     42 * evaluates expr and if it is false prints
    4343 * error message and terminate program.
    4444 *
     
    4747 */
    4848
    49 #include <stdio.h>
    50 #include <stdlib.h>
    51 
    5249#ifndef NDEBUG
    5350
    5451#define assert(expr) \
    5552        do { \
    56                 if (!(expr)) { \
    57                         printf("Assertion failed (%s) at file '%s', " \
    58                             "line %d.\n", #expr, __FILE__, __LINE__); \
    59                         abort(); \
    60                 } \
     53                if (!(expr)) \
     54                        assert_abort(#expr, __FILE__, __LINE__); \
    6155        } while (0)
    6256
     
    6761#endif /* NDEBUG */
    6862
     63extern void assert_abort(const char *, const char *, unsigned int)
     64    __attribute__((noreturn));
     65
    6966#endif
    7067
  • uspace/lib/c/include/dlfcn.h

    r18ba2e4f r544a2e4  
    11/*
    2  * Copyright (c) 2009 Martin Decky
     2 * Copyright (c) 2008 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #include <test.h>
     29/** @addtogroup rtld
     30 * @{
     31 */
     32/** @file
     33 * @brief UNIX-like dynamic linker interface.
     34 */
    3035
    31 const char *test_mips2(void)
    32 {
    33         return NULL;
    34 }
     36#ifndef LIBC_DLFCN_H_
     37#define LIBC_DLFCN_H_
     38
     39void *dlopen(const char *, int);
     40void *dlsym(void *, const char *);
     41
     42#endif
     43
     44/**
     45 * @}
     46 */
  • uspace/lib/c/include/entry_point.h

    r18ba2e4f r544a2e4  
    11/*
    2  * Copyright (c) 2006 Jakub Jermar
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup sparc64mm       
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_sparc64_CACHE_H_
    36 #define KERN_sparc64_CACHE_H_
     35#ifndef LIBC_ENTRY_POINT_H_
     36#define LIBC_ENTRY_POINT_H_
    3737
    38 #include <mm/page.h>
    39 #include <mm/frame.h>
     38/* Defined in arch/ARCH/src/entryjmp.[c|s] */
     39void entry_point_jmp(void *, void *);
    4040
    4141#endif
  • uspace/lib/c/include/errno.h

    r18ba2e4f r544a2e4  
    3939#include <fibril.h>
    4040
    41 #define errno _errno
     41#define errno  (*(__errno()))
    4242
    43 extern int _errno;
     43extern int *__errno(void) __attribute__((const));
    4444
    4545#define EMFILE        (-18)
  • uspace/lib/c/include/event.h

    r18ba2e4f r544a2e4  
    3939
    4040extern int event_subscribe(event_type_t, sysarg_t);
     41extern int event_unmask(event_type_t);
    4142
    4243#endif
  • uspace/lib/c/include/fibril.h

    r18ba2e4f r544a2e4  
    7070        int (*func)(void *);
    7171        tcb_t *tcb;
    72 
     72       
    7373        struct fibril *clean_after_me;
    7474        int retval;
    7575        int flags;
    76 
     76       
    7777        fibril_owner_info_t *waits_for;
    7878} fibril_t;
  • uspace/lib/c/include/fibril_synch.h

    r18ba2e4f r544a2e4  
    3636#define LIBC_FIBRIL_SYNCH_H_
    3737
    38 #include <async.h>
    3938#include <fibril.h>
    4039#include <adt/list.h>
    4140#include <libarch/tls.h>
    4241#include <sys/time.h>
     42#include <bool.h>
    4343
    4444typedef struct {
    45         fibril_owner_info_t oi;         /* Keep this the first thing. */
     45        fibril_owner_info_t oi;  /**< Keep this the first thing. */
    4646        int counter;
    4747        link_t waiters;
     
    6464
    6565typedef struct {
    66         fibril_owner_info_t oi; /* Keep this the first thing. */
     66        fibril_owner_info_t oi;  /**< Keep this the first thing. */
    6767        unsigned writers;
    6868        unsigned readers;
  • uspace/lib/c/include/io/klog.h

    r18ba2e4f r544a2e4  
    3737
    3838#include <sys/types.h>
     39#include <stdarg.h>
    3940
    4041extern size_t klog_write(const void *, size_t);
    4142extern void klog_update(void);
     43extern int klog_printf(const char *, ...);
     44extern int klog_vprintf(const char *, va_list);
    4245
    4346#endif
  • uspace/lib/c/include/loader/pcb.h

    r18ba2e4f r544a2e4  
    7272        /** Pointer to ELF dynamic section of the program. */
    7373        void *dynamic;
     74        /** Pointer to dynamic linker state structure (runtime_env_t). */
     75        void *rtld_runtime;
    7476} pcb_t;
    7577
  • uspace/lib/c/include/macros.h

    r18ba2e4f r544a2e4  
    3939#define max(a, b)  ((a) > (b) ? (a) : (b))
    4040
    41 #define SIZE2KB(size)  ((size) >> 10)
    42 #define SIZE2MB(size)  ((size) >> 20)
    43 
    44 #define KB2SIZE(kb)  ((kb) << 10)
    45 #define MB2SIZE(mb)  ((mb) << 20)
     41#define KiB2SIZE(kb)  ((kb) << 10)
     42#define MiB2SIZE(mb)  ((mb) << 20)
    4643
    4744#define STRING(arg)      STRING_ARG(arg)
  • uspace/lib/c/include/malloc.h

    r18ba2e4f r544a2e4  
    4646extern void *realloc(const void *addr, const size_t size);
    4747extern void free(const void *addr);
     48extern void *heap_check(void);
    4849
    4950#endif
  • uspace/lib/c/include/rtld/symbol.h

    r18ba2e4f r544a2e4  
    11/*
    2  * Copyright (c) 2009 Martin Decky
     2 * Copyright (c) 2008 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #include <test.h>
     29/** @addtogroup libc
     30 * @{
     31 */
     32/** @file
     33 */
    3034
    31 const char *test_sse1(void)
    32 {
    33         return NULL;
    34 }
     35#ifndef LIBC_RTLD_SYMBOL_H_
     36#define LIBC_RTLD_SYMBOL_H_
     37
     38#include <rtld/rtld.h>
     39#include <elf.h>
     40
     41elf_symbol_t *symbol_bfs_find(const char *name, module_t *start, module_t **mod);
     42elf_symbol_t *symbol_def_find(const char *name, module_t *origin, module_t **mod);
     43void *symbol_get_addr(elf_symbol_t *sym, module_t *m);
     44
     45#endif
     46
     47/** @}
     48 */
  • uspace/lib/c/include/str.h

    r18ba2e4f r544a2e4  
    8989extern int str_size_t(const char *, char **, unsigned int, bool, size_t *);
    9090
    91 extern void order_suffix(const uint64_t val, uint64_t *rv, char *suffix);
     91extern void order_suffix(const uint64_t, uint64_t *, char *);
     92extern void bin_order_suffix(const uint64_t, uint64_t *, const char **, bool);
    9293
    9394/*
  • uspace/lib/net/il/ip_client.c

    r18ba2e4f r544a2e4  
    181181        /* Set the header */
    182182        header = (ip_header_t *) data;
    183         header->header_length = IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) +
    184             ipopt_length);
     183        SET_IP_HEADER_LENGTH(header,
     184            (IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) + ipopt_length)));
    185185        header->ttl = (ttl ? ttl : IPDEFTTL);
    186186        header->tos = tos;
     
    188188
    189189        if (dont_fragment)
    190                 header->flags = IPFLAG_DONT_FRAGMENT;
     190                SET_IP_HEADER_FLAGS(header, IPFLAG_DONT_FRAGMENT);
    191191
    192192        return EOK;
     
    227227                *tos = header->tos;
    228228        if (dont_fragment)
    229                 *dont_fragment = header->flags & IPFLAG_DONT_FRAGMENT;
     229                *dont_fragment = GET_IP_HEADER_FLAGS(header) & IPFLAG_DONT_FRAGMENT;
    230230        if (ipopt_length) {
    231231                *ipopt_length = IP_HEADER_LENGTH(header) - sizeof(ip_header_t);
  • uspace/lib/net/include/ip_header.h

    r18ba2e4f r544a2e4  
    6464 */
    6565#define IP_FRAGMENT_OFFSET(header) \
    66         ((((header)->fragment_offset_high << 8) + \
     66        (((GET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header) << 8) + \
    6767            (header)->fragment_offset_low) * 8U)
    6868
     
    8383 */
    8484#define IP_HEADER_LENGTH(header) \
    85         ((header)->header_length * 4U)
     85        (GET_IP_HEADER_LENGTH(header) * 4U)
    8686
    8787/** Returns the actual IP packet total length.
     
    143143 */
    144144struct ip_header {
    145 #ifdef ARCH_IS_BIG_ENDIAN
    146         uint8_t version : 4;
    147         uint8_t header_length : 4;
    148 #else
    149         uint8_t header_length : 4;
    150         uint8_t version : 4;
    151 #endif
     145        uint8_t vhl; /* version, header_length */
     146
     147#define GET_IP_HEADER_VERSION(header) \
     148        (((header)->vhl & 0xf0) >> 4)
     149#define SET_IP_HEADER_VERSION(header, version) \
     150        ((header)->vhl = \
     151         ((version & 0x0f) << 4) | ((header)->vhl & 0x0f))
     152
     153#define GET_IP_HEADER_LENGTH(header) \
     154        ((header)->vhl & 0x0f)
     155#define SET_IP_HEADER_LENGTH(header, length) \
     156        ((header)->vhl = \
     157         (length & 0x0f) | ((header)->vhl & 0xf0))
    152158
    153159        uint8_t tos;
     
    155161        uint16_t identification;
    156162
    157 #ifdef ARCH_IS_BIG_ENDIAN
    158         uint8_t flags : 3;
    159         uint8_t fragment_offset_high : 5;
    160 #else
    161         uint8_t fragment_offset_high : 5;
    162         uint8_t flags : 3;
    163 #endif
     163        uint8_t ffoh; /* flags, fragment_offset_high */
     164
     165#define GET_IP_HEADER_FLAGS(header) \
     166        (((header)->ffoh & 0xe0) >> 5)
     167#define SET_IP_HEADER_FLAGS(header, flags) \
     168        ((header)->ffoh = \
     169         ((flags & 0x07) << 5) | ((header)->ffoh & 0x1f))
     170
     171#define GET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header) \
     172        ((header)->ffoh & 0x1f)
     173#define SET_IP_HEADER_FRAGMENT_OFFSET_HIGH(header, fragment_offset_high) \
     174        ((header)->ffoh = \
     175         (fragment_offset_high & 0x1f) | ((header)->ffoh & 0xe0))
    164176
    165177        uint8_t fragment_offset_low;
     
    181193        uint8_t pointer;
    182194
    183 #ifdef ARCH_IS_BIG_ENDIAN
    184         uint8_t overflow : 4;
    185         uint8_t flags : 4;
    186 #else
    187         uint8_t flags : 4;
    188         uint8_t overflow : 4;
    189 #endif
     195        uint8_t of; /* overflow, flags */
     196
     197#define GET_IP_OPTION_OVERFLOW(option) \
     198        (((option)->of & 0xf0) >> 4)
     199#define SET_IP_OPTION_OVERFLOW(option, overflow) \
     200        ((option)->of = \
     201         ((overflow & 0x0f) << 4) | ((option)->of & 0x0f))
     202
     203#define GET_IP_OPTION_FLAGS(option) \
     204        ((option)->of & 0x0f)
     205#define SET_IP_OPTION_FLAGS(option, flags) \
     206        ((option)->of = \
     207         (flags & 0x0f) | ((option)->of & 0xf0))
     208
    190209} __attribute__ ((packed));
    191210
  • uspace/lib/softfloat/generic/add.c

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29 /** @addtogroup softfloat       
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include<sftypes.h>
    36 #include<add.h>
    37 #include<comparison.h>
     35#include <sftypes.h>
     36#include <add.h>
     37#include <comparison.h>
    3838
    3939/** Add two Float32 numbers with same signs
     
    139139        a.parts.exp = exp1;
    140140       
    141         /*Clear hidden bit and shift */
     141        /* Clear hidden bit and shift */
    142142        a.parts.fraction = ((frac1 >> 6) & (~FLOAT32_HIDDEN_BIT_MASK)) ;
    143143        return a;
    144144}
    145 
    146145
    147146/** Add two Float64 numbers with same signs
     
    250249       
    251250        a.parts.exp = exp1;
    252         /*Clear hidden bit and shift */
     251        /* Clear hidden bit and shift */
    253252        a.parts.fraction = ( (frac1 >> 6 ) & (~FLOAT64_HIDDEN_BIT_MASK));
    254253       
  • uspace/lib/softfloat/generic/common.c

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29 /** @addtogroup softfloat       
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include<sftypes.h>
    36 #include<common.h>
     35#include <sftypes.h>
     36#include <common.h>
    3737
    3838/* Table for fast leading zeroes counting */
     
    213213/** @}
    214214 */
    215 
  • uspace/lib/softfloat/generic/comparison.c

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29 /** @addtogroup softfloat       
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include<sftypes.h>
    36 #include<comparison.h>
     35#include <sftypes.h>
     36#include <comparison.h>
    3737
    38 inline int isFloat32NaN(float32 f)
    39 {       /* NaN : exp = 0xff and nonzero fraction */
    40         return ((f.parts.exp==0xFF)&&(f.parts.fraction));
     38/* NaN : exp = 0xff and nonzero fraction */
     39int isFloat32NaN(float32 f)
     40{
     41        return ((f.parts.exp == 0xFF) && (f.parts.fraction));
    4142}
    4243
    43 inline int isFloat64NaN(float64 d)
    44 {       /* NaN : exp = 0x7ff and nonzero fraction */
    45         return ((d.parts.exp==0x7FF)&&(d.parts.fraction));
     44/* NaN : exp = 0x7ff and nonzero fraction */
     45int isFloat64NaN(float64 d)
     46{
     47        return ((d.parts.exp == 0x7FF) && (d.parts.fraction));
    4648}
    4749
    48 inline int isFloat32SigNaN(float32 f)
    49 {       /* SigNaN : exp = 0xff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
    50         return ((f.parts.exp==0xFF)&&(f.parts.fraction<0x400000)&&(f.parts.fraction));
     50/* SigNaN : exp = 0xff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
     51int isFloat32SigNaN(float32 f)
     52{
     53        return ((f.parts.exp == 0xFF) && (f.parts.fraction < 0x400000) && (f.parts.fraction));
    5154}
    5255
    53 inline int isFloat64SigNaN(float64 d)
    54 {       /* SigNaN : exp = 0x7ff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
    55         return ((d.parts.exp==0x7FF)&&(d.parts.fraction)&&(d.parts.fraction<0x8000000000000ll));
     56/* SigNaN : exp = 0x7ff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
     57int isFloat64SigNaN(float64 d)
     58{
     59        return ((d.parts.exp == 0x7FF) && (d.parts.fraction) && (d.parts.fraction < 0x8000000000000ll));
    5660}
    5761
    58 inline int isFloat32Infinity(float32 f)
     62int isFloat32Infinity(float32 f)
    5963{
    60         return ((f.parts.exp==0xFF)&&(f.parts.fraction==0x0));
     64        return ((f.parts.exp == 0xFF) && (f.parts.fraction == 0x0));
    6165}
    6266
    63 inline int isFloat64Infinity(float64 d)
     67int isFloat64Infinity(float64 d)
    6468{
    65         return ((d.parts.exp==0x7FF)&&(d.parts.fraction==0x0));
     69        return ((d.parts.exp == 0x7FF) && (d.parts.fraction == 0x0));
    6670}
    6771
    68 inline int isFloat32Zero(float32 f)
     72int isFloat32Zero(float32 f)
    6973{
    7074        return (((f.binary) & 0x7FFFFFFF) == 0);
    7175}
    7276
    73 inline int isFloat64Zero(float64 d)
     77int isFloat64Zero(float64 d)
    7478{
    7579        return (((d.binary) & 0x7FFFFFFFFFFFFFFFll) == 0);
     
    7781
    7882/**
    79  * @return 1, if both floats are equal - but NaNs are not recognized
     83 * @return 1 if both floats are equal - but NaNs are not recognized
    8084 */
    81 inline int isFloat32eq(float32 a, float32 b)
     85int isFloat32eq(float32 a, float32 b)
    8286{
    83         return ((a.binary==b.binary)||(((a.binary| b.binary)&0x7FFFFFFF)==0)); /* a equals to b or both are zeros (with any sign) */
     87        /* a equals to b or both are zeros (with any sign) */
     88        return ((a.binary==b.binary) || (((a.binary | b.binary) & 0x7FFFFFFF) == 0));
    8489}
    8590
    8691/**
    87  * @return 1, if a<b - but NaNs are not recognized
     92 * @return 1 if a < b - but NaNs are not recognized
    8893 */
    89 inline int isFloat32lt(float32 a, float32 b)
     94int isFloat32lt(float32 a, float32 b)
    9095{
    91         if (((a.binary| b.binary)&0x7FFFFFFF)==0) {
     96        if (((a.binary | b.binary) & 0x7FFFFFFF) == 0)
    9297                return 0; /* +- zeroes */
    93         };
    9498       
    95         if ((a.parts.sign)&&(b.parts.sign)) {
    96                 /*if both are negative, smaller is that with greater binary value*/
    97                 return (a.binary>b.binary);
    98                 };
     99        if ((a.parts.sign) && (b.parts.sign))
     100                /* if both are negative, smaller is that with greater binary value */
     101                return (a.binary > b.binary);
    99102       
    100         /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison)*/
    101         a.parts.sign=!a.parts.sign;
    102         b.parts.sign=!b.parts.sign;
    103         return (a.binary<b.binary);
    104                        
     103        /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison) */
     104        a.parts.sign = !a.parts.sign;
     105        b.parts.sign = !b.parts.sign;
     106        return (a.binary < b.binary);
    105107}
    106108
    107109/**
    108  * @return 1, if a>b - but NaNs are not recognized
     110 * @return 1 if a > b - but NaNs are not recognized
    109111 */
    110 inline int isFloat32gt(float32 a, float32 b)
     112int isFloat32gt(float32 a, float32 b)
    111113{
    112         if (((a.binary| b.binary)&0x7FFFFFFF)==0) {
     114        if (((a.binary | b.binary) & 0x7FFFFFFF) == 0)
    113115                return 0; /* zeroes are equal with any sign */
    114         };
    115116       
    116         if ((a.parts.sign)&&(b.parts.sign)) {
    117                 /*if both are negative, greater is that with smaller binary value*/
    118                 return (a.binary<b.binary);
    119                 };
     117        if ((a.parts.sign) && (b.parts.sign))
     118                /* if both are negative, greater is that with smaller binary value */
     119                return (a.binary < b.binary);
    120120       
    121         /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison)*/
    122         a.parts.sign=!a.parts.sign;
    123         b.parts.sign=!b.parts.sign;
    124         return (a.binary>b.binary);
    125                        
     121        /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison) */
     122        a.parts.sign = !a.parts.sign;
     123        b.parts.sign = !b.parts.sign;
     124        return (a.binary > b.binary);
    126125}
    127126
  • uspace/lib/softfloat/generic/div.c

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29 /** @addtogroup softfloat       
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include<sftypes.h>
    36 #include<add.h>
    37 #include<div.h>
    38 #include<comparison.h>
    39 #include<mul.h>
    40 #include<common.h>
    41 
     35#include <sftypes.h>
     36#include <add.h>
     37#include <div.h>
     38#include <comparison.h>
     39#include <mul.h>
     40#include <common.h>
    4241
    4342float32 divFloat32(float32 a, float32 b)
  • uspace/lib/softfloat/generic/mul.c

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29 /** @addtogroup softfloat       
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include<sftypes.h>
    36 #include<mul.h>
    37 #include<comparison.h>
    38 #include<common.h>
     35#include <sftypes.h>
     36#include <mul.h>
     37#include <comparison.h>
     38#include <common.h>
    3939
    4040/** Multiply two 32 bit float numbers
  • uspace/lib/softfloat/generic/other.c

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29 /** @addtogroup softfloat       
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
  • uspace/lib/softfloat/generic/softfloat.c

    r18ba2e4f r544a2e4  
    3535 */
    3636
    37 #include<softfloat.h>
    38 #include<sftypes.h>
    39 
    40 #include<add.h>
    41 #include<sub.h>
    42 #include<mul.h>
    43 #include<div.h>
    44 
    45 #include<conversion.h>
    46 #include<comparison.h>
    47 #include<other.h>
    48 
    49 #include<functions.h>
     37#include <softfloat.h>
     38#include <sftypes.h>
     39
     40#include <add.h>
     41#include <sub.h>
     42#include <mul.h>
     43#include <div.h>
     44
     45#include <conversion.h>
     46#include <comparison.h>
     47#include <other.h>
     48
     49#include <functions.h>
    5050
    5151/* Arithmetic functions */
     
    494494}
    495495
    496 
    497496/** @}
    498497 */
    499 
  • uspace/lib/softfloat/generic/sub.c

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29  /** @addtogroup softfloat     
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include<sftypes.h>
    36 #include<sub.h>
    37 #include<comparison.h>
     35#include <sftypes.h>
     36#include <sub.h>
     37#include <comparison.h>
    3838
    3939/** Subtract two float32 numbers with same signs
     
    260260}
    261261
    262 
    263  /** @}
    264  */
    265 
     262/** @}
     263 */
  • uspace/lib/softfloat/include/add.h

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29  /** @addtogroup softfloat     
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3636#define __ADD_H__
    3737
    38 float32 addFloat32(float32 a, float32 b);
    39 
    40 float64 addFloat64(float64 a, float64 b);
     38extern float32 addFloat32(float32, float32);
     39extern float64 addFloat64(float64, float64);
    4140
    4241#endif
    4342
    44 
    45  /** @}
     43/** @}
    4644 */
    47 
  • uspace/lib/softfloat/include/common.h

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29  /** @addtogroup softfloat     
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3636#define __COMMON_H__
    3737
    38 #include<sftypes.h>
     38#include <sftypes.h>
    3939
    40 float64 finishFloat64(int32_t cexp, uint64_t cfrac, char sign);
     40extern float64 finishFloat64(int32_t, uint64_t, char);
    4141
    42 int countZeroes64(uint64_t i);
    43 int countZeroes32(uint32_t i);
    44 int countZeroes8(uint8_t i);
     42extern int countZeroes64(uint64_t);
     43extern int countZeroes32(uint32_t);
     44extern int countZeroes8(uint8_t);
    4545
    46 void roundFloat32(int32_t *exp, uint32_t *fraction);
    47 void roundFloat64(int32_t *exp, uint64_t *fraction);
     46extern void roundFloat32(int32_t *, uint32_t *);
     47extern void roundFloat64(int32_t *, uint64_t *);
    4848
    4949#endif
    5050
    51  /** @}
     51/** @}
    5252 */
    53 
  • uspace/lib/softfloat/include/comparison.h

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29  /** @addtogroup softfloat     
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3636#define __COMPARISON_H__
    3737
    38 inline int isFloat32NaN(float32 f);
    39 inline int isFloat32SigNaN(float32 f);
     38extern int isFloat32NaN(float32);
     39extern int isFloat32SigNaN(float32);
    4040
    41 inline int isFloat32Infinity(float32 f);
    42 inline int isFloat32Zero(float32 f);
     41extern int isFloat32Infinity(float32);
     42extern int isFloat32Zero(float32);
    4343
    44 inline int isFloat64NaN(float64 d);
    45 inline int isFloat64SigNaN(float64 d);
     44extern int isFloat64NaN(float64);
     45extern int isFloat64SigNaN(float64);
    4646
    47 inline int isFloat64Infinity(float64 d);
    48 inline int isFloat64Zero(float64 d);
     47extern int isFloat64Infinity(float64);
     48extern int isFloat64Zero(float64);
    4949
    50 inline int isFloat32eq(float32 a, float32 b);
    51 inline int isFloat32lt(float32 a, float32 b);
    52 inline int isFloat32gt(float32 a, float32 b);
     50extern int isFloat32eq(float32, float32);
     51extern int isFloat32lt(float32, float32);
     52extern int isFloat32gt(float32, float32);
    5353
    5454#endif
    5555
    56 
    57  /** @}
     56/** @}
    5857 */
    59 
  • uspace/lib/softfloat/include/conversion.h

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29  /** @addtogroup softfloat     
     29 /** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3636#define __CONVERSION_H__
    3737
    38 float64 convertFloat32ToFloat64(float32 a);
     38extern float64 convertFloat32ToFloat64(float32);
     39extern float32 convertFloat64ToFloat32(float64);
    3940
    40 float32 convertFloat64ToFloat32(float64 a);
     41extern uint32_t float32_to_uint32(float32);
     42extern int32_t float32_to_int32(float32);
    4143
    42 uint32_t float32_to_uint32(float32 a);
    43 int32_t float32_to_int32(float32 a);
     44extern uint64_t float32_to_uint64(float32);
     45extern int64_t float32_to_int64(float32);
    4446
    45 uint64_t float32_to_uint64(float32 a);
    46 int64_t float32_to_int64(float32 a);
     47extern uint64_t float64_to_uint64(float64);
     48extern int64_t float64_to_int64(float64);
    4749
    48 uint64_t float64_to_uint64(float64 a);
    49 int64_t float64_to_int64(float64 a);
     50extern uint32_t float64_to_uint32(float64);
     51extern int32_t float64_to_int32(float64);
    5052
    51 uint32_t float64_to_uint32(float64 a);
    52 int32_t float64_to_int32(float64 a);
     53extern float32 uint32_to_float32(uint32_t);
     54extern float32 int32_to_float32(int32_t);
    5355
    54 float32 uint32_to_float32(uint32_t i);
    55 float32 int32_to_float32(int32_t i);
     56extern float32 uint64_to_float32(uint64_t);
     57extern float32 int64_to_float32(int64_t);
    5658
    57 float32 uint64_to_float32(uint64_t i);
    58 float32 int64_to_float32(int64_t i);
     59extern float64 uint32_to_float64(uint32_t);
     60extern float64 int32_to_float64(int32_t);
    5961
    60 float64 uint32_to_float64(uint32_t i);
    61 float64 int32_to_float64(int32_t i);
    62 
    63 float64 uint64_to_float64(uint64_t i);
    64 float64 int64_to_float64(int64_t i);
     62extern float64 uint64_to_float64(uint64_t);
     63extern float64 int64_to_float64(int64_t);
    6564
    6665#endif
    6766
    68 
    69  /** @}
     67/** @}
    7068 */
    71 
  • uspace/lib/softfloat/include/div.h

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29  /** @addtogroup softfloat     
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3636#define __DIV_H__
    3737
    38 float32 divFloat32(float32 a, float32 b);
    39 float64 divFloat64(float64 a, float64 b);
     38extern float32 divFloat32(float32, float32);
     39extern float64 divFloat64(float64, float64);
    4040
    41 uint64_t divFloat64estim(uint64_t a, uint64_t b);
     41extern uint64_t divFloat64estim(uint64_t, uint64_t);
    4242
    4343#endif
    4444
    45 
    46  /** @}
     45/** @}
    4746 */
    48 
  • uspace/lib/softfloat/include/mul.h

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29  /** @addtogroup softfloat     
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3636#define __MUL_H__
    3737
    38 float32 mulFloat32(float32 a, float32 b);
     38extern float32 mulFloat32(float32, float32);
     39extern float64 mulFloat64(float64, float64);
    3940
    40 float64 mulFloat64(float64 a, float64 b);
    41 
    42 void mul64integers(uint64_t a,uint64_t b, uint64_t *lo, uint64_t *hi);
     41extern void mul64integers(uint64_t, uint64_t, uint64_t *, uint64_t *);
    4342
    4443#endif
    4544
    46 
    47  /** @}
     45/** @}
    4846 */
    49 
  • uspace/lib/softfloat/include/other.h

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29  /** @addtogroup softfloat     
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3838#endif
    3939
    40 
    41  /** @}
     40/** @}
    4241 */
    43 
  • uspace/lib/softfloat/include/sftypes.h

    r18ba2e4f r544a2e4  
    5555        #error Unknown endianess
    5656#endif
    57                 } parts __attribute__ ((packed));
     57        } parts __attribute__ ((packed));
    5858} float32;
    5959
     
    7777} float64;
    7878
    79 #define FLOAT32_MAX 0x7f800000
    80 #define FLOAT32_MIN 0xff800000
     79#define FLOAT32_MAX  0x7f800000
     80#define FLOAT32_MIN  0xff800000
    8181#define FLOAT64_MAX
    8282#define FLOAT64_MIN
     
    8686 * comparing with these constants is not sufficient.
    8787 */
    88 #define FLOAT32_NAN 0x7FC00001
    89 #define FLOAT32_SIGNAN 0x7F800001
    90 #define FLOAT32_INF 0x7F800000
    9188
    92 #define FLOAT64_NAN 0x7FF8000000000001ll
    93 #define FLOAT64_SIGNAN 0x7FF0000000000001ll
    94 #define FLOAT64_INF 0x7FF0000000000000ll
     89#define FLOAT32_NAN     0x7FC00001
     90#define FLOAT32_SIGNAN  0x7F800001
     91#define FLOAT32_INF     0x7F800000
    9592
    96 #define FLOAT32_FRACTION_SIZE 23
    97 #define FLOAT64_FRACTION_SIZE 52
     93#define FLOAT64_NAN     0x7FF8000000000001ll
     94#define FLOAT64_SIGNAN  0x7FF0000000000001ll
     95#define FLOAT64_INF     0x7FF0000000000000ll
    9896
    99 #define FLOAT32_HIDDEN_BIT_MASK 0x800000
    100 #define FLOAT64_HIDDEN_BIT_MASK 0x10000000000000ll
     97#define FLOAT32_FRACTION_SIZE  23
     98#define FLOAT64_FRACTION_SIZE  52
    10199
    102 #define FLOAT32_MAX_EXPONENT 0xFF
    103 #define FLOAT64_MAX_EXPONENT 0x7FF
     100#define FLOAT32_HIDDEN_BIT_MASK  0x800000
     101#define FLOAT64_HIDDEN_BIT_MASK  0x10000000000000ll
    104102
    105 #define FLOAT32_BIAS 0x7F
    106 #define FLOAT64_BIAS 0x3FF
    107 #define FLOAT80_BIAS 0x3FFF
     103#define FLOAT32_MAX_EXPONENT  0xFF
     104#define FLOAT64_MAX_EXPONENT  0x7FF
    108105
     106#define FLOAT32_BIAS  0x7F
     107#define FLOAT64_BIAS  0x3FF
     108#define FLOAT80_BIAS  0x3FFF
    109109
    110110#endif
  • uspace/lib/softfloat/include/softfloat.h

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29  /** @addtogroup softfloat     
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3636#define __SOFTFLOAT_H__
    3737
    38 float __addsf3(float a, float b);
    39 double __adddf3(double a, double b);
    40 long double __addtf3(long double a, long double b);
    41 long double __addxf3(long double a, long double b);
    42  
    43 float __subsf3(float a, float b);
    44 double __subdf3(double a, double b);
    45 long double __subtf3(long double a, long double b);
    46 long double __subxf3(long double a, long double b);
    47  
    48 float __mulsf3(float a, float b);
    49 double __muldf3(double a, double b);
    50 long double __multf3(long double a, long double b);
    51 long double __mulxf3(long double a, long double b);
    52  
    53 float __divsf3(float a, float b);
    54 double __divdf3(double a, double b);
    55 long double __divtf3(long double a, long double b);
    56 long double __divxf3(long double a, long double b);
    57  
    58 float __negsf2(float a);
    59 double __negdf2(double a);
    60 long double __negtf2(long double a);
    61 long double __negxf2(long double a);
    62  
    63 double __extendsfdf2(float a);
    64 long double __extendsftf2(float a);
    65 long double __extendsfxf2(float a);
    66 long double __extenddftf2(double a);
    67 long double __extenddfxf2(double a);
    68  
    69 double __truncxfdf2(long double a);
    70 double __trunctfdf2(long double a);
    71 float __truncxfsf2(long double a);
    72 float __trunctfsf2(long double a);
    73 float __truncdfsf2(double a);
    74  
    75 int __fixsfsi(float a);
    76 int __fixdfsi(double a);
    77 int __fixtfsi(long double a);
    78 int __fixxfsi(long double a);
    79  
    80 long __fixsfdi(float a);
    81 long __fixdfdi(double a);
    82 long __fixtfdi(long double a);
    83 long __fixxfdi(long double a);
    84  
    85 long long __fixsfti(float a);
    86 long long __fixdfti(double a);
    87 long long __fixtfti(long double a);
    88 long long __fixxfti(long double a);
    89  
    90 unsigned int __fixunssfsi(float a);
    91 unsigned int __fixunsdfsi(double a);
    92 unsigned int __fixunstfsi(long double a);
    93 unsigned int __fixunsxfsi(long double a);
    94  
    95 unsigned long __fixunssfdi(float a);
    96 unsigned long __fixunsdfdi(double a);
    97 unsigned long __fixunstfdi(long double a);
    98 unsigned long __fixunsxfdi(long double a);
    99  
    100 unsigned long long __fixunssfti(float a);
    101 unsigned long long __fixunsdfti(double a);
    102 unsigned long long __fixunstfti(long double a);
    103 unsigned long long __fixunsxfti(long double a);
    104  
    105 float __floatsisf(int i);
    106 double __floatsidf(int i);
    107 long double __floatsitf(int i);
    108 long double __floatsixf(int i);
    109  
    110 float __floatdisf(long i);
    111 double __floatdidf(long i);
    112 long double __floatditf(long i);
    113 long double __floatdixf(long i);
    114  
    115 float __floattisf(long long i);
    116 double __floattidf(long long i);
    117 long double __floattitf(long long i);
    118 long double __floattixf(long long i);
    119  
    120 float __floatunsisf(unsigned int i);
    121 double __floatunsidf(unsigned int i);
    122 long double __floatunsitf(unsigned int i);
    123 long double __floatunsixf(unsigned int i);
    124  
    125 float __floatundisf(unsigned long i);
    126 double __floatundidf(unsigned long i);
    127 long double __floatunditf(unsigned long i);
    128 long double __floatundixf(unsigned long i);
    129  
    130 float __floatuntisf(unsigned long long i);
    131 double __floatuntidf(unsigned long long i);
    132 long double __floatuntitf(unsigned long long i);
    133 long double __floatuntixf(unsigned long long i);
    134  
    135 int __cmpsf2(float a, float b);
    136 int __cmpdf2(double a, double b);
    137 int __cmptf2(long double a, long double b);
    138  
    139 int __unordsf2(float a, float b);
    140 int __unorddf2(double a, double b);
    141 int __unordtf2(long double a, long double b);
    142  
    143 int __eqsf2(float a, float b);
    144 int __eqdf2(double a, double b);
    145 int __eqtf2(long double a, long double b);
    146  
    147 int __nesf2(float a, float b);
    148 int __nedf2(double a, double b);
    149 int __netf2(long double a, long double b);
    150  
    151 int __gesf2(float a, float b);
    152 int __gedf2(double a, double b);
    153 int __getf2(long double a, long double b);
    154  
    155 int __ltsf2(float a, float b);
    156 int __ltdf2(double a, double b);
    157 int __lttf2(long double a, long double b);
    158 int __lesf2(float a, float b);
    159 int __ledf2(double a, double b);
    160 int __letf2(long double a, long double b);
    161  
    162 int __gtsf2(float a, float b);
    163 int __gtdf2(double a, double b);
    164 int __gttf2(long double a, long double b);
    165  
    166 /* Not implemented yet*/
    167 float __powisf2(float a, int b);
     38extern float __addsf3(float, float);
     39extern double __adddf3(double, double);
     40extern long double __addtf3(long double, long double);
     41extern long double __addxf3(long double, long double);
     42
     43extern float __subsf3(float, float);
     44extern double __subdf3(double, double);
     45extern long double __subtf3(long double, long double);
     46extern long double __subxf3(long double, long double);
     47
     48extern float __mulsf3(float, float);
     49extern double __muldf3(double, double);
     50extern long double __multf3(long double, long double);
     51extern long double __mulxf3(long double, long double);
     52
     53extern float __divsf3(float, float);
     54extern double __divdf3(double, double);
     55extern long double __divtf3(long double, long double);
     56extern long double __divxf3(long double, long double);
     57
     58extern float __negsf2(float);
     59extern double __negdf2(double);
     60extern long double __negtf2(long double);
     61extern long double __negxf2(long double);
     62
     63extern double __extendsfdf2(float);
     64extern long double __extendsftf2(float);
     65extern long double __extendsfxf2(float);
     66extern long double __extenddftf2(double);
     67extern long double __extenddfxf2(double);
     68
     69extern double __truncxfdf2(long double);
     70extern double __trunctfdf2(long double);
     71extern float __truncxfsf2(long double);
     72extern float __trunctfsf2(long double);
     73extern float __truncdfsf2(double);
     74
     75extern int __fixsfsi(float);
     76extern int __fixdfsi(double);
     77extern int __fixtfsi(long double);
     78extern int __fixxfsi(long double);
     79
     80extern long __fixsfdi(float);
     81extern long __fixdfdi(double);
     82extern long __fixtfdi(long double);
     83extern long __fixxfdi(long double);
     84
     85extern long long __fixsfti(float);
     86extern long long __fixdfti(double);
     87extern long long __fixtfti(long double);
     88extern long long __fixxfti(long double);
     89
     90extern unsigned int __fixunssfsi(float);
     91extern unsigned int __fixunsdfsi(double);
     92extern unsigned int __fixunstfsi(long double);
     93extern unsigned int __fixunsxfsi(long double);
     94
     95extern unsigned long __fixunssfdi(float);
     96extern unsigned long __fixunsdfdi(double);
     97extern unsigned long __fixunstfdi(long double);
     98extern unsigned long __fixunsxfdi(long double);
     99
     100extern unsigned long long __fixunssfti(float);
     101extern unsigned long long __fixunsdfti(double);
     102extern unsigned long long __fixunstfti(long double);
     103extern unsigned long long __fixunsxfti(long double);
     104
     105extern float __floatsisf(int);
     106extern double __floatsidf(int);
     107extern long double __floatsitf(int);
     108extern long double __floatsixf(int);
     109
     110extern float __floatdisf(long);
     111extern double __floatdidf(long);
     112extern long double __floatditf(long);
     113extern long double __floatdixf(long);
     114
     115extern float __floattisf(long long);
     116extern double __floattidf(long long);
     117extern long double __floattitf(long long);
     118extern long double __floattixf(long long);
     119
     120extern float __floatunsisf(unsigned int);
     121extern double __floatunsidf(unsigned int);
     122extern long double __floatunsitf(unsigned int);
     123extern long double __floatunsixf(unsigned int);
     124
     125extern float __floatundisf(unsigned long);
     126extern double __floatundidf(unsigned long);
     127extern long double __floatunditf(unsigned long);
     128extern long double __floatundixf(unsigned long);
     129
     130extern float __floatuntisf(unsigned long long);
     131extern double __floatuntidf(unsigned long long);
     132extern long double __floatuntitf(unsigned long long);
     133extern long double __floatuntixf(unsigned long long);
     134
     135extern int __cmpsf2(float, float);
     136extern int __cmpdf2(double, double);
     137extern int __cmptf2(long double, long double);
     138
     139extern int __unordsf2(float, float);
     140extern int __unorddf2(double, double);
     141extern int __unordtf2(long double, long double);
     142
     143extern int __eqsf2(float, float);
     144extern int __eqdf2(double, double);
     145extern int __eqtf2(long double, long double);
     146
     147extern int __nesf2(float, float);
     148extern int __nedf2(double, double);
     149extern int __netf2(long double, long double);
     150
     151extern int __gesf2(float, float);
     152extern int __gedf2(double, double);
     153extern int __getf2(long double, long double);
     154
     155extern int __ltsf2(float, float);
     156extern int __ltdf2(double, double);
     157extern int __lttf2(long double, long double);
     158extern int __lesf2(float, float);
     159extern int __ledf2(double, double);
     160extern int __letf2(long double, long double);
     161
     162extern int __gtsf2(float, float);
     163extern int __gtdf2(double, double);
     164extern int __gttf2(long double, long double);
     165
     166/* Not implemented yet */
     167extern float __powisf2(float, int);
    168168
    169169#endif
    170170
    171 
    172  /** @}
     171/** @}
    173172 */
    174 
  • uspace/lib/softfloat/include/sub.h

    r18ba2e4f r544a2e4  
    2727 */
    2828
    29  /** @addtogroup softfloat     
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3636#define __SUB_H__
    3737
    38 float32 subFloat32(float32 a, float32 b);
    39 
    40 float64 subFloat64(float64 a, float64 b);
     38extern float32 subFloat32(float32, float32);
     39extern float64 subFloat64(float64, float64);
    4140
    4241#endif
    4342
    44 
    45  /** @}
     43/** @}
    4644 */
    47 
  • uspace/lib/softint/Makefile

    r18ba2e4f r544a2e4  
    3131EXTRA_CFLAGS = -Iinclude
    3232LIBRARY = libsoftint
     33SLIBRARY = libsoftint.so.0.0
     34LSONAME = libsofti.so0
    3335
    3436SOURCES = \
    35         generic/division.c\
     37        generic/division.c \
    3638        generic/multiplication.c
    3739
Note: See TracChangeset for help on using the changeset viewer.