Perform minor fixups

One of those fixups is making sure that AF_LOCAL is equal to AF_UNIX on
the New Technology. See #122
This commit is contained in:
Justine Tunney 2021-03-13 19:39:17 -08:00
parent 83d0c3b870
commit 807706a099
14 changed files with 76 additions and 134 deletions

View file

@ -64,9 +64,6 @@ COSMOPOLITAN_C_START_
typedef int sig_atomic_t;
extern const struct sigset kSigsetFull;
extern const struct sigset kSigsetEmpty;
DIR *fdopendir(int) nodiscard;
DIR *opendir(const char *) nodiscard;
bool fileexists(const char *);

View file

@ -64,10 +64,6 @@ o/$(MODE)/libc/calls/raise.o: \
OVERRIDE_COPTS += \
$(NO_MAGIC)
o/$(MODE)/libc/calls/siggy.o: \
OVERRIDE_COPTS += \
-ffunction-sections
o/$(MODE)/libc/calls/sigenter-freebsd.o \
o/$(MODE)/libc/calls/sigenter-netbsd.o \
o/$(MODE)/libc/calls/sigenter-openbsd.o \

View file

@ -19,7 +19,6 @@
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/sysv/consts/at.h"
#include "libc/sysv/errfuns.h"
/**
* Changes owner and/or group of pathname.

View file

@ -1,7 +1,7 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
Copyright 2021 Justine Alexandra Roberts Tunney
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
@ -16,19 +16,11 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/macros.internal.h"
.source __FILE__
#include "libc/calls/calls.h"
// Sets effective user ID.
//
// @param %edi is user id
// @see setuid(), getauxval(AT_SECURE)
seteuid:push %rbp
mov %rsp,%rbp
.profilable
mov %edi,%esi
mov $-1,%edi
call setreuid
pop %rbp
ret
.endfn seteuid,globl
/**
* Sets effective group ID.
*/
int setegid(unsigned gid) {
return setregid(-1, gid);
}

View file

@ -1,7 +1,7 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
Copyright 2021 Justine Alexandra Roberts Tunney
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
@ -16,19 +16,11 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/macros.internal.h"
.source __FILE__
#include "libc/calls/calls.h"
// Sets effective group ID.
//
// @param %edi is group id
// @see setgid(), getauxval(AT_SECURE)
setegid:push %rbp
mov %rsp,%rbp
.profilable
mov %edi,%esi
mov $-1,%edi
call setregid
pop %rbp
ret
.endfn setegid,globl
/**
* Sets effective user ID.
*/
int seteuid(unsigned euid) {
return setreuid(-1, euid);
}

View file

