Skip to content

Question: Naming of C macros #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nominolo opened this issue Sep 30, 2017 · 2 comments
Closed

Question: Naming of C macros #84

nominolo opened this issue Sep 30, 2017 · 2 comments

Comments

@nominolo
Copy link
Contributor

I think for convenience we also want to implement not just the core intrinsics but also convenience macros. For example, there are a number of convenience macros around the _mm_getcsr intrinsic. For the following macro:

#define _MM_GET_EXCEPTION_MASK() (_mm_getcsr() & _MM_MASK_MASK)

In Rust, we would define the same thing as a function:

#[inline(always)]
#[target_feature = "+sse"]
pub unsafe fn _MM_GET_EXCEPTION_MASK() -> u32 {
    _mm_getcsr() & _MM_MASK_MASK;
}

But in Rust we normally wouldn't use all-uppercase for a function name. So, the question here is: Should we

  • use C naming convention for familiarity/compatibility with the C API, or
  • use Rust naming convention for Rust-internal consistency?

Personally, I'm leaning towards the second option (i.e., lower-case), because most search tools are case-insensitive, so anyone who knows the name will be able to find it.

@alexcrichton
Copy link
Member

I might lean a bit towards the C naming convention, as basically everything in this crate is intended to follow the same conventions as C as opposed to following Rust conventions. If we were following Rust conventions we'd probably be using the module system and avoiding weird names :)

nominolo added a commit to nominolo/stdsimd that referenced this issue Oct 4, 2017
alexcrichton pushed a commit that referenced this issue Oct 5, 2017
* Add _mm_sfence

* Add _mm_getcsr/_mm_setcsr and convenience wrappers

* Use test::black_box to simplify tests

* Use uppercase naming for C-macro equivalents

Discussed at #84
@alexcrichton
Copy link
Member

In #88 ended up landing the upper case names, so closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants