Skip to content
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

Atomics pose restrictions on consumer #603

Open
vlmarek opened this issue Feb 24, 2022 · 0 comments
Open

Atomics pose restrictions on consumer #603

vlmarek opened this issue Feb 24, 2022 · 0 comments

Comments

@vlmarek
Copy link

vlmarek commented Feb 24, 2022

Hi,

While packaging jansson for Solaris we found out that the use of atomic operations complicates things. The configure script detects what kind of atomic implementation is available. Either _atomic* , or _sync* or none. It records the outcome as defined/undefined macros JSON_HAVE_ATOMIC_BUILTINS / JSON_HAVE_ATOMIC_BUILTINS and defines JSON_INTERNAL_INCREF / JSON_INTERNAL_DECREF accordingly in jansson_config.h. And starts to use the atomic functions internally in function json_incref / json_decref.

The problem is that it silently expects that the consumer will be able to use the same atomic primitives. That might easily not be the case if you use different compiler and/or you are forced to use C89 standard.

There are two workarounds

  • make every consumer undefine JSON_HAVE_ATOMIC_BUILTINS / JSON_HAVE_SYNC_BUILTINS to make the consumer not use atomics at all
  • patch jansson sources to remove atomic support.

Would it perhaps make more sense to make json_incref / json_decref a real functions (exported by the dynamic library) instead of having them as macros as they are now?

Thank you

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

1 participant