Repository navigation
Conversation
|
Is Some quick googling suggests:
|
| } | ||
| lua_pushstring(L, buf); | ||
| return 1; | ||
| } /* ct_setname() */ |
|
Oh, you're right, that's quite a mess. I've added checks to explicitly support the relevant functions on Linux, the BSDs and OS X. |
daurnimator
left a comment
There was a problem hiding this comment.
Note that config.h.guess is from the autoguess project (https://github.com/wahern/autoguess/).
You may want to send your changes there?
| #if HAVE_PTHREAD_SETNAME | ||
| static int ct_setname(lua_State *L) { | ||
| struct cthread *ct = ct_checkthread(L, 1); | ||
| char *name = luaL_checkstring(L, 2); |
There was a problem hiding this comment.
there is too much whitespace here.
| #elif HAVE_MACOSX_PTHREAD | ||
| if (pthread_equal(ct->id, pthread_self())) { | ||
| lua_pushboolean(L, 0); | ||
| lua_pushliteral(L, "thread name cannot be set from outside the thread on this platform"); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| switch(rc) { | ||
| case 0: | ||
| lua_pushboolean(L, 1); | ||
| return 1; | ||
| case ERANGE: | ||
| lua_pushboolean(L, 0); | ||
| lua_pushliteral(L, "thread name too long"); | ||
| lua_pushinteger(L, rc); | ||
| return 3; | ||
| case EINVAL: | ||
| lua_pushboolean(L, 0); | ||
| lua_pushliteral(L, "invalid parameter when setting thread name"); | ||
| lua_pushinteger(L, rc); | ||
| return 3; | ||
| case ENOMEM: | ||
| lua_pushboolean(L, 0); | ||
| lua_pushliteral(L, "out of memory when setting thread name"); | ||
| lua_pushinteger(L, rc); | ||
| return 3; | ||
| } |
There was a problem hiding this comment.
And what if rc is something else: needs a default option
Adds wrappers for
pthread_setname_npandpthread_getname_npto the thread metatable. It's quite useful to be able to name long-running threads!