Re: Calling libiptc API from a separate thread in a C program throws segmentati

On 2012-01-17, Richard Kettlewell <rjk@xxxxxxxxxxxxxxx> wrote:
Kaz Kylheku <kaz@xxxxxxxxxxx> writes:
Richard Kettlewell <rjk@xxxxxxxxxxxxxxx> wrote:

errno ends up indirected either way though (at least here).
"Either way" between which alternatives?

$ cat t.c
#include <errno.h>

int main() { return errno; }
$ gcc -E t.c|grep main
int main() { return (*__errno_location ()); }
$ gcc -pthread -E t.c|grep main
int main() { return (*__errno_location ()); }

I think you must have misread the condition in bits/errno.h.

Indeed I did. But what's shocking is how long ago that behavior changed, wow.

They have all the history back-ported into git.

It was in 1997 that checks for __USE_REENTRANT was dropped from there and other
numerous other places:;a=commit;f=sysdeps/unix/sysv/linux/bits/errno.h;h=19361cb768c280e47f2ca69ed63e1d75f332e592

In the commit comment, Drepper declared a policy:

``Don't use __USE_REENTRENT. All code must be prepared to be running in a
multi-threaded environment.''

So that's that. On glibc, -lpthread is basically enough. Everything is switched
to thread-safe by linkage to stub pthread routines that get overriden by the
real ones.

(I was just thinking that errno was still an exception.)

Relevant Pages

  • Re: strtol question
    ... >>supposed to return 0 and set endptr to s? ... >>I have run into an implementation (not gcc, ... it sets errno to ERANGE under this situation. ... The implementation under question is the Intel C++ compiler suite v8.0.055 ...
  • partition sizes
    ... The following packages are available: ... SMCgcc gcc ... errno 28, ... pkgadd: ERROR: attempt to process datastream failed ...
  • Re: The philosophy of errno
    ... >condition using errno. ... >What is the good programming for this? ... >set errno to the appropriate code in case of error ... compile this with gcc x.c ...
  • Re: Calling libiptc API from a separate thread in a C program throws segmentati
    ... $ cat t.c ... int main{return errno;} ... $ gcc -pthread -E t.c|grep main ...
  • Re: x86, ARM, PARISC, PPC, MIPS and Sparc folks please run this
    ... If it says the store buffer isn't coherent, ... is returned and `errno' is set. ... open_shared_memory_file (int use_tmp_file) ...