@ -26,9 +26,10 @@
/**
* Changes program signal blocking state, e.g.:
*
* sigset_t oldmask;
* sigprocmask(SIG_BLOCK, &kSigsetFull, &oldmask);
* sigprocmask(SIG_SETMASK, &oldmask, NULL);
* sigset_t neu,old;
* sigfillset(&neu);
* sigprocmask(SIG_BLOCK, &neu, &old);
* sigprocmask(SIG_SETMASK, &old, NULL);
*
* @param how can be SIG_BLOCK (U), SIG_UNBLOCK (/), SIG_SETMASK (=)
* @param set is the new mask content (optional)

View file

@ -585,7 +585,7 @@ typedef uint64_t uintmax_t;
#endif
#ifndef unreachable
#if defined(__GNUC__) && !defined(__STRICT_ANSI)
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
#define unreachable __builtin_unreachable()
#else
#define unreachable \

View file

@ -1,36 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/macros.internal.h"
// Signal mask constant w/ no signal bits set.
.initbss 300,_init_kSigsetEmpty
kSigsetEmpty:
.rept NSIG / 64
.quad 0
.endr
.if NSIG % 64
.error "bad signal max"
.endif
.endobj kSigsetEmpty,globl
.previous
.init.start 300,_init_kSigsetEmpty
add $NSIG/8,%rdi
.init.end 300,_init_kSigsetEmpty
.source __FILE__

View file

@ -1,39 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/macros.internal.h"
// Signal mask constant w/ every signal bit set.
.initbss 300,_init_kSigsetFull
kSigsetFull:
.rept NSIG / 64
.quad 0
.endr
.if NSIG % 64
.error "bad signal max"
.endif
.endobj kSigsetFull,globl
.previous
.init.start 300,_init_kSigsetFull
or $-1,%rax
.rept NSIG / 64
stosq
.endr
.init.end 300,_init_kSigsetFull
.source __FILE__

View file

@ -19,6 +19,7 @@
#include "libc/bits/bits.h"
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/calls/sigbits.h"
#include "libc/calls/struct/sigset.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/symbols.internal.h"
@ -45,14 +46,15 @@
privileged void __hook(void *ifunc, struct SymbolTable *symbols) {
size_t i;
intptr_t addr;
sigset_t oldmask;
uint64_t code, mcode;
unsigned char *p, *pe;
sigset_t mask, oldmask;
const intptr_t kMcount = (intptr_t)&mcount;
const intptr_t kProgramCodeStart = (intptr_t)&_ereal;
const intptr_t kPrivilegedStart = (intptr_t)&__privileged_start;
const bool kIsBinaryAligned = !(kPrivilegedStart & (PAGESIZE - 1));
sigprocmask(SIG_BLOCK, &kSigsetFull, &oldmask);
sigfillset(&mask);
sigprocmask(SIG_BLOCK, &mask, &oldmask);
if (mprotect((void *)symbols->addr_base,
kPrivilegedStart - symbols->addr_base,
kIsBinaryAligned ? PROT_READ | PROT_WRITE

View file

@ -1105,7 +1105,7 @@ syscon sio SIOGIFINDEX 0x8933 0 0 0 0 0
syscon af AF_UNSPEC 0 0 0 0 0 0 # consensus
syscon af AF_UNIX 1 1 1 1 1 1 # consensus
syscon af AF_LOCAL 1 1 1 1 1 0 # unix consensus
syscon af AF_LOCAL 1 1 1 1 1 1 # consensus
syscon af AF_FILE 1 0 0 0 0 0
syscon af AF_INET 2 2 2 2 2 2 # consensus
syscon af AF_AX25 3 0 0 0 0 0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon af,AF_LOCAL,1,1,1,1,1,0
.syscon af,AF_LOCAL,1,1,1,1,1,1

View file

@ -17,6 +17,7 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/calls.h"
#include "libc/calls/sigbits.h"
#include "libc/calls/struct/sigset.h"
#include "libc/log/log.h"
#include "libc/nexgen32e/nexgen32e.h"
@ -33,9 +34,10 @@ TEST(fastdiv, test) {
}
TEST(dsleep, test) {
sigset_t oldmask;
long double t1, t2;
sigprocmask(SIG_BLOCK, &kSigsetFull, &oldmask);
sigset_t mask, oldmask;
sigfillset(&mask);
sigprocmask(SIG_BLOCK, &mask, &oldmask);
sched_yield();
t1 = dtime(CLOCK_MONOTONIC);
dsleep(0.001L);

View file

@ -1059,9 +1059,45 @@ static optimizesize void ReadKeyboard(void) {
break;
case '1':
switch (b[i++]) {
case '1':
switch (b[i++]) {
case '~': /* \e[11~ is F1 */
pf1_ = !pf1_;
break;
default:
break;
}
break;
case '2':
switch (b[i++]) {
case '~': /* \e[12~ is F2 */
pf2_ = !pf2_;
break;
default:
break;
}
break;
case '3':
switch (b[i++]) {
case '~': /* \e[13~ is F3 */
pf3_ = !pf3_;
break;
default:
break;
}
break;
case '4':
switch (b[i++]) {
case '~': /* \e[14~ is F4 */
pf4_ = !pf4_;
break;
default:
break;
}
break;
case '5':
switch (b[i++]) {
case '~': /* \e[20~ is F5 */
case '~': /* \e[15~ is F5 */
pf5_ = !pf5_;
break;
default:
@ -1070,7 +1106,7 @@ static optimizesize void ReadKeyboard(void) {
break;
case '7':
switch (b[i++]) {
case '~': /* \e[21~ is F6 */
case '~': /* \e[17~ is F6 */
pf6_ = !pf6_;
break;
default:
@ -1079,7 +1115,7 @@ static optimizesize void ReadKeyboard(void) {
break;
case '8':
switch (b[i++]) {
case '~': /* \e[22~ is F7 */
case '~': /* \e[18~ is F7 */
pf7_ = !pf7_;
break;
default:
@ -1088,7 +1124,7 @@ static optimizesize void ReadKeyboard(void) {
break;
case '9':
switch (b[i++]) {
case '~': /* \e[23~ is F8 */
case '~': /* \e[19~ is F8 */
pf8_ = !pf8_;
break;
default:
@ -1103,7 +1139,7 @@ static optimizesize void ReadKeyboard(void) {
switch (b[i++]) {
case '0':
switch (b[i++]) {
case '~': /* \e[20~ is F10 */
case '~': /* \e[20~ is F9 */
pf9_ = !pf9_;
break;
default: