Coder Social home page Coder Social logo

Comments (3)

daurnimator avatar daurnimator commented on May 24, 2024

Looks like https://github.com/keplerproject/lua-compat-5.3/blob/9cb6834fe07297ba79e7453978cf7e7d8d8c339a/c-api/compat-5.3.c#L36 should be change to just !defined(_GNU_SOURCE)

from lua-compat-5.3.

siffiejoe avatar siffiejoe commented on May 24, 2024

First, it should be !defined(_GNU_SOURCE). At least that's what the official headers use apparently (even though the manpage claims (_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE), probably to avoid this exact issue.

Second, we have another problem: It seems that we don't have a reliable way to detect whether we have the GNU version or the POSIX version of strerror_r. Checking the same preprocessor symbols might not do it, because those can change between inclusion of string.h and our tests.

At the moment I'm considering something like the following when a glibc is used:

char buffer[255] = { 0 };  /* zero initialized */
int myerrno = errno;
strerror_r(myerrno, buffer, sizeof(buffer));  /* use either version of strerror_r */
if (buffer[0] != '\0')
  return buffer; /* strerror_r wrote into our buffer */
else
  /* buffer is unchanged, so we probably have GNU strerror_r which returned a
   * static constant string. Chances are that strerror will return the same static
   * constant string and therefore be thread-safe. */
  return strerror(myerrno);

When I find time I'll take a look at the glibc sources to make sure that the last assumption at least holds for the current glibc version.

I'm open to other suggestions.

from lua-compat-5.3.

hishamhm avatar hishamhm commented on May 24, 2024

from lua-compat-5.3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.