Make some foss compatibility improvements

This commit is contained in:
Justine Tunney 2022-10-14 09:52:35 -07:00
parent 8111462789
commit 5af19b7eed
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
34 changed files with 319 additions and 48 deletions

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/kprintf.h"
#include "libc/runtime/runtime.h"
#include "libc/str/path.h"
#include "libc/str/str.h"
@ -23,12 +24,14 @@
#include "libc/thread/thread.h"
const char *__sem_name(const char *name, char path[hasatleast PATH_MAX]) {
const char *res;
if (_isabspath(name)) {
return name;
res = name;
} else {
strlcpy(path, kTmpPath, PATH_MAX);
strlcat(path, ".sem-", PATH_MAX);
strlcat(path, name, PATH_MAX);
return path;
res = path;
}
return res;
}

View file

@ -66,7 +66,12 @@ sem_t *sem_open(const char *name, int oflag, ...) {
}
sem = mmap(0, sizeof(sem_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (sem != MAP_FAILED) sem->sem_pshared = true;
if (sem != MAP_FAILED) {
sem->sem_pshared = true;
} else {
sem = SEM_FAILED;
}
_npassert(!close(fd));
return sem;
}