mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 00:38:31 +00:00
Make some foss compatibility improvements
This commit is contained in:
parent
8111462789
commit
5af19b7eed
34 changed files with 319 additions and 48 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue