Changeset 1d4024cf in mainline for uspace/lib


Ignore:
Timestamp:
2012-06-13T16:19:01Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
49c94a3
Parents:
33f9670 (diff), 2902e1bb (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 with mainline

Location:
uspace/lib
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/ia64/include/fibril.h

    r33f9670 r1d4024cf  
    4949#define PFM_MASK  (~0x3fffffffff)
    5050
    51 #define PSTHREAD_INITIAL_STACK_PAGES_NO  2
    52 
    5351/* Stack is divided into two equal parts (for memory stack and register stack). */
    54 #define PSTHREAD_INITIAL_STACK_DIVISION  2
     52#define FIBRIL_INITIAL_STACK_DIVISION  2
    5553
    5654#define context_set(c, _pc, stack, size, tls) \
     
    5856                (c)->pc = (uint64_t) _pc; \
    5957                (c)->bsp = ((uint64_t) stack) + \
    60                     size / PSTHREAD_INITIAL_STACK_DIVISION; \
     58                    size / FIBRIL_INITIAL_STACK_DIVISION; \
    6159                (c)->ar_pfs &= PFM_MASK; \
    6260                (c)->sp = ((uint64_t) stack) + \
    63                     ALIGN_UP((size / PSTHREAD_INITIAL_STACK_DIVISION), STACK_ALIGNMENT) - \
     61                    ALIGN_UP((size / FIBRIL_INITIAL_STACK_DIVISION), STACK_ALIGNMENT) - \
    6462                    SP_DELTA; \
    6563                (c)->tp = (uint64_t) tls; \
  • uspace/lib/c/arch/ia64/include/thread.h

    r33f9670 r1d4024cf  
    2727 */
    2828
    29 /** @addtogroup libcia64       
     29/** @addtogroup libcia64
    3030 * @{
    3131 */
     
    3636#define LIBC_ia64_THREAD_H_
    3737
    38 #define THREAD_INITIAL_STACK_PAGES_NO 2
    39 
    4038#endif
    4139
  • uspace/lib/c/generic/as.c

    r33f9670 r1d4024cf  
    4646 *
    4747 * @param base  Starting virtual address of the area.
    48  *              If set to (void *) -1, the kernel finds
    49  *              a mappable area.
     48 *              If set to AS_AREA_ANY ((void *) -1),
     49 *              the kernel finds a mappable area.
    5050 * @param size  Size of the area.
    5151 * @param flags Flags describing type of the area.
    5252 *
    5353 * @return Starting virtual address of the created area on success.
    54  * @return (void *) -1 otherwise.
     54 * @return AS_MAP_FAILED ((void *) -1) otherwise.
    5555 *
    5656 */
  • uspace/lib/c/generic/elf/elf_load.c

    r33f9670 r1d4024cf  
    366366        a = as_area_create((uint8_t *) base + bias, mem_sz,
    367367            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
    368         if (a == (void *) -1) {
     368        if (a == AS_MAP_FAILED) {
    369369                DPRINTF("memory mapping failed (0x%x, %d)\n",
    370370                    base + bias, mem_sz);
  • uspace/lib/c/generic/fibril.c

    r33f9670 r1d4024cf  
    286286}
    287287
     288/** Delete a fibril that has never run.
     289 *
     290 * Free resources of a fibril that has been created with fibril_create()
     291 * but never readied using fibril_add_ready().
     292 *
     293 * @param fid Pointer to the fibril structure of the fibril to be
     294 *            added.
     295 */
     296void fibril_destroy(fid_t fid)
     297{
     298        fibril_t *fibril = (fibril_t *) fid;
     299       
     300        free(fibril->stack);
     301        fibril_teardown(fibril);
     302}
     303
    288304/** Add a fibril to the ready list.
    289305 *
  • uspace/lib/c/generic/malloc.c

    r33f9670 r1d4024cf  
    285285        /* Align the heap area size on page boundary */
    286286        size_t asize = ALIGN_UP(size, PAGE_SIZE);
    287         void *astart = as_area_create((void *) -1, asize,
     287        void *astart = as_area_create(AS_AREA_ANY, asize,
    288288            AS_AREA_WRITE | AS_AREA_READ);
    289         if (astart == (void *) -1)
     289        if (astart == AS_MAP_FAILED)
    290290                return false;
    291291       
  • uspace/lib/c/generic/mman.c

    r33f9670 r1d4024cf  
    4242{
    4343        if (!start)
    44                 start = (void *) -1;
     44                start = AS_AREA_ANY;
    4545       
    4646//      if (!((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE)))
  • uspace/lib/c/generic/thread.c

    r33f9670 r1d4024cf  
    4141#include <str.h>
    4242#include <async.h>
     43#include <errno.h>
     44#include <as.h>
    4345#include "private/thread.h"
    4446
    45 #ifndef THREAD_INITIAL_STACK_PAGES_NO
    46 #define THREAD_INITIAL_STACK_PAGES_NO   2
     47#ifndef THREAD_INITIAL_STACK_PAGES
     48        #define THREAD_INITIAL_STACK_PAGES  2
    4749#endif
    4850
     
    6567       
    6668        uarg->uspace_thread_function(uarg->uspace_thread_arg);
    67         /* XXX: we cannot free the userspace stack while running on it
    68                 free(uarg->uspace_stack);
    69                 free(uarg);
    70         */
     69        /*
     70         * XXX: we cannot free the userspace stack while running on it
     71         *
     72         * free(uarg->uspace_stack);
     73         * free(uarg);
     74         */
    7175       
    7276        /* If there is a manager, destroy it */
     
    9296    thread_id_t *tid)
    9397{
    94         char *stack;
    95         uspace_arg_t *uarg;
    96         int rc;
    97 
    98         stack = (char *) malloc(getpagesize() * THREAD_INITIAL_STACK_PAGES_NO);
    99         if (!stack)
    100                 return -1;
    101                
    102         uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t));
    103         if (!uarg) {
    104                 free(stack);
    105                 return -1;
     98        uspace_arg_t *uarg =
     99            (uspace_arg_t *) malloc(sizeof(uspace_arg_t));
     100        if (!uarg)
     101                return ENOMEM;
     102       
     103        size_t stack_size = getpagesize() * THREAD_INITIAL_STACK_PAGES;
     104        void *stack = as_area_create(AS_AREA_ANY, stack_size,
     105            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
     106        if (stack == AS_MAP_FAILED) {
     107                free(uarg);
     108                return ENOMEM;
    106109        }
    107110       
    108111        uarg->uspace_entry = (void *) FADDR(__thread_entry);
    109         uarg->uspace_stack = (void *) stack;
     112        uarg->uspace_stack = stack;
     113        uarg->uspace_stack_size = stack_size;
    110114        uarg->uspace_thread_function = function;
    111115        uarg->uspace_thread_arg = arg;
    112116        uarg->uspace_uarg = uarg;
    113117       
    114         rc = __SYSCALL4(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name,
    115             (sysarg_t) str_size(name), (sysarg_t) tid);
     118        int rc = __SYSCALL4(SYS_THREAD_CREATE, (sysarg_t) uarg,
     119            (sysarg_t) name, (sysarg_t) str_size(name), (sysarg_t) tid);
    116120       
    117         if (rc) {
     121        if (rc != EOK) {
    118122                /*
    119123                 * Failed to create a new thread.
    120                  * Free up the allocated structures.
     124                 * Free up the allocated data.
    121125                 */
     126                as_area_destroy(stack);
    122127                free(uarg);
    123                 free(stack);
    124128        }
    125 
     129       
    126130        return rc;
    127131}
  • uspace/lib/c/include/as.h

    r33f9670 r1d4024cf  
    4141#include <libarch/config.h>
    4242
     43#define AS_AREA_ANY    ((void *) -1)
     44#define AS_MAP_FAILED  ((void *) -1)
     45
    4346static inline size_t SIZE2PAGES(size_t size)
    4447{
  • uspace/lib/c/include/fibril.h

    r33f9670 r1d4024cf  
    8787
    8888extern fid_t fibril_create(int (*func)(void *), void *arg);
     89extern void fibril_destroy(fid_t fid);
    8990extern fibril_t *fibril_setup(void);
    9091extern void fibril_teardown(fibril_t *f);
  • uspace/lib/c/include/sys/mman.h

    r33f9670 r1d4024cf  
    3939#include <sys/types.h>
    4040
    41 #define MAP_FAILED  ((void *) -1)
     41#define MAP_FAILED  AS_MAP_FAILED
    4242
    4343#define MAP_SHARED     (1 << 0)
  • uspace/lib/fb/imgmap.c

    r33f9670 r1d4024cf  
    420420       
    421421        if ((flags & IMGMAP_FLAG_SHARED) == IMGMAP_FLAG_SHARED) {
    422                 imgmap = (imgmap_t *) as_area_create((void *) -1, size,
     422                imgmap = (imgmap_t *) as_area_create(AS_AREA_ANY, size,
    423423                    AS_AREA_READ | AS_AREA_WRITE);
    424                 if (imgmap == (void *) -1)
     424                if (imgmap == AS_MAP_FAILED)
    425425                        return NULL;
    426426        } else {
  • uspace/lib/fb/screenbuffer.c

    r33f9670 r1d4024cf  
    7979       
    8080        if ((flags & SCREENBUFFER_FLAG_SHARED) == SCREENBUFFER_FLAG_SHARED) {
    81                 scrbuf = (screenbuffer_t *) as_area_create((void *) -1, size,
     81                scrbuf = (screenbuffer_t *) as_area_create(AS_AREA_ANY, size,
    8282                    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
    83                 if (scrbuf == (void *) -1)
     83                if (scrbuf == AS_MAP_FAILED)
    8484                        return NULL;
    8585        } else {
  • uspace/lib/fs/libfs.c

    r33f9670 r1d4024cf  
    339339         */
    340340        rc = async_share_in_start_0_0(exch, PLB_SIZE, (void *) &reg.plb_ro);
    341         if (reg.plb_ro == (void *) -1) {
     341        if (reg.plb_ro == AS_MAP_FAILED) {
    342342                async_exchange_end(exch);
    343343                async_forget(req);
Note: See TracChangeset for help on using the changeset viewer.