Changeset dc5c303 in mainline for uspace/lib/c


Ignore:
Timestamp:
2023-12-28T13:59:23Z (22 months ago)
Author:
GitHub <noreply@…>
Children:
6b66de6b
Parents:
42c2e65 (diff), f87ff8e (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.
git-author:
boba-buba <120932204+boba-buba@…> (2023-12-28 13:59:23)
git-committer:
GitHub <noreply@…> (2023-12-28 13:59:23)
Message:

Merge branch 'master' into topic/packet-capture

Location:
uspace/lib/c
Files:
3 added
3 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/arm32/src/atomic.c

    r42c2e65 rdc5c303  
    3838volatile unsigned *ras_page;
    3939
    40 bool __atomic_compare_exchange_4(volatile unsigned *mem, unsigned *expected, unsigned desired, bool weak, int success, int failure)
     40bool __atomic_compare_exchange_4(volatile void *mem0, void *expected0,
     41    unsigned desired, bool weak, int success, int failure)
    4142{
     43        volatile unsigned *mem = mem0;
     44        unsigned *expected = expected0;
     45
    4246        (void) success;
    4347        (void) failure;
     
    8286}
    8387
    84 unsigned short __atomic_fetch_add_2(volatile unsigned short *mem, unsigned short val, int model)
     88unsigned short __atomic_fetch_add_2(volatile void *mem0, unsigned short val,
     89    int model)
    8590{
     91        volatile unsigned short *mem = mem0;
     92
    8693        (void) model;
    8794
     
    116123}
    117124
    118 unsigned __atomic_fetch_add_4(volatile unsigned *mem, unsigned val, int model)
     125unsigned __atomic_fetch_add_4(volatile void *mem0, unsigned val, int model)
    119126{
     127        volatile unsigned *mem = mem0;
     128
    120129        (void) model;
    121130
     
    150159}
    151160
    152 unsigned __atomic_fetch_sub_4(volatile unsigned *mem, unsigned val, int model)
     161unsigned __atomic_fetch_sub_4(volatile void *mem, unsigned val, int model)
    153162{
    154163        return __atomic_fetch_add_4(mem, -val, model);
  • uspace/lib/c/generic/io/asprintf.c

    r42c2e65 rdc5c303  
    3939#include <stddef.h>
    4040#include <str.h>
    41 #include <io/printf_core.h>
     41#include <printf_core.h>
    4242
    4343static int asprintf_str_write(const char *str, size_t count, void *unused)
  • uspace/lib/c/generic/io/kio.c

    r42c2e65 rdc5c303  
    4242#include <abi/kio.h>
    4343#include <io/kio.h>
    44 #include <io/printf_core.h>
     44#include <printf_core.h>
    4545#include <macros.h>
    4646#include <libarch/config.h>
  • uspace/lib/c/generic/io/printf.c

    r42c2e65 rdc5c303  
    3333 */
    3434
    35 #include <io/printf_core.h>
     35#include <printf_core.h>
    3636#include <stdio.h>
    3737
  • uspace/lib/c/generic/io/vprintf.c

    r42c2e65 rdc5c303  
    3535#include <stdarg.h>
    3636#include <stdio.h>
    37 #include <io/printf_core.h>
     37#include <printf_core.h>
    3838#include <fibril_synch.h>
    3939#include <async.h>
  • uspace/lib/c/generic/io/vsnprintf.c

    r42c2e65 rdc5c303  
    3636#include <stdio.h>
    3737#include <str.h>
    38 #include <io/printf_core.h>
     38#include <printf_core.h>
    3939#include <errno.h>
    4040
  • uspace/lib/c/generic/loc.c

    r42c2e65 rdc5c303  
    11/*
     2 * Copyright (c) 2023 Jiri Svoboda
    23 * Copyright (c) 2007 Josef Cejka
    3  * Copyright (c) 2011 Jiri Svoboda
    44 * All rights reserved.
    55 *
     
    3939#include <stdbool.h>
    4040
    41 static FIBRIL_MUTEX_INITIALIZE(loc_supp_block_mutex);
    4241static FIBRIL_MUTEX_INITIALIZE(loc_cons_block_mutex);
    43 
    44 static FIBRIL_MUTEX_INITIALIZE(loc_supplier_mutex);
    4542static FIBRIL_MUTEX_INITIALIZE(loc_consumer_mutex);
    4643
     
    5047static void *cat_change_arg = NULL;
    5148
    52 static async_sess_t *loc_supp_block_sess = NULL;
    5349static async_sess_t *loc_cons_block_sess = NULL;
    54 
    55 static async_sess_t *loc_supplier_sess = NULL;
    5650static async_sess_t *loc_consumer_sess = NULL;
    5751
     
    108102        if (!loc_callback_created) {
    109103                async_exch_t *exch =
    110                     loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
     104                    loc_exchange_begin_blocking();
    111105
    112106                ipc_call_t answer;
     
    135129/** Start an async exchange on the loc session (blocking).
    136130 *
    137  * @param iface Location service interface to choose
    138  *
    139131 * @return New exchange.
    140132 *
    141133 */
    142 async_exch_t *loc_exchange_begin_blocking(iface_t iface)
    143 {
    144         switch (iface) {
    145         case INTERFACE_LOC_SUPPLIER:
    146                 fibril_mutex_lock(&loc_supp_block_mutex);
    147 
    148                 while (loc_supp_block_sess == NULL) {
    149                         clone_session(&loc_supplier_mutex, loc_supplier_sess,
    150                             &loc_supp_block_sess);
    151 
    152                         if (loc_supp_block_sess == NULL)
    153                                 loc_supp_block_sess =
    154                                     service_connect_blocking(SERVICE_LOC,
    155                                     INTERFACE_LOC_SUPPLIER, 0, NULL);
    156                 }
    157 
    158                 fibril_mutex_unlock(&loc_supp_block_mutex);
    159 
    160                 clone_session(&loc_supplier_mutex, loc_supp_block_sess,
    161                     &loc_supplier_sess);
    162 
    163                 return async_exchange_begin(loc_supp_block_sess);
    164         case INTERFACE_LOC_CONSUMER:
    165                 fibril_mutex_lock(&loc_cons_block_mutex);
    166 
    167                 while (loc_cons_block_sess == NULL) {
    168                         clone_session(&loc_consumer_mutex, loc_consumer_sess,
    169                             &loc_cons_block_sess);
    170 
    171                         if (loc_cons_block_sess == NULL)
    172                                 loc_cons_block_sess =
    173                                     service_connect_blocking(SERVICE_LOC,
    174                                     INTERFACE_LOC_CONSUMER, 0, NULL);
    175                 }
    176 
    177                 fibril_mutex_unlock(&loc_cons_block_mutex);
    178 
    179                 clone_session(&loc_consumer_mutex, loc_cons_block_sess,
    180                     &loc_consumer_sess);
    181 
    182                 return async_exchange_begin(loc_cons_block_sess);
    183         default:
     134async_exch_t *loc_exchange_begin_blocking(void)
     135{
     136        fibril_mutex_lock(&loc_cons_block_mutex);
     137
     138        while (loc_cons_block_sess == NULL) {
     139                clone_session(&loc_consumer_mutex, loc_consumer_sess,
     140                    &loc_cons_block_sess);
     141
     142                if (loc_cons_block_sess == NULL)
     143                        loc_cons_block_sess =
     144                            service_connect_blocking(SERVICE_LOC,
     145                            INTERFACE_LOC_CONSUMER, 0, NULL);
     146        }
     147
     148        fibril_mutex_unlock(&loc_cons_block_mutex);
     149
     150        clone_session(&loc_consumer_mutex, loc_cons_block_sess,
     151            &loc_consumer_sess);
     152
     153        return async_exchange_begin(loc_cons_block_sess);
     154}
     155
     156/** Start an async exchange on the loc session.
     157 *
     158 * @return New exchange.
     159 *
     160 */
     161async_exch_t *loc_exchange_begin(void)
     162{
     163        fibril_mutex_lock(&loc_consumer_mutex);
     164
     165        if (loc_consumer_sess == NULL)
     166                loc_consumer_sess =
     167                    service_connect(SERVICE_LOC,
     168                    INTERFACE_LOC_CONSUMER, 0, NULL);
     169
     170        fibril_mutex_unlock(&loc_consumer_mutex);
     171
     172        if (loc_consumer_sess == NULL)
    184173                return NULL;
    185         }
    186 }
    187 
    188 /** Start an async exchange on the loc session.
    189  *
    190  * @param iface Location service interface to choose
    191  *
    192  * @return New exchange.
    193  *
    194  */
    195 async_exch_t *loc_exchange_begin(iface_t iface)
    196 {
    197         switch (iface) {
    198         case INTERFACE_LOC_SUPPLIER:
    199                 fibril_mutex_lock(&loc_supplier_mutex);
    200 
    201                 if (loc_supplier_sess == NULL)
    202                         loc_supplier_sess =
    203                             service_connect(SERVICE_LOC,
    204                             INTERFACE_LOC_SUPPLIER, 0, NULL);
    205 
    206                 fibril_mutex_unlock(&loc_supplier_mutex);
    207 
    208                 if (loc_supplier_sess == NULL)
    209                         return NULL;
    210 
    211                 return async_exchange_begin(loc_supplier_sess);
    212         case INTERFACE_LOC_CONSUMER:
    213                 fibril_mutex_lock(&loc_consumer_mutex);
    214 
    215                 if (loc_consumer_sess == NULL)
    216                         loc_consumer_sess =
    217                             service_connect(SERVICE_LOC,
    218                             INTERFACE_LOC_CONSUMER, 0, NULL);
    219 
    220                 fibril_mutex_unlock(&loc_consumer_mutex);
    221 
    222                 if (loc_consumer_sess == NULL)
    223                         return NULL;
    224 
    225                 return async_exchange_begin(loc_consumer_sess);
    226         default:
    227                 return NULL;
    228         }
     174
     175        return async_exchange_begin(loc_consumer_sess);
    229176}
    230177
     
    239186}
    240187
    241 /** Register new server with loc. */
    242 errno_t loc_server_register(const char *name)
    243 {
    244         async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_SUPPLIER);
     188/** Register new server with loc.
     189 *
     190 * @param name Server name
     191 * @param rsrv Place to store new server object on success
     192 * @return EOK on succes or an error code
     193 */
     194errno_t loc_server_register(const char *name, loc_srv_t **rsrv)
     195{
     196        async_exch_t *exch;
     197        loc_srv_t *srv;
     198
     199        srv = calloc(1, sizeof(loc_srv_t));
     200        if (srv == NULL)
     201                return ENOMEM;
     202
     203        srv->sess = service_connect_blocking(SERVICE_LOC,
     204            INTERFACE_LOC_SUPPLIER, 0, NULL);
     205        if (srv->sess == NULL) {
     206                free(srv);
     207                return ENOMEM;
     208        }
     209
     210        exch = async_exchange_begin(srv->sess);
    245211
    246212        ipc_call_t answer;
     
    250216        if (retval != EOK) {
    251217                async_forget(req);
    252                 loc_exchange_end(exch);
     218                async_exchange_end(exch);
     219                async_hangup(srv->sess);
     220                free(srv);
    253221                return retval;
    254222        }
     
    262230         */
    263231        async_wait_for(req, &retval);
    264         loc_exchange_end(exch);
    265 
     232        async_exchange_end(exch);
     233
     234        if (retval != EOK) {
     235                async_hangup(srv->sess);
     236                free(srv);
     237                return retval;
     238        }
     239
     240        *rsrv = srv;
    266241        return retval;
    267242}
    268243
     244/** Unregister server from loc.
     245 *
     246 * Unregister server and free server object.
     247 *
     248 * @param srv Server object
     249 */
     250void loc_server_unregister(loc_srv_t *srv)
     251{
     252        async_hangup(srv->sess);
     253        free(srv);
     254}
     255
    269256/** Register new service.
    270257 *
    271  * @param      fqsn  Fully qualified service name
    272  * @param[out] sid   Service ID of new service
    273  *
    274  */
    275 errno_t loc_service_register(const char *fqsn, service_id_t *sid)
    276 {
    277         async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_SUPPLIER);
    278 
     258 * @param srv Server object
     259 * @param fqsn Fully qualified service name
     260 * @param sid  Service ID of new service
     261 *
     262 */
     263errno_t loc_service_register(loc_srv_t *srv, const char *fqsn,
     264    service_id_t *sid)
     265{
     266        async_exch_t *exch = async_exchange_begin(srv->sess);
    279267        ipc_call_t answer;
    280268        aid_t req = async_send_0(exch, LOC_SERVICE_REGISTER, &answer);
     
    283271        if (retval != EOK) {
    284272                async_forget(req);
    285                 loc_exchange_end(exch);
     273                async_exchange_end(exch);
    286274                return retval;
    287275        }
     
    293281         */
    294282        async_wait_for(req, &retval);
    295         loc_exchange_end(exch);
     283        async_exchange_end(exch);
    296284
    297285        if (retval != EOK) {
     
    310298/** Unregister service.
    311299 *
    312  * @param sid   Service ID
    313  */
    314 errno_t loc_service_unregister(service_id_t sid)
     300 * @param srv Server object
     301 * @param sid Service ID
     302 */
     303errno_t loc_service_unregister(loc_srv_t *srv, service_id_t sid)
    315304{
    316305        async_exch_t *exch;
    317306        errno_t retval;
    318307
    319         exch = loc_exchange_begin_blocking(INTERFACE_LOC_SUPPLIER);
     308        exch = async_exchange_begin(srv->sess);
    320309        retval = async_req_1_0(exch, LOC_SERVICE_UNREGISTER, sid);
    321         loc_exchange_end(exch);
     310        async_exchange_end(exch);
    322311
    323312        return (errno_t)retval;
     
    330319
    331320        if (flags & IPC_FLAG_BLOCKING)
    332                 exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
     321                exch = loc_exchange_begin_blocking();
    333322        else {
    334                 exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER);
     323                exch = loc_exchange_begin();
    335324                if (exch == NULL)
    336325                        return errno;
     
    383372
    384373        *name = NULL;
    385         exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
     374        exch = loc_exchange_begin_blocking();
    386375
    387376        ipc_call_t answer;
     
    463452
    464453        if (flags & IPC_FLAG_BLOCKING)
    465                 exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
     454                exch = loc_exchange_begin_blocking();
    466455        else {
    467                 exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER);
     456                exch = loc_exchange_begin();
    468457                if (exch == NULL)
    469458                        return errno;
     
    512501
    513502        if (flags & IPC_FLAG_BLOCKING)
    514                 exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
     503                exch = loc_exchange_begin_blocking();
    515504        else {
    516                 exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER);
     505                exch = loc_exchange_begin();
    517506                if (exch == NULL)
    518507                        return errno;
     
    548537loc_object_type_t loc_id_probe(service_id_t handle)
    549538{
    550         async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
     539        async_exch_t *exch = loc_exchange_begin_blocking();
    551540
    552541        sysarg_t type;
     
    579568int loc_null_create(void)
    580569{
    581         async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
     570        async_exch_t *exch = loc_exchange_begin_blocking();
    582571
    583572        sysarg_t null_id;
     
    594583void loc_null_destroy(int null_id)
    595584{
    596         async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
     585        async_exch_t *exch = loc_exchange_begin_blocking();
    597586        async_req_1_0(exch, LOC_NULL_DESTROY, (sysarg_t) null_id);
    598587        loc_exchange_end(exch);
     
    611600/** Add service to category.
    612601 *
    613  * @param svc_id        Service ID
    614  * @param cat_id        Category ID
    615  * @return              EOK on success or an error code
    616  */
    617 errno_t loc_service_add_to_cat(service_id_t svc_id, service_id_t cat_id)
     602 * @param srv    Server object
     603 * @param svc_id Service ID
     604 * @param cat_id Category ID
     605 *
     606 * @return EOK on success or an error code
     607 */
     608errno_t loc_service_add_to_cat(loc_srv_t *srv, service_id_t svc_id,
     609    service_id_t cat_id)
    618610{
    619611        async_exch_t *exch;
    620612        errno_t retval;
    621613
    622         exch = loc_exchange_begin_blocking(INTERFACE_LOC_SUPPLIER);
     614        exch = async_exchange_begin(srv->sess);
    623615        retval = async_req_2_0(exch, LOC_SERVICE_ADD_TO_CAT, svc_id, cat_id);
    624         loc_exchange_end(exch);
     616        async_exchange_end(exch);
    625617
    626618        return retval;
     
    641633size_t loc_count_namespaces(void)
    642634{
    643         async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
     635        async_exch_t *exch = loc_exchange_begin_blocking();
    644636        size_t size = loc_count_namespaces_internal(exch);
    645637        loc_exchange_end(exch);
     
    650642size_t loc_count_services(service_id_t ns_handle)
    651643{
    652         async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
     644        async_exch_t *exch = loc_exchange_begin_blocking();
    653645        size_t size = loc_count_services_internal(exch, ns_handle);
    654646        loc_exchange_end(exch);
     
    661653        /* Loop until read is succesful */
    662654        while (true) {
    663                 async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
     655                async_exch_t *exch = loc_exchange_begin_blocking();
    664656                size_t count = loc_count_namespaces_internal(exch);
    665657                loc_exchange_end(exch);
     
    672664                        return 0;
    673665
    674                 exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER);
     666                exch = loc_exchange_begin();
    675667
    676668                ipc_call_t answer;
     
    710702        /* Loop until read is succesful */
    711703        while (true) {
    712                 async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
     704                async_exch_t *exch = loc_exchange_begin_blocking();
    713705                size_t count = loc_count_services_internal(exch, ns_handle);
    714706                loc_exchange_end(exch);
     
    721713                        return 0;
    722714
    723                 exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER);
     715                exch = loc_exchange_begin();
    724716
    725717                ipc_call_t answer;
     
    758750    sysarg_t *id_buf, size_t buf_size, size_t *act_size)
    759751{
    760         async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER);
     752        async_exch_t *exch = loc_exchange_begin_blocking();
    761753
    762754        ipc_call_t answer;
  • uspace/lib/c/generic/malloc.c

    r42c2e65 rdc5c303  
    3434 */
    3535
    36 #include <malloc.h>
     36#include <stdlib.h>
    3737#include <stdalign.h>
    3838#include <stdbool.h>
     
    4747#include <stdlib.h>
    4848#include <adt/gcdlcm.h>
     49#include <malloc.h>
    4950
    5051#include "private/malloc.h"
     
    773774}
    774775
    775 /** Allocate memory by number of elements
    776  *
    777  * @param nmemb Number of members to allocate.
    778  * @param size  Size of one member in bytes.
    779  *
    780  * @return Allocated memory or NULL.
    781  *
    782  */
    783 void *calloc(const size_t nmemb, const size_t size)
    784 {
    785         // FIXME: Check for overflow
    786 
    787         void *block = malloc(nmemb * size);
    788         if (block == NULL)
    789                 return NULL;
    790 
    791         memset(block, 0, nmemb * size);
    792         return block;
    793 }
    794 
    795776/** Allocate memory
    796777 *
  • uspace/lib/c/generic/rtld/symbol.c

    r42c2e65 rdc5c303  
    135135        modules_untag(start->rtld);
    136136
    137         /* Insert root (the program) into the queue and tag it */
     137        /*
     138         * Insert root (the program) into the queue and tag it.
     139         *
     140         * We disable the dangling-pointer warning because the compiler incorrectly
     141         * assumes that we leak local address (queue) to a parent scope (to start
     142         * argument). However, we always empty the list so the pointer cannot
     143         * actually escape. Probably the compiler can never statically analyze that
     144         * correctly.
     145         */
    138146        list_initialize(&queue);
    139147        start->bfs_tag = true;
     148#pragma GCC diagnostic push
     149#if defined(__GNUC__) && (__GNUC__ >= 12)
     150#pragma GCC diagnostic ignored "-Wdangling-pointer"
     151#endif
    140152        list_append(&start->queue_link, &queue);
     153#pragma GCC diagnostic pop
    141154
    142155        /* If the symbol is found, it will be stored in 'sym' */
  • uspace/lib/c/generic/thread/fibril_synch.c

    r42c2e65 rdc5c303  
    160160{
    161161        check_fibril_for_deadlock(oi, fibril_self());
    162 }
    163 
    164 void fibril_mutex_initialize(fibril_mutex_t *fm)
    165 {
    166         fm->oi.owned_by = NULL;
    167         fm->counter = 1;
    168         list_initialize(&fm->waiters);
    169162}
    170163
  • uspace/lib/c/include/fibril_synch.h

    r42c2e65 rdc5c303  
    153153extern void __fibril_synch_fini(void);
    154154
    155 extern void fibril_mutex_initialize(fibril_mutex_t *);
     155/** Initialize fibril mutex.
     156 *
     157 * Kept as in-line to allow constexpr marker for C++ library where this
     158 * is used by C++ mutex type (list initialization are two assignments
     159 * so it is actually reasonable to have this inlined).
     160 */
     161static inline __CONSTEXPR void fibril_mutex_initialize(fibril_mutex_t *fm)
     162{
     163        fm->oi.owned_by = NULL;
     164        fm->counter = 1;
     165        list_initialize(&fm->waiters);
     166}
     167
    156168extern void fibril_mutex_lock(fibril_mutex_t *);
    157169extern bool fibril_mutex_trylock(fibril_mutex_t *);
  • uspace/lib/c/include/loc.h

    r42c2e65 rdc5c303  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3939#include <async.h>
    4040#include <stdbool.h>
     41#include <types/loc.h>
    4142
    4243typedef void (*loc_cat_change_cb_t)(void *);
    4344
    44 extern async_exch_t *loc_exchange_begin_blocking(iface_t);
    45 extern async_exch_t *loc_exchange_begin(iface_t);
     45extern async_exch_t *loc_exchange_begin_blocking(void);
     46extern async_exch_t *loc_exchange_begin(void);
    4647extern void loc_exchange_end(async_exch_t *);
    4748
    48 extern errno_t loc_server_register(const char *);
    49 extern errno_t loc_service_register(const char *, service_id_t *);
    50 extern errno_t loc_service_unregister(service_id_t);
    51 extern errno_t loc_service_add_to_cat(service_id_t, category_id_t);
     49extern errno_t loc_server_register(const char *, loc_srv_t **);
     50extern void loc_server_unregister(loc_srv_t *);
     51extern errno_t loc_service_register(loc_srv_t *, const char *, service_id_t *);
     52extern errno_t loc_service_unregister(loc_srv_t *, service_id_t);
     53extern errno_t loc_service_add_to_cat(loc_srv_t *, service_id_t, category_id_t);
    5254
    5355extern errno_t loc_service_get_id(const char *, service_id_t *,
  • uspace/lib/c/include/malloc.h

    r42c2e65 rdc5c303  
    3939#include <_bits/decls.h>
    4040
    41 __C_DECLS_BEGIN;
    42 
    43 extern void *malloc(size_t size)
    44     __attribute__((malloc));
    45 extern void *calloc(size_t nmemb, size_t size)
    46     __attribute__((malloc));
    47 extern void *realloc(void *addr, size_t size)
    48     __attribute__((warn_unused_result));
    49 extern void free(void *addr);
    50 
    51 __C_DECLS_END;
    52 
    5341#ifdef _HELENOS_SOURCE
    5442__HELENOS_DECLS_BEGIN;
    5543
    56 extern void *memalign(size_t align, size_t size)
    57     __attribute__((malloc));
    5844extern void *heap_check(void);
    5945
  • uspace/lib/c/meson.build

    r42c2e65 rdc5c303  
    11#
     2# Copyright (c) 2023 Jiri Svoboda
    23# Copyright (c) 2005 Martin Decky
    34# Copyright (c) 2007 Jakub Jermar
     
    4142        root_path / 'abi' / 'arch' / UARCH / 'include',
    4243        root_path / 'abi' / 'include',
     44        root_path / 'common' / 'include',
    4345]
    4446
     
    4648
    4749allow_shared = true
    48 
    49 # FIXME: symlinks from uspace to kernel will break in future Meson version
    50 #        we should instead move the duplicated library parts into a shared location.
    5150
    5251uspace_lib_devel_install_script_text += 'mkdir -p "${DESTDIR}include/libc"'
     
    5958
    6059src += files(
     60        'common/adt/checksum.c',
     61        'common/adt/circ_buf.c',
     62        'common/adt/list.c',
     63        'common/adt/hash_table.c',
     64        'common/adt/odict.c',
     65        'common/printf/printf_core.c',
     66        'common/stdc/ctype.c',
     67        'common/stdc/mem.c',
     68        'common/stdc/bsearch.c',
     69        'common/stdc/qsort.c',
     70        'common/stdc/calloc.c',
     71        'common/gsort.c',
     72        'common/str.c',
     73        'common/str_error.c',
     74        'common/strtol.c',
     75
    6176        'generic/libc.c',
     77        'generic/adt/prodcons.c',
    6278        'generic/as.c',
    6379        'generic/ddi.c',
    6480        'generic/perm.c',
    6581        'generic/capa.c',
    66         'generic/clipboard.c',
    6782        'generic/config.c',
    6883        'generic/context.c',
    69         'generic/corecfg.c',
    70         'generic/ctype.c',
    7184        'generic/device/clock_dev.c',
    7285        'generic/device/hw_res.c',
     
    8093        'generic/event.c',
    8194        'generic/errno.c',
    82         'generic/gsort.c',
    8395        'generic/inttypes.c',
    84         'generic/ipc_test.c',
    8596        'generic/loc.c',
    86         'generic/mem.c',
    87         'generic/str.c',
    8897        'generic/string.c',
    89         'generic/str_error.c',
    90         'generic/strtol.c',
    9198        'generic/l18n/langs.c',
    9299        'generic/pcb.c',
     
    96103        'generic/imath.c',
    97104        'generic/io/asprintf.c',
    98         'generic/io/input.c',
    99105        'generic/io/io.c',
    100         'generic/io/chargrid.c',
    101         'generic/io/output.c',
    102106        'generic/io/printf.c',
    103107        'generic/io/log.c',
     
    108112        'generic/io/vprintf.c',
    109113        'generic/io/vsnprintf.c',
    110         'generic/io/printf_core.c',
    111         'generic/io/con_srv.c',
    112         'generic/io/console.c',
    113114        'generic/io/table.c',
    114115        'generic/irq.c',
     
    137138        'generic/loader.c',
    138139        'generic/getopt.c',
    139         'generic/adt/checksum.c',
    140         'generic/adt/circ_buf.c',
    141         'generic/adt/list.c',
    142         'generic/adt/hash_table.c',
    143         'generic/adt/odict.c',
    144         'generic/adt/prodcons.c',
    145140        'generic/time.c',
    146141        'generic/tmpfile.c',
     
    158153        'generic/stats.c',
    159154        'generic/assert.c',
    160         'generic/bsearch.c',
    161         'generic/qsort.c',
    162155        'generic/ubsan.c',
    163156        'generic/uuid.c',
     
    186179        'test/inttypes.c',
    187180        'test/io/table.c',
     181        'test/loc.c',
    188182        'test/main.c',
    189183        'test/mem.c',
  • uspace/lib/c/test/main.c

    r42c2e65 rdc5c303  
    11/*
     2 * Copyright (c) 2023 Jiri Svoboda
    23 * Copyright (c) 2014 Vojtech Horky
    34 * All rights reserved.
     
    4243PCUT_IMPORT(imath);
    4344PCUT_IMPORT(inttypes);
     45PCUT_IMPORT(loc);
    4446PCUT_IMPORT(mem);
    4547PCUT_IMPORT(odict);
  • uspace/lib/c/test/string.c

    r42c2e65 rdc5c303  
    799799PCUT_TEST(strndup_nonempty_short)
    800800{
     801#pragma GCC diagnostic push
     802        // Intentionally checking it works with _longer_ size than actual
     803#if defined(__GNUC__) && (__GNUC__ >= 11)
     804#pragma GCC diagnostic ignored "-Wstringop-overread"
     805#endif
    801806        char *d = strndup("abc", 5);
     807#pragma GCC diagnostic pop
    802808        PCUT_ASSERT_NOT_NULL(d);
    803809        PCUT_ASSERT_TRUE(d[0] == 'a');
Note: See TracChangeset for help on using the changeset viewer.