diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile | 3 | ||||
-rw-r--r-- | lib/libc/Makefile | 10 | ||||
-rw-r--r-- | lib/libc/gen/readpassphrase.c | 24 | ||||
-rw-r--r-- | lib/libc/net/sctp_sys_calls.c | 16 | ||||
-rw-r--r-- | lib/libelftc/Makefile | 2 | ||||
-rw-r--r-- | lib/libproc/proc_bkpt.c | 3 | ||||
-rw-r--r-- | lib/libproc/proc_regs.c | 8 |
7 files changed, 49 insertions, 17 deletions
diff --git a/lib/Makefile b/lib/Makefile index 51532e7..ccc6507 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -264,7 +264,8 @@ _libproc= libproc _librtld_db= librtld_db .endif -.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" +.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" || \ + ${MACHINE_CPUARCH} == "riscv" _libproc= libproc _librtld_db= librtld_db .endif diff --git a/lib/libc/Makefile b/lib/libc/Makefile index d02c028..a48b3e5 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -169,15 +169,15 @@ SUBDIR+= tests .if !defined(_SKIP_BUILD) # We need libutil.h, get it directly to avoid # recording a build dependency -CFLAGS+= -I${.CURDIR:H}/libutil +CFLAGS+= -I${SRCTOP}/lib/libutil # Same issue with libm -MSUN_ARCH_SUBDIR != ${MAKE} -B -C ${.CURDIR:H}/msun -V ARCH_SUBDIR +MSUN_ARCH_SUBDIR != ${MAKE} -B -C ${SRCTOP}/lib/msun -V ARCH_SUBDIR # unfortunately msun/src contains both private and public headers -CFLAGS+= -I${.CURDIR:H}/msun/${MSUN_ARCH_SUBDIR} +CFLAGS+= -I${SRCTOP}/lib/msun/${MSUN_ARCH_SUBDIR} .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" -CFLAGS+= -I${.CURDIR:H}/msun/x86 +CFLAGS+= -I${SRCTOP}/lib/msun/x86 .endif -CFLAGS+= -I${.CURDIR:H}/msun/src +CFLAGS+= -I${SRCTOP}/lib/msun/src # and we do not want to record a dependency on msun .if ${.MAKE.LEVEL} > 0 GENDIRDEPS_FILTER+= N${RELDIR:H}/msun diff --git a/lib/libc/gen/readpassphrase.c b/lib/libc/gen/readpassphrase.c index 60051a1..0961fbb 100644 --- a/lib/libc/gen/readpassphrase.c +++ b/lib/libc/gen/readpassphrase.c @@ -46,7 +46,7 @@ char * readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags) { ssize_t nr; - int input, output, save_errno, i, need_restart; + int input, output, save_errno, i, need_restart, input_is_tty; char ch, *p, *end; struct termios term, oterm; struct sigaction sa, savealrm, saveint, savehup, savequit, saveterm; @@ -68,12 +68,20 @@ restart: * Read and write to /dev/tty if available. If not, read from * stdin and write to stderr unless a tty is required. */ - if ((flags & RPP_STDIN) || - (input = output = _open(_PATH_TTY, O_RDWR | O_CLOEXEC)) == -1) { - if (flags & RPP_REQUIRE_TTY) { - errno = ENOTTY; - return(NULL); + input_is_tty = 0; + if (!(flags & RPP_STDIN)) { + input = output = _open(_PATH_TTY, O_RDWR | O_CLOEXEC); + if (input == -1) { + if (flags & RPP_REQUIRE_TTY) { + errno = ENOTTY; + return(NULL); + } + input = STDIN_FILENO; + output = STDERR_FILENO; + } else { + input_is_tty = 1; } + } else { input = STDIN_FILENO; output = STDERR_FILENO; } @@ -83,7 +91,7 @@ restart: * If we are using a tty but are not the foreground pgrp this will * generate SIGTTOU, so do it *before* installing the signal handlers. */ - if (input != STDIN_FILENO && tcgetattr(input, &oterm) == 0) { + if (input_is_tty && tcgetattr(input, &oterm) == 0) { memcpy(&term, &oterm, sizeof(term)); if (!(flags & RPP_ECHO_ON)) term.c_lflag &= ~(ECHO | ECHONL); @@ -152,7 +160,7 @@ restart: (void)__libc_sigaction(SIGTSTP, &savetstp, NULL); (void)__libc_sigaction(SIGTTIN, &savettin, NULL); (void)__libc_sigaction(SIGTTOU, &savettou, NULL); - if (input != STDIN_FILENO) + if (input_is_tty) (void)_close(input); /* diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c index f07aa43..dcbcee7 100644 --- a/lib/libc/net/sctp_sys_calls.c +++ b/lib/libc/net/sctp_sys_calls.c @@ -700,14 +700,19 @@ sctp_sendx(int sd, const void *msg, size_t msg_len, #ifdef SYS_sctp_generic_sendmsg if (addrcnt == 1) { socklen_t l; + ssize_t ret; /* * Quick way, we don't need to do a connectx so lets use the * syscall directly. */ l = addrs->sa_len; - return (syscall(SYS_sctp_generic_sendmsg, sd, - msg, msg_len, addrs, l, sinfo, flags)); + ret = syscall(SYS_sctp_generic_sendmsg, sd, + msg, msg_len, addrs, l, sinfo, flags); + if ((ret >= 0) && (sinfo != NULL)) { + sinfo->sinfo_assoc_id = sctp_getassocid(sd, addrs); + } + return (ret); } #endif @@ -984,6 +989,7 @@ sctp_sendv(int sd, struct sockaddr *addr; struct sockaddr_in *addr_in; struct sockaddr_in6 *addr_in6; + sctp_assoc_t *assoc_id; if ((addrcnt < 0) || (iovcnt < 0) || @@ -1002,6 +1008,7 @@ sctp_sendv(int sd, errno = ENOMEM; return (-1); } + assoc_id = NULL; msg.msg_control = cmsgbuf; msg.msg_controllen = 0; cmsg = (struct cmsghdr *)cmsgbuf; @@ -1025,6 +1032,7 @@ sctp_sendv(int sd, memcpy(CMSG_DATA(cmsg), info, sizeof(struct sctp_sndinfo)); msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_sndinfo)); cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_sndinfo))); + assoc_id = &(((struct sctp_sndinfo *)info)->snd_assoc_id); break; case SCTP_SENDV_PRINFO: if ((info == NULL) || (infolen < sizeof(struct sctp_prinfo))) { @@ -1066,6 +1074,7 @@ sctp_sendv(int sd, memcpy(CMSG_DATA(cmsg), &spa_info->sendv_sndinfo, sizeof(struct sctp_sndinfo)); msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_sndinfo)); cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_sndinfo))); + assoc_id = &(spa_info->sendv_sndinfo.snd_assoc_id); } if (spa_info->sendv_flags & SCTP_SEND_PRINFO_VALID) { cmsg->cmsg_level = IPPROTO_SCTP; @@ -1164,6 +1173,9 @@ sctp_sendv(int sd, msg.msg_flags = 0; ret = sendmsg(sd, &msg, flags); free(cmsgbuf); + if ((ret >= 0) && (addrs != NULL) && (assoc_id != NULL)) { + *assoc_id = sctp_getassocid(sd, addrs); + } return (ret); } diff --git a/lib/libelftc/Makefile b/lib/libelftc/Makefile index ccae1a5..ed5c02a 100644 --- a/lib/libelftc/Makefile +++ b/lib/libelftc/Makefile @@ -25,6 +25,6 @@ SRCS= elftc_bfdtarget.c \ INCS= libelftc.h CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/common -NO_MAN= yes +MAN= .include <bsd.lib.mk> diff --git a/lib/libproc/proc_bkpt.c b/lib/libproc/proc_bkpt.c index f0ff5c5..4a100cb 100644 --- a/lib/libproc/proc_bkpt.c +++ b/lib/libproc/proc_bkpt.c @@ -61,6 +61,9 @@ __FBSDID("$FreeBSD$"); #elif defined(__powerpc__) #define BREAKPOINT_INSTR 0x7fe00008 /* trap */ #define BREAKPOINT_INSTR_SZ 4 +#elif defined(__riscv__) +#define BREAKPOINT_INSTR 0x00100073 /* sbreak */ +#define BREAKPOINT_INSTR_SZ 4 #else #error "Add support for your architecture" #endif diff --git a/lib/libproc/proc_regs.c b/lib/libproc/proc_regs.c index aae43ba..745fa09 100644 --- a/lib/libproc/proc_regs.c +++ b/lib/libproc/proc_regs.c @@ -66,6 +66,8 @@ proc_regget(struct proc_handle *phdl, proc_reg_t reg, unsigned long *regvalue) *regvalue = regs.r_regs[PC]; #elif defined(__powerpc__) *regvalue = regs.pc; +#elif defined(__riscv__) + *regvalue = regs.sepc; #endif break; case REG_SP: @@ -81,6 +83,8 @@ proc_regget(struct proc_handle *phdl, proc_reg_t reg, unsigned long *regvalue) *regvalue = regs.r_regs[SP]; #elif defined(__powerpc__) *regvalue = regs.fixreg[1]; +#elif defined(__riscv__) + *regvalue = regs.sp; #endif break; default: @@ -117,6 +121,8 @@ proc_regset(struct proc_handle *phdl, proc_reg_t reg, unsigned long regvalue) regs.r_regs[PC] = regvalue; #elif defined(__powerpc__) regs.pc = regvalue; +#elif defined(__riscv__) + regs.sepc = regvalue; #endif break; case REG_SP: @@ -132,6 +138,8 @@ proc_regset(struct proc_handle *phdl, proc_reg_t reg, unsigned long regvalue) regs.r_regs[PC] = regvalue; #elif defined(__powerpc__) regs.fixreg[1] = regvalue; +#elif defined(__riscv__) + regs.sp = regvalue; #endif break; default: |