Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • mesa mesa
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,033
    • Issues 3,033
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 993
    • Merge requests 993
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • MesaMesa
  • mesamesa
  • Merge requests
  • !19252

RFC: util: Add IS_ALIGNED macro

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Alyssa Rosenzweig requested to merge alyssa/mesa:util/is-aligned-rfc into main Oct 22, 2022
  • Overview 2
  • Commits 2
  • Pipelines 2
  • Changes 6

This idiom comes up a lot, add a macro to make it clearer. Questions to bike shed:

  • Name. IS_ALIGNED? Or simply ALIGNED? The kernel uses IS_ALIGNED.
  • Must alignments be a power-of-two? This influences whether we define with & or with %
  • Once we settle on the name and semantics, should the tree be updated to use the new macro instead of open-coding the checks? This would be an easy Coccinelle script but I don't want to stomp on people's code. (Right now, just a few representative uses in Panfrost are changed, there are piles more within Panfrost alone that I didn't bother to change in case we bike shed the name.)

For comparison, the kernel definition is

#define IS_ALIGNED(x, a)		(((x) & ((typeof(x))(a) - 1)) == 0)
Edited Oct 22, 2022 by Alyssa Rosenzweig
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: util/is-aligned-rfc