-
Notifications
You must be signed in to change notification settings - Fork 555
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
Add lock_definitions.h #22283
base: blead
Are you sure you want to change the base?
Add lock_definitions.h #22283
Conversation
This file is intended to insulate C code from thread issues, when used as directed.
0a50c29
to
167d080
Compare
if $entry->{locks} || $entry->{categories}; | ||
print $l <<~EOT; | ||
#${dindent}define ${USE}_LOCK \\ | ||
#${dindent} error_${use}_not_suitable_for_multi-threaded_operation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this generate:
# error_foo_not suitable...
rather than
# error foo_not suitable...
?
The first may produce an error, but it might not include the text of the symbol.
The second will produce the requested message, though it might be better to quote it, which will prevent macro replacement, allowing you to avoid the need for all_the_underscores
.
# previous preprocessor lines. If there was no "#else" line, macros expanding | ||
# to no-ops are automatically generated for the #else case. | ||
|
||
__DATA__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two issues, in general:
- This defines a huge number of names most of which will never be used, and have a potential to conflict with names from other libraries.
I think this should add a PERL_
prefix to each lock name.
- This defines separate symbols for each function in a closely related group of functions, for example
dbm_*
and any read locale function.
The separate macros imply the need to do each of those locks, even though in some cases it doesn't make sense, eg. if I do a dbm_delete(), I really don't want to release the lock until I do dbm_error()
.
I think macros should be defined for groups of such functions where it makes sense, eg. a single macro for the dbm_*
functions, and just document the need for LC_*_LOCK
for locale reading functions etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I share @tonycoz's skepticism as to whether the addition of this header file is necessary or desirable.
This file is intended to insulate C code from thread issues, when used as directed.