Changeset 06b0211b in mainline for uspace/lib/c/generic


Ignore:
Timestamp:
2013-04-29T11:29:45Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aa2b32c
Parents:
ba4799a (diff), df956b9b (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/generic
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/adt/hash_table.c

    rba4799a r06b0211b  
    8181 * @param init_size Initial desired number of hash table buckets. Pass zero
    8282 *                 if you want the default initial size.
    83  * @param max_keys Maximal number of keys needed to identify an item.
     83 * @param max_load The table is resized when the average load per bucket
     84 *                 exceeds this number. Pass zero if you want the default.
    8485 * @param op       Hash table operations structure. remove_callback()
    8586 *                 is optional and can be NULL if no action is to be taken
  • uspace/lib/c/generic/async.c

    rba4799a r06b0211b  
    350350static async_client_conn_t client_connection = default_client_connection;
    351351static async_interrupt_handler_t interrupt_received = default_interrupt_received;
     352static size_t interrupt_handler_stksz = FIBRIL_DFLT_STK_SIZE;
    352353
    353354/** Setter for client_connection function pointer.
     
    370371{
    371372        interrupt_received = intr;
     373}
     374
     375/** Set the stack size for the interrupt handler notification fibrils.
     376 *
     377 * @param size Stack size in bytes.
     378 */
     379void async_set_interrupt_handler_stack_size(size_t size)
     380{
     381        interrupt_handler_stksz = size;
    372382}
    373383
     
    587597        msg->call = *call;
    588598       
    589         fid_t fid = fibril_create(notification_fibril, msg);
     599        fid_t fid = fibril_create_generic(notification_fibril, msg,
     600            interrupt_handler_stksz);
    590601        if (fid == 0) {
    591602                free(msg);
     
    20572068       
    20582069        async_sess_t *sess = exch->sess;
     2070        assert(sess != NULL);
    20592071       
    20602072        atomic_dec(&sess->refcnt);
     
    20782090 * @param arg   User defined argument.
    20792091 * @param flags Storage for the received flags. Can be NULL.
    2080  * @param dst   Destination address space area base. Cannot be NULL.
     2092 * @param dst   Address of the storage for the destination address space area
     2093 *              base address. Cannot be NULL.
    20812094 *
    20822095 * @return Zero on success or a negative error code from errno.h.
     
    22062219 *
    22072220 * @param callid Hash of the IPC_M_DATA_WRITE call to answer.
    2208  * @param dst    Destination address space area base address.
     2221 * @param dst    Address of the storage for the destination address space area
     2222 *               base address.
    22092223 *
    22102224 * @return Zero on success or a value from @ref errno.h on failure.
  • uspace/lib/c/generic/fibril.c

    rba4799a r06b0211b  
    9595fibril_t *fibril_setup(void)
    9696{
    97         tcb_t *tcb = __make_tls();
     97        tcb_t *tcb = tls_make();
    9898        if (!tcb)
    9999                return NULL;
     
    101101        fibril_t *fibril = malloc(sizeof(fibril_t));
    102102        if (!fibril) {
    103                 __free_tls(tcb);
     103                tls_free(tcb);
    104104                return NULL;
    105105        }
     
    122122void fibril_teardown(fibril_t *fibril)
    123123{
    124         __free_tls(fibril->tcb);
     124        tls_free(fibril->tcb);
    125125        free(fibril);
    126126}
     
    256256 * @param func Implementing function of the new fibril.
    257257 * @param arg Argument to pass to func.
     258 * @param stksz Stack size in bytes.
    258259 *
    259260 * @return 0 on failure or TLS of the new fibril.
    260261 *
    261262 */
    262 fid_t fibril_create(int (*func)(void *), void *arg)
     263fid_t fibril_create_generic(int (*func)(void *), void *arg, size_t stksz)
    263264{
    264265        fibril_t *fibril;
     
    268269                return 0;
    269270       
    270         size_t stack_size = stack_size_get();
     271        size_t stack_size = (stksz == FIBRIL_DFLT_STK_SIZE) ?
     272            stack_size_get() : stksz;
    271273        fibril->stack = as_area_create((void *) -1, stack_size,
    272274            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD |
  • uspace/lib/c/generic/net/socket_client.c

    rba4799a r06b0211b  
    192192/** Default thread for new connections.
    193193 *
    194  * @param[in] iid       The initial message identifier.
    195  * @param[in] icall     The initial message call structure.
    196  * @param[in] arg       Local argument.
     194 * @param[in] iid   The initial message identifier.
     195 * @param[in] icall The initial message call structure.
     196 * @param[in] arg   Local argument.
     197 *
    197198 */
    198199static void socket_connection(ipc_callid_t iid, ipc_call_t * icall, void *arg)
    199200{
    200         ipc_callid_t callid;
    201         ipc_call_t call;
    202         socket_t *socket;
    203         int rc;
    204 
    205 loop:
    206         callid = async_get_call(&call);
    207 
    208         switch (IPC_GET_IMETHOD(call)) {
    209         case NET_SOCKET_RECEIVED:
    210         case NET_SOCKET_ACCEPTED:
    211         case NET_SOCKET_DATA_FRAGMENT_SIZE:
    212                 fibril_rwlock_read_lock(&socket_globals.lock);
    213 
    214                 /* Find the socket */
    215                 socket = sockets_find(socket_get_sockets(),
    216                     SOCKET_GET_SOCKET_ID(call));
    217                 if (!socket) {
    218                         rc = ENOTSOCK;
    219                         fibril_rwlock_read_unlock(&socket_globals.lock);
    220                         break;
     201        while (true) {
     202                ipc_call_t call;
     203                ipc_callid_t callid = async_get_call(&call);
     204               
     205                if (!IPC_GET_IMETHOD(call)) {
     206                        async_answer_0(callid, 0);
     207                        return;
    221208                }
     209               
     210                int rc;
    222211               
    223212                switch (IPC_GET_IMETHOD(call)) {
    224213                case NET_SOCKET_RECEIVED:
    225                         fibril_mutex_lock(&socket->receive_lock);
    226                         /* Push the number of received packet fragments */
    227                         rc = dyn_fifo_push(&socket->received,
    228                             SOCKET_GET_DATA_FRAGMENTS(call),
    229                             SOCKET_MAX_RECEIVED_SIZE);
    230                         if (rc == EOK) {
    231                                 /* Signal the received packet */
    232                                 fibril_condvar_signal(&socket->receive_signal);
     214                case NET_SOCKET_ACCEPTED:
     215                case NET_SOCKET_DATA_FRAGMENT_SIZE:
     216                        fibril_rwlock_read_lock(&socket_globals.lock);
     217                       
     218                        /* Find the socket */
     219                        socket_t *socket = sockets_find(socket_get_sockets(),
     220                            SOCKET_GET_SOCKET_ID(call));
     221                        if (!socket) {
     222                                rc = ENOTSOCK;
     223                                fibril_rwlock_read_unlock(&socket_globals.lock);
     224                                break;
    233225                        }
    234                         fibril_mutex_unlock(&socket->receive_lock);
     226                       
     227                        switch (IPC_GET_IMETHOD(call)) {
     228                        case NET_SOCKET_RECEIVED:
     229                                fibril_mutex_lock(&socket->receive_lock);
     230                                /* Push the number of received packet fragments */
     231                                rc = dyn_fifo_push(&socket->received,
     232                                    SOCKET_GET_DATA_FRAGMENTS(call),
     233                                    SOCKET_MAX_RECEIVED_SIZE);
     234                                if (rc == EOK) {
     235                                        /* Signal the received packet */
     236                                        fibril_condvar_signal(&socket->receive_signal);
     237                                }
     238                                fibril_mutex_unlock(&socket->receive_lock);
     239                                break;
     240                               
     241                        case NET_SOCKET_ACCEPTED:
     242                                /* Push the new socket identifier */
     243                                fibril_mutex_lock(&socket->accept_lock);
     244                                rc = dyn_fifo_push(&socket->accepted, 1,
     245                                    SOCKET_MAX_ACCEPTED_SIZE);
     246                                if (rc == EOK) {
     247                                        /* Signal the accepted socket */
     248                                        fibril_condvar_signal(&socket->accept_signal);
     249                                }
     250                                fibril_mutex_unlock(&socket->accept_lock);
     251                                break;
     252                       
     253                        default:
     254                                rc = ENOTSUP;
     255                        }
     256                       
     257                        if ((SOCKET_GET_DATA_FRAGMENT_SIZE(call) > 0) &&
     258                            (SOCKET_GET_DATA_FRAGMENT_SIZE(call) !=
     259                            socket->data_fragment_size)) {
     260                                fibril_rwlock_write_lock(&socket->sending_lock);
     261                               
     262                                /* Set the data fragment size */
     263                                socket->data_fragment_size =
     264                                    SOCKET_GET_DATA_FRAGMENT_SIZE(call);
     265                               
     266                                fibril_rwlock_write_unlock(&socket->sending_lock);
     267                        }
     268                       
     269                        fibril_rwlock_read_unlock(&socket_globals.lock);
    235270                        break;
    236 
    237                 case NET_SOCKET_ACCEPTED:
    238                         /* Push the new socket identifier */
    239                         fibril_mutex_lock(&socket->accept_lock);
    240                         rc = dyn_fifo_push(&socket->accepted, 1,
    241                             SOCKET_MAX_ACCEPTED_SIZE);
    242                         if (rc == EOK) {
    243                                 /* Signal the accepted socket */
    244                                 fibril_condvar_signal(&socket->accept_signal);
    245                         }
    246                         fibril_mutex_unlock(&socket->accept_lock);
    247                         break;
    248 
     271                       
    249272                default:
    250273                        rc = ENOTSUP;
    251274                }
    252 
    253                 if ((SOCKET_GET_DATA_FRAGMENT_SIZE(call) > 0) &&
    254                     (SOCKET_GET_DATA_FRAGMENT_SIZE(call) !=
    255                     socket->data_fragment_size)) {
    256                         fibril_rwlock_write_lock(&socket->sending_lock);
    257 
    258                         /* Set the data fragment size */
    259                         socket->data_fragment_size =
    260                             SOCKET_GET_DATA_FRAGMENT_SIZE(call);
    261 
    262                         fibril_rwlock_write_unlock(&socket->sending_lock);
    263                 }
    264 
    265                 fibril_rwlock_read_unlock(&socket_globals.lock);
    266                 break;
    267 
    268         default:
    269                 rc = ENOTSUP;
    270         }
    271 
    272         async_answer_0(callid, (sysarg_t) rc);
    273         goto loop;
     275               
     276                async_answer_0(callid, (sysarg_t) rc);
     277        }
    274278}
    275279
  • uspace/lib/c/generic/tls.c

    rba4799a r06b0211b  
    5151 * @return Pointer to TCB.
    5252 */
    53 tcb_t *__make_tls(void)
     53tcb_t *tls_make(void)
    5454{
    5555        void *data;
     
    5757        size_t tls_size = &_tbss_end - &_tdata_start;
    5858       
    59         tcb = __alloc_tls(&data, tls_size);
     59        tcb = tls_alloc_arch(&data, tls_size);
    6060        if (!tcb)
    6161                return NULL;
     
    7474}
    7575
    76 void __free_tls(tcb_t *tcb)
     76void tls_free(tcb_t *tcb)
    7777{
    7878        size_t tls_size = &_tbss_end - &_tdata_start;
    79         __free_tls_arch(tcb, tls_size);
     79        tls_free_arch(tcb, tls_size);
    8080}
    8181
Note: See TracChangeset for help on using the changeset viewer.