rtapi_div_u64(3rtapi)

πŸ“¦
version 2.9.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ rtapi_div_u64 ✨

okay bestie, welcome to the rtapi manual, section 3 πŸŽ€ this one's called rtapi_div_u64 and it's literally just... unsigned division of a 64-bit number by a 32-bit number. that's it. that's the whole vibe. πŸ’…


🌸 NAME 🌸

rtapi_div_u64 β€” unsigned division of a 64-bit number by a 32-bit number


πŸ¦‹ SYNTAX πŸ¦‹

no cap, there are four flavors and you get to pick your fighter:

__u64 rtapi_div_u64_rem(__u64 dividend, __u32 divisor, __u32 *remainder)

__u64 rtapi_div_u64(__u64 dividend, __u32 divisor)

__s64 rtapi_div_s64(__s64 dividend, __s32 divisor)

__s64 rtapi_div_s64_rem(__s64 dividend, __s32 divisor, __s32 *remainder)

πŸ’– ARGUMENTS πŸ’–

  • dividend β€” the value to be divided. the main character of this operation, fr fr.
  • divisor β€” the value to divide by. the one doing the dividing. iconic behavior honestly.
  • remainder β€” pointer to the location to store the remainder. 🫢 this may not be a NULL pointer β€” like, do not. if you don't actually want the remainder, just call rtapi_div_u64 or rtapi_div_s64 instead and save yourself the trouble, bestie.

🌈 DESCRIPTION 🌈

perform integer division (and optionally compute the remainder) with a 64-bit dividend and 32-bit divisor. that's the tea. πŸ“ it's giving "math but make it realtime."


⭐ RETURN VALUE ⭐

the result of integer division of dividend / divisor. πŸ’« and in the versions that take the remainder argument, the remainder gets stored in the pointed-to location. so you get two-for-one, lowkey a steal.


πŸ‘‘ NOTES πŸ‘‘

if the result of the division does not fit in the return type, the result is undefined. πŸ’€ that's not a vibe check you want to fail, so be careful.

this function exists because in kernel space the use of the division operator on a 64-bit type can lead to an undefined symbol such as __umoddi3 when the module is loaded. 😭 so yeah, this whole thing is basically a workaround so your module doesn't explode on load. iykyk.


🧚 REALTIME CONSIDERATIONS 🧚

  • may be called from init/cleanup code and from within realtime tasks. ✨
  • available in non-realtime components. 🫢

and that's the whole page, bestie!! 🌸 this was the LinuxCNC Documentation version, dated 2006-10-12, for rtapi_div_u64(3rtapi). slay, go divide something. πŸ’œπŸŽ€

πŸ“¦ where this page comes from