hal_type_t(3hal)

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

πŸ’– hal_type_t β€” the typedefs for HAL datatypes, bestie πŸ’–

okay so this is the hal_type_t page from section 3hal of the HAL manual, and it's basically the whole cast list of HAL datatypes. like, the friend group. every type gets its moment, no cap. ✨


🌸 NAME 🌸

hal_type_t β€” typedefs for HAL datatypes. that's it, that's the vibe. πŸŽ€


✨ DESCRIPTION ✨

here's the roster, in order, with zero skips. πŸ’…

  • hal_bool β€” a type which may have a value of 0 or nonzero.
  • hal_bit_t β€” a volatile type which may have a value of 0 or nonzero.
  • hal_s32_t β€” a volatile type which may have a value from -2147483648 to 2147483647.
  • hal_u32_t β€” a volatile type which may have a value from 0 to 4294967295.
  • hal_port_t β€” a volatile handle to a port object. used with the hal_port* functions. iykyk 🫢
  • hal_float_t β€” a volatile floating-point type, which typically has the same precision and range as the C type double.
  • real_t β€” a nonvolatile floating-point type with at least as much precision as hal_float_t.
  • ireal_t β€” a nonvolatile unsigned integral type the same size as hal_float_t.

and then there's the enum itself:

typedef enum hal_type_t;

and its members, each one a lil legend: πŸ‘‘

  • HAL_BIT β€” corresponds to the type hal_bit_t.
  • HAL_FLOAT β€” corresponds to the type hal_float_t.
  • HAL_S32 β€” corresponds to the type hal_s32_t.
  • HAL_U32 β€” corresponds to the type hal_u32_t.

πŸŽ€ NOTES πŸŽ€

okay this is the part where i hold your hand, because there's a trap here and it will humble you. 😭

hal_bit_t is typically a typedef to an integer type whose range is larger than just 0 and 1. so when you're testing the value of a hal_bit_t, never compare it to 1. just don't. instead, prefer one of these:

  • if(b)
  • if(b != 0)

periodt. πŸ’…


it's often useful to refer to a type that can represent all the values as a HAL type, but without the volatile qualifier. the following types correspond with the HAL types:

  • hal_bit_t β†’ int
  • hal_s32_t β†’ __s32
  • hal_u32_t β†’ __u32
  • hal_float_t β†’ hal_real_t
  • hal_port_t β†’ int

⚠️ take care not to use the types s32 and u32. these will compile in kernel modules but not in userspace, and not for realtime components when using uspace realtime. it's giving "works on my machine" and then it does NOT. πŸ’€

🌈 SEE ALSO 🌈


and that's the whole page, bestie!! πŸ¦‹ go forth and typedef responsibly. this one's brought to you by LinuxCNC Documentation, dated 2006-10-12 β€” yeah she's an elder but she ate and left no crumbs. πŸ“βœ¨πŸ’œ