Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: Re: [OMPI devel] "prefix" style guideline
From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2009-07-09 13:31:06


On Jul 8, 2009, at 2:17 PM, Eugene Loh wrote:

> In https://svn.open-mpi.org/trac/ompi/wiki/CodingStyle , there is
> mention of "the prefix rule." What is this rule?
>

In components, you have to prefix all public symbols with
"<layer>_<framework>_<component>", where <layer> is one of "mca",
"ompi", "orte", or "opal" ("mca" used to be used, but it has fallen
out of favor; "ompi", "orte", and "opal" are a bit more common these
days -- but still the bulk of existing code probably uses "mca").

> Let me ask specifically this. If I look at
> https://svn.open-mpi.org/source/xref/ompi_1.3/ompi/mca/btl/sm/btl_sm_endpoint.h
> #46
> , I see a declaration for "void btl_sm_add_pending". Should that
> really
> have an "mca_" appended to the name?
>

Prepended. If it's a public symbol, yes. If it's not public, then it
can be named whatever you want.

> Don't worry about the
> particulars. I'm about to change this code. I'm just asking about
> the
> principles. Because this function is callable from a file other than
> where it is defined, should the prefix be "mca_btl_sm_" or does
> "btl_sm_" suffice?
>
> Similarly, I see a btl_sm_pending_send_item_t type. Should that also
> have mca_ appended?
>
> Ouch, and this one: sm_fifo_t. (This one is my fault.) I assume it
> should be mca_btl_sm_fifo_t, yes?
>

Correct on all counts -- when in doubt, add the prefix. It never
hurts to add the prefix.

Most plaforms will obey the DECLSPEC stuff these days, so this is
mostly moot for non-DECLSPEC'ed symbols. But there probably are a
handful of platforms/compilers out there that make symbols public even
though we don't DECLSPEC them. That being said, I haven't checked in
a while to know what the status is in this regard (e.g., if only
ancient compilers don't obey DECLSPEC, etc.).

> P.S. Shouldn't the "prefix rule" be explained in the "coding style"
> twiki page?
>

Why? Then we'd be *clear*...

:-p

I'd volunteer to add something, but I'm heading out on vacation
tomorrow afternoon, and have a bagillion things to finish before then
-- would you mind adding something?

-- 
Jeff Squyres
Cisco Systems