From: kosmirror <kos...@us...> - 2025-08-05 05:23:12
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via b4d54adf23275f7682359ab32c7df3349cda0393 (commit) via db307a62b687d6a1f4cf9ce4f89a25eb5f99ec91 (commit) via 6e74c3487262e469d2a6a6980c3e282c9b83a7fd (commit) from f26ec6edfd6df6508242b53122b8a9d51557a849 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b4d54adf23275f7682359ab32c7df3349cda0393 Author: QuzarDC <qu...@co...> Date: Sat May 10 14:13:53 2025 -0400 fmath mark functions __pure. commit db307a62b687d6a1f4cf9ce4f89a25eb5f99ec91 Author: QuzarDC <qu...@co...> Date: Sat May 10 14:08:35 2025 -0400 Mark functions __pure. Additionally clean up some white space in `net.h` commit 6e74c3487262e469d2a6a6980c3e282c9b83a7fd Author: QuzarDC <qu...@co...> Date: Sat May 10 14:02:46 2025 -0400 Remove KOS redefinition of `__pure`. I believe this may have been correct in the past, but now gcc offers an actual 'pure' attribute which differs from const. Unlike const, pure allows data pointed to by pointer arguments to change. Now, not only does `__pure` not have to fall back to `const` but newlib offers it in their cdefs so we shouldn't need to redefine it. ----------------------------------------------------------------------- Summary of changes: include/kos/cdefs.h | 11 --- include/kos/net.h | 102 ++++++++++----------- kernel/arch/dreamcast/fs/vmufs.c | 2 +- kernel/arch/dreamcast/hardware/maple/controller.c | 4 +- kernel/arch/dreamcast/hardware/ubc.c | 6 +- kernel/arch/dreamcast/include/arch/arch.h | 6 +- kernel/arch/dreamcast/include/dc/fmath.h | 23 +++-- .../arch/dreamcast/include/dc/maple/controller.h | 4 +- kernel/arch/dreamcast/kernel/banner.c | 7 +- kernel/arch/dreamcast/kernel/gdb_stub.c | 8 +- kernel/arch/dreamcast/math/fmath.c | 22 ++--- kernel/arch/dreamcast/util/vmu_fb.c | 2 +- kernel/arch/dreamcast/util/vmu_pkg.c | 6 +- kernel/net/net_crc.c | 6 +- kernel/net/net_dhcp.c | 6 +- kernel/net/net_ipv4.c | 10 +- kernel/net/net_ipv4.h | 4 +- kernel/net/net_ipv4_frag.c | 2 +- kernel/net/net_ipv6.c | 2 +- kernel/thread/mutex.c | 2 +- 20 files changed, 112 insertions(+), 123 deletions(-) diff --git a/include/kos/cdefs.h b/include/kos/cdefs.h index dcb1f192..87ddcaa2 100644 --- a/include/kos/cdefs.h +++ b/include/kos/cdefs.h @@ -47,12 +47,6 @@ #define __noreturn __attribute__((__noreturn__)) #endif -#ifndef __pure -/** \brief Identify a function that has no side effects other than its return, - and only uses its arguments for any work. */ -#define __pure __attribute__((__const__)) -#endif - #ifndef __unused /** \brief Identify a function or variable that may be unused. */ #define __unused __attribute__((__unused__)) @@ -78,11 +72,6 @@ #define __dead2 __noreturn /* BSD compat */ #endif -#ifndef __pure2 -/** \brief Alias for \ref __pure. For BSD compatibility. */ -#define __pure2 __pure /* ditto */ -#endif - #ifndef __likely /** \brief Directive to inform the compiler the condition is in the likely path. diff --git a/include/kos/net.h b/include/kos/net.h index a23929af..786cac7b 100644 --- a/include/kos/net.h +++ b/include/kos/net.h @@ -299,7 +299,7 @@ void net_arp_shutdown(void); \param timestamp The entry's timestamp. Set to 0 for a permanent entry, otherwise set to the current number of milliseconds since boot (i.e, timer_ms_gettime64()). - + \retval 0 On success. \retval -1 Error allocating memory. */ @@ -320,7 +320,7 @@ int net_arp_insert(netif_t *nif, const uint8_t mac[6], const uint8_t ip[4], response comes in (if not found immediately). \param data Packet data to go with the header. \param data_size The size of data. - + \retval 0 On success. \retval -1 A query is outstanding for that address. \retval -2 Address not found, query generated. @@ -338,7 +338,7 @@ int net_arp_lookup(netif_t *nif, const uint8_t ip_in[4], uint8_t mac_out[6], \param nif The network device in use. \param ip_out Storage for the IPv4 address. \param mac_in The MAC address to look up. - + \retval 0 On success. \retval -1 On failure. */ @@ -350,7 +350,7 @@ int net_arp_revlookup(netif_t *nif, uint8_t ip_out[4], const uint8_t mac_in[6]); \param nif The network device in use. \param pkt The packet received. \param len The length of the packet. - + \retval 0 On success (no error conditions defined). */ int net_arp_input(netif_t *nif, const uint8_t *pkt, int len); @@ -360,7 +360,7 @@ int net_arp_input(netif_t *nif, const uint8_t *pkt, int len); \param nif The network device to use. \param ip The IP to query. - + \retval 0 On success (no error conditions defined). */ int net_arp_query(netif_t *nif, const uint8_t ip[4]); @@ -374,12 +374,12 @@ int net_arp_query(netif_t *nif, const uint8_t ip[4]); \param nif The network device in use. \param pkt The packet received. \param len The length of the packet, in bytes. - + \return 0 on success, <0 on failure. */ typedef int (*net_input_func)(netif_t *nif, const uint8_t *pkt, int len); -/** \brief Where will input packets be routed? +/** \brief Where will input packets be routed? \ingroup networking_drivers */ extern net_input_func net_input_target; @@ -394,7 +394,7 @@ extern net_input_func net_input_target; \param device The network device submitting packets. \param data The packet to submit. \param len The length of the packet, in bytes. - + \return 0 on success, <0 on failure. */ int net_input(netif_t *device, const uint8_t *data, int len); @@ -403,7 +403,7 @@ int net_input(netif_t *device, const uint8_t *data, int len); \ingroup networking_drivers \param t The new target callback. - + \return The old target. */ net_input_func net_input_set_target(net_input_func t); @@ -448,13 +448,13 @@ extern net_echo_cb net_icmp_echo_cb; \param seq A packet sequence number. \param data Data to send with the packet. \param size The size of the data to send. - + \return 0 on success, <0 on failure. */ int net_icmp_send_echo(netif_t *net, const uint8_t ipaddr[4], uint16_t ident, uint16_t seq, const uint8_t *data, size_t size); -/** \defgroup networking_icmp_unreach Unreachable Values +/** \defgroup networking_icmp_unreach Unreachable Values \brief Valid values for net_icmp_send_dest_unreach(). \ingroup networking_icmpv4 @{ @@ -470,7 +470,7 @@ int net_icmp_send_echo(netif_t *net, const uint8_t ipaddr[4], uint16_t ident, \param net The network device to use. \param code The type of message this is. \param msg The message that caused this error. - + \return 0 on success, <0 on failure. */ int net_icmp_send_dest_unreach(netif_t *net, uint8_t code, const uint8_t *msg); @@ -483,11 +483,11 @@ int net_icmp_send_dest_unreach(netif_t *net, uint8_t code, const uint8_t *msg); /** \brief Send an ICMP Time Exceeded packet in reply to the given message. \ingroup networking_icmp - + \param net The network device to use. \param code The type of message this is. \param msg The message that caused this error. - + \return 0 on success, <0 on failure. */ int net_icmp_send_time_exceeded(netif_t *net, uint8_t code, const uint8_t *msg); @@ -523,15 +523,15 @@ net_ipv4_stats_t net_ipv4_get_stats(void); \ingroup networking_ipv4 \param addr Array of IP address octets. - + \return The address, in host byte order. */ -uint32_t net_ipv4_address(const uint8_t addr[4]); +uint32_t __pure net_ipv4_address(const uint8_t addr[4]); /** \brief Parse an IP address that is packet into a uint32 into an array of the individual bytes. \ingroup networking_ipv4 - + \param addr The full address, in host byte order. \param out The output buffer. */ @@ -547,7 +547,7 @@ void net_ipv4_parse_address(uint32_t addr, uint8_t out[4]); /** \brief ICMPv6 echo reply callback type. \ingroup networking_icmpv6 - + \param ip The IPv6 address the reply is from. \param seq The sequence number of the packet. \param delta_us The time difference, in microseconds. @@ -566,14 +566,14 @@ extern net6_echo_cb net_icmp6_echo_cb; /** \brief Send an ICMPv6 Echo (PING6) packet to the specified device. \ingroup networking_icmpv6 - + \param net The network device to use. \param dst The address to send to. \param ident A packet identifier. \param seq A packet sequence number. \param data Data to send with the packet. \param size Length of the data, in bytes. - + \return 0 on success, <0 on failure. */ int net_icmp6_send_echo(netif_t *net, const struct in6_addr *dst, uint16_t ident, @@ -581,12 +581,12 @@ int net_icmp6_send_echo(netif_t *net, const struct in6_addr *dst, uint16_t ident /** \brief Send a Neighbor Solicitation packet on the specified device. \ingroup networking_icmpv6 - + \param net The network device to use. \param dst The destination address. \param target The target address. \param dupdet 1 if this is for duplicate detection. - + \return 0 on success, <0 on failure. */ int net_icmp6_send_nsol(netif_t *net, const struct in6_addr *dst, @@ -594,12 +594,12 @@ int net_icmp6_send_nsol(netif_t *net, const struct in6_addr *dst, /** \brief Send a Neighbor Advertisement packet on the specified device. \ingroup networking_icmpv6 - + \param net The network device to use. \param dst The destination address. \param target The target address. \param sol 1 if solicited, 0 otherwise. - + \return 0 on success, <0 on failure. */ int net_icmp6_send_nadv(netif_t *net, const struct in6_addr *dst, @@ -607,9 +607,9 @@ int net_icmp6_send_nadv(netif_t *net, const struct in6_addr *dst, /** \brief Send a Router Solicitation request on the specified interface. \ingroup networking_icmpv6 - + \param net The network device to use. - + \return 0 on success, <0 on failure. */ int net_icmp6_send_rsol(netif_t *net); @@ -638,7 +638,7 @@ int net_icmp6_send_rsol(netif_t *net); \param code The type of message this is. \param ppkt The message that caused this error. \param psz Size of the original message. - + \return 0 on success, <0 on failure. */ int net_icmp6_send_dest_unreach(netif_t *net, uint8_t code, const uint8_t *ppkt, @@ -648,7 +648,7 @@ int net_icmp6_send_dest_unreach(netif_t *net, uint8_t code, const uint8_t *ppkt, \brief Time exceeded codes for ICMPv6 \ingroup networking_icmpv6 - Only fragment reassembly time exceeded makes sense + Only fragment reassembly time exceeded makes sense @{ */ @@ -658,12 +658,12 @@ int net_icmp6_send_dest_unreach(netif_t *net, uint8_t code, const uint8_t *ppkt, /** \brief Send a time exceeded message on the specified interface. \ingroup networking_icmpv6 - + \param net The network device to use. \param code The error code. \param ppkt The message that caused this error. \param psz Size of the original packet. - + \return 0 on success, <0 on failure. */ int net_icmp6_send_time_exceeded(netif_t *net, uint8_t code, const uint8_t *ppkt, @@ -681,13 +681,13 @@ int net_icmp6_send_time_exceeded(netif_t *net, uint8_t code, const uint8_t *ppkt /** \brief Send an ICMPv6 Parameter Problem about the given packet. \ingroup networking_icmpv6 - + \param net The network device to use. \param code The error code. \param ptr Where in the packet is the error? \param ppkt The message that caused the error. \param psz Size of the original packet. - + \return 0 on success, <0 on failure. */ int net_icmp6_send_param_prob(netif_t *net, uint8_t code, uint32_t ptr, @@ -795,13 +795,13 @@ typedef struct net_udp_stats { } net_udp_stats_t; /** \brief Retrieve statistics from the UDP layer. - + \return The global UDP stats struct. */ net_udp_stats_t net_udp_get_stats(void); /** \brief Init UDP. - + \retval 0 On success (no error conditions defined). */ int net_udp_init(void); @@ -838,25 +838,25 @@ void net_tcp_shutdown(void); */ /** \brief Calculate a "little-endian" CRC-32 over a block of data. - + \param data The data to calculate over. \param size The size of the data, in bytes. - + \return The calculated CRC-32. */ -uint32_t net_crc32le(const uint8_t *data, int size); +uint32_t __pure net_crc32le(const uint8_t *data, int size); /** \brief Calculate a "big-endian" CRC-32 over a block of data. - + \param data The data to calculate over. \param size The size of the data, in bytes. - + \return The calculated CRC-32. */ -uint32_t net_crc32be(const uint8_t *data, int size); +uint32_t __pure net_crc32be(const uint8_t *data, int size); /** \brief Calculate a CRC16-CCITT over a block of data. - + \note Based on code found online at http://www.ccsinfo.com/forum/viewtopic.php?t=24977 @@ -866,10 +866,10 @@ uint32_t net_crc32be(const uint8_t *data, int size); return value from this function (if continuing a previous calculation) or some initial seed value (typically 0xFFFF or 0x0000). - + \return The calculated CRC16-CCITT. */ -uint16_t net_crc16ccitt(const uint8_t *data, int size, uint16_t start); +uint16_t __pure net_crc16ccitt(const uint8_t *data, int size, uint16_t start); /** @} */ @@ -921,14 +921,14 @@ void net_multicast_shutdown(void); /***** net_core.c *********************************************************/ -/** \brief Interface list; note: do not manipulate directly! +/** \brief Interface list; note: do not manipulate directly! \ingroup networking_drivers */ extern struct netif_list net_if_list; /** \brief Function to retrieve the interface list. \ingroup networking_drivers - + \warning Do not manipulate what this returns to you! @@ -936,8 +936,8 @@ extern struct netif_list net_if_list; */ struct netif_list * net_get_if_list(void); -/** \brief The default network device, used with sockets (read-only). - \ingroup networking_drivers +/** \brief The default network device, used with sockets (read-only). + \ingroup networking_drivers */ extern netif_t *net_default_dev; @@ -945,7 +945,7 @@ extern netif_t *net_default_dev; \ingroup networking_drivers \param n The device to set as default. - + \return The old default device. */ netif_t *net_set_default(netif_t *n); @@ -963,14 +963,14 @@ int net_reg_device(netif_t *device); \ingroup networking_drivers \param device The device to unregister. - + \return 0 on success, <0 on failure. */ int net_unreg_device(netif_t *device); /** \brief Init network support. \ingroup networking_drivers - + \note To auto-detect the IP address to assign to the default device (i.e, over DHCP or from the flashrom on the Dreamcast), pass 0 as the IP parameter. @@ -982,7 +982,7 @@ int net_unreg_device(netif_t *device); */ int net_init(uint32_t ip); -/** \brief Shutdown network support. +/** \brief Shutdown network support. \ingroup networking_drivers */ void net_shutdown(void); diff --git a/kernel/arch/dreamcast/fs/vmufs.c b/kernel/arch/dreamcast/fs/vmufs.c index 726c223f..f80b8613 100644 --- a/kernel/arch/dreamcast/fs/vmufs.c +++ b/kernel/arch/dreamcast/fs/vmufs.c @@ -49,7 +49,7 @@ Function comments located in vmufs.h. static mutex_t mutex; /* Convert a decimal number to BCD; max of two digits */ -static uint8 dec_to_bcd(int dec) { +static uint8 __pure dec_to_bcd(int dec) { uint8 rv = 0; rv = dec % 10; diff --git a/kernel/arch/dreamcast/hardware/maple/controller.c b/kernel/arch/dreamcast/hardware/maple/controller.c index eb60f696..e20f21fe 100644 --- a/kernel/arch/dreamcast/hardware/maple/controller.c +++ b/kernel/arch/dreamcast/hardware/maple/controller.c @@ -51,13 +51,13 @@ static TAILQ_HEAD(cont_btn_callback_list, cont_callback_params) btn_cbs; static mutex_t btn_cbs_mtx = MUTEX_INITIALIZER; /* Check whether the controller has EXACTLY the given capabilities. */ -int cont_is_type(const maple_device_t *cont, uint32_t type) { +int __pure cont_is_type(const maple_device_t *cont, uint32_t type) { return cont ? cont->info.function_data[CONT_FUNCTION_DATA_INDEX] == type : -1; } /* Check whether the controller has at LEAST the given capabilities. */ -int cont_has_capabilities(const maple_device_t *cont, uint32_t capabilities) { +int __pure cont_has_capabilities(const maple_device_t *cont, uint32_t capabilities) { return cont ? ((cont->info.function_data[CONT_FUNCTION_DATA_INDEX] & capabilities) == capabilities) : -1; } diff --git a/kernel/arch/dreamcast/hardware/ubc.c b/kernel/arch/dreamcast/hardware/ubc.c index ba59bc9e..4e96c666 100755 --- a/kernel/arch/dreamcast/hardware/ubc.c +++ b/kernel/arch/dreamcast/hardware/ubc.c @@ -76,7 +76,7 @@ static struct ubc_channel_state { } channel_state[ubc_channel_count] = { 0 }; /* Translates ubc_access_t to BBR.ID field format. */ -inline static uint8_t get_access_mask(ubc_access_t access) { +inline static uint8_t __pure get_access_mask(ubc_access_t access) { switch(access) { case ubc_access_either: return 0x3; @@ -86,7 +86,7 @@ inline static uint8_t get_access_mask(ubc_access_t access) { } /* Translates ubc_rw_t to BBR.RW field format. */ -inline static uint8_t get_rw_mask(ubc_rw_t rw) { +inline static uint8_t __pure get_rw_mask(ubc_rw_t rw) { switch(rw) { case ubc_rw_either: return 0x3; @@ -96,7 +96,7 @@ inline static uint8_t get_rw_mask(ubc_rw_t rw) { } /* Translates ubc_address_mask_t to BASR.BAM field format. */ -inline static uint8_t get_address_mask(ubc_address_mask_t addr_mask) { +inline static uint8_t __pure get_address_mask(ubc_address_mask_t addr_mask) { switch(addr_mask) { case ubc_address_mask_all: return 3; diff --git a/kernel/arch/dreamcast/include/arch/arch.h b/kernel/arch/dreamcast/include/arch/arch.h index cbc731cc..972bbd6a 100644 --- a/kernel/arch/dreamcast/include/arch/arch.h +++ b/kernel/arch/dreamcast/include/arch/arch.h @@ -340,7 +340,7 @@ int hardware_sys_mode(int *region); \return A pointer to the banner string. */ -const char *kos_get_banner(void); +const char * __pure kos_get_banner(void); /** \brief Retrieve the license information for the compiled copy of KOS. \ingroup attribution @@ -351,7 +351,7 @@ const char *kos_get_banner(void); ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |