Changeset 78f0422c in mainline


Ignore:
Timestamp:
2023-10-22T17:27:09Z (14 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
133461c
Parents:
71b4444 (diff), dfb16c4 (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 C/C++ changes needed to build with newer GCC

Files:
13 edited

Legend:

Unmodified
Added
Removed
  • abi/include/_bits/decls.h

    r71b4444 r78f0422c  
    6161#endif  /* __cplusplus */
    6262
     63/*
     64 * __CONSTEXPR for headers shared by C and C++. Headers that are purely for
     65 * C++ sources should use constexpr directly.
     66 */
     67#ifdef __cplusplus
     68#define __CONSTEXPR constexpr
     69#else
     70#define __CONSTEXPR
     71#endif
     72
    6373#endif
    6474
  • abi/include/_bits/uchar.h

    r71b4444 r78f0422c  
    3838#include <stdint.h>
    3939
     40/*
     41 * char8_t became part of C++ with C++20.
     42 * It is part of C23 hence we define it for C compilations only.
     43 */
     44#ifndef __cplusplus
    4045typedef uint8_t char8_t;
     46#endif
     47
    4148typedef uint32_t char32_t;
    4249
  • kernel/generic/src/interrupt/interrupt.c

    r71b4444 r78f0422c  
    5858#include <trace.h>
    5959
     60/*
     61 * If IVT_ITEMS is zero (e.g. for special/abs32le) we hide completely any
     62 * access to the exception table array and panic if the function is called
     63 * at all. It also silences (correct) compiler warnings about possible
     64 * out-of-bound array access.
     65 */
     66
    6067exc_table_t exc_table[IVT_ITEMS];
    6168IRQ_SPINLOCK_INITIALIZE(exctbl_lock);
     
    7784#if (IVT_ITEMS > 0)
    7885        assert(n < IVT_ITEMS);
    79 #endif
    8086
    8187        irq_spinlock_lock(&exctbl_lock, true);
     
    9197
    9298        return old;
     99#else
     100        panic("No space for any exception handler, cannot register.");
     101#endif
    93102}
    94103
     
    103112#if (IVT_ITEMS > 0)
    104113        assert(n < IVT_ITEMS);
    105 #endif
    106114
    107115        /* Account user cycles */
     
    152160                irq_spinlock_unlock(&THREAD->lock, false);
    153161        }
     162#else
     163        panic("No space for any exception handler, yet we want to handle some exception.");
     164#endif
    154165}
    155166
  • uspace/app/tester/fault/fault1.c

    r71b4444 r78f0422c  
    3030#include "../tester.h"
    3131
     32#pragma GCC diagnostic ignored "-Warray-bounds"
     33
    3234const char *test_fault1(void)
    3335{
  • uspace/app/tester/print/print5.c

    r71b4444 r78f0422c  
    3838 */
    3939#pragma GCC diagnostic ignored "-Wformat"
     40#pragma GCC diagnostic ignored "-Wformat-overflow"
    4041
    4142#include <stdio.h>
  • uspace/lib/c/generic/rtld/symbol.c

    r71b4444 r78f0422c  
    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

    r71b4444 r78f0422c  
    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/adt/list.h

    r71b4444 r78f0422c  
    183183 *
    184184 */
    185 _NO_TRACE static inline void list_initialize(list_t *list)
     185_NO_TRACE static inline __CONSTEXPR void list_initialize(list_t *list)
    186186{
    187187        list->head.prev = &list->head;
  • uspace/lib/c/include/fibril_synch.h

    r71b4444 r78f0422c  
    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/test/string.c

    r71b4444 r78f0422c  
    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');
  • uspace/lib/cpp/include/__bits/algorithm.hpp

    r71b4444 r78f0422c  
    11101110                                 InputIterator2 last2)
    11111111    {
     1112        while ((first1 != last1) && (first2 != last2))
     1113        {
     1114            if (*first1 < *first2)
     1115                return true;
     1116            if (*first2 < *first1)
     1117                return false;
     1118
     1119            ++first1;
     1120            ++first2;
     1121        }
     1122
    11121123        /**
    1113          * *first1 and *first2 can have different types
    1114          * so we use a transparent comparator.
     1124         * Up until now they are same, so we have to check
     1125         * if we reached the end on one.
    11151126         */
    1116         return lexicographical_compare(
    1117             first1, last1, first2, last2,
    1118             less<void>{}
    1119         );
     1127        return (first1 == last1) && (first2 != last2);
    11201128    }
    11211129
  • uspace/lib/cpp/include/__bits/thread/threading.hpp

    r71b4444 r78f0422c  
    8787        struct mutex
    8888        {
    89             static void init(mutex_type& mtx)
     89            static constexpr void init(mutex_type& mtx)
    9090            {
    9191                ::helenos::fibril_mutex_initialize(&mtx);
  • uspace/srv/hid/display/test/window.c

    r71b4444 r78f0422c  
    11091109        PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
    11101110
     1111        // Check that invalid cursors cannot be set: ignore enum conversions
     1112        // as we are out-of-bounds
     1113#pragma GCC diagnostic push
     1114#if defined(__GNUC__) && (__GNUC__ >= 10)
     1115#pragma GCC diagnostic ignored "-Wenum-conversion"
     1116#endif
    11111117        rc = ds_window_set_cursor(wnd, dcurs_limit);
    11121118        PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
     
    11161122        PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
    11171123        PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
     1124#pragma GCC diagnostic pop
    11181125
    11191126        rc = ds_window_set_cursor(wnd, dcurs_size_lr);
Note: See TracChangeset for help on using the changeset viewer.