[petsc-dev] Reminder: *every* symbol with extern linkage *must* be namespaced

Jed Brown jedbrown at mcs.anl.gov
Sat Mar 17 10:46:24 CDT 2012


On Sat, Mar 17, 2012 at 10:17, Mark F. Adams <mark.adams at columbia.edu>wrote:

> What does namespaced mean exactly?
>

The symbol has to contain (usually prefixed) an identifier that makes it
unique to PETSc. Currently this is Petsc, Vec, IS, Mat, DM, AO, PC, KSP,
SNES, TS, EventPerfLog, EventRefLog, and Characteristic.

Vec and Mat are the most likely to conflict with user code, but also the
most annoying to type if we renamed them all as PetscVec. Others would have
low impact and should be changed. We've had this discussion before and it's
not really what I wanted to bring up. The point is that if you define a
symbol with extern linkage that does not have one of the prefixes above, it
should be considered a bug.


> *
> *
> On Mar 17, 2012, at 10:58 AM, Jed Brown wrote:
>
> *Every* symbol (both functions and data) with extern linkage *must* be
> namespaced to avoid link- or run-time conflicts when the user (or any other
> library to be used in the same application) defines their own variable
> called "rankkey" or "actions" or "objects" or "ListCreate" or
> "createLevel", etc. No exceptions.
>
> Either use static linkage or namespace the symbols. Some old code was
> sloppy about this (and needs to be fixed), but we really need to be careful
> to never do this is new code.
>
> You can build a libpetsc.a (--with-shared-libraries=0) and search for any
> defined symbols (T, B, R, C, D) that are not namespaced. Some examples
> below.
>
> *pthread.c:*
> 00000000000004c5 T DoCoreAffinity
> 0000000000000232 T FuncFinish
> 0000000000000010 B MainThreadCoreAffinity
> 0000000000000100 R ThreadAffinityPolicyTypes
> 0000000000000008 B ThreadCoreAffinity
> 0000000000000060 R ThreadSynchronizationTypes
> 0000000000000004 C rankkey
> 0000000000000018 B threadranks
>
> plog.c:
> 0000000000000000 B actions
> 0000000000000010 B logActions
> 0000000000000014 B logObjects
> 0000000000000038 D maxActions
> 000000000000003c D maxObjects
> 0000000000000018 B numActions
> 000000000000001c B numObjects
> 0000000000000020 B numObjectsDestroyed
> 0000000000000008 B objects
> 0000000000000040 D traceblanks
> 00000000000000d8 B tracefile
> 00000000000000e0 B tracelevel
> 0000000000000060 D tracespace
> 00000000000000e8 B tracetime
>
> *ctetgen.c:*
> 000000000000ade7 T ArrayPoolCreate
> 000000000000b979 T ArrayPoolDestroy
> 000000000000b0cf T ArrayPoolGetBlock
> 000000000000b6f7 T ArrayPoolNewIndex
> 000000000000ac41 T ArrayPoolRestart
> 0000000000006cfe T ListAppend
> 00000000000082ec T ListClear
> 00000000000069c7 T ListCreate
> 00000000000077ad T ListDelete
> 0000000000008491 T ListDestroy
> 0000000000007ae2 T ListHasItem
> 000000000000718e T ListInsert
> 0000000000007ea0 T ListItem
> 0000000000007cf5 T ListLength
> 00000000000080c6 T ListSetItem
> 00000000000096af T MemoryPoolAlloc
> 000000000000a415 T MemoryPoolCreate
> 0000000000009a9d T MemoryPoolDealloc
> 000000000000a827 T MemoryPoolDestroy
> 000000000000a1ed T MemoryPoolRestart
> 0000000000009c6a T MemoryPoolTraversalInit
> 0000000000009e6e T MemoryPoolTraverse
> 0000000000008868 T QueueCreate
> 0000000000009324 T QueueDestroy
> 0000000000008c23 T QueueLength
> 00000000000090b0 T QueuePop
> 0000000000008dd5 T QueuePush
> 0000000000003f06 T lu_decmp
> 0000000000004303 T lu_solve
>
> *gamg.c/agg.c/geo.c/tools.c:*
> 0000000000000926 T createLevel
> 0000000000000050 C gamg_setup_events
> 00000000000054c6 T formProl0
> 0000000000002989 T smoothAggs
> 0000000000000629 T geo_mg_compare
> 00000000000012f0 T getGIDsOnSquareGraph
> 0000000000001292 T triangulateAndFormProl
> 0000000000000629 T createSimpleGraph
> 00000000000028fe T getDataWithGhosts
> 0000000000001415 T scaleFilterGrap
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120317/0071b419/attachment.html>


More information about the petsc-dev mailing list