Changeset 694ca93f in mainline for uspace/lib/c


Ignore:
Timestamp:
2011-05-01T19:34:26Z (14 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0e26444
Parents:
1ff896e (diff), 042fbe0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

Location:
uspace/lib/c
Files:
15 added
55 edited
15 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/Makefile

    r1ff896e r694ca93f  
    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 = \
     
    7687        generic/io/io.c \
    7788        generic/io/printf.c \
     89        generic/io/log.c \
    7890        generic/io/klog.c \
    7991        generic/io/snprintf.c \
     
    112124        generic/arg_parse.c \
    113125        generic/sort.c \
    114         generic/stats.c
     126        generic/stats.c \
     127        generic/assert.c
     128
     129ifeq ($(CONFIG_RTLD), y)
     130        GENERIC_SOURCES += \
     131                generic/dlfcn.c \
     132                generic/rtld/rtld.c \
     133                generic/rtld/elf_load.c \
     134                generic/rtld/dynamic.c \
     135                generic/rtld/module.c \
     136                generic/rtld/symbol.c
     137endif
    115138
    116139SOURCES = \
     
    131154        ln -sfn ../$< $@
    132155
    133 $(LINKER_SCRIPT): $(LINKER_SCRIPT).in
     156$(LIBC_PREFIX)/arch/$(UARCH)/_link.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
    134157        $(GCC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -E -x c $< | grep -v "^\#" > $@
     158
     159$(LIBC_PREFIX)/arch/$(UARCH)/_link-loader.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
     160        $(GCC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -DLOADER -E -x c $< | grep -v "^\#" > $@
     161
     162$(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
     163        $(GCC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -DSHLIB -E -x c $< | grep -v "^\#" > $@
     164
     165$(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld: $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld.in
     166        $(GCC) $(DEFS) $(CFLAGS) -DLIBC_PATH=$(CURDIR) -DDLEXE -E -x c $< | grep -v "^\#" > $@
    135167
    136168$(COMMON_HEADER_ARCH): $(COMMON_HEADER)
  • uspace/lib/c/arch/abs32le/Makefile.inc

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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 : {
    13                 *(.text);
    14                 *(.rodata*);
     25                *(.text .text.*);
     26                *(.rodata .rodata.*);
    1527        } :text
    1628       
  • uspace/lib/c/arch/abs32le/src/entryjmp.c

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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);
     
    1628       
    1729        .text : {
    18                 *(.text);
    19                 *(.rodata*);
     30                *(.text .text.*);
     31                *(.rodata .rodata.*);
    2032        } :text
    2133       
  • uspace/lib/c/arch/amd64/src/entryjmp.s

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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);
     
    1527       
    1628        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     29                *(.text .text.*);
     30                *(.rodata .rodata.*);
    1931        } :text
    2032       
  • uspace/lib/c/arch/arm32/src/entryjmp.s

    r1ff896e r694ca93f  
    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.inc

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
     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);
     
    1634       
    1735        .text : {
    18                 *(.text);
    19                 *(.rodata*);
     36                *(.text .text.*);
     37                *(.rodata .rodata.*);
     38        } :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.*);
    2050        } :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

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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/include/rtld/elf_dyn.h

    r1ff896e r694ca93f  
    11/*
    2  * Copyright (c) 2005 Sergey Bondari
     2 * Copyright (c) 2008 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup arm32
     29/** @addtogroup generic
    3030 * @{
    3131 */
    3232/** @file
    33  *  @brief Memory manipulating functions declarations.
    3433 */
    3534
    36 #ifndef KERN_arm32_MEMSTR_H_
    37 #define KERN_arm32_MEMSTR_H_
     35#ifndef LIBC_ia32_RTLD_ELF_DYN_H_
     36#define LIBC_ia32_RTLD_ELF_DYN_H_
    3837
    39 #define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
     38/*
     39 * ia32 dynamic relocation types
     40 */
    4041
    41 extern void memsetw(void *, size_t, uint16_t);
    42 extern void memsetb(void *, size_t, uint8_t);
     42#define R_386_32        1
     43#define R_386_PC32      2
     44#define R_386_COPY      5
     45#define R_386_GLOB_DAT  6
     46#define R_386_JUMP_SLOT 7
     47#define R_386_RELATIVE  8
     48
     49#define R_386_TLS_DTPMOD32 35
    4350
    4451#endif
  • uspace/lib/c/arch/ia32/src/entryjmp.s

    r1ff896e r694ca93f  
    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/rtld/dynamic.c

    r1ff896e r694ca93f  
    11/*
    2  * Copyright (c) 2005 Sergey Bondari
     2 * Copyright (c) 2008 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup ia64
     29/** @addtogroup libcia32
     30 * @brief
    3031 * @{
    3132 */
    32 /** @file
     33/**
     34 * @file
    3335 */
    3436
    35 #ifndef KERN_ia64_MEMSTR_H_
    36 #define KERN_ia64_MEMSTR_H_
     37#include <stdio.h>
     38#include <stdlib.h>
    3739
    38 #define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
     40#include <rtld/elf_dyn.h>
     41#include <rtld/dynamic.h>
    3942
    40 extern void memsetw(void *, size_t, uint16_t);
    41 extern void memsetb(void *, size_t, uint8_t);
    42 
    43 #endif
     43void dyn_parse_arch(elf_dyn_t *dp, size_t bias, dyn_info_t *info)
     44{
     45        (void) dp;
     46        (void) bias;
     47        (void) info;
     48}
    4449
    4550/** @}
  • uspace/lib/c/arch/ia32/src/stacktrace.c

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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);
     
    1533       
    1634        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     35                *(.text .text.*);
     36                *(.rodata .rodata.*);
    1937        } :text
    2038       
     
    2240       
    2341        .got : {
    24                 _gp = .;
    25                 *(.got*);
     42                /* Tell the linker where we expect GP to point. */
     43                __gp = .;
     44                *(.got .got.*);
    2645        } :data
    2746       
  • uspace/lib/c/arch/ia64/src/entry.s

    r1ff896e r694ca93f  
    3939__entry:
    4040        alloc loc0 = ar.pfs, 0, 1, 2, 0
    41         movl gp = _gp
     41        movl gp = __gp
    4242       
    4343        # Pass PCB pointer as the first argument to __main
  • uspace/lib/c/arch/ia64/src/entryjmp.s

    r1ff896e r694ca93f  
    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/ia64/src/thread_entry.s

    r1ff896e r694ca93f  
    3737        alloc loc0 = ar.pfs, 0, 1, 1, 0
    3838
    39         movl gp = _gp
     39        movl gp = __gp
    4040       
    4141        #
  • uspace/lib/c/arch/mips32/Makefile.inc

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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);
     
    1527       
    1628        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     29                *(.text .text.*);
     30                *(.rodata .rodata.*);
    1931        } :text
    2032       
  • uspace/lib/c/arch/mips32/include/atomic.h

    r1ff896e r694ca93f  
    7070                "       sc %0, %1\n"
    7171                "       beq %0, %4, 1b\n"       /* if the atomic operation failed, try again */
    72                 /*      nop     */              /* nop is inserted automatically by compiler */
    7372                "       nop\n"
    7473                : "=&r" (tmp),
  • uspace/lib/c/arch/mips32/src/entryjmp.s

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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);
     
    1527       
    1628        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     29                *(.text .text.*);
     30                *(.rodata .rodata.*);
    1931        } :text
    2032       
  • uspace/lib/c/arch/ppc32/src/entryjmp.s

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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);
     
    1527       
    1628        .text : {
    17                 *(.text);
    18                 *(.rodata*);
     29                *(.text .text.*);
     30                *(.rodata .rodata.*);
    1931        } :text
    2032       
  • uspace/lib/c/arch/sparc64/src/entryjmp.s

    r1ff896e r694ca93f  
    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/adt/measured_strings.c

    r1ff896e r694ca93f  
    7474        new->length = length;
    7575        new->value = ((uint8_t *) new) + sizeof(measured_string_t);
    76         // append terminating zero explicitly - to be safe
     76        /* Append terminating zero explicitly - to be safe */
    7777        memcpy(new->value, string, new->length);
    7878        new->value[new->length] = '\0';
  • uspace/lib/c/generic/assert.c

    r1ff896e r694ca93f  
    11/*
    2  * Copyright (c) 2010 Martin Decky
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup abs32le
     29/** @addtogroup libc
    3030 * @{
    3131 */
    32 /** @file
    33  */
    3432
    35 #ifndef KERN_abs32le_MEMSTR_H_
    36 #define KERN_abs32le_MEMSTR_H_
     33#include <assert.h>
     34#include <stdio.h>
     35#include <stdlib.h>
     36#include <stacktrace.h>
    3737
    38 #define memcpy(dst, src, cnt)   _memcpy((dst), (src), (cnt))
    39 #define memsetb(dst, cnt, val)  _memsetb((dst), (cnt), (val))
    40 #define memsetw(dst, cnt, val)  _memsetw((dst), (cnt), (val))
    41 
    42 #endif
     38void assert_abort(const char *cond, const char *file, unsigned int line)
     39{
     40        printf("Assertion failed (%s) in file \"%s\", line %u.\n",
     41            cond, file, line);
     42        stacktrace_print();
     43        abort();
     44}
    4345
    4446/** @}
  • uspace/lib/c/generic/async.c

    r1ff896e r694ca93f  
    102102#include <arch/barrier.h>
    103103#include <bool.h>
     104#include <stdlib.h>
     105#include <malloc.h>
    104106#include "private/async.h"
    105107
     
    15721574 * @param dst     Address of the beginning of the destination buffer.
    15731575 * @param size    Size of the destination buffer.
     1576 * @param flags   Flags to control the data transfer.
    15741577 *
    15751578 * @return Zero on success or a negative error code from errno.h.
    15761579 *
    15771580 */
    1578 int async_data_read_start(int phoneid, void *dst, size_t size)
    1579 {
    1580         return async_req_2_0(phoneid, IPC_M_DATA_READ, (sysarg_t) dst,
    1581             (sysarg_t) size);
     1581int
     1582async_data_read_start_generic(int phoneid, void *dst, size_t size, int flags)
     1583{
     1584        return async_req_3_0(phoneid, IPC_M_DATA_READ, (sysarg_t) dst,
     1585            (sysarg_t) size, (sysarg_t) flags);
    15821586}
    15831587
     
    16691673 * @param src     Address of the beginning of the source buffer.
    16701674 * @param size    Size of the source buffer.
     1675 * @param flags   Flags to control the data transfer.
    16711676 *
    16721677 * @return Zero on success or a negative error code from errno.h.
    16731678 *
    16741679 */
    1675 int async_data_write_start(int phoneid, const void *src, size_t size)
    1676 {
    1677         return async_req_2_0(phoneid, IPC_M_DATA_WRITE, (sysarg_t) src,
    1678             (sysarg_t) size);
     1680int
     1681async_data_write_start_generic(int phoneid, const void *src, size_t size,
     1682    int flags)
     1683{
     1684        return async_req_3_0(phoneid, IPC_M_DATA_WRITE, (sysarg_t) src,
     1685            (sysarg_t) size, (sysarg_t) flags);
    16791686}
    16801687
  • uspace/lib/c/generic/async_sess.c

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

    r1ff896e r694ca93f  
    147147                ret = devman_send_match_id(phone, match_id);
    148148                if (ret != EOK) {
    149                         printf("Driver failed to send match id, error %d\n",
    150                             ret);
    151149                        return ret;
    152150                }
     
    195193        }
    196194       
    197         devman_send_match_ids(phone, match_ids);
    198        
    199         async_wait_for(req, &retval);
    200        
    201         async_serialize_end();
    202        
     195        int match_ids_rc = devman_send_match_ids(phone, match_ids);
     196       
     197        async_wait_for(req, &retval);
     198       
     199        async_serialize_end();
     200       
     201        /* Prefer the answer to DEVMAN_ADD_FUNCTION in case of errors. */
     202        if ((match_ids_rc != EOK) && (retval == EOK)) {
     203                retval = match_ids_rc;
     204        }
     205
    203206        if (retval == EOK)
    204207                fun_handle = (int) IPC_GET_ARG1(answer);
     
    326329}
    327330
     331int devman_device_get_handle_by_class(const char *classname,
     332    const char *devname, devman_handle_t *handle, unsigned int flags)
     333{
     334        int phone = devman_get_phone(DEVMAN_CLIENT, flags);
     335
     336        if (phone < 0)
     337                return phone;
     338
     339        async_serialize_start();
     340
     341        ipc_call_t answer;
     342        aid_t req = async_send_1(phone, DEVMAN_DEVICE_GET_HANDLE_BY_CLASS,
     343            flags, &answer);
     344
     345        sysarg_t retval = async_data_write_start(phone, classname,
     346            str_size(classname));
     347        if (retval != EOK) {
     348                async_wait_for(req, NULL);
     349                async_serialize_end();
     350                return retval;
     351        }
     352        retval = async_data_write_start(phone, devname,
     353            str_size(devname));
     354        if (retval != EOK) {
     355                async_wait_for(req, NULL);
     356                async_serialize_end();
     357                return retval;
     358        }
     359
     360        async_wait_for(req, &retval);
     361
     362        async_serialize_end();
     363
     364        if (retval != EOK) {
     365                if (handle != NULL)
     366                        *handle = (devman_handle_t) -1;
     367                return retval;
     368        }
     369
     370        if (handle != NULL)
     371                *handle = (devman_handle_t) IPC_GET_ARG1(answer);
     372
     373        return retval;
     374}
     375
    328376
    329377/** @}
  • uspace/lib/c/generic/errno.c

    r1ff896e r694ca93f  
    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/fibril_synch.c

    r1ff896e r694ca93f  
    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

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

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    4444#include <mem.h>
    4545#include <futex.h>
     46#include <stdlib.h>
    4647#include <adt/gcdlcm.h>
    4748#include "private/malloc.h"
  • uspace/lib/c/generic/net/packet.c

    r1ff896e r694ca93f  
    190190                }
    191191        }
    192         gpm_destroy(&pm_globals.packet_map);
     192        gpm_destroy(&pm_globals.packet_map, free);
    193193        /* leave locked */
    194194}
  • uspace/lib/c/generic/net/socket_client.c

    r1ff896e r694ca93f  
    749749        dyn_fifo_destroy(&socket->received);
    750750        dyn_fifo_destroy(&socket->accepted);
    751         sockets_exclude(socket_get_sockets(), socket->socket_id);
     751        sockets_exclude(socket_get_sockets(), socket->socket_id, free);
    752752}
    753753
  • uspace/lib/c/generic/stacktrace.c

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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/vfs/vfs.c

    r1ff896e r694ca93f  
    378378       
    379379        req = async_send_1(vfs_phone, VFS_IN_READ, fildes, &answer);
    380         rc = async_data_read_start(vfs_phone, (void *)buf, nbyte);
     380        rc = async_data_read_start_generic(vfs_phone, (void *) buf, nbyte,
     381            IPC_XF_RESTRICT);
    381382        if (rc != EOK) {
    382383                vfs_exchange_end(vfs_phone);
     
    407408       
    408409        req = async_send_1(vfs_phone, VFS_IN_WRITE, fildes, &answer);
    409         rc = async_data_write_start(vfs_phone, (void *)buf, nbyte);
     410        rc = async_data_write_start_generic(vfs_phone, (void *) buf, nbyte,
     411            IPC_XF_RESTRICT);
    410412        if (rc != EOK) {
    411413                vfs_exchange_end(vfs_phone);
     
    756758{
    757759        struct stat stat;
    758         int rc;
    759 
    760         rc = fstat(fildes, &stat);
    761 
     760       
     761        int rc = fstat(fildes, &stat);
     762        if (rc != 0)
     763                return rc;
     764       
    762765        if (!stat.device)
    763766                return -1;
  • uspace/lib/c/include/adt/generic_char_map.h

    r1ff896e r694ca93f  
    4747#define GENERIC_CHAR_MAP_MAGIC_VALUE    0x12345622
    4848
     49/** Generic destructor function pointer. */
     50#define DTOR_T(identifier) \
     51        void (*identifier)(const void *)
     52
    4953/** Character string to generic type map declaration.
    5054 *  @param[in] name     Name of the map.
     
    6468        int name##_add(name##_t *, const uint8_t *, const size_t, type *); \
    6569        int name##_count(name##_t *); \
    66         void name##_destroy(name##_t *); \
    67         void name##_exclude(name##_t *, const uint8_t *, const size_t); \
     70        void name##_destroy(name##_t *, DTOR_T()); \
     71        void name##_exclude(name##_t *, const uint8_t *, const size_t, DTOR_T()); \
    6872        type *name##_find(name##_t *, const uint8_t *, const size_t); \
    6973        int name##_initialize(name##_t *); \
     
    8488             type *value) \
    8589        { \
    86                 int rc; \
    8790                int index; \
    8891                if (!name##_is_valid(map)) \
     
    9194                if (index < 0) \
    9295                        return index; \
    93                 rc = char_map_add(&map->names, name, length, index); \
    94                 if (rc != EOK) { \
    95                         name##_items_exclude_index(&map->values, index); \
    96                         return rc; \
    97                 } \
    98                 return EOK; \
     96                return char_map_add(&map->names, name, length, index); \
    9997        } \
    10098        \
     
    105103        } \
    106104        \
    107         void name##_destroy(name##_t *map) \
     105        void name##_destroy(name##_t *map, DTOR_T(dtor)) \
    108106        { \
    109107                if (name##_is_valid(map)) { \
    110108                        char_map_destroy(&map->names); \
    111                         name##_items_destroy(&map->values); \
     109                        name##_items_destroy(&map->values, dtor); \
    112110                } \
    113111        } \
    114112        \
    115113        void name##_exclude(name##_t *map, const uint8_t *name, \
    116             const size_t length) \
     114            const size_t length, DTOR_T(dtor)) \
    117115        { \
    118116                if (name##_is_valid(map)) { \
     
    121119                        if (index != CHAR_MAP_NULL) \
    122120                                name##_items_exclude_index(&map->values, \
    123                                      index); \
     121                                     index, dtor); \
    124122                } \
    125123        } \
  • uspace/lib/c/include/adt/generic_field.h

    r1ff896e r694ca93f  
    4646#define GENERIC_FIELD_MAGIC_VALUE               0x55667788
    4747
     48/** Generic destructor function pointer. */
     49#define DTOR_T(identifier) \
     50        void (*identifier)(const void *)
     51
    4852/** Generic type field declaration.
    4953 *
     
    6367        int name##_add(name##_t *, type *); \
    6468        int name##_count(name##_t *); \
    65         void name##_destroy(name##_t *); \
    66         void name##_exclude_index(name##_t *, int); \
     69        void name##_destroy(name##_t *, DTOR_T()); \
     70        void name##_exclude_index(name##_t *, int, DTOR_T()); \
    6771        type **name##_get_field(name##_t *); \
    6872        type *name##_get_index(name##_t *, int); \
     
    103107        } \
    104108        \
    105         void name##_destroy(name##_t *field) \
     109        void name##_destroy(name##_t *field, DTOR_T(dtor)) \
    106110        { \
    107111                if (name##_is_valid(field)) { \
    108112                        int index; \
    109113                        field->magic = 0; \
    110                         for (index = 0; index < field->next; index++) { \
    111                                 if (field->items[index]) \
    112                                         free(field->items[index]); \
     114                        if (dtor) { \
     115                                for (index = 0; index < field->next; index++) { \
     116                                        if (field->items[index]) \
     117                                                dtor(field->items[index]); \
     118                                } \
    113119                        } \
    114120                        free(field->items); \
     
    116122        } \
    117123         \
    118         void name##_exclude_index(name##_t *field, int index) \
     124        void name##_exclude_index(name##_t *field, int index, DTOR_T(dtor)) \
    119125        { \
    120126                if (name##_is_valid(field) && (index >= 0) && \
    121127                    (index < field->next) && (field->items[index])) { \
    122                         free(field->items[index]); \
     128                        if (dtor) \
     129                                dtor(field->items[index]); \
    123130                        field->items[index] = NULL; \
    124131                } \
  • uspace/lib/c/include/adt/int_map.h

    r1ff896e r694ca93f  
    4949#define INT_MAP_ITEM_MAGIC_VALUE        0x55667788
    5050
     51/** Generic destructor function pointer. */
     52#define DTOR_T(identifier) \
     53        void (*identifier)(const void *)
     54
    5155/** Integer to generic type map declaration.
    5256 *
     
    7276        \
    7377        int name##_add(name##_t *, int, type *); \
    74         void name##_clear(name##_t *); \
     78        void name##_clear(name##_t *, DTOR_T()); \
    7579        int name##_count(name##_t *); \
    76         void name##_destroy(name##_t *); \
    77         void name##_exclude(name##_t *, int); \
    78         void name##_exclude_index(name##_t *, int); \
     80        void name##_destroy(name##_t *, DTOR_T()); \
     81        void name##_exclude(name##_t *, int, DTOR_T()); \
     82        void name##_exclude_index(name##_t *, int, DTOR_T()); \
    7983        type *name##_find(name##_t *, int); \
    8084        int name##_update(name##_t *, int, int); \
     
    8286        int name##_initialize(name##_t *); \
    8387        int name##_is_valid(name##_t *); \
    84         void name##_item_destroy(name##_item_t *); \
     88        void name##_item_destroy(name##_item_t *, DTOR_T()); \
    8589        int name##_item_is_valid(name##_item_t *);
    8690
     
    115119        } \
    116120        \
    117         void name##_clear(name##_t *map) \
     121        void name##_clear(name##_t *map, DTOR_T(dtor)) \
    118122        { \
    119123                if (name##_is_valid(map)) { \
     
    122126                                if (name##_item_is_valid(&map->items[index])) { \
    123127                                        name##_item_destroy( \
    124                                             &map->items[index]); \
     128                                            &map->items[index], dtor); \
    125129                                } \
    126130                        } \
     
    135139        } \
    136140        \
    137         void name##_destroy(name##_t *map) \
     141        void name##_destroy(name##_t *map, DTOR_T(dtor)) \
    138142        { \
    139143                if (name##_is_valid(map)) { \
     
    143147                                if (name##_item_is_valid(&map->items[index])) { \
    144148                                        name##_item_destroy( \
    145                                             &map->items[index]); \
     149                                            &map->items[index], dtor); \
    146150                                } \
    147151                        } \
     
    150154        } \
    151155        \
    152         void name##_exclude(name##_t *map, int key) \
     156        void name##_exclude(name##_t *map, int key, DTOR_T(dtor)) \
    153157        { \
    154158                if (name##_is_valid(map)) { \
     
    158162                                    (map->items[index].key == key)) { \
    159163                                        name##_item_destroy( \
    160                                             &map->items[index]); \
    161                                 } \
    162                         } \
    163                 } \
    164         } \
    165         \
    166         void name##_exclude_index(name##_t *map, int index) \
     164                                            &map->items[index], dtor); \
     165                                } \
     166                        } \
     167                } \
     168        } \
     169        \
     170        void name##_exclude_index(name##_t *map, int index, DTOR_T(dtor)) \
    167171        { \
    168172                if (name##_is_valid(map) && (index >= 0) && \
    169173                    (index < map->next) && \
    170174                    name##_item_is_valid(&map->items[index])) { \
    171                         name##_item_destroy(&map->items[index]); \
     175                        name##_item_destroy(&map->items[index], dtor); \
    172176                } \
    173177        } \
     
    236240        } \
    237241        \
    238         void name##_item_destroy(name##_item_t *item) \
     242        void name##_item_destroy(name##_item_t *item, DTOR_T(dtor)) \
    239243        { \
    240244                if (name##_item_is_valid(item)) { \
    241245                        item->magic = 0; \
    242246                        if (item->value) { \
    243                                 free(item->value); \
     247                                if (dtor) \
     248                                        dtor(item->value); \
    244249                                item->value = NULL; \
    245250                        } \
  • uspace/lib/c/include/assert.h

    r1ff896e r694ca93f  
    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/async.h

    r1ff896e r694ca93f  
    340340            (arg4), (answer))
    341341
    342 extern int async_data_read_start(int, void *, size_t);
     342#define async_data_read_start(p, buf, len) \
     343        async_data_read_start_generic((p), (buf), (len), IPC_XF_NONE)
     344
     345extern int async_data_read_start_generic(int, void *, size_t, int);
    343346extern bool async_data_read_receive(ipc_callid_t *, size_t *);
    344347extern int async_data_read_finalize(ipc_callid_t, const void *, size_t);
     
    379382            (arg4), (answer))
    380383
    381 extern int async_data_write_start(int, const void *, size_t);
     384#define async_data_write_start(p, buf, len) \
     385        async_data_write_start_generic((p), (buf), (len), IPC_XF_NONE)
     386
     387extern int async_data_write_start_generic(int, const void *, size_t, int);
    382388extern bool async_data_write_receive(ipc_callid_t *, size_t *);
    383389extern int async_data_write_finalize(ipc_callid_t, void *, size_t);
  • uspace/lib/c/include/devman.h

    r1ff896e r694ca93f  
    5353extern int devman_device_get_handle(const char *, devman_handle_t *,
    5454    unsigned int);
     55extern int devman_device_get_handle_by_class(const char *, const char *,
     56    devman_handle_t *, unsigned int);
    5557
    5658extern int devman_add_device_to_class(devman_handle_t, const char *);
  • uspace/lib/c/include/entry_point.h

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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/fibril_synch.h

    r1ff896e r694ca93f  
    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/ipc/devman.h

    r1ff896e r694ca93f  
    148148
    149149typedef enum {
    150         DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD
     150        DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD,
     151        DEVMAN_DEVICE_GET_HANDLE_BY_CLASS
    151152} client_to_devman_t;
    152153
  • uspace/lib/c/include/ipc/services.h

    r1ff896e r694ca93f  
    4747        SERVICE_DEVMAP,
    4848        SERVICE_DEVMAN,
    49         SERVICE_FHC,
    50         SERVICE_OBIO,
    51         SERVICE_APIC,
    52         SERVICE_I8259,
     49        SERVICE_IRC,
    5350        SERVICE_CLIPBOARD,
    5451        SERVICE_NETWORKING,
  • uspace/lib/c/include/loader/pcb.h

    r1ff896e r694ca93f  
    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

    r1ff896e r694ca93f  
    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/rtld/module.h

    r1ff896e r694ca93f  
    11/*
    2  * Copyright (c) 2007 Jan Hudecek
    3  * Copyright (c) 2008 Martin Decky
     2 * Copyright (c) 2008 Jiri Svoboda
    43 * All rights reserved.
    54 *
     
    2827 */
    2928
    30 /** @addtogroup genericproc
     29/** @addtogroup libc
    3130 * @{
    3231 */
    33 /** @file tasklet.h
    34  * @brief Tasklets declarations
     32/** @file
    3533 */
    3634
    37 #ifndef KERN_TASKLET_H_
    38 #define KERN_TASKLET_H_
     35#ifndef LIBC_RTLD_MODULE_H_
     36#define LIBC_RTLD_MODULE_H_
    3937
     38#include <sys/types.h>
     39#include <rtld/dynamic.h>
    4040#include <adt/list.h>
    4141
    42 /** Tasklet callback type */
    43 typedef void (* tasklet_callback_t)(void *arg);
     42typedef struct module {
     43        dyn_info_t dyn;
     44        size_t bias;
    4445
    45 /** Tasklet state */
    46 typedef enum {
    47         NotActive,
    48         Scheduled,
    49         InProgress,
    50         Disabled
    51 } tasklet_state_t;
     46        /** Array of pointers to directly dependent modules */
     47        struct module **deps;
     48        /** Number of fields in deps */
     49        size_t n_deps;
    5250
    53 /** Structure describing a tasklet */
    54 typedef struct tasklet_descriptor {
    55         link_t link;
    56        
    57         /** Callback to call */
    58         tasklet_callback_t callback;
    59        
    60         /** Argument passed to the callback */
    61         void *arg;
    62        
    63         /** State of the tasklet */
    64         tasklet_state_t state;
    65 } tasklet_descriptor_t;
     51        /** True iff relocations have already been processed in this module. */
     52        bool relocated;
    6653
     54        /** Link to list of all modules in runtime environment */
     55        link_t modules_link;
    6756
    68 extern void tasklet_init(void);
     57        /** Link to BFS queue. Only used when doing a BFS of the module graph */
     58        link_t queue_link;
     59        /** Tag for modules already processed during a BFS */
     60        bool bfs_tag;
     61} module_t;
     62
     63void module_process_relocs(module_t *m);
     64module_t *module_find(const char *name);
     65module_t *module_load(const char *name);
     66void module_load_deps(module_t *m);
     67
     68void modules_process_relocs(module_t *start);
     69void modules_untag(void);
    6970
    7071#endif
  • uspace/lib/c/include/rtld/rtld_debug.h

    r1ff896e r694ca93f  
    11/*
    2  * Copyright (c) 2005 Sergey Bondari
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup amd64
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef KERN_amd64_MEMSTR_H_
    36 #define KERN_amd64_MEMSTR_H_
     35#ifndef LIBC_RTLD_RTLD_DEBUG_H_
     36#define LIBC_RTLD_RTLD_DEBUG_H_
    3737
    38 #define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
     38/* Define to enable debugging mode. */
     39#undef RTLD_DEBUG
    3940
    40 extern void memsetw(void *, size_t, uint16_t);
    41 extern void memsetb(void *, size_t, uint8_t);
     41#ifdef RTLD_DEBUG
     42        #define DPRINTF(format, ...) printf(format, ##__VA_ARGS__)
     43#else
     44        #define DPRINTF(format, ...) if (0) printf(format, ##__VA_ARGS__)
     45#endif
    4246
    4347#endif
  • uspace/lib/c/include/str.h

    r1ff896e r694ca93f  
    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/*
Note: See TracChangeset for help on using the changeset viewer.