Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
Where is glibc's code for setjmp?

I was interested in what exactly setjmp does at least in x86_64 linux, so I searched through glibc's source code, but I cannot really find where the register saving is done. Could you explain what is going on here?

setjmp.h

extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROWNL;
#define setjmp(env)     _setjmp (env)

bsd-_setjmp.c

int
_setjmp (jmp_buf env)
{
  return __sigsetjmp (env, 0);
}

libc_hidden_def (_setjmp)

setjmp.c

int
__libc_sigsetjmp (jmp_buf env, int savemask)
{
  __sigjmp_save (env, savemask);
  __set_errno (ENOSYS);
  return 0;
}

weak_alias (__libc_sigsetjmp, __sigsetjmp)
stub_warning (__sigsetjmp)

sigjmp.c

int
__sigjmp_save (sigjmp_buf env, int savemask)
{
  env[0].__mask_was_saved = (savemask &&
                             __sigprocmask (SIG_BLOCK, (sigset_t *) NULL,
                                            &env[0].__saved_mask) == 0);
  return 0;
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

setjmp is a macro which calls _setjmp. For the x86_64 architecture, it's defined in ../sysdeps/x86_64/bsd-_setjmp.S. _setjmp will then call __sigsetjmp, defined in ../sysdeps/x86_64/setjmp.S; this function is strictly platform dependent and needs to be implemented in assembly.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